@crediblex.io/fineract-api-client 0.1.6
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/dist/api/fineract-creditlines-api.d.ts +95 -0
- package/dist/api/fineract-creditlines-api.d.ts.map +1 -0
- package/dist/api/fineract-creditlines-api.js +196 -0
- package/dist/api/fineract-creditlines-api.js.map +1 -0
- package/dist/api/fineract-datatable-api.d.ts +64 -0
- package/dist/api/fineract-datatable-api.d.ts.map +1 -0
- package/dist/api/fineract-datatable-api.js +146 -0
- package/dist/api/fineract-datatable-api.js.map +1 -0
- package/dist/api/fineract-holidays-api.d.ts +29 -0
- package/dist/api/fineract-holidays-api.d.ts.map +1 -0
- package/dist/api/fineract-holidays-api.js +57 -0
- package/dist/api/fineract-holidays-api.js.map +1 -0
- package/dist/api/fineract-loanproducts-api.d.ts +57 -0
- package/dist/api/fineract-loanproducts-api.d.ts.map +1 -0
- package/dist/api/fineract-loanproducts-api.js +140 -0
- package/dist/api/fineract-loanproducts-api.js.map +1 -0
- package/dist/api/fineract-loansaccounts-api.d.ts +77 -0
- package/dist/api/fineract-loansaccounts-api.d.ts.map +1 -0
- package/dist/api/fineract-loansaccounts-api.js +209 -0
- package/dist/api/fineract-loansaccounts-api.js.map +1 -0
- package/dist/api/fineract-reports-api.d.ts +33 -0
- package/dist/api/fineract-reports-api.d.ts.map +1 -0
- package/dist/api/fineract-reports-api.js +94 -0
- package/dist/api/fineract-reports-api.js.map +1 -0
- package/dist/api/fineract-savingsaccounts-api.d.ts +59 -0
- package/dist/api/fineract-savingsaccounts-api.d.ts.map +1 -0
- package/dist/api/fineract-savingsaccounts-api.js +141 -0
- package/dist/api/fineract-savingsaccounts-api.js.map +1 -0
- package/dist/api/fineract-savingsproducts-api.d.ts +86 -0
- package/dist/api/fineract-savingsproducts-api.d.ts.map +1 -0
- package/dist/api/fineract-savingsproducts-api.js +184 -0
- package/dist/api/fineract-savingsproducts-api.js.map +1 -0
- package/dist/api/fineract-sme-api.d.ts +39 -0
- package/dist/api/fineract-sme-api.d.ts.map +1 -0
- package/dist/api/fineract-sme-api.js +82 -0
- package/dist/api/fineract-sme-api.js.map +1 -0
- package/dist/api/fineract-workingdays-api.d.ts +28 -0
- package/dist/api/fineract-workingdays-api.d.ts.map +1 -0
- package/dist/api/fineract-workingdays-api.js +84 -0
- package/dist/api/fineract-workingdays-api.js.map +1 -0
- package/dist/examples/run-examples.d.ts +2 -0
- package/dist/examples/run-examples.d.ts.map +1 -0
- package/dist/examples/run-examples.js +868 -0
- package/dist/examples/run-examples.js.map +1 -0
- package/dist/fineract-sdk.d.ts +50 -0
- package/dist/fineract-sdk.d.ts.map +1 -0
- package/dist/fineract-sdk.js +55 -0
- package/dist/fineract-sdk.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/types/creditlines.d.ts +271 -0
- package/dist/types/creditlines.d.ts.map +1 -0
- package/dist/types/creditlines.js +3 -0
- package/dist/types/creditlines.js.map +1 -0
- package/dist/types/datatable.d.ts +36 -0
- package/dist/types/datatable.d.ts.map +1 -0
- package/dist/types/datatable.js +3 -0
- package/dist/types/datatable.js.map +1 -0
- package/dist/types/errors.d.ts +7 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +17 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/holidays.d.ts +32 -0
- package/dist/types/holidays.d.ts.map +1 -0
- package/dist/types/holidays.js +3 -0
- package/dist/types/holidays.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/loanproducts.d.ts +1 -0
- package/dist/types/loanproducts.d.ts.map +1 -0
- package/dist/types/loanproducts.js +2 -0
- package/dist/types/loanproducts.js.map +1 -0
- package/dist/types/loansaccounts.d.ts +195 -0
- package/dist/types/loansaccounts.d.ts.map +1 -0
- package/dist/types/loansaccounts.js +3 -0
- package/dist/types/loansaccounts.js.map +1 -0
- package/dist/types/reports.d.ts +49 -0
- package/dist/types/reports.d.ts.map +1 -0
- package/dist/types/reports.js +4 -0
- package/dist/types/reports.js.map +1 -0
- package/dist/types/savingsaccounts.d.ts +145 -0
- package/dist/types/savingsaccounts.d.ts.map +1 -0
- package/dist/types/savingsaccounts.js +3 -0
- package/dist/types/savingsaccounts.js.map +1 -0
- package/dist/types/savingsproducts.d.ts +83 -0
- package/dist/types/savingsproducts.d.ts.map +1 -0
- package/dist/types/savingsproducts.js +3 -0
- package/dist/types/savingsproducts.js.map +1 -0
- package/dist/types/sme.d.ts +68 -0
- package/dist/types/sme.d.ts.map +1 -0
- package/dist/types/sme.js +3 -0
- package/dist/types/sme.js.map +1 -0
- package/dist/types/workingdays.d.ts +41 -0
- package/dist/types/workingdays.d.ts.map +1 -0
- package/dist/types/workingdays.js +3 -0
- package/dist/types/workingdays.js.map +1 -0
- package/dist/utils/http-client.d.ts +29 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +93 -0
- package/dist/utils/http-client.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the request body for creating a new sme.
|
|
3
|
+
* Based on EnhancedSmeRequest from the provided clients.ts.
|
|
4
|
+
*/
|
|
5
|
+
export interface CreateSmeRequest {
|
|
6
|
+
officeId: number;
|
|
7
|
+
fullname: string;
|
|
8
|
+
active: boolean;
|
|
9
|
+
activationDate: string;
|
|
10
|
+
dateFormat: string;
|
|
11
|
+
locale: string;
|
|
12
|
+
legalFormId: number;
|
|
13
|
+
externalId: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents the successful response after creating a sme.
|
|
17
|
+
*/
|
|
18
|
+
export interface CreateSmeResponse {
|
|
19
|
+
officeId: number;
|
|
20
|
+
clientId: number;
|
|
21
|
+
resourceId: number;
|
|
22
|
+
resourceExternalId: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents the structure of sme details.
|
|
26
|
+
*/
|
|
27
|
+
export interface SmeDetails {
|
|
28
|
+
id?: number;
|
|
29
|
+
accountNo?: string;
|
|
30
|
+
externalId?: string;
|
|
31
|
+
status?: {
|
|
32
|
+
id?: number;
|
|
33
|
+
code?: string;
|
|
34
|
+
value?: string;
|
|
35
|
+
};
|
|
36
|
+
active?: boolean;
|
|
37
|
+
activationDate?: [number, number, number];
|
|
38
|
+
fullname?: string;
|
|
39
|
+
displayName?: string;
|
|
40
|
+
isStaff?: boolean;
|
|
41
|
+
officeId?: number;
|
|
42
|
+
officeName?: string;
|
|
43
|
+
timeline?: {
|
|
44
|
+
submittedOnDate?: [number, number, number];
|
|
45
|
+
activatedOnDate?: [number, number, number];
|
|
46
|
+
activatedByUsername?: string;
|
|
47
|
+
activatedByFirstname?: string;
|
|
48
|
+
activatedByLastname?: string;
|
|
49
|
+
};
|
|
50
|
+
savingsProductName?: string;
|
|
51
|
+
legalForm?: {
|
|
52
|
+
id?: number;
|
|
53
|
+
code?: string;
|
|
54
|
+
value?: string;
|
|
55
|
+
};
|
|
56
|
+
clientCollateralManagements?: any[];
|
|
57
|
+
groups?: any[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Represents a generic error response from the Fineract API.
|
|
61
|
+
*/
|
|
62
|
+
export interface FineractErrorResponse {
|
|
63
|
+
error: string;
|
|
64
|
+
message: string;
|
|
65
|
+
details?: any;
|
|
66
|
+
statusCode?: number;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=sme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sme.d.ts","sourceRoot":"","sources":["../../src/types/sme.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,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;KAC9B,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE;QACV,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,2BAA2B,CAAC,EAAE,GAAG,EAAE,CAAC;IACpC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sme.js","sourceRoot":"","sources":["../../src/types/sme.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the repayment reschedule type option.
|
|
3
|
+
*/
|
|
4
|
+
export interface RepaymentRescheduleOption {
|
|
5
|
+
id: number;
|
|
6
|
+
code: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents the repayment reschedule type.
|
|
11
|
+
*/
|
|
12
|
+
export interface RepaymentRescheduleType {
|
|
13
|
+
id: number;
|
|
14
|
+
code: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Represents the raw working days response from Fineract API.
|
|
19
|
+
*/
|
|
20
|
+
export interface FineractWorkingDaysResponse {
|
|
21
|
+
id: number;
|
|
22
|
+
recurrence: string;
|
|
23
|
+
repaymentRescheduleType: RepaymentRescheduleType;
|
|
24
|
+
extendTermForDailyRepayments: boolean;
|
|
25
|
+
extendTermForRepaymentsOnHolidays: boolean;
|
|
26
|
+
repaymentRescheduleOptions: RepaymentRescheduleOption[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Represents the formatted working days response returned to consumers.
|
|
30
|
+
* Each day of the week is mapped to a boolean indicating if it's a working day.
|
|
31
|
+
*/
|
|
32
|
+
export interface WorkingDaysResponse {
|
|
33
|
+
Monday: boolean;
|
|
34
|
+
Tuesday: boolean;
|
|
35
|
+
Wednesday: boolean;
|
|
36
|
+
Thursday: boolean;
|
|
37
|
+
Friday: boolean;
|
|
38
|
+
Saturday: boolean;
|
|
39
|
+
Sunday: boolean;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=workingdays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workingdays.d.ts","sourceRoot":"","sources":["../../src/types/workingdays.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,4BAA4B,EAAE,OAAO,CAAC;IACtC,iCAAiC,EAAE,OAAO,CAAC;IAC3C,0BAA0B,EAAE,yBAAyB,EAAE,CAAC;CACzD;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workingdays.js","sourceRoot":"","sources":["../../src/types/workingdays.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
export interface HttpClientConfig {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
tenantId?: string;
|
|
5
|
+
username?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* HttpClient is a wrapper around the Axios library that provides a more
|
|
11
|
+
* user-friendly interface for making HTTP requests.
|
|
12
|
+
*
|
|
13
|
+
* It handles the configuration of headers, authentication, and request
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This class is not intended to be used directly. It is used internally by the Fineract API client.
|
|
17
|
+
*/
|
|
18
|
+
export declare class HttpClient {
|
|
19
|
+
private readonly axiosInstance;
|
|
20
|
+
private readonly tenantId?;
|
|
21
|
+
constructor(config: HttpClientConfig);
|
|
22
|
+
private transformError;
|
|
23
|
+
request<T>(method: string, url: string, data?: any, params?: any, headers?: Record<string, string>): Promise<AxiosResponse<T>>;
|
|
24
|
+
get<T>(url: string, params?: any, headers?: Record<string, string>): Promise<AxiosResponse<T>>;
|
|
25
|
+
post<T>(url: string, data?: any, headers?: Record<string, string>): Promise<AxiosResponse<T>>;
|
|
26
|
+
put<T>(url: string, data?: any, headers?: Record<string, string>): Promise<AxiosResponse<T>>;
|
|
27
|
+
delete<T>(url: string, headers?: Record<string, string>): Promise<AxiosResponse<T>>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAGZ,aAAa,EAEd,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,gBAAgB;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EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAG7B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HttpClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
/**
|
|
9
|
+
* HttpClient is a wrapper around the Axios library that provides a more
|
|
10
|
+
* user-friendly interface for making HTTP requests.
|
|
11
|
+
*
|
|
12
|
+
* It handles the configuration of headers, authentication, and request
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This class is not intended to be used directly. It is used internally by the Fineract API client.
|
|
16
|
+
*/
|
|
17
|
+
class HttpClient {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.tenantId = config.tenantId || "default";
|
|
20
|
+
const headers = {
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
};
|
|
24
|
+
if (this.tenantId) {
|
|
25
|
+
headers["Fineract-Platform-TenantId"] = this.tenantId; // Corrected header name
|
|
26
|
+
}
|
|
27
|
+
const auth = config.username && config.password
|
|
28
|
+
? { username: config.username, password: config.password }
|
|
29
|
+
: undefined;
|
|
30
|
+
this.axiosInstance = axios_1.default.create({
|
|
31
|
+
baseURL: config.baseURL,
|
|
32
|
+
timeout: config.timeout || 30000,
|
|
33
|
+
headers,
|
|
34
|
+
auth,
|
|
35
|
+
});
|
|
36
|
+
this.axiosInstance.interceptors.response.use((response) => response, (error) => {
|
|
37
|
+
const fineractError = this.transformError(error);
|
|
38
|
+
return Promise.reject(fineractError);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
transformError(error) {
|
|
42
|
+
if (error.response) {
|
|
43
|
+
const { status, data } = error.response;
|
|
44
|
+
const errorBody = data; // Fineract error body can be complex
|
|
45
|
+
return {
|
|
46
|
+
error: errorBody?.developerMessage || `HTTP Error: ${status}`,
|
|
47
|
+
message: errorBody?.defaultUserMessage || error.message,
|
|
48
|
+
details: errorBody,
|
|
49
|
+
statusCode: status,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else if (error.request) {
|
|
53
|
+
// Avoid circular JSON issues by not directly including error.request
|
|
54
|
+
return {
|
|
55
|
+
error: "Network Error",
|
|
56
|
+
message: "No response received from server. Check network connectivity or server status.",
|
|
57
|
+
details: {
|
|
58
|
+
code: error.code, // e.g., ECONNREFUSED, ENOTFOUND
|
|
59
|
+
message: "The request was made, but no response was received. This usually indicates a network issue or that the server is not reachable at the specified address.",
|
|
60
|
+
targetAddress: `${error.config?.baseURL || ""}${error.config?.url || ""}`,
|
|
61
|
+
},
|
|
62
|
+
statusCode: 0, // Or another appropriate code for network errors
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return {
|
|
67
|
+
error: "Request Setup Error",
|
|
68
|
+
message: error.message ||
|
|
69
|
+
"An unexpected error occurred while setting up the request.",
|
|
70
|
+
statusCode: -1, // Or another appropriate code for client-side errors
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async request(method, url, data, params, headers) {
|
|
75
|
+
const config = { method, url, data, params, headers };
|
|
76
|
+
const response = await this.axiosInstance.request(config);
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
async get(url, params, headers) {
|
|
80
|
+
return this.request("GET", url, undefined, params, headers);
|
|
81
|
+
}
|
|
82
|
+
async post(url, data, headers) {
|
|
83
|
+
return this.request("POST", url, data, undefined, headers);
|
|
84
|
+
}
|
|
85
|
+
async put(url, data, headers) {
|
|
86
|
+
return this.request("PUT", url, data, undefined, headers);
|
|
87
|
+
}
|
|
88
|
+
async delete(url, headers) {
|
|
89
|
+
return this.request("DELETE", url, undefined, undefined, headers);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.HttpClient = HttpClient;
|
|
93
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAKe;AAWf;;;;;;;;GAQG;AACH,MAAa,UAAU;IAIrB,YAAY,MAAwB;QAClC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,SAAS,CAAC;QAE7C,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,kBAAkB;SAC3B,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,4BAA4B,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,wBAAwB;QACjF,CAAC;QAED,MAAM,IAAI,GACR,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ;YAChC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;YAC1D,CAAC,CAAC,SAAS,CAAC;QAEhB,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,OAAO;YACP,IAAI;SACL,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACtB,CAAC,KAAiB,EAAE,EAAE;YACpB,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACjD,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC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QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAI,MAAM,CAAC,CAAC;QAC7D,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,GAAG,CACP,GAAW,EACX,MAAY,EACZ,OAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,IAAI,CACR,GAAW,EACX,IAAU,EACV,OAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,GAAG,CACP,GAAW,EACX,IAAU,EACV,OAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAW,EACX,OAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC;CACF;AApHD,gCAoHC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crediblex.io/fineract-api-client",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "TypeScript client for Fineract APIs",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"build:docs": "typedoc",
|
|
13
|
+
"dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node src/examples/run-examples.ts",
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"lint": "eslint src/**/*.ts",
|
|
16
|
+
"prepare": "npm run build",
|
|
17
|
+
"prepublishOnly": "npm test"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"fineract",
|
|
21
|
+
"api-client",
|
|
22
|
+
"typescript"
|
|
23
|
+
],
|
|
24
|
+
"author": "Haider Abbas haider@crediblex.io",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/crediblex/fineract-api-client.git"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"axios": "^1.6.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/jest": "^29.5.0",
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
37
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
38
|
+
"eslint": "^8.45.0",
|
|
39
|
+
"jest": "^29.5.0",
|
|
40
|
+
"ts-jest": "^29.1.0",
|
|
41
|
+
"ts-node": "^10.9.0",
|
|
42
|
+
"typedoc": "^0.25.0",
|
|
43
|
+
"typescript": "^5.2.0"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=16.0.0"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|