@zauto/api-connector 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 +208 -0
- package/dist/dto/api-config.dto.d.ts +24 -0
- package/dist/dto/api-config.dto.js +94 -0
- package/dist/dto/api-config.dto.js.map +1 -0
- package/dist/dto/endpoint-config.dto.d.ts +7 -0
- package/dist/dto/endpoint-config.dto.js +39 -0
- package/dist/dto/endpoint-config.dto.js.map +1 -0
- package/dist/dto/field-mapping.dto.d.ts +7 -0
- package/dist/dto/field-mapping.dto.js +34 -0
- package/dist/dto/field-mapping.dto.js.map +1 -0
- package/dist/enums/resources.enum.d.ts +8 -0
- package/dist/enums/resources.enum.js +13 -0
- package/dist/enums/resources.enum.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +611 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +86 -0
- package/src/dto/api-config.dto.ts +115 -0
- package/src/dto/endpoint-config.dto.ts +23 -0
- package/src/dto/field-mapping.dto.ts +19 -0
- package/src/enums/resources.enum.ts +9 -0
- package/src/index.ts +850 -0
package/README.md
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
# API Connector Package
|
2
|
+
|
3
|
+
A dynamic and flexible TypeScript-based API connector package designed to facilitate seamless integration between a local database and external APIs. The package includes features like dynamic field mapping, endpoint configuration, and robust authentication support.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- **Dynamic API Configuration**: Manage API settings like base URL, authentication, and headers dynamically.
|
8
|
+
- **Endpoint Management**: Configure endpoints with methods, headers, and field mappings.
|
9
|
+
- **Field Mapping**: Dynamically map request and response fields for six resources: `Patient`, `Physician`, `Facility`, `Schedule`, `Slot`, and `Appointment`.
|
10
|
+
- **Authentication**: Supports multiple authentication types (`BASIC`, `BEARER`, `API_KEY`, or `NONE`).
|
11
|
+
- **Retry and Timeout Policies**: Define retry strategies and request timeouts for robust communication.
|
12
|
+
- **Prisma Integration**: Leverages Prisma for database interactions with models such as `ApiConfig`, `EndpointConfig`, and `FieldMapping`.
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Install the package using npm:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
npm install <package-name>
|
22
|
+
```
|
23
|
+
|
24
|
+
---
|
25
|
+
|
26
|
+
## Database Design
|
27
|
+
|
28
|
+
### Models
|
29
|
+
|
30
|
+
- **ApiConfig**: Stores the top-level configuration for APIs.
|
31
|
+
- **EndpointConfig**: Manages endpoint-specific configurations linked to an API.
|
32
|
+
- **FieldMapping**: Handles request and response field mappings for endpoints.
|
33
|
+
|
34
|
+
### Example Schema
|
35
|
+
|
36
|
+
```prisma
|
37
|
+
model ApiConfig {
|
38
|
+
id String @id @default(uuid())
|
39
|
+
baseUrl String
|
40
|
+
authType String
|
41
|
+
infoForAuthType Json @default("{}")
|
42
|
+
defaultHeaders Json @default("{}")
|
43
|
+
timeout Int?
|
44
|
+
environment String?
|
45
|
+
retryPolicy Json @default("{}")
|
46
|
+
orgId String?
|
47
|
+
doneBy String?
|
48
|
+
createdAt DateTime @default(now())
|
49
|
+
updatedAt DateTime @updatedAt
|
50
|
+
endpoints EndpointConfig[]
|
51
|
+
}
|
52
|
+
|
53
|
+
model EndpointConfig {
|
54
|
+
id String @id @default(uuid())
|
55
|
+
name String
|
56
|
+
method String
|
57
|
+
suburl String
|
58
|
+
headers Json @default("{}")
|
59
|
+
createdAt DateTime @default(now())
|
60
|
+
updatedAt DateTime @updatedAt
|
61
|
+
apiConfigId String
|
62
|
+
apiConfig ApiConfig @relation(fields: [apiConfigId], references: [id])
|
63
|
+
FieldMapping FieldMapping[]
|
64
|
+
|
65
|
+
@@unique([name, apiConfigId])
|
66
|
+
}
|
67
|
+
|
68
|
+
model FieldMapping {
|
69
|
+
id String @id @default(uuid())
|
70
|
+
resourceType ResourceType
|
71
|
+
requestMapping Json?
|
72
|
+
responseMapping Json?
|
73
|
+
createdAt DateTime @default(now())
|
74
|
+
updatedAt DateTime @updatedAt
|
75
|
+
endpointId String
|
76
|
+
endpoint EndpointConfig @relation(fields: [endpointId], references: [id])
|
77
|
+
}
|
78
|
+
|
79
|
+
enum ResourceType {
|
80
|
+
Patient
|
81
|
+
Physician
|
82
|
+
Facility
|
83
|
+
Schedule
|
84
|
+
Slot
|
85
|
+
Appointment
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
89
|
+
---
|
90
|
+
|
91
|
+
## Usage
|
92
|
+
|
93
|
+
### API Configuration
|
94
|
+
|
95
|
+
Use `saveApiConfig` to save or update API configurations dynamically:
|
96
|
+
|
97
|
+
```typescript
|
98
|
+
import { PrismaClient } from '@prisma/client';
|
99
|
+
import { saveApiConfig } from '<package-name>';
|
100
|
+
|
101
|
+
const prisma = new PrismaClient();
|
102
|
+
|
103
|
+
const apiConfig = {
|
104
|
+
baseUrl: 'https://api.example.com',
|
105
|
+
authType: 'BEARER',
|
106
|
+
infoForAuthType: { token: 'your-token' },
|
107
|
+
};
|
108
|
+
|
109
|
+
const result = await saveApiConfig(prisma, apiConfig, { orgId: '123' });
|
110
|
+
console.log(result);
|
111
|
+
```
|
112
|
+
|
113
|
+
### Endpoint Configuration
|
114
|
+
|
115
|
+
Save or update endpoint configurations linked to an API configuration:
|
116
|
+
|
117
|
+
```typescript
|
118
|
+
import { saveEndpointConfig } from '<package-name>';
|
119
|
+
|
120
|
+
const endpointConfig = {
|
121
|
+
name: 'getPatients',
|
122
|
+
method: 'GET',
|
123
|
+
suburl: '/patients',
|
124
|
+
apiConfigId: 'api-config-id',
|
125
|
+
};
|
126
|
+
|
127
|
+
const result = await saveEndpointConfig(prisma, endpointConfig);
|
128
|
+
console.log(result);
|
129
|
+
```
|
130
|
+
|
131
|
+
### Field Mapping
|
132
|
+
|
133
|
+
Configure dynamic mappings for request and response data:
|
134
|
+
|
135
|
+
```typescript
|
136
|
+
import { saveFieldMapping } from '<package-name>';
|
137
|
+
|
138
|
+
const fieldMapping = {
|
139
|
+
resourceType: 'Patient',
|
140
|
+
requestMapping: { localField1: 'apiField1', localField2: 'apiField2' },
|
141
|
+
responseMapping: { apiField1: 'localField1', apiField2: 'localField2' },
|
142
|
+
endpointId: 'endpoint-id',
|
143
|
+
};
|
144
|
+
|
145
|
+
const result = await saveFieldMapping(prisma, fieldMapping);
|
146
|
+
console.log(result);
|
147
|
+
```
|
148
|
+
|
149
|
+
### API Call with Dynamic Mapping
|
150
|
+
|
151
|
+
Make API calls with dynamic field mapping applied to request and response data:
|
152
|
+
|
153
|
+
```typescript
|
154
|
+
import { callApiWithMapping } from '<package-name>';
|
155
|
+
|
156
|
+
const response = await callApiWithMapping(prisma, 'endpoint-id', {
|
157
|
+
localField1: 'value1',
|
158
|
+
});
|
159
|
+
console.log(response);
|
160
|
+
```
|
161
|
+
|
162
|
+
---
|
163
|
+
|
164
|
+
## Authentication Types
|
165
|
+
|
166
|
+
- **BASIC**: Username and password authentication.
|
167
|
+
- **BEARER**: Token-based authentication.
|
168
|
+
- **API_KEY**: API key authentication.
|
169
|
+
- **NONE**: No authentication.
|
170
|
+
|
171
|
+
---
|
172
|
+
|
173
|
+
## Development
|
174
|
+
|
175
|
+
### Directory Structure
|
176
|
+
|
177
|
+
```plaintext
|
178
|
+
/src
|
179
|
+
/dto
|
180
|
+
api-config.dto.ts
|
181
|
+
endpoint-config.dto.ts
|
182
|
+
field-mapping.dto.ts
|
183
|
+
index.ts
|
184
|
+
```
|
185
|
+
|
186
|
+
### Exported Functions
|
187
|
+
|
188
|
+
- `saveApiConfig`
|
189
|
+
- `updateApiConfig`
|
190
|
+
- `saveEndpointConfig`
|
191
|
+
- `saveFieldMapping`
|
192
|
+
- `callApiWithMapping`
|
193
|
+
|
194
|
+
---
|
195
|
+
|
196
|
+
## Contributing
|
197
|
+
|
198
|
+
Contributions are welcome! Submit issues or pull requests on GitHub.
|
199
|
+
|
200
|
+
---
|
201
|
+
|
202
|
+
## License
|
203
|
+
|
204
|
+
[MIT License](LICENSE)
|
205
|
+
|
206
|
+
---
|
207
|
+
|
208
|
+
Let me know if there are additional details or changes you'd like to make!
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export declare enum AuthType {
|
2
|
+
NONE = "none",
|
3
|
+
BASIC = "basic",
|
4
|
+
BEARER = "bearer",
|
5
|
+
API_KEY = "apiKey"
|
6
|
+
}
|
7
|
+
export declare class AuthCredentialsDto {
|
8
|
+
username?: string;
|
9
|
+
password?: string;
|
10
|
+
token?: string;
|
11
|
+
apiKey?: string;
|
12
|
+
}
|
13
|
+
export declare class RetryPolicyDto {
|
14
|
+
maxRetries?: number;
|
15
|
+
retryDelayMs?: number;
|
16
|
+
retryOnStatusCodes?: string[];
|
17
|
+
}
|
18
|
+
export declare class ApiConfigDto {
|
19
|
+
baseUrl: string;
|
20
|
+
authType: AuthType;
|
21
|
+
infoForAuthType?: AuthCredentialsDto;
|
22
|
+
timeout?: number;
|
23
|
+
retryPolicy?: RetryPolicyDto;
|
24
|
+
}
|
@@ -0,0 +1,94 @@
|
|
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.ApiConfigDto = exports.RetryPolicyDto = exports.AuthCredentialsDto = exports.AuthType = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
15
|
+
var AuthType;
|
16
|
+
(function (AuthType) {
|
17
|
+
AuthType["NONE"] = "none";
|
18
|
+
AuthType["BASIC"] = "basic";
|
19
|
+
AuthType["BEARER"] = "bearer";
|
20
|
+
AuthType["API_KEY"] = "apiKey";
|
21
|
+
})(AuthType || (exports.AuthType = AuthType = {}));
|
22
|
+
class AuthCredentialsDto {
|
23
|
+
}
|
24
|
+
exports.AuthCredentialsDto = AuthCredentialsDto;
|
25
|
+
__decorate([
|
26
|
+
(0, class_validator_1.IsOptional)(),
|
27
|
+
(0, class_validator_1.IsString)(),
|
28
|
+
__metadata("design:type", String)
|
29
|
+
], AuthCredentialsDto.prototype, "username", void 0);
|
30
|
+
__decorate([
|
31
|
+
(0, class_validator_1.IsOptional)(),
|
32
|
+
(0, class_validator_1.IsString)(),
|
33
|
+
__metadata("design:type", String)
|
34
|
+
], AuthCredentialsDto.prototype, "password", void 0);
|
35
|
+
__decorate([
|
36
|
+
(0, class_validator_1.IsOptional)(),
|
37
|
+
(0, class_validator_1.IsString)(),
|
38
|
+
__metadata("design:type", String)
|
39
|
+
], AuthCredentialsDto.prototype, "token", void 0);
|
40
|
+
__decorate([
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
42
|
+
(0, class_validator_1.IsString)(),
|
43
|
+
__metadata("design:type", String)
|
44
|
+
], AuthCredentialsDto.prototype, "apiKey", void 0);
|
45
|
+
class RetryPolicyDto {
|
46
|
+
}
|
47
|
+
exports.RetryPolicyDto = RetryPolicyDto;
|
48
|
+
__decorate([
|
49
|
+
(0, class_validator_1.IsOptional)(),
|
50
|
+
(0, class_validator_1.IsInt)(),
|
51
|
+
(0, class_validator_1.Min)(0),
|
52
|
+
__metadata("design:type", Number)
|
53
|
+
], RetryPolicyDto.prototype, "maxRetries", void 0);
|
54
|
+
__decorate([
|
55
|
+
(0, class_validator_1.IsOptional)(),
|
56
|
+
(0, class_validator_1.IsNumber)(),
|
57
|
+
(0, class_validator_1.Min)(0),
|
58
|
+
__metadata("design:type", Number)
|
59
|
+
], RetryPolicyDto.prototype, "retryDelayMs", void 0);
|
60
|
+
__decorate([
|
61
|
+
(0, class_validator_1.IsOptional)(),
|
62
|
+
(0, class_validator_1.IsString)({ each: true }),
|
63
|
+
__metadata("design:type", Array)
|
64
|
+
], RetryPolicyDto.prototype, "retryOnStatusCodes", void 0);
|
65
|
+
class ApiConfigDto {
|
66
|
+
}
|
67
|
+
exports.ApiConfigDto = ApiConfigDto;
|
68
|
+
__decorate([
|
69
|
+
(0, class_validator_1.IsString)(),
|
70
|
+
__metadata("design:type", String)
|
71
|
+
], ApiConfigDto.prototype, "baseUrl", void 0);
|
72
|
+
__decorate([
|
73
|
+
(0, class_validator_1.IsEnum)(AuthType),
|
74
|
+
__metadata("design:type", String)
|
75
|
+
], ApiConfigDto.prototype, "authType", void 0);
|
76
|
+
__decorate([
|
77
|
+
(0, class_validator_1.IsOptional)(),
|
78
|
+
(0, class_validator_1.ValidateNested)(),
|
79
|
+
(0, class_transformer_1.Type)(() => AuthCredentialsDto),
|
80
|
+
__metadata("design:type", AuthCredentialsDto)
|
81
|
+
], ApiConfigDto.prototype, "infoForAuthType", void 0);
|
82
|
+
__decorate([
|
83
|
+
(0, class_validator_1.IsOptional)(),
|
84
|
+
(0, class_validator_1.IsNumber)(),
|
85
|
+
(0, class_validator_1.Min)(0),
|
86
|
+
__metadata("design:type", Number)
|
87
|
+
], ApiConfigDto.prototype, "timeout", void 0);
|
88
|
+
__decorate([
|
89
|
+
(0, class_validator_1.IsOptional)(),
|
90
|
+
(0, class_validator_1.ValidateNested)(),
|
91
|
+
(0, class_transformer_1.Type)(() => RetryPolicyDto),
|
92
|
+
__metadata("design:type", RetryPolicyDto)
|
93
|
+
], ApiConfigDto.prototype, "retryPolicy", void 0);
|
94
|
+
//# sourceMappingURL=api-config.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"api-config.dto.js","sourceRoot":"","sources":["../../src/dto/api-config.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA+G;AAC/G,yDAAyC;AAKzC,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,6BAAiB,CAAA;IACjB,8BAAkB,CAAA;AACpB,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAKD,MAAa,kBAAkB;CA4B9B;AA5BD,gDA4BC;AAtBC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACO;AAOlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACO;AAOlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;iDACI;AAOf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACK;AAMlB,MAAa,cAAc;CAuB1B;AAvBD,wCAuBC;AAhBC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;kDACa;AAQpB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;;oDACe;AAOtB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;0DACK;AAMhC,MAAa,YAAY;CAqCxB;AArCD,oCAqCC;AA/BC;IADC,IAAA,0BAAQ,GAAE;;6CACK;AAMhB;IADC,IAAA,wBAAM,EAAC,QAAQ,CAAC;;8CACE;AAQnB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;8BACb,kBAAkB;qDAAC;AAQrC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,CAAC,CAAC;;6CACU;AAQjB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,cAAc,CAAC;8BACb,cAAc;iDAAC"}
|
@@ -0,0 +1,39 @@
|
|
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.EndpointConfigDto = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class EndpointConfigDto {
|
15
|
+
}
|
16
|
+
exports.EndpointConfigDto = EndpointConfigDto;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsString)(),
|
19
|
+
__metadata("design:type", String)
|
20
|
+
], EndpointConfigDto.prototype, "name", void 0);
|
21
|
+
__decorate([
|
22
|
+
(0, class_validator_1.IsString)(),
|
23
|
+
(0, class_validator_1.IsIn)(['GET', 'POST', 'PUT', 'DELETE']),
|
24
|
+
__metadata("design:type", String)
|
25
|
+
], EndpointConfigDto.prototype, "method", void 0);
|
26
|
+
__decorate([
|
27
|
+
(0, class_validator_1.IsString)(),
|
28
|
+
__metadata("design:type", String)
|
29
|
+
], EndpointConfigDto.prototype, "suburl", void 0);
|
30
|
+
__decorate([
|
31
|
+
(0, class_validator_1.IsOptional)(),
|
32
|
+
(0, class_validator_1.IsObject)(),
|
33
|
+
__metadata("design:type", Object)
|
34
|
+
], EndpointConfigDto.prototype, "headers", void 0);
|
35
|
+
__decorate([
|
36
|
+
(0, class_validator_1.IsString)(),
|
37
|
+
__metadata("design:type", String)
|
38
|
+
], EndpointConfigDto.prototype, "apiConfigId", void 0);
|
39
|
+
//# sourceMappingURL=endpoint-config.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"endpoint-config.dto.js","sourceRoot":"","sources":["../../src/dto/endpoint-config.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8E;AAK9E,MAAa,iBAAiB;CAiB7B;AAjBD,8CAiBC;AAfC;IADC,IAAA,0BAAQ,GAAE;;+CACE;AAIb;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,sBAAI,EAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;;iDACG;AAG1C;IADC,IAAA,0BAAQ,GAAE;;iDACI;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACsB;AAGjC;IADC,IAAA,0BAAQ,GAAE;;sDACS"}
|
@@ -0,0 +1,34 @@
|
|
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.FieldMappingDto = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
const resources_enum_1 = require("../enums/resources.enum");
|
15
|
+
class FieldMappingDto {
|
16
|
+
}
|
17
|
+
exports.FieldMappingDto = FieldMappingDto;
|
18
|
+
__decorate([
|
19
|
+
(0, class_validator_1.IsEnum)(resources_enum_1.ResourceType),
|
20
|
+
__metadata("design:type", String)
|
21
|
+
], FieldMappingDto.prototype, "resourceType", void 0);
|
22
|
+
__decorate([
|
23
|
+
(0, class_validator_1.IsObject)(),
|
24
|
+
__metadata("design:type", Object)
|
25
|
+
], FieldMappingDto.prototype, "requestMapping", void 0);
|
26
|
+
__decorate([
|
27
|
+
(0, class_validator_1.IsObject)(),
|
28
|
+
__metadata("design:type", Object)
|
29
|
+
], FieldMappingDto.prototype, "responseMapping", void 0);
|
30
|
+
__decorate([
|
31
|
+
(0, class_validator_1.IsString)(),
|
32
|
+
__metadata("design:type", String)
|
33
|
+
], FieldMappingDto.prototype, "endpointId", void 0);
|
34
|
+
//# sourceMappingURL=field-mapping.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"field-mapping.dto.js","sourceRoot":"","sources":["../../src/dto/field-mapping.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoE;AACpE,4DAAwD;AAKxD,MAAa,eAAe;CAY3B;AAZD,0CAYC;AAVC;IADC,IAAA,wBAAM,EAAC,6BAAY,CAAC;;qDACM;AAG3B;IADC,IAAA,0BAAQ,GAAE;;uDAC6B;AAGxC;IADC,IAAA,0BAAQ,GAAE;;wDAC8B;AAGzC;IADC,IAAA,0BAAQ,GAAE;;mDACQ"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ResourceType = void 0;
|
4
|
+
var ResourceType;
|
5
|
+
(function (ResourceType) {
|
6
|
+
ResourceType["Patient"] = "Patient";
|
7
|
+
ResourceType["Physician"] = "Physician";
|
8
|
+
ResourceType["Facility"] = "Facility";
|
9
|
+
ResourceType["Schedule"] = "Schedule";
|
10
|
+
ResourceType["Slot"] = "Slot";
|
11
|
+
ResourceType["Appointment"] = "Appointment";
|
12
|
+
})(ResourceType || (exports.ResourceType = ResourceType = {}));
|
13
|
+
//# sourceMappingURL=resources.enum.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resources.enum.js","sourceRoot":"","sources":["../../src/enums/resources.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAOT;AAPH,WAAY,YAAY;IACpB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,2CAA2B,CAAA;AAC7B,CAAC,EAPS,YAAY,4BAAZ,YAAY,QAOrB"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
2
|
+
import { ApiConfigDto } from './dto/api-config.dto';
|
3
|
+
import { EndpointConfigDto } from './dto/endpoint-config.dto';
|
4
|
+
import { FieldMappingDto } from './dto/field-mapping.dto';
|
5
|
+
export declare function saveApiConfig(prisma: PrismaClient, apiConfig: ApiConfigDto, additionalParams?: Record<string, any>, searchCriteria?: Record<string, any>): Promise<{
|
6
|
+
operation: string;
|
7
|
+
config: any;
|
8
|
+
}>;
|
9
|
+
export declare function updateApiConfig(prisma: PrismaClient, updateData: Partial<ApiConfigDto> & Record<string, any>, searchCriteria: Record<string, any>): Promise<any>;
|
10
|
+
export declare function saveEndpointConfig(prisma: PrismaClient, endpointConfig: EndpointConfigDto): Promise<{
|
11
|
+
message: string;
|
12
|
+
config: any;
|
13
|
+
operation?: undefined;
|
14
|
+
} | {
|
15
|
+
operation: string;
|
16
|
+
config: any;
|
17
|
+
message?: undefined;
|
18
|
+
}>;
|
19
|
+
export declare function updateEndpointConfig(prisma: PrismaClient, endpointId: string, updateData: Partial<EndpointConfigDto>): Promise<{
|
20
|
+
operation: string;
|
21
|
+
config: any;
|
22
|
+
}>;
|
23
|
+
export declare function saveFieldMapping(prisma: PrismaClient, fieldMapping: FieldMappingDto): Promise<{
|
24
|
+
message: string;
|
25
|
+
operation?: undefined;
|
26
|
+
mapping?: undefined;
|
27
|
+
} | {
|
28
|
+
operation: string;
|
29
|
+
mapping: any;
|
30
|
+
message?: undefined;
|
31
|
+
}>;
|
32
|
+
export declare function updateFieldMapping(prisma: PrismaClient, fieldMappingId: string, updateData: Partial<FieldMappingDto>): Promise<{
|
33
|
+
operation: string;
|
34
|
+
mapping: any;
|
35
|
+
}>;
|
36
|
+
export declare function callApiWithMapping(prisma: PrismaClient, endpointId: string, data?: Record<string, any>, queryParams?: Record<string, any>, pathParams?: string, subUrl?: string): Promise<any>;
|
37
|
+
export declare function executeDynamicFunction(prisma: PrismaClient, orgId: string, functionName: string, input: Record<string, any>): Promise<Record<string, any>>;
|
38
|
+
export { ApiConfigDto } from './dto/api-config.dto';
|
39
|
+
export { AuthType } from './dto/api-config.dto';
|