@integraciones_doc24/sdk 1.16.29 → 1.16.30
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 +206 -206
- package/lib/baseSdk/consultation.d.ts +99 -0
- package/lib/baseSdk/consultation.js +23 -0
- package/lib/baseSdk/diagnostica.d.ts +54 -54
- package/lib/baseSdk/diagnostica.js +82 -82
- package/lib/baseSdk/external.d.ts +177 -177
- package/lib/baseSdk/external.js +96 -96
- package/lib/baseSdk/index.d.ts +2 -2
- package/lib/baseSdk/index.js +77 -76
- package/lib/baseSdk/user.d.ts +112 -112
- package/lib/baseSdk/user.js +136 -136
- package/lib/index.d.ts +400 -400
- package/lib/index.js +22 -22
- package/lib/request/index.d.ts +4 -4
- package/lib/request/index.js +32 -32
- package/lib/request/token.d.ts +2 -2
- package/lib/request/token.js +34 -34
- package/lib/request/validation.d.ts +10 -10
- package/lib/request/validation.js +28 -28
- package/lib/schemas.d.ts +2518 -2518
- package/lib/schemas.js +548 -548
- package/lib/types.d.ts +170 -170
- package/lib/types.js +2 -2
- package/lib/userSdk/binah.d.ts +21 -21
- package/lib/userSdk/binah.js +20 -20
- package/lib/userSdk/chat.d.ts +57 -57
- package/lib/userSdk/chat.js +98 -98
- package/lib/userSdk/external.d.ts +34 -34
- package/lib/userSdk/external.js +72 -72
- package/lib/userSdk/index.d.ts +2 -2
- package/lib/userSdk/index.js +33 -33
- package/lib/userSdk/patients.d.ts +58 -58
- package/lib/userSdk/patients.js +89 -89
- package/lib/userSdk/schedule.d.ts +58 -58
- package/lib/userSdk/schedule.js +89 -89
- package/lib/userSdk/specialties.d.ts +19 -19
- package/lib/userSdk/specialties.js +48 -48
- package/lib/userSdk/videoVisit.d.ts +187 -187
- package/lib/userSdk/videoVisit.js +250 -250
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +43 -43
- package/lib/webhook/index.d.ts +2 -2
- package/lib/webhook/index.js +67 -67
- package/lib/webhook/responses.d.ts +35 -35
- package/lib/webhook/responses.js +42 -42
- package/lib/webhook/token.d.ts +2 -2
- package/lib/webhook/token.js +23 -23
- package/package.json +37 -37
package/lib/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doc24Sdk = void 0;
|
|
4
|
-
const webhook_1 = require("./webhook");
|
|
5
|
-
const baseSdk_1 = require("./baseSdk");
|
|
6
|
-
const request_1 = require("./request");
|
|
7
|
-
const doc24Sdk = async (params) => {
|
|
8
|
-
const baseSdk = await baseSdk_1.getBaseSdk(params.url, params.credentials);
|
|
9
|
-
const makeRequest = await request_1.getRequestFactory(params.url, params.credentials);
|
|
10
|
-
return {
|
|
11
|
-
...baseSdk,
|
|
12
|
-
getRequestHandler: async (params) => {
|
|
13
|
-
await makeRequest('PUT', '/webhook', {
|
|
14
|
-
url: params.baseAddress,
|
|
15
|
-
issuer: params.credentials.iss,
|
|
16
|
-
secret: params.credentials.key,
|
|
17
|
-
});
|
|
18
|
-
return webhook_1.getRequestHandler(params.credentials, baseSdk, params.eventHandlers);
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.doc24Sdk = doc24Sdk;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doc24Sdk = void 0;
|
|
4
|
+
const webhook_1 = require("./webhook");
|
|
5
|
+
const baseSdk_1 = require("./baseSdk");
|
|
6
|
+
const request_1 = require("./request");
|
|
7
|
+
const doc24Sdk = async (params) => {
|
|
8
|
+
const baseSdk = await baseSdk_1.getBaseSdk(params.url, params.credentials);
|
|
9
|
+
const makeRequest = await request_1.getRequestFactory(params.url, params.credentials);
|
|
10
|
+
return {
|
|
11
|
+
...baseSdk,
|
|
12
|
+
getRequestHandler: async (params) => {
|
|
13
|
+
await makeRequest('PUT', '/webhook', {
|
|
14
|
+
url: params.baseAddress,
|
|
15
|
+
issuer: params.credentials.iss,
|
|
16
|
+
secret: params.credentials.key,
|
|
17
|
+
});
|
|
18
|
+
return webhook_1.getRequestHandler(params.credentials, baseSdk, params.eventHandlers);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.doc24Sdk = doc24Sdk;
|
package/lib/request/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Doc24 } from '../types';
|
|
2
|
-
import FormData from 'form-data';
|
|
3
|
-
export declare const getRequestFactory: (url: string, credentials: Doc24.SdkCredentials, userId?: number | undefined) => Promise<RequestMaker>;
|
|
4
|
-
export declare type RequestMaker = (method: 'POST' | 'GET' | 'PUT' | 'DELETE', path: string, body?: object | FormData) => Promise<any>;
|
|
1
|
+
import { Doc24 } from '../types';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
export declare const getRequestFactory: (url: string, credentials: Doc24.SdkCredentials, userId?: number | undefined) => Promise<RequestMaker>;
|
|
4
|
+
export declare type RequestMaker = (method: 'POST' | 'GET' | 'PUT' | 'DELETE', path: string, body?: object | FormData) => Promise<any>;
|
package/lib/request/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
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.getRequestFactory = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const token_1 = require("./token");
|
|
9
|
-
const debug_1 = __importDefault(require("debug"));
|
|
10
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
11
|
-
const debugRequest = debug_1.default('doc24Sdk:request');
|
|
12
|
-
const getRequestFactory = async (url, credentials, userId) => {
|
|
13
|
-
const makeRequest = async (method, path, body) => {
|
|
14
|
-
const isMultipart = body instanceof form_data_1.default;
|
|
15
|
-
const token = await token_1.getToken(credentials, body && !isMultipart ? JSON.stringify(body) : undefined, userId);
|
|
16
|
-
const fullUrl = url + path;
|
|
17
|
-
let headers = { Authentication: token };
|
|
18
|
-
if (isMultipart) {
|
|
19
|
-
headers = { ...headers, ...body.getHeaders() };
|
|
20
|
-
}
|
|
21
|
-
const result = await axios_1.default({
|
|
22
|
-
method,
|
|
23
|
-
url: fullUrl,
|
|
24
|
-
headers,
|
|
25
|
-
data: body,
|
|
26
|
-
});
|
|
27
|
-
debugRequest({ url: fullUrl, response: result.data, body });
|
|
28
|
-
return result.data;
|
|
29
|
-
};
|
|
30
|
-
return makeRequest;
|
|
31
|
-
};
|
|
32
|
-
exports.getRequestFactory = getRequestFactory;
|
|
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.getRequestFactory = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const token_1 = require("./token");
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
11
|
+
const debugRequest = debug_1.default('doc24Sdk:request');
|
|
12
|
+
const getRequestFactory = async (url, credentials, userId) => {
|
|
13
|
+
const makeRequest = async (method, path, body) => {
|
|
14
|
+
const isMultipart = body instanceof form_data_1.default;
|
|
15
|
+
const token = await token_1.getToken(credentials, body && !isMultipart ? JSON.stringify(body) : undefined, userId);
|
|
16
|
+
const fullUrl = url + path;
|
|
17
|
+
let headers = { Authentication: token };
|
|
18
|
+
if (isMultipart) {
|
|
19
|
+
headers = { ...headers, ...body.getHeaders() };
|
|
20
|
+
}
|
|
21
|
+
const result = await axios_1.default({
|
|
22
|
+
method,
|
|
23
|
+
url: fullUrl,
|
|
24
|
+
headers,
|
|
25
|
+
data: body,
|
|
26
|
+
});
|
|
27
|
+
debugRequest({ url: fullUrl, response: result.data, body });
|
|
28
|
+
return result.data;
|
|
29
|
+
};
|
|
30
|
+
return makeRequest;
|
|
31
|
+
};
|
|
32
|
+
exports.getRequestFactory = getRequestFactory;
|
package/lib/request/token.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Doc24 } from '../types';
|
|
2
|
-
export declare const getToken: (credentials: Doc24.SdkCredentials, bodyAsJson?: string | undefined, userId?: number | undefined) => Promise<string>;
|
|
1
|
+
import { Doc24 } from '../types';
|
|
2
|
+
export declare const getToken: (credentials: Doc24.SdkCredentials, bodyAsJson?: string | undefined, userId?: number | undefined) => Promise<string>;
|
package/lib/request/token.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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.getToken = void 0;
|
|
7
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
-
const tokenLifeTimeInSeconds = 500 * 60;
|
|
10
|
-
const getToken = async (credentials, bodyAsJson, userId) => {
|
|
11
|
-
const tokenData = {
|
|
12
|
-
msg_sig: createSignature(credentials.key, bodyAsJson),
|
|
13
|
-
user_id: userId,
|
|
14
|
-
};
|
|
15
|
-
const encodedToken = await makeJwt(tokenData, credentials.key, {
|
|
16
|
-
expiresIn: tokenLifeTimeInSeconds,
|
|
17
|
-
issuer: credentials.iss,
|
|
18
|
-
});
|
|
19
|
-
return encodedToken;
|
|
20
|
-
};
|
|
21
|
-
exports.getToken = getToken;
|
|
22
|
-
const makeJwt = (payload, key, options = {}) => new Promise((resolve, reject) => jsonwebtoken_1.default.sign(payload, key, options, (err, token) => {
|
|
23
|
-
if (err || !token)
|
|
24
|
-
return reject(err);
|
|
25
|
-
resolve(token);
|
|
26
|
-
}));
|
|
27
|
-
const createSignature = (secret, bodyAsJson) => {
|
|
28
|
-
//TODO: verify this, seems wrong
|
|
29
|
-
const realSecret = bodyAsJson ? secret : 'true';
|
|
30
|
-
const realBody = bodyAsJson !== null && bodyAsJson !== void 0 ? bodyAsJson : secret;
|
|
31
|
-
const hmac = crypto_1.default.createHmac('sha256', realSecret);
|
|
32
|
-
hmac.update(realBody);
|
|
33
|
-
return hmac.digest('base64');
|
|
34
|
-
};
|
|
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.getToken = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const tokenLifeTimeInSeconds = 500 * 60;
|
|
10
|
+
const getToken = async (credentials, bodyAsJson, userId) => {
|
|
11
|
+
const tokenData = {
|
|
12
|
+
msg_sig: createSignature(credentials.key, bodyAsJson),
|
|
13
|
+
user_id: userId,
|
|
14
|
+
};
|
|
15
|
+
const encodedToken = await makeJwt(tokenData, credentials.key, {
|
|
16
|
+
expiresIn: tokenLifeTimeInSeconds,
|
|
17
|
+
issuer: credentials.iss,
|
|
18
|
+
});
|
|
19
|
+
return encodedToken;
|
|
20
|
+
};
|
|
21
|
+
exports.getToken = getToken;
|
|
22
|
+
const makeJwt = (payload, key, options = {}) => new Promise((resolve, reject) => jsonwebtoken_1.default.sign(payload, key, options, (err, token) => {
|
|
23
|
+
if (err || !token)
|
|
24
|
+
return reject(err);
|
|
25
|
+
resolve(token);
|
|
26
|
+
}));
|
|
27
|
+
const createSignature = (secret, bodyAsJson) => {
|
|
28
|
+
//TODO: verify this, seems wrong
|
|
29
|
+
const realSecret = bodyAsJson ? secret : 'true';
|
|
30
|
+
const realBody = bodyAsJson !== null && bodyAsJson !== void 0 ? bodyAsJson : secret;
|
|
31
|
+
const hmac = crypto_1.default.createHmac('sha256', realSecret);
|
|
32
|
+
hmac.update(realBody);
|
|
33
|
+
return hmac.digest('base64');
|
|
34
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ZodError, ZodType } from 'zod';
|
|
2
|
-
export declare class ParametersValidationError extends Error {
|
|
3
|
-
details: ZodError;
|
|
4
|
-
constructor(details: ZodError);
|
|
5
|
-
}
|
|
6
|
-
export declare class ResponseValidationError extends Error {
|
|
7
|
-
details: ZodError;
|
|
8
|
-
constructor(details: ZodError);
|
|
9
|
-
}
|
|
10
|
-
export declare const validateFunction: <TParams extends unknown[], TResponse>(inValidation: ZodType<TParams, import("zod").ZodTypeDef, TParams>, outValidation: ZodType<TResponse, import("zod").ZodTypeDef, TResponse>, fn: (...params: TParams) => Promise<TResponse>) => (...params: TParams) => Promise<TResponse>;
|
|
1
|
+
import { ZodError, ZodType } from 'zod';
|
|
2
|
+
export declare class ParametersValidationError extends Error {
|
|
3
|
+
details: ZodError;
|
|
4
|
+
constructor(details: ZodError);
|
|
5
|
+
}
|
|
6
|
+
export declare class ResponseValidationError extends Error {
|
|
7
|
+
details: ZodError;
|
|
8
|
+
constructor(details: ZodError);
|
|
9
|
+
}
|
|
10
|
+
export declare const validateFunction: <TParams extends unknown[], TResponse>(inValidation: ZodType<TParams, import("zod").ZodTypeDef, TParams>, outValidation: ZodType<TResponse, import("zod").ZodTypeDef, TResponse>, fn: (...params: TParams) => Promise<TResponse>) => (...params: TParams) => Promise<TResponse>;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFunction = exports.ResponseValidationError = exports.ParametersValidationError = void 0;
|
|
4
|
-
class ParametersValidationError extends Error {
|
|
5
|
-
constructor(details) {
|
|
6
|
-
super('Invalid parameters supplied to function');
|
|
7
|
-
this.details = details;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ParametersValidationError = ParametersValidationError;
|
|
11
|
-
class ResponseValidationError extends Error {
|
|
12
|
-
constructor(details) {
|
|
13
|
-
super('Invalid response returned from function');
|
|
14
|
-
this.details = details;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ResponseValidationError = ResponseValidationError;
|
|
18
|
-
const validateFunction = (inValidation, outValidation, fn) => async (...params) => {
|
|
19
|
-
const validationResult = inValidation.safeParse(params);
|
|
20
|
-
if (!validationResult.success)
|
|
21
|
-
throw new ParametersValidationError(validationResult.error);
|
|
22
|
-
const out = await fn(...validationResult.data);
|
|
23
|
-
const responseValidationResult = outValidation.safeParse(out);
|
|
24
|
-
if (!responseValidationResult.success)
|
|
25
|
-
throw new ResponseValidationError(responseValidationResult.error);
|
|
26
|
-
return responseValidationResult.data;
|
|
27
|
-
};
|
|
28
|
-
exports.validateFunction = validateFunction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFunction = exports.ResponseValidationError = exports.ParametersValidationError = void 0;
|
|
4
|
+
class ParametersValidationError extends Error {
|
|
5
|
+
constructor(details) {
|
|
6
|
+
super('Invalid parameters supplied to function');
|
|
7
|
+
this.details = details;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ParametersValidationError = ParametersValidationError;
|
|
11
|
+
class ResponseValidationError extends Error {
|
|
12
|
+
constructor(details) {
|
|
13
|
+
super('Invalid response returned from function');
|
|
14
|
+
this.details = details;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ResponseValidationError = ResponseValidationError;
|
|
18
|
+
const validateFunction = (inValidation, outValidation, fn) => async (...params) => {
|
|
19
|
+
const validationResult = inValidation.safeParse(params);
|
|
20
|
+
if (!validationResult.success)
|
|
21
|
+
throw new ParametersValidationError(validationResult.error);
|
|
22
|
+
const out = await fn(...validationResult.data);
|
|
23
|
+
const responseValidationResult = outValidation.safeParse(out);
|
|
24
|
+
if (!responseValidationResult.success)
|
|
25
|
+
throw new ResponseValidationError(responseValidationResult.error);
|
|
26
|
+
return responseValidationResult.data;
|
|
27
|
+
};
|
|
28
|
+
exports.validateFunction = validateFunction;
|