@integraciones_doc24/sdk 0.35.0 → 1.1.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.
Files changed (102) hide show
  1. package/README.md +131 -83
  2. package/lib/baseSdk/diagnostica.d.ts +6 -6
  3. package/lib/baseSdk/user.d.ts +51 -4
  4. package/lib/baseSdk/user.js +67 -25
  5. package/lib/index.d.ts +44 -16
  6. package/lib/schemas.d.ts +220 -30
  7. package/lib/schemas.js +33 -2
  8. package/lib/test.js +1 -0
  9. package/lib/types.d.ts +10 -2
  10. package/lib/userSdk/chat.d.ts +1 -1
  11. package/lib/userSdk/patients.d.ts +22 -2
  12. package/lib/userSdk/patients.js +34 -6
  13. package/lib/userSdk/videoVisit.d.ts +2 -2
  14. package/lib/utils.d.ts +1 -1
  15. package/lib/utils.js +3 -3
  16. package/package.json +4 -1
  17. package/lib/baseSdk/external.d.ts +0 -28
  18. package/lib/baseSdk/external.js +0 -73
  19. package/lib/lib/baseSdk/diagnostica.d.ts +0 -11
  20. package/lib/lib/baseSdk/diagnostica.js +0 -79
  21. package/lib/lib/baseSdk/external.d.ts +0 -15
  22. package/lib/lib/baseSdk/external.js +0 -73
  23. package/lib/lib/baseSdk/index.d.ts +0 -114
  24. package/lib/lib/baseSdk/index.js +0 -66
  25. package/lib/lib/baseSdk/user.d.ts +0 -30
  26. package/lib/lib/baseSdk/user.js +0 -88
  27. package/lib/lib/index.d.ts +0 -154
  28. package/lib/lib/index.js +0 -22
  29. package/lib/lib/request/index.d.ts +0 -2
  30. package/lib/lib/request/index.js +0 -26
  31. package/lib/lib/request/token.d.ts +0 -2
  32. package/lib/lib/request/token.js +0 -34
  33. package/lib/lib/request/validation.d.ts +0 -10
  34. package/lib/lib/request/validation.js +0 -28
  35. package/lib/lib/schemas.d.ts +0 -1138
  36. package/lib/lib/schemas.js +0 -294
  37. package/lib/lib/test.d.ts +0 -1
  38. package/lib/lib/test.js +0 -55
  39. package/lib/lib/types.d.ts +0 -1
  40. package/lib/lib/types.js +0 -2
  41. package/lib/lib/userSdk/chat.d.ts +0 -9
  42. package/lib/lib/userSdk/chat.js +0 -98
  43. package/lib/lib/userSdk/index.d.ts +0 -220
  44. package/lib/lib/userSdk/index.js +0 -27
  45. package/lib/lib/userSdk/patients.d.ts +0 -4
  46. package/lib/lib/userSdk/patients.js +0 -27
  47. package/lib/lib/userSdk/sarasas.d.ts +0 -6
  48. package/lib/lib/userSdk/sarasas.js +0 -13
  49. package/lib/lib/userSdk/schedule.d.ts +0 -15
  50. package/lib/lib/userSdk/schedule.js +0 -76
  51. package/lib/lib/userSdk/specialties.d.ts +0 -4
  52. package/lib/lib/userSdk/specialties.js +0 -19
  53. package/lib/lib/userSdk/videoVisit.d.ts +0 -72
  54. package/lib/lib/userSdk/videoVisit.js +0 -147
  55. package/lib/lib/utils.d.ts +0 -4
  56. package/lib/lib/utils.js +0 -19
  57. package/lib/lib/webhook/index.d.ts +0 -8
  58. package/lib/lib/webhook/index.js +0 -55
  59. package/lib/lib/webhook/responses.d.ts +0 -36
  60. package/lib/lib/webhook/responses.js +0 -42
  61. package/lib/lib/webhook/token.d.ts +0 -2
  62. package/lib/lib/webhook/token.js +0 -23
  63. package/lib/src/baseSdk/diagnostica.d.ts +0 -54
  64. package/lib/src/baseSdk/diagnostica.js +0 -79
  65. package/lib/src/baseSdk/index.d.ts +0 -2
  66. package/lib/src/baseSdk/index.js +0 -66
  67. package/lib/src/baseSdk/user.d.ts +0 -41
  68. package/lib/src/baseSdk/user.js +0 -88
  69. package/lib/src/index.d.ts +0 -159
  70. package/lib/src/index.js +0 -22
  71. package/lib/src/request/index.d.ts +0 -3
  72. package/lib/src/request/index.js +0 -26
  73. package/lib/src/request/token.d.ts +0 -2
  74. package/lib/src/request/token.js +0 -34
  75. package/lib/src/request/validation.d.ts +0 -10
  76. package/lib/src/request/validation.js +0 -28
  77. package/lib/src/schemas.d.ts +0 -1115
  78. package/lib/src/schemas.js +0 -294
  79. package/lib/src/types.d.ts +0 -116
  80. package/lib/src/types.js +0 -2
  81. package/lib/src/userSdk/chat.d.ts +0 -57
  82. package/lib/src/userSdk/chat.js +0 -98
  83. package/lib/src/userSdk/index.d.ts +0 -2
  84. package/lib/src/userSdk/index.js +0 -27
  85. package/lib/src/userSdk/patients.d.ts +0 -12
  86. package/lib/src/userSdk/patients.js +0 -27
  87. package/lib/src/userSdk/schedule.d.ts +0 -44
  88. package/lib/src/userSdk/schedule.js +0 -76
  89. package/lib/src/userSdk/specialties.d.ts +0 -7
  90. package/lib/src/userSdk/specialties.js +0 -19
  91. package/lib/src/userSdk/videoVisit.d.ts +0 -111
  92. package/lib/src/userSdk/videoVisit.js +0 -147
  93. package/lib/src/utils.d.ts +0 -4
  94. package/lib/src/utils.js +0 -19
  95. package/lib/src/webhook/index.d.ts +0 -2
  96. package/lib/src/webhook/index.js +0 -55
  97. package/lib/src/webhook/responses.d.ts +0 -35
  98. package/lib/src/webhook/responses.js +0 -42
  99. package/lib/src/webhook/token.d.ts +0 -2
  100. package/lib/src/webhook/token.js +0 -23
  101. package/lib/userSdk/sarasas.d.ts +0 -6
  102. package/lib/userSdk/sarasas.js +0 -13
@@ -1,154 +0,0 @@
1
- export var __esModule: boolean;
2
- export function doc24Sdk(params: any): Promise<{
3
- getRequestHandler: (params: any) => Promise<import("./types").Doc24.Webhook.Handler>;
4
- declareUser: (user: {
5
- firstName: string;
6
- lastName: string;
7
- identificationType: "ndi" | "passport" | "credential";
8
- identificationValue: string;
9
- gender: "m" | "f";
10
- phone: string;
11
- email: string;
12
- countryId: string;
13
- birthdate: Date;
14
- }) => Promise<number>;
15
- getUserInstance: (user: number | {
16
- firstName: string;
17
- lastName: string;
18
- identificationType: "ndi" | "passport" | "credential";
19
- identificationValue: string;
20
- gender: "m" | "f";
21
- phone: string;
22
- email: string;
23
- countryId: string;
24
- birthdate: Date;
25
- }) => Promise<import("./types").Doc24.UserSdk>;
26
- getProfessional: (professionalId: number) => Promise<{
27
- id: number;
28
- logoUrl: string;
29
- firstName: string;
30
- lastName: string;
31
- gender: "m" | "f";
32
- phone: string | null;
33
- email: string;
34
- birthdate: Date;
35
- specialties: {
36
- id: number;
37
- description: string;
38
- }[];
39
- matriculation: {
40
- number: string;
41
- type: string;
42
- }[];
43
- degree: string;
44
- languages: string[];
45
- resume: {
46
- link: string;
47
- brief: string;
48
- };
49
- }>;
50
- getAvailableScheduleClinics: () => Promise<{
51
- specialties: {
52
- id: number;
53
- description: string;
54
- }[];
55
- specialtiesER: {
56
- id: number;
57
- description: string;
58
- }[];
59
- professionals: {
60
- id: number;
61
- fullName: string;
62
- clinicId: number;
63
- specialties: {
64
- id: number;
65
- description: string;
66
- }[];
67
- }[];
68
- }>;
69
- enroll: (params: {
70
- firstName: string;
71
- lastName: string;
72
- gender: "m" | "f";
73
- email: string;
74
- birthdate: Date;
75
- startDate: Date;
76
- identificationNumber: string;
77
- plan: string;
78
- }) => Promise<void>;
79
- getConverageInfo: (identificationValue: string) => Promise<{
80
- firstName: string | null;
81
- lastName: string | null;
82
- gender: "m" | "f";
83
- email: string | null;
84
- birthdate: Date;
85
- identificationNumber: string;
86
- plan: string | null;
87
- financerId: number | null;
88
- defaultAffiliationId: number | null;
89
- credentialNumber: string | null;
90
- financerPlanId: number | null;
91
- brand: number | null;
92
- holderIdentificationNumber: string | null;
93
- copaymentValue: number | null;
94
- mobilePhone: string | null;
95
- company: string | null;
96
- dischargeDate: Date | null;
97
- leavingDate: Date | null;
98
- identificacion_tributaria: string | null;
99
- deregistrationDate: Date | null;
100
- authorizationCode: string | null;
101
- authorizationCodeExpiration: Date | null;
102
- } | null>;
103
- getDiagnosticaHistory: (patient: {
104
- identificationType: "ndi" | "passport" | "credential";
105
- identificationValue: string;
106
- gender: "m" | "f";
107
- }, from: Date, to: Date) => Promise<{
108
- date: Date;
109
- location: string;
110
- exams: string[];
111
- deepLink: string;
112
- }[]>;
113
- getDiagnosticaDeepLink: (kiosk: string, user: {
114
- language: string;
115
- firstName: string;
116
- lastName: string;
117
- birthday: Date;
118
- identificationType: "dni";
119
- identificationValue: string;
120
- gender: "m" | "f";
121
- phone: string;
122
- email: string;
123
- }, patient: {
124
- firstName: string;
125
- lastName: string;
126
- birthday: Date;
127
- identificationType: "dni";
128
- identificationValue: string;
129
- gender: "m" | "f";
130
- }) => Promise<{
131
- forwardingRequired: true;
132
- deepLink: string;
133
- } | {
134
- forwardingRequired: false;
135
- }>;
136
- getDiagnosticaAccess: (kiosk: string, user: {
137
- language: string;
138
- firstName: string;
139
- lastName: string;
140
- birthday: Date;
141
- identificationType: "dni";
142
- identificationValue: string;
143
- gender: "m" | "f";
144
- phone: string;
145
- email: string;
146
- }, patient: {
147
- firstName: string;
148
- lastName: string;
149
- birthday: Date;
150
- identificationType: "dni";
151
- identificationValue: string;
152
- gender: "m" | "f";
153
- }) => Promise<void>;
154
- }>;
package/lib/lib/index.js DELETED
@@ -1,22 +0,0 @@
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,2 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getRequestFactory(url: any, credentials: any, userId: any): Promise<(method: any, path: any, body: any) => Promise<any>>;
@@ -1,26 +0,0 @@
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 debugRequest = debug_1.default('doc24Sdk:request');
11
- const getRequestFactory = async (url, credentials, userId) => {
12
- const makeRequest = async (method, path, body) => {
13
- const token = await token_1.getToken(credentials, body ? JSON.stringify(body) : undefined, userId);
14
- const fullUrl = url + path;
15
- const result = await axios_1.default({
16
- method,
17
- url: fullUrl,
18
- headers: { Authentication: token },
19
- data: body,
20
- });
21
- debugRequest({ url: fullUrl, response: result.data, body });
22
- return result.data;
23
- };
24
- return makeRequest;
25
- };
26
- exports.getRequestFactory = getRequestFactory;
@@ -1,2 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getToken(credentials: any, bodyAsJson: any, userId: any): Promise<any>;
@@ -1,34 +0,0 @@
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 +0,0 @@
1
- export var __esModule: boolean;
2
- export class ParametersValidationError extends Error {
3
- constructor(details: any);
4
- details: any;
5
- }
6
- export class ResponseValidationError extends Error {
7
- constructor(details: any);
8
- details: any;
9
- }
10
- export function validateFunction(inValidation: any, outValidation: any, fn: any): (...params: any[]) => Promise<any>;
@@ -1,28 +0,0 @@
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;