@venturialstd/capa 0.0.1
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 +253 -0
- package/dist/capa.module.d.ts +3 -0
- package/dist/capa.module.d.ts.map +1 -0
- package/dist/capa.module.js +53 -0
- package/dist/capa.module.js.map +1 -0
- package/dist/clients/capa.client.d.ts +8 -0
- package/dist/clients/capa.client.d.ts.map +1 -0
- package/dist/clients/capa.client.js +53 -0
- package/dist/clients/capa.client.js.map +1 -0
- package/dist/constants/capa-base.constant.d.ts +7 -0
- package/dist/constants/capa-base.constant.d.ts.map +1 -0
- package/dist/constants/capa-base.constant.js +11 -0
- package/dist/constants/capa-base.constant.js.map +1 -0
- package/dist/constants/capa.constant.d.ts +11 -0
- package/dist/constants/capa.constant.d.ts.map +1 -0
- package/dist/constants/capa.constant.js +15 -0
- package/dist/constants/capa.constant.js.map +1 -0
- package/dist/constants/capa.settings.constant.d.ts +6 -0
- package/dist/constants/capa.settings.constant.d.ts.map +1 -0
- package/dist/constants/capa.settings.constant.js +9 -0
- package/dist/constants/capa.settings.constant.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +20 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/services/capa-base.service.d.ts +14 -0
- package/dist/services/capa-base.service.d.ts.map +1 -0
- package/dist/services/capa-base.service.js +116 -0
- package/dist/services/capa-base.service.js.map +1 -0
- package/dist/services/capa-cross-ramp.service.d.ts +13 -0
- package/dist/services/capa-cross-ramp.service.d.ts.map +1 -0
- package/dist/services/capa-cross-ramp.service.js +48 -0
- package/dist/services/capa-cross-ramp.service.js.map +1 -0
- package/dist/services/capa-kyb.service.d.ts +11 -0
- package/dist/services/capa-kyb.service.d.ts.map +1 -0
- package/dist/services/capa-kyb.service.js +35 -0
- package/dist/services/capa-kyb.service.js.map +1 -0
- package/dist/services/capa-kyc.service.d.ts +11 -0
- package/dist/services/capa-kyc.service.d.ts.map +1 -0
- package/dist/services/capa-kyc.service.js +35 -0
- package/dist/services/capa-kyc.service.js.map +1 -0
- package/dist/services/capa-off-ramp.service.d.ts +11 -0
- package/dist/services/capa-off-ramp.service.d.ts.map +1 -0
- package/dist/services/capa-off-ramp.service.js +35 -0
- package/dist/services/capa-off-ramp.service.js.map +1 -0
- package/dist/services/capa-on-ramp.service.d.ts +11 -0
- package/dist/services/capa-on-ramp.service.d.ts.map +1 -0
- package/dist/services/capa-on-ramp.service.js +35 -0
- package/dist/services/capa-on-ramp.service.js.map +1 -0
- package/dist/services/capa-quotes.service.d.ts +12 -0
- package/dist/services/capa-quotes.service.d.ts.map +1 -0
- package/dist/services/capa-quotes.service.js +44 -0
- package/dist/services/capa-quotes.service.js.map +1 -0
- package/dist/services/capa-receivers.service.d.ts +13 -0
- package/dist/services/capa-receivers.service.d.ts.map +1 -0
- package/dist/services/capa-receivers.service.js +50 -0
- package/dist/services/capa-receivers.service.js.map +1 -0
- package/dist/services/capa-transactions.service.d.ts +13 -0
- package/dist/services/capa-transactions.service.d.ts.map +1 -0
- package/dist/services/capa-transactions.service.js +50 -0
- package/dist/services/capa-transactions.service.js.map +1 -0
- package/dist/services/capa-users.service.d.ts +16 -0
- package/dist/services/capa-users.service.d.ts.map +1 -0
- package/dist/services/capa-users.service.js +54 -0
- package/dist/services/capa-users.service.js.map +1 -0
- package/dist/services/capa-webhook-settings.service.d.ts +11 -0
- package/dist/services/capa-webhook-settings.service.d.ts.map +1 -0
- package/dist/services/capa-webhook-settings.service.js +35 -0
- package/dist/services/capa-webhook-settings.service.js.map +1 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +28 -0
- package/dist/services/index.js.map +1 -0
- package/dist/settings/capa.settings.d.ts +3 -0
- package/dist/settings/capa.settings.d.ts.map +1 -0
- package/dist/settings/capa.settings.js +47 -0
- package/dist/settings/capa.settings.js.map +1 -0
- package/dist/types/capa-api.types.d.ts +520 -0
- package/dist/types/capa-api.types.d.ts.map +1 -0
- package/dist/types/capa-api.types.js +3 -0
- package/dist/types/capa-api.types.js.map +1 -0
- package/dist/types/capa.config.type.d.ts +11 -0
- package/dist/types/capa.config.type.d.ts.map +1 -0
- package/dist/types/capa.config.type.js +3 -0
- package/dist/types/capa.config.type.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# @venturialstd/capa
|
|
2
|
+
|
|
3
|
+
A comprehensive **NestJS SDK for Capa Partner API v2**, developed by **Venturial**, that provides full integration with Capa.fi's payment infrastructure. This module enables seamless fiat-to-crypto, crypto-to-fiat, and fiat-to-fiat transactions, along with complete KYC/KYB verification management.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Quotes Management**: Get and create quotes for on-ramp, off-ramp, and cross-ramp transactions
|
|
10
|
+
- **Transaction Processing**: Create and manage on-ramp (fiat→crypto), off-ramp (crypto→fiat), and cross-ramp (fiat→fiat) transactions
|
|
11
|
+
- **User Management**: Create users, manage agreements, and handle document signatures
|
|
12
|
+
- **KYC/KYB Verification**: Complete KYC and KYB verification workflows with detailed status retrieval
|
|
13
|
+
- **Receiver Management**: Create, list, and manage payment receivers
|
|
14
|
+
- **Transaction Tracking**: List, filter, and cancel transactions with comprehensive status management
|
|
15
|
+
- **Webhook Configuration**: Configure webhooks for real-time transaction notifications
|
|
16
|
+
- **Enhanced Error Handling**: Detailed error messages with validation feedback and troubleshooting hints
|
|
17
|
+
- **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @venturialstd/capa
|
|
25
|
+
# or
|
|
26
|
+
yarn add @venturialstd/capa
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Peer Dependencies
|
|
30
|
+
|
|
31
|
+
This package requires the following peer dependencies:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @nestjs/common@^11.0.11 @nestjs/core@^11.0.5 @nestjs/axios@^4.0.0 @venturialstd/core@^1.0.16 rxjs@^7.8.1
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Basic Usage
|
|
40
|
+
|
|
41
|
+
### 1. Import the Module
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Module } from '@nestjs/common';
|
|
45
|
+
import { CapaModule } from '@venturialstd/capa';
|
|
46
|
+
|
|
47
|
+
@Module({
|
|
48
|
+
imports: [
|
|
49
|
+
CapaModule,
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
export class AppModule {}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. Inject and Use Services
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Injectable } from '@nestjs/common';
|
|
59
|
+
import {
|
|
60
|
+
CapaQuotesService,
|
|
61
|
+
CapaOnRampService,
|
|
62
|
+
CapaUsersService,
|
|
63
|
+
CapaKycService,
|
|
64
|
+
} from '@venturialstd/capa';
|
|
65
|
+
|
|
66
|
+
@Injectable()
|
|
67
|
+
export class PaymentService {
|
|
68
|
+
constructor(
|
|
69
|
+
private readonly quotesService: CapaQuotesService,
|
|
70
|
+
private readonly onRampService: CapaOnRampService,
|
|
71
|
+
private readonly usersService: CapaUsersService,
|
|
72
|
+
private readonly kycService: CapaKycService,
|
|
73
|
+
) {}
|
|
74
|
+
|
|
75
|
+
async processPayment(userId: string, amount: number) {
|
|
76
|
+
// Get a quote
|
|
77
|
+
const quote = await this.quotesService.getQuote({
|
|
78
|
+
tokenSymbol: 'USDC',
|
|
79
|
+
transactionType: 'ON_RAMP',
|
|
80
|
+
blockchainSymbol: 'POL',
|
|
81
|
+
fiatCurrency: 'MXN',
|
|
82
|
+
fiatAmount: amount,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Create on-ramp transaction
|
|
86
|
+
const transaction = await this.onRampService.createOnRamp({
|
|
87
|
+
userId,
|
|
88
|
+
destinationWalletAddress: '0x...',
|
|
89
|
+
fiatCurrency: 'MXN',
|
|
90
|
+
blockchainSymbol: 'POL',
|
|
91
|
+
tokenSymbol: 'USDC',
|
|
92
|
+
fiatAmount: amount,
|
|
93
|
+
quoteId: quote.quoteId,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return transaction;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async checkKycStatus(userId: string) {
|
|
100
|
+
const kycDetails = await this.kycService.getVerificationDetails(userId);
|
|
101
|
+
return kycDetails;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 3. Configuration
|
|
107
|
+
|
|
108
|
+
The module uses `SettingsService` from `@venturialstd/core` to retrieve credentials. Configure the following settings:
|
|
109
|
+
|
|
110
|
+
- `CAPA_PARTNER_API_KEY`: Your Capa partner API key
|
|
111
|
+
- `CAPA_BASE_URL`: Base URL for the API (optional, defaults based on environment)
|
|
112
|
+
- `CAPA_ENVIRONMENT`: Environment setting (`staging` or `production`)
|
|
113
|
+
|
|
114
|
+
Alternatively, you can pass configuration directly to service methods:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
await this.quotesService.getQuote(query, {
|
|
118
|
+
partnerApiKey: 'your-api-key',
|
|
119
|
+
environment: 'staging',
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## API
|
|
126
|
+
|
|
127
|
+
### CapaQuotesService
|
|
128
|
+
|
|
129
|
+
| Method | Endpoint | Description |
|
|
130
|
+
|--------|----------|-------------|
|
|
131
|
+
| `getQuote(query: CapaGetQuoteQuery)` | `GET /api/partner/v2/quotes` | Get quote rate using query parameters |
|
|
132
|
+
| `createQuote(request: CapaCreateQuoteRequest)` | `POST /api/partner/v2/quotes` | Create a new quote |
|
|
133
|
+
|
|
134
|
+
### CapaOnRampService
|
|
135
|
+
|
|
136
|
+
| Method | Endpoint | Description |
|
|
137
|
+
|--------|----------|-------------|
|
|
138
|
+
| `createOnRamp(request: CapaCreateOnRampRequest)` | `POST /api/partner/v2/on-ramp` | Create a fiat-to-crypto transaction |
|
|
139
|
+
|
|
140
|
+
### CapaOffRampService
|
|
141
|
+
|
|
142
|
+
| Method | Endpoint | Description |
|
|
143
|
+
|--------|----------|-------------|
|
|
144
|
+
| `createOffRamp(request: CapaCreateOffRampRequest)` | `POST /api/partner/v2/off-ramp` | Create a crypto-to-fiat transaction |
|
|
145
|
+
|
|
146
|
+
### CapaCrossRampService
|
|
147
|
+
|
|
148
|
+
| Method | Endpoint | Description |
|
|
149
|
+
|--------|----------|-------------|
|
|
150
|
+
| `getCrossRampQuote(query: CapaGetCrossRampQuoteQuery)` | `GET /api/partner/v2/cross-ramp/quotes` | Get cross-ramp quote rate |
|
|
151
|
+
| `createCrossRampQuote(request: CapaCreateCrossRampQuoteRequest)` | `POST /api/partner/v2/cross-ramp/quotes` | Create a cross-ramp quote |
|
|
152
|
+
| `createCrossRamp(request: CapaCreateCrossRampRequest)` | `POST /api/partner/v2/cross-ramp` | Create a fiat-to-fiat transaction |
|
|
153
|
+
|
|
154
|
+
### CapaUsersService
|
|
155
|
+
|
|
156
|
+
| Method | Endpoint | Description |
|
|
157
|
+
|--------|----------|-------------|
|
|
158
|
+
| `createUser(request: CapaCreateUserRequest)` | `POST /api/partner/v2/users` | Create a new user |
|
|
159
|
+
| `getUserAgreements(userId: string)` | `GET /api/partner/v2/users/{id}/agreements` | Get user agreements |
|
|
160
|
+
| `requestDocumentSignature(userId: string, request: CapaDocumentSignRequest)` | `POST /api/partner/v2/users/{id}/documents/sign` | Request document signature |
|
|
161
|
+
|
|
162
|
+
### CapaKycService
|
|
163
|
+
|
|
164
|
+
| Method | Endpoint | Description |
|
|
165
|
+
|--------|----------|-------------|
|
|
166
|
+
| `getVerificationDetails(userId: string)` | `GET /api/partner/v2/kyc/details?userId={userId}` | Get KYC verification details including AML, face match, fraud insights, and ID information |
|
|
167
|
+
|
|
168
|
+
### CapaKybService
|
|
169
|
+
|
|
170
|
+
| Method | Endpoint | Description |
|
|
171
|
+
|--------|----------|-------------|
|
|
172
|
+
| `getUserKybDetails(userId: string)` | `GET /api/partner/v2/kyb/details?userId={userId}` | Get KYB verification details including business info and beneficial owners |
|
|
173
|
+
|
|
174
|
+
### CapaReceiversService
|
|
175
|
+
|
|
176
|
+
| Method | Endpoint | Description |
|
|
177
|
+
|--------|----------|-------------|
|
|
178
|
+
| `createReceiver(request: CapaCreateReceiverRequest)` | `POST /api/partner/v2/receivers` | Create a payment receiver |
|
|
179
|
+
| `listReceivers(query?: CapaListReceiversQuery)` | `GET /api/partner/v2/receivers` | List receivers with optional filtering |
|
|
180
|
+
| `deleteReceiver(id: string, request: CapaDeleteReceiverRequest)` | `DELETE /api/partner/v2/receivers/{id}` | Disable (soft-delete) a receiver |
|
|
181
|
+
|
|
182
|
+
### CapaTransactionsService
|
|
183
|
+
|
|
184
|
+
| Method | Endpoint | Description |
|
|
185
|
+
|--------|----------|-------------|
|
|
186
|
+
| `listTransactions(query?: CapaListTransactionsQuery)` | `GET /api/partner/v2/transactions` | List transactions with filtering options |
|
|
187
|
+
| `cancelTransaction(transactionId: string)` | `PUT /api/partner/v2/transactions/{id}/cancel` | Cancel a transaction |
|
|
188
|
+
| `getMockTestingGuide()` | `GET /api/partner/v2/transactions/mock-testing-guide` | Get mock testing guide for staging environment |
|
|
189
|
+
|
|
190
|
+
### CapaWebhookSettingsService
|
|
191
|
+
|
|
192
|
+
| Method | Endpoint | Description |
|
|
193
|
+
|--------|----------|-------------|
|
|
194
|
+
| `updateWebhookSettings(request: CapaUpdateWebhookSettingsRequest)` | `PUT /api/partner/v2/webhook-settings` | Update webhook notification URL |
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Error Handling
|
|
199
|
+
|
|
200
|
+
The module includes enhanced error handling that provides detailed information about:
|
|
201
|
+
|
|
202
|
+
- **HTTP Status Codes**: Identifies error types (400, 401, 404, 422, 500, etc.)
|
|
203
|
+
- **Error Messages**: Shows specific error messages from Capa API
|
|
204
|
+
- **Validation Errors**: Lists fields that failed validation with specific messages
|
|
205
|
+
- **Contextual Information**: Includes endpoint, HTTP method, and response time
|
|
206
|
+
- **Troubleshooting Hints**: Provides suggestions on what might be missing or incorrect
|
|
207
|
+
|
|
208
|
+
### Example Error Message
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Capa API call failed: POST /quotes (HTTP 422) - Validation failed | Validation errors: fiatAmount: Required field, tokenSymbol: Invalid token symbol | Unprocessable Entity: Check request body validation
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Error Object Properties
|
|
215
|
+
|
|
216
|
+
When an error is thrown, you can access:
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
try {
|
|
220
|
+
await this.quotesService.createQuote(request);
|
|
221
|
+
} catch (error: any) {
|
|
222
|
+
console.log(error.statusCode); // HTTP status code
|
|
223
|
+
console.log(error.responseData); // Full response data
|
|
224
|
+
console.log(error.endpoint); // API endpoint
|
|
225
|
+
console.log(error.method); // HTTP method
|
|
226
|
+
console.log(error.message); // Detailed error message
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Notes
|
|
233
|
+
|
|
234
|
+
- **Environment Support**: The module supports both staging and production environments. Defaults to staging if not specified.
|
|
235
|
+
- **Type Safety**: All request and response types are fully typed for better IDE support and compile-time error checking.
|
|
236
|
+
- **Logging**: All API calls are automatically logged with timing information using `AppLogger` from `@venturialstd/core`.
|
|
237
|
+
- **Configuration Flexibility**: You can configure credentials globally via settings or pass them per-request.
|
|
238
|
+
- **Rate Limiting**: Be aware of Capa's rate limits when making multiple API calls.
|
|
239
|
+
- **Quote Expiration**: Quotes have expiration times. Always check `expiresAt` before using a quote.
|
|
240
|
+
- **KYC/KYB Requirements**: Users must complete KYC/KYB verification before creating transactions.
|
|
241
|
+
- **Webhook Security**: Ensure your webhook endpoints are secured and validate webhook signatures from Capa.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Support
|
|
252
|
+
|
|
253
|
+
For issues, questions, or contributions, please contact the Venturial development team.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.module.d.ts","sourceRoot":"","sources":["../src/capa.module.ts"],"names":[],"mappings":"AAkBA,qBAiCa,UAAU;CAAG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CapaModule = void 0;
|
|
10
|
+
const axios_1 = require("@nestjs/axios");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const core_1 = require("@venturialstd/core");
|
|
13
|
+
const capa_client_1 = require("./clients/capa.client");
|
|
14
|
+
const services_1 = require("./services");
|
|
15
|
+
let CapaModule = class CapaModule {
|
|
16
|
+
};
|
|
17
|
+
exports.CapaModule = CapaModule;
|
|
18
|
+
exports.CapaModule = CapaModule = __decorate([
|
|
19
|
+
(0, common_1.Module)({
|
|
20
|
+
imports: [
|
|
21
|
+
core_1.SharedModule,
|
|
22
|
+
axios_1.HttpModule,
|
|
23
|
+
],
|
|
24
|
+
controllers: [],
|
|
25
|
+
providers: [
|
|
26
|
+
capa_client_1.CapaClient,
|
|
27
|
+
services_1.CapaQuotesService,
|
|
28
|
+
services_1.CapaReceiversService,
|
|
29
|
+
services_1.CapaUsersService,
|
|
30
|
+
services_1.CapaTransactionsService,
|
|
31
|
+
services_1.CapaOnRampService,
|
|
32
|
+
services_1.CapaOffRampService,
|
|
33
|
+
services_1.CapaCrossRampService,
|
|
34
|
+
services_1.CapaKycService,
|
|
35
|
+
services_1.CapaKybService,
|
|
36
|
+
services_1.CapaWebhookSettingsService,
|
|
37
|
+
],
|
|
38
|
+
exports: [
|
|
39
|
+
capa_client_1.CapaClient,
|
|
40
|
+
services_1.CapaQuotesService,
|
|
41
|
+
services_1.CapaReceiversService,
|
|
42
|
+
services_1.CapaUsersService,
|
|
43
|
+
services_1.CapaTransactionsService,
|
|
44
|
+
services_1.CapaOnRampService,
|
|
45
|
+
services_1.CapaOffRampService,
|
|
46
|
+
services_1.CapaCrossRampService,
|
|
47
|
+
services_1.CapaKycService,
|
|
48
|
+
services_1.CapaKybService,
|
|
49
|
+
services_1.CapaWebhookSettingsService,
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
], CapaModule);
|
|
53
|
+
//# sourceMappingURL=capa.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.module.js","sourceRoot":"","sources":["../src/capa.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAA2C;AAC3C,2CAAwC;AACxC,6CAAkD;AAElD,uDAAmD;AACnD,yCAWoB;AAmCb,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAjCtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,mBAAY;YACZ,kBAAU;SACX;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE;YACT,wBAAU;YACV,4BAAiB;YACjB,+BAAoB;YACpB,2BAAgB;YAChB,kCAAuB;YACvB,4BAAiB;YACjB,6BAAkB;YAClB,+BAAoB;YACpB,yBAAc;YACd,yBAAc;YACd,qCAA0B;SAC3B;QACD,OAAO,EAAE;YACP,wBAAU;YACV,4BAAiB;YACjB,+BAAoB;YACpB,2BAAgB;YAChB,kCAAuB;YACvB,4BAAiB;YACjB,6BAAkB;YAClB,+BAAoB;YACpB,yBAAc;YACd,yBAAc;YACd,qCAA0B;SAC3B;KACF,CAAC;GACW,UAAU,CAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SettingsService } from '@venturialstd/core';
|
|
2
|
+
import { CapaClientCredentials, CapaConfig } from '../types/capa.config.type';
|
|
3
|
+
export declare class CapaClient {
|
|
4
|
+
private readonly settingsService;
|
|
5
|
+
constructor(settingsService: SettingsService);
|
|
6
|
+
getCredentials(config?: CapaConfig | null): Promise<CapaClientCredentials>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=capa.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.client.d.ts","sourceRoot":"","sources":["../../src/clients/capa.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE9E,qBACa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,eAAe;IAEvD,cAAc,CAAC,MAAM,GAAE,UAAU,GAAG,IAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAiCvF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CapaClient = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@venturialstd/core");
|
|
15
|
+
const capa_constant_1 = require("../constants/capa.constant");
|
|
16
|
+
const capa_settings_constant_1 = require("../constants/capa.settings.constant");
|
|
17
|
+
let CapaClient = class CapaClient {
|
|
18
|
+
settingsService;
|
|
19
|
+
constructor(settingsService) {
|
|
20
|
+
this.settingsService = settingsService;
|
|
21
|
+
}
|
|
22
|
+
async getCredentials(config = null) {
|
|
23
|
+
if (config && config.partnerApiKey) {
|
|
24
|
+
const baseUrl = config.baseUrl ||
|
|
25
|
+
(config.environment
|
|
26
|
+
? capa_constant_1.CAPA_BASE_URLS[config.environment]
|
|
27
|
+
: capa_constant_1.CAPA_BASE_URLS[capa_constant_1.CapaEnvironment.STAGING]);
|
|
28
|
+
return {
|
|
29
|
+
partnerApiKey: config.partnerApiKey,
|
|
30
|
+
baseUrl,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const capaSettings = await this.settingsService.getManyWithDefaults([
|
|
34
|
+
capa_settings_constant_1.CAPA_SETTING_KEYS.GENERAL_PARTNER_API_KEY,
|
|
35
|
+
capa_settings_constant_1.CAPA_SETTING_KEYS.GENERAL_BASE_URL,
|
|
36
|
+
capa_settings_constant_1.CAPA_SETTING_KEYS.GENERAL_ENVIRONMENT,
|
|
37
|
+
]);
|
|
38
|
+
const environment = capaSettings[capa_settings_constant_1.CAPA_SETTING_KEYS.GENERAL_ENVIRONMENT] ||
|
|
39
|
+
capa_constant_1.CapaEnvironment.STAGING;
|
|
40
|
+
const baseUrl = capaSettings[capa_settings_constant_1.CAPA_SETTING_KEYS.GENERAL_BASE_URL] ||
|
|
41
|
+
capa_constant_1.CAPA_BASE_URLS[environment];
|
|
42
|
+
return {
|
|
43
|
+
partnerApiKey: capaSettings[capa_settings_constant_1.CAPA_SETTING_KEYS.GENERAL_PARTNER_API_KEY],
|
|
44
|
+
baseUrl,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.CapaClient = CapaClient;
|
|
49
|
+
exports.CapaClient = CapaClient = __decorate([
|
|
50
|
+
(0, common_1.Injectable)(),
|
|
51
|
+
__metadata("design:paramtypes", [core_1.SettingsService])
|
|
52
|
+
], CapaClient);
|
|
53
|
+
//# sourceMappingURL=capa.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.client.js","sourceRoot":"","sources":["../../src/clients/capa.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAqD;AAErD,8DAA6E;AAC7E,gFAAwE;AAIjE,IAAM,UAAU,GAAhB,MAAM,UAAU;IACQ;IAA7B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAEjE,KAAK,CAAC,cAAc,CAAC,SAA4B,IAAI;QACnD,IAAI,MAAM,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACnC,MAAM,OAAO,GACX,MAAM,CAAC,OAAO;gBACd,CAAC,MAAM,CAAC,WAAW;oBACjB,CAAC,CAAC,8BAAc,CAAC,MAAM,CAAC,WAAW,CAAC;oBACpC,CAAC,CAAC,8BAAc,CAAC,+BAAe,CAAC,OAAO,CAAC,CAAC,CAAC;YAE/C,OAAO;gBACL,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,OAAO;aACR,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;YAClE,0CAAiB,CAAC,uBAAuB;YACzC,0CAAiB,CAAC,gBAAgB;YAClC,0CAAiB,CAAC,mBAAmB;SACtC,CAAC,CAAC;QAEH,MAAM,WAAW,GACd,YAAY,CAAC,0CAAiB,CAAC,mBAAmB,CAAqB;YACxE,+BAAe,CAAC,OAAO,CAAC;QAE1B,MAAM,OAAO,GACX,YAAY,CAAC,0CAAiB,CAAC,gBAAgB,CAAC;YAChD,8BAAc,CAAC,WAAW,CAAC,CAAC;QAE9B,OAAO;YACL,aAAa,EAAE,YAAY,CAAC,0CAAiB,CAAC,uBAAuB,CAAC;YACtE,OAAO;SACR,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAEmC,sBAAe;GADlD,UAAU,CAoCtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa-base.constant.d.ts","sourceRoot":"","sources":["../../src/constants/capa-base.constant.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CapaBaseMethod = void 0;
|
|
4
|
+
var CapaBaseMethod;
|
|
5
|
+
(function (CapaBaseMethod) {
|
|
6
|
+
CapaBaseMethod["GET"] = "GET";
|
|
7
|
+
CapaBaseMethod["POST"] = "POST";
|
|
8
|
+
CapaBaseMethod["PUT"] = "PUT";
|
|
9
|
+
CapaBaseMethod["DELETE"] = "DELETE";
|
|
10
|
+
})(CapaBaseMethod || (exports.CapaBaseMethod = CapaBaseMethod = {}));
|
|
11
|
+
//# sourceMappingURL=capa-base.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa-base.constant.js","sourceRoot":"","sources":["../../src/constants/capa-base.constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum CapaEnvironment {
|
|
2
|
+
STAGING = "staging",
|
|
3
|
+
PRODUCTION = "production"
|
|
4
|
+
}
|
|
5
|
+
export declare const CAPA_BASE_URLS: {
|
|
6
|
+
staging: string;
|
|
7
|
+
production: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const CAPA_API_VERSION = "v2";
|
|
10
|
+
export declare const CAPA_API_PREFIX = "/api/partner/v2";
|
|
11
|
+
//# sourceMappingURL=capa.constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.constant.d.ts","sourceRoot":"","sources":["../../src/constants/capa.constant.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,cAAc;;;CAG1B,CAAC;AAEF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,eAAe,oBAAqC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CAPA_API_PREFIX = exports.CAPA_API_VERSION = exports.CAPA_BASE_URLS = exports.CapaEnvironment = void 0;
|
|
4
|
+
var CapaEnvironment;
|
|
5
|
+
(function (CapaEnvironment) {
|
|
6
|
+
CapaEnvironment["STAGING"] = "staging";
|
|
7
|
+
CapaEnvironment["PRODUCTION"] = "production";
|
|
8
|
+
})(CapaEnvironment || (exports.CapaEnvironment = CapaEnvironment = {}));
|
|
9
|
+
exports.CAPA_BASE_URLS = {
|
|
10
|
+
[CapaEnvironment.STAGING]: 'https://staging-api.capa.fi',
|
|
11
|
+
[CapaEnvironment.PRODUCTION]: 'https://production-api.capa.fi',
|
|
12
|
+
};
|
|
13
|
+
exports.CAPA_API_VERSION = 'v2';
|
|
14
|
+
exports.CAPA_API_PREFIX = `/api/partner/${exports.CAPA_API_VERSION}`;
|
|
15
|
+
//# sourceMappingURL=capa.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.constant.js","sourceRoot":"","sources":["../../src/constants/capa.constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,4CAAyB,CAAA;AAC3B,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B;AAEY,QAAA,cAAc,GAAG;IAC5B,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,6BAA6B;IACxD,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,gCAAgC;CAC/D,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAI,CAAC;AACxB,QAAA,eAAe,GAAG,gBAAgB,wBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const CAPA_SETTING_KEYS: {
|
|
2
|
+
readonly GENERAL_PARTNER_API_KEY: "GLOBAL:CAPA:GENERAL:PARTNER_API_KEY";
|
|
3
|
+
readonly GENERAL_BASE_URL: "GLOBAL:CAPA:GENERAL:BASE_URL";
|
|
4
|
+
readonly GENERAL_ENVIRONMENT: "GLOBAL:CAPA:GENERAL:ENVIRONMENT";
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=capa.settings.constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.settings.constant.d.ts","sourceRoot":"","sources":["../../src/constants/capa.settings.constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CAPA_SETTING_KEYS = void 0;
|
|
4
|
+
exports.CAPA_SETTING_KEYS = {
|
|
5
|
+
GENERAL_PARTNER_API_KEY: 'GLOBAL:CAPA:GENERAL:PARTNER_API_KEY',
|
|
6
|
+
GENERAL_BASE_URL: 'GLOBAL:CAPA:GENERAL:BASE_URL',
|
|
7
|
+
GENERAL_ENVIRONMENT: 'GLOBAL:CAPA:GENERAL:ENVIRONMENT',
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=capa.settings.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa.settings.constant.js","sourceRoot":"","sources":["../../src/constants/capa.settings.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;IAC/B,uBAAuB,EAAE,qCAAqC;IAC9D,gBAAgB,EAAE,8BAA8B;IAChD,mBAAmB,EAAE,iCAAiC;CAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./capa.constant"), exports);
|
|
18
|
+
__exportStar(require("./capa.settings.constant"), exports);
|
|
19
|
+
__exportStar(require("./capa-base.constant"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,2DAAyC;AACzC,uDAAqC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAC;AAGtC,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,YAAY,CAAC;AAG3B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./clients/capa.client"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
__exportStar(require("./services"), exports);
|
|
21
|
+
__exportStar(require("./settings/capa.settings"), exports);
|
|
22
|
+
__exportStar(require("./capa.module"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,wDAAsC;AAGtC,8CAA4B;AAG5B,0CAAwB;AAGxB,6CAA2B;AAG3B,2DAAyC;AAGzC,gDAA8B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpService } from '@nestjs/axios';
|
|
2
|
+
import { AppLogger } from '@venturialstd/core';
|
|
3
|
+
import { CapaClient } from '../clients/capa.client';
|
|
4
|
+
import { CapaConfig } from '../types/capa.config.type';
|
|
5
|
+
import { CapaBaseMethod } from '../constants/capa-base.constant';
|
|
6
|
+
export declare abstract class CapaBaseService {
|
|
7
|
+
protected readonly httpService: HttpService;
|
|
8
|
+
protected readonly capaClient: CapaClient;
|
|
9
|
+
protected readonly logger: AppLogger;
|
|
10
|
+
constructor(httpService: HttpService, capaClient: CapaClient, logger: AppLogger);
|
|
11
|
+
protected getCredentials(config?: CapaConfig | null): Promise<import("../types/capa.config.type").CapaClientCredentials>;
|
|
12
|
+
protected makeApiCall<T>(endpoint: string, method?: CapaBaseMethod, body?: unknown, config?: CapaConfig | null): Promise<T>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=capa-base.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capa-base.service.d.ts","sourceRoot":"","sources":["../../src/services/capa-base.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,8BACsB,eAAe;IAEjC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW;IAC3C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS;gBAFjB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,SAAS;cAKtB,cAAc,CAAC,MAAM,GAAE,UAAU,GAAG,IAAW;cAI/C,WAAW,CAAC,CAAC,EAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,cAAmC,EAC3C,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,GAAE,UAAU,GAAG,IAAW,GAC/B,OAAO,CAAC,CAAC,CAAC;CAyGd"}
|