@ctchealth/plato-sdk 0.0.11 → 0.0.12
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 +168 -9
- package/package.json +1 -1
- package/src/lib/constants.d.ts +15 -0
- package/src/lib/constants.js +19 -0
- package/src/lib/constants.js.map +1 -0
- package/src/lib/plato-intefaces.d.ts +57 -17
- package/src/lib/plato-intefaces.js +24 -1
- package/src/lib/plato-intefaces.js.map +1 -1
- package/src/lib/plato-sdk.d.ts +6 -2
- package/src/lib/plato-sdk.js +96 -4
- package/src/lib/plato-sdk.js.map +1 -1
- package/src/lib/utils.d.ts +29 -0
- package/src/lib/utils.js +50 -0
- package/src/lib/utils.js.map +1 -0
package/README.md
CHANGED
|
@@ -6,6 +6,16 @@ A TypeScript SDK for interacting with the Plato API to create and manage AI-powe
|
|
|
6
6
|
|
|
7
7
|
The Plato SDK provides a simple and type-safe way to integrate with the Plato platform, allowing you to create medical training simulations with AI personas and manage voice-based interactions.
|
|
8
8
|
|
|
9
|
+
## Authentication
|
|
10
|
+
|
|
11
|
+
All API requests require authentication using a Bearer token. Include your JWT token in the `API-AUTH` header:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
API-AUTH: Bearer <your-jwt-token>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requests without a valid JWT token will be rejected with a `401 Unauthorized` response.
|
|
18
|
+
|
|
9
19
|
## Features
|
|
10
20
|
|
|
11
21
|
- Create AI personas with customizable professional profiles and personalities
|
|
@@ -24,7 +34,7 @@ npm install plato-sdk
|
|
|
24
34
|
## Quick Start
|
|
25
35
|
|
|
26
36
|
```typescript
|
|
27
|
-
import { PlatoApiClient } from 'plato-sdk';
|
|
37
|
+
import { PlatoApiClient, AvatarLanguage } from 'plato-sdk';
|
|
28
38
|
|
|
29
39
|
// Initialize the client
|
|
30
40
|
const client = new PlatoApiClient({
|
|
@@ -33,6 +43,9 @@ const client = new PlatoApiClient({
|
|
|
33
43
|
user: 'test@test.test',
|
|
34
44
|
});
|
|
35
45
|
|
|
46
|
+
// Get available assistant images
|
|
47
|
+
const images = await client.getAssistantImages();
|
|
48
|
+
|
|
36
49
|
// Create a simulation
|
|
37
50
|
const simulation = await client.createSimulation({
|
|
38
51
|
persona: {
|
|
@@ -69,6 +82,8 @@ const simulation = await client.createSimulation({
|
|
|
69
82
|
'Demonstrate efficacy of Ibuprofen in pain management Highlight safety profile and contraindications Encourage patient adherence',
|
|
70
83
|
anticipatedObjections:
|
|
71
84
|
'Concerns about gastrointestinal side effects Preference for lower-cost generic alternatives Potential interactions with other medications',
|
|
85
|
+
imageId: images[0]._id,
|
|
86
|
+
avatarLanguage: AvatarLanguage.English,
|
|
72
87
|
});
|
|
73
88
|
|
|
74
89
|
// Check the simulation status - If simulation creation phase is equals to FINISHED, the simulation is ready to use
|
|
@@ -225,12 +240,7 @@ Uploads a PDF file for slide analysis. The file will be uploaded to S3 and analy
|
|
|
225
240
|
|
|
226
241
|
- `file` (File | Blob): The PDF file to upload
|
|
227
242
|
|
|
228
|
-
**Returns:** `Promise<
|
|
229
|
-
|
|
230
|
-
- `objectKey`: The S3 object key where the PDF was saved
|
|
231
|
-
- `filename`: The original filename
|
|
232
|
-
- `size`: The file size in bytes
|
|
233
|
-
- `contentType`: The content type of the file
|
|
243
|
+
**Returns:** `Promise<string>` — A success message if the upload was successful.
|
|
234
244
|
|
|
235
245
|
**Example:**
|
|
236
246
|
|
|
@@ -241,11 +251,85 @@ const file = fileInput.files?.[0];
|
|
|
241
251
|
|
|
242
252
|
if (file) {
|
|
243
253
|
const result = await client.uploadPdfSlides(file);
|
|
244
|
-
console.log('PDF
|
|
245
|
-
console.log('Original filename:', result.filename);
|
|
254
|
+
console.log('PDF upload initiated');
|
|
246
255
|
}
|
|
247
256
|
```
|
|
248
257
|
|
|
258
|
+
##### getSlidesAnalysis(queryParams: PdfSlidesAnalysisQueryDto)
|
|
259
|
+
|
|
260
|
+
Retrieves a paginated and sorted list of PDF slide analysis records.
|
|
261
|
+
|
|
262
|
+
**Parameters:**
|
|
263
|
+
|
|
264
|
+
- `queryParams` (PdfSlidesAnalysisQueryDto):
|
|
265
|
+
- `limit` (optional): Number of records per page
|
|
266
|
+
- `page` (optional): Page number
|
|
267
|
+
- `sort` (optional): Sort order (`'asc'` or `'desc'`)
|
|
268
|
+
- `sortBy` (optional): Field to sort by (`'createdAt'`, `'originalFilename'`, or `'totalSlides'`)
|
|
269
|
+
|
|
270
|
+
**Returns:** `Promise<PdfSlidesDto[]>`
|
|
271
|
+
|
|
272
|
+
**Example:**
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
const analysisList = await client.getSlidesAnalysis({
|
|
276
|
+
limit: 10,
|
|
277
|
+
page: 0,
|
|
278
|
+
sort: 'desc',
|
|
279
|
+
sortBy: 'createdAt',
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
##### getSlideAnalysis(id: string)
|
|
284
|
+
|
|
285
|
+
Retrieves the detailed analysis data for a specific PDF slide record, including the overview and individual slide analysis.
|
|
286
|
+
|
|
287
|
+
**Parameters:**
|
|
288
|
+
|
|
289
|
+
- `id` (string): The unique ID of the PDF slide record
|
|
290
|
+
|
|
291
|
+
**Returns:** `Promise<PdfSlideDto>`
|
|
292
|
+
|
|
293
|
+
**Example:**
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
const details = await client.getSlideAnalysis('pdf-slide-id');
|
|
297
|
+
console.log('Lesson Overview:', details.lessonOverview);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
##### deleteSlideAnalysis(id: string)
|
|
301
|
+
|
|
302
|
+
Deletes a PDF slide analysis record from the database and removes the corresponding file from S3 storage.
|
|
303
|
+
|
|
304
|
+
**Parameters:**
|
|
305
|
+
|
|
306
|
+
- `id` (string): The unique ID of the PDF slide record to delete
|
|
307
|
+
|
|
308
|
+
**Returns:** `Promise<void>`
|
|
309
|
+
|
|
310
|
+
**Example:**
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
await client.deleteSlideAnalysis('pdf-slide-id');
|
|
314
|
+
console.log('Analysis deleted successfully');
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
##### getAssistantImages()
|
|
318
|
+
|
|
319
|
+
Retrieves all available assistant images that can be used when creating a simulation.
|
|
320
|
+
|
|
321
|
+
**Returns:** `Promise<AssistantImageDto[]>` — An array of assistant image objects, each containing:
|
|
322
|
+
|
|
323
|
+
- `_id`: Unique identifier for the image
|
|
324
|
+
- `imageUrl`: URL of the assistant image
|
|
325
|
+
|
|
326
|
+
**Example:**
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
// Get all available assistant images
|
|
330
|
+
const images = await client.getAssistantImages();
|
|
331
|
+
```
|
|
332
|
+
|
|
249
333
|
##### getRecommendations()
|
|
250
334
|
|
|
251
335
|
Retrieves recommendations based on the user's recent call performance. Analyzes up to 10 of the most recent calls to identify patterns and provide actionable insights.
|
|
@@ -408,6 +492,8 @@ interface CreateSimulationDto {
|
|
|
408
492
|
objectives?: string;
|
|
409
493
|
anticipatedObjections?: string;
|
|
410
494
|
trainingConfiguration: TrainingConfigurationDto;
|
|
495
|
+
imageId: string;
|
|
496
|
+
avatarLanguage: AvatarLanguage;
|
|
411
497
|
}
|
|
412
498
|
```
|
|
413
499
|
|
|
@@ -489,6 +575,79 @@ interface ImprovementAreaDto {
|
|
|
489
575
|
}
|
|
490
576
|
```
|
|
491
577
|
|
|
578
|
+
### PdfSlidesDto
|
|
579
|
+
|
|
580
|
+
Simplified data structure for PDF slide records (used in lists):
|
|
581
|
+
|
|
582
|
+
```typescript
|
|
583
|
+
interface PdfSlidesDto {
|
|
584
|
+
_id: string;
|
|
585
|
+
originalFilename: string;
|
|
586
|
+
totalSlides?: number;
|
|
587
|
+
lessonOverview?: string;
|
|
588
|
+
createdAt: Date;
|
|
589
|
+
updatedAt: Date;
|
|
590
|
+
}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### PdfSlideDto
|
|
594
|
+
|
|
595
|
+
Detailed data structure for a single PDF slide analysis:
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
interface PdfSlideDto {
|
|
599
|
+
_id: string;
|
|
600
|
+
originalFilename: string;
|
|
601
|
+
totalSlides?: number;
|
|
602
|
+
lessonOverview?: string;
|
|
603
|
+
slideAnalysis?: Array<{
|
|
604
|
+
slideNumber: number;
|
|
605
|
+
title: string;
|
|
606
|
+
textExtraction: string;
|
|
607
|
+
}>;
|
|
608
|
+
createdAt: Date;
|
|
609
|
+
updatedAt: Date;
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### PdfSlidesAnalysisQueryDto
|
|
614
|
+
|
|
615
|
+
Query parameters for retrieving slide analysis records:
|
|
616
|
+
|
|
617
|
+
```typescript
|
|
618
|
+
interface PdfSlidesAnalysisQueryDto {
|
|
619
|
+
limit?: 5 | 10 | 25;
|
|
620
|
+
page?: number;
|
|
621
|
+
sort?: 'asc' | 'desc';
|
|
622
|
+
sortBy?: 'createdAt' | 'originalFilename' | 'totalSlides';
|
|
623
|
+
}
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### AssistantImageDto
|
|
627
|
+
|
|
628
|
+
Data structure for assistant images:
|
|
629
|
+
|
|
630
|
+
```typescript
|
|
631
|
+
interface AssistantImageDto {
|
|
632
|
+
_id: string;
|
|
633
|
+
imageUrl: string;
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### AvatarLanguage
|
|
638
|
+
|
|
639
|
+
Enum representing available avatar languages:
|
|
640
|
+
|
|
641
|
+
```typescript
|
|
642
|
+
enum AvatarLanguage {
|
|
643
|
+
English = 'en',
|
|
644
|
+
German = 'de',
|
|
645
|
+
Spanish = 'es',
|
|
646
|
+
Italian = 'it',
|
|
647
|
+
French = 'fr',
|
|
648
|
+
}
|
|
649
|
+
```
|
|
650
|
+
|
|
492
651
|
## Error Handling
|
|
493
652
|
|
|
494
653
|
The SDK throws errors for invalid configurations and API failures:
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 ctcHealth. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the ctcHealth Plato Platform, a proprietary software system developed by ctcHealth.
|
|
5
|
+
*
|
|
6
|
+
* This source code and all related materials are confidential and proprietary to ctcHealth.
|
|
7
|
+
* Unauthorized access, use, copying, modification, distribution, or disclosure is strictly prohibited
|
|
8
|
+
* and may result in disciplinary action and civil and/or criminal penalties.
|
|
9
|
+
*
|
|
10
|
+
* This software is intended solely for authorized use within ctcHealth and its designated partners.
|
|
11
|
+
*
|
|
12
|
+
* For internal use only.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MAX_PDF_FILE_SIZE: number;
|
|
15
|
+
export declare const ALLOWED_PDF_MIME_TYPES: string[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALLOWED_PDF_MIME_TYPES = exports.MAX_PDF_FILE_SIZE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) 2025 ctcHealth. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This file is part of the ctcHealth Plato Platform, a proprietary software system developed by ctcHealth.
|
|
8
|
+
*
|
|
9
|
+
* This source code and all related materials are confidential and proprietary to ctcHealth.
|
|
10
|
+
* Unauthorized access, use, copying, modification, distribution, or disclosure is strictly prohibited
|
|
11
|
+
* and may result in disciplinary action and civil and/or criminal penalties.
|
|
12
|
+
*
|
|
13
|
+
* This software is intended solely for authorized use within ctcHealth and its designated partners.
|
|
14
|
+
*
|
|
15
|
+
* For internal use only.
|
|
16
|
+
*/
|
|
17
|
+
exports.MAX_PDF_FILE_SIZE = 20 * 1024 * 1024; // 20MB
|
|
18
|
+
exports.ALLOWED_PDF_MIME_TYPES = ['application/pdf'];
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACU,QAAA,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AAC7C,QAAA,sBAAsB,GAAG,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -35,6 +35,13 @@ export declare enum AssistantVoiceGender {
|
|
|
35
35
|
Male = "Male",
|
|
36
36
|
Female = "Female"
|
|
37
37
|
}
|
|
38
|
+
export declare enum AvatarLanguage {
|
|
39
|
+
English = "en",
|
|
40
|
+
German = "de",
|
|
41
|
+
Spanish = "es",
|
|
42
|
+
Italian = "it",
|
|
43
|
+
French = "fr"
|
|
44
|
+
}
|
|
38
45
|
export declare class PersonalityAndBehaviourDto {
|
|
39
46
|
riskTolerance: number;
|
|
40
47
|
researchOrientation: number;
|
|
@@ -72,6 +79,8 @@ export declare class CreateSimulationDto {
|
|
|
72
79
|
scenario: string;
|
|
73
80
|
objectives?: string;
|
|
74
81
|
anticipatedObjections?: string;
|
|
82
|
+
imageId: string;
|
|
83
|
+
avatarLanguage: AvatarLanguage;
|
|
75
84
|
}
|
|
76
85
|
export type RecordingsLimit = 5 | 10 | 25;
|
|
77
86
|
export declare class SimulationRecordingsQueryDto {
|
|
@@ -213,25 +222,18 @@ export declare enum CreationPhase {
|
|
|
213
222
|
ERROR = "ERROR"
|
|
214
223
|
}
|
|
215
224
|
/**
|
|
216
|
-
*
|
|
225
|
+
* Presigned POST data for S3 upload.
|
|
217
226
|
*/
|
|
218
|
-
export interface
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
export interface PresignedPost {
|
|
228
|
+
url: string;
|
|
229
|
+
fields: Record<string, string>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Response for requesting a PDF upload.
|
|
233
|
+
*/
|
|
234
|
+
export interface RequestPdfUploadResponse {
|
|
235
|
+
presignedPost: PresignedPost;
|
|
222
236
|
objectKey: string;
|
|
223
|
-
/**
|
|
224
|
-
* The original filename
|
|
225
|
-
*/
|
|
226
|
-
filename: string;
|
|
227
|
-
/**
|
|
228
|
-
* The file size in bytes
|
|
229
|
-
*/
|
|
230
|
-
size: number;
|
|
231
|
-
/**
|
|
232
|
-
* The content type of the file
|
|
233
|
-
*/
|
|
234
|
-
contentType: string;
|
|
235
237
|
}
|
|
236
238
|
export interface SimulationDetailsDto {
|
|
237
239
|
simulationId: string;
|
|
@@ -267,3 +269,41 @@ export interface RecommendationsResponseDto {
|
|
|
267
269
|
callsAnalyzed: number;
|
|
268
270
|
generatedAt: Date;
|
|
269
271
|
}
|
|
272
|
+
export declare enum PdfSlidesSortField {
|
|
273
|
+
CREATED_AT = "createdAt",
|
|
274
|
+
FILENAME = "originalFilename",
|
|
275
|
+
TOTAL_SLIDES = "totalSlides"
|
|
276
|
+
}
|
|
277
|
+
export declare class PdfSlidesAnalysisQueryDto {
|
|
278
|
+
limit?: RecordingsLimit;
|
|
279
|
+
page?: number;
|
|
280
|
+
sort?: SortOrder;
|
|
281
|
+
sortBy?: PdfSlidesSortField;
|
|
282
|
+
}
|
|
283
|
+
export interface SlideAnalysis {
|
|
284
|
+
slideNumber: number;
|
|
285
|
+
title?: string;
|
|
286
|
+
textExtraction?: string;
|
|
287
|
+
visualDescription?: string;
|
|
288
|
+
}
|
|
289
|
+
export interface PdfSlidesDto {
|
|
290
|
+
_id: string;
|
|
291
|
+
originalFilename: string;
|
|
292
|
+
totalSlides?: number;
|
|
293
|
+
lessonOverview?: string;
|
|
294
|
+
createdAt: Date;
|
|
295
|
+
updatedAt: Date;
|
|
296
|
+
}
|
|
297
|
+
export interface PdfSlideDto {
|
|
298
|
+
_id: string;
|
|
299
|
+
originalFilename: string;
|
|
300
|
+
totalSlides?: number;
|
|
301
|
+
lessonOverview?: string;
|
|
302
|
+
slideAnalysis?: SlideAnalysis[];
|
|
303
|
+
createdAt: Date;
|
|
304
|
+
updatedAt: Date;
|
|
305
|
+
}
|
|
306
|
+
export interface AssistantImageDto {
|
|
307
|
+
_id: string;
|
|
308
|
+
imageUrl: string;
|
|
309
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecommendationPriority = exports.CreationPhase = exports.SimulationRecordingsDto = exports.RecordingStatus = exports.SortOrder = exports.SimulationRecordingsQueryDto = exports.CreateSimulationDto = exports.ProductConfig = exports.CharacterCreateDto = exports.ContextDto = exports.ProfessionalProfileDto = exports.PersonalityAndBehaviourDto = exports.AssistantVoiceGender = exports.SegmentType = exports.PracticeType = exports.YearOfExperience = void 0;
|
|
3
|
+
exports.PdfSlidesAnalysisQueryDto = exports.PdfSlidesSortField = exports.RecommendationPriority = exports.CreationPhase = exports.SimulationRecordingsDto = exports.RecordingStatus = exports.SortOrder = exports.SimulationRecordingsQueryDto = exports.CreateSimulationDto = exports.ProductConfig = exports.CharacterCreateDto = exports.ContextDto = exports.ProfessionalProfileDto = exports.PersonalityAndBehaviourDto = exports.AvatarLanguage = exports.AssistantVoiceGender = exports.SegmentType = exports.PracticeType = exports.YearOfExperience = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (c) 2025 ctcHealth. All rights reserved.
|
|
6
6
|
*
|
|
@@ -42,6 +42,14 @@ var AssistantVoiceGender;
|
|
|
42
42
|
AssistantVoiceGender["Male"] = "Male";
|
|
43
43
|
AssistantVoiceGender["Female"] = "Female";
|
|
44
44
|
})(AssistantVoiceGender || (exports.AssistantVoiceGender = AssistantVoiceGender = {}));
|
|
45
|
+
var AvatarLanguage;
|
|
46
|
+
(function (AvatarLanguage) {
|
|
47
|
+
AvatarLanguage["English"] = "en";
|
|
48
|
+
AvatarLanguage["German"] = "de";
|
|
49
|
+
AvatarLanguage["Spanish"] = "es";
|
|
50
|
+
AvatarLanguage["Italian"] = "it";
|
|
51
|
+
AvatarLanguage["French"] = "fr";
|
|
52
|
+
})(AvatarLanguage || (exports.AvatarLanguage = AvatarLanguage = {}));
|
|
45
53
|
class PersonalityAndBehaviourDto {
|
|
46
54
|
riskTolerance;
|
|
47
55
|
researchOrientation;
|
|
@@ -84,6 +92,8 @@ class CreateSimulationDto {
|
|
|
84
92
|
scenario;
|
|
85
93
|
objectives;
|
|
86
94
|
anticipatedObjections;
|
|
95
|
+
imageId;
|
|
96
|
+
avatarLanguage;
|
|
87
97
|
}
|
|
88
98
|
exports.CreateSimulationDto = CreateSimulationDto;
|
|
89
99
|
class SimulationRecordingsQueryDto {
|
|
@@ -127,4 +137,17 @@ var RecommendationPriority;
|
|
|
127
137
|
RecommendationPriority["MEDIUM"] = "medium";
|
|
128
138
|
RecommendationPriority["LOW"] = "low";
|
|
129
139
|
})(RecommendationPriority || (exports.RecommendationPriority = RecommendationPriority = {}));
|
|
140
|
+
var PdfSlidesSortField;
|
|
141
|
+
(function (PdfSlidesSortField) {
|
|
142
|
+
PdfSlidesSortField["CREATED_AT"] = "createdAt";
|
|
143
|
+
PdfSlidesSortField["FILENAME"] = "originalFilename";
|
|
144
|
+
PdfSlidesSortField["TOTAL_SLIDES"] = "totalSlides";
|
|
145
|
+
})(PdfSlidesSortField || (exports.PdfSlidesSortField = PdfSlidesSortField = {}));
|
|
146
|
+
class PdfSlidesAnalysisQueryDto {
|
|
147
|
+
limit;
|
|
148
|
+
page;
|
|
149
|
+
sort;
|
|
150
|
+
sortBy;
|
|
151
|
+
}
|
|
152
|
+
exports.PdfSlidesAnalysisQueryDto = PdfSlidesAnalysisQueryDto;
|
|
130
153
|
//# sourceMappingURL=plato-intefaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plato-intefaces.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/plato-intefaces.ts"],"names":[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AAI,CAAU;IACd,WAAW,CAAU;CACtB;AAHD,sCAGC;AAED,MAAa,mBAAmB;IAC9B,OAAO,CAAsB;IAC7B,OAAO,CAAiB;IACxB,YAAY,CAAU;IACtB,QAAQ,CAAU;IAClB,UAAU,CAAU;IACpB,qBAAqB,CAAU;
|
|
1
|
+
{"version":3,"file":"plato-intefaces.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/plato-intefaces.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,qCAAmB,CAAA;IACnB,uCAAqB,CAAA;IACrB,yCAAuB,CAAA;IACvB,qCAAmB,CAAA;AACrB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAED,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,4CAA4B,CAAA;IAC5B,qCAAqB,CAAA;IACrB,iEAAiD,CAAA;IACjD,iCAAiB,CAAA;AACnB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AACD,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,oDAAqC,CAAA;IACrC,0CAA2B,CAAA;IAC3B,0EAA2D,CAAA;IAC3D,gFAAiE,CAAA;IACjE,qDAAsC,CAAA;IACtC,wEAAyD,CAAA;AAC3D,CAAC,EAPW,WAAW,2BAAX,WAAW,QAOtB;AAED,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,yCAAiB,CAAA;AACnB,CAAC,EAHW,oBAAoB,oCAApB,oBAAoB,QAG/B;AAED,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,gCAAc,CAAA;IACd,+BAAa,CAAA;IACb,gCAAc,CAAA;IACd,gCAAc,CAAA;IACd,+BAAa,CAAA;AACf,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED,MAAa,0BAA0B;IACrC,aAAa,CAAU;IACvB,mBAAmB,CAAU;IAC7B,eAAe,CAAU;IACzB,YA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,CAAA;IACzB,0DAAyC,CAAA;IACzC,kEAAiD,CAAA;IACjD,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;AACjB,CAAC,EATW,aAAa,6BAAb,aAAa,QASxB;AA2BD,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,2CAAiB,CAAA;IACjB,qCAAW,CAAA;AACb,CAAC,EAJW,sBAAsB,sCAAtB,sBAAsB,QAIjC;AA2BD,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,8CAAwB,CAAA;IACxB,mDAA6B,CAAA;IAC7B,kDAA4B,CAAA;AAC9B,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAED,MAAa,yBAAyB;IACpC,KAAK,CAAmB;IACxB,IAAI,CAAU;IACd,IAAI,CAAa;IACjB,MAAM,CAAsB;CAC7B;AALD,8DAKC"}
|
package/src/lib/plato-sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallDTO, CreateSimulationDto, CreationPhase, SimulationRecordingsDto, SimulationRecordingsQueryDto,
|
|
1
|
+
import { CallDTO, CreateSimulationDto, CreationPhase, SimulationRecordingsDto, SimulationRecordingsQueryDto, SimulationDetailsDto, RecommendationsResponseDto, PdfSlidesDto, PdfSlideDto, PdfSlidesAnalysisQueryDto, AssistantImageDto } from './plato-intefaces';
|
|
2
2
|
export interface ApiClientConfig {
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
token?: string;
|
|
@@ -98,6 +98,10 @@ export declare class PlatoApiClient {
|
|
|
98
98
|
off: <K extends CallEventNames>(event: K, listener: CallEventListener<K>) => void;
|
|
99
99
|
}>;
|
|
100
100
|
private createCall;
|
|
101
|
-
uploadPdfSlides(file: File | Blob): Promise<
|
|
101
|
+
uploadPdfSlides(file: File | Blob): Promise<string>;
|
|
102
102
|
getRecommendations(): Promise<RecommendationsResponseDto>;
|
|
103
|
+
getSlidesAnalysis(queryParams: PdfSlidesAnalysisQueryDto): Promise<PdfSlidesDto[]>;
|
|
104
|
+
getSlideAnalysis(id: string): Promise<PdfSlideDto>;
|
|
105
|
+
deleteSlideAnalysis(id: string): Promise<void>;
|
|
106
|
+
getAssistantImages(): Promise<AssistantImageDto[]>;
|
|
103
107
|
}
|
package/src/lib/plato-sdk.js
CHANGED
|
@@ -17,6 +17,8 @@ const tslib_1 = require("tslib");
|
|
|
17
17
|
*/
|
|
18
18
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
19
19
|
const web_1 = tslib_1.__importDefault(require("@vapi-ai/web"));
|
|
20
|
+
const utils_1 = require("./utils");
|
|
21
|
+
const constants_1 = require("./constants");
|
|
20
22
|
class PlatoApiClient {
|
|
21
23
|
config;
|
|
22
24
|
http;
|
|
@@ -247,10 +249,51 @@ class PlatoApiClient {
|
|
|
247
249
|
return response.data;
|
|
248
250
|
}
|
|
249
251
|
async uploadPdfSlides(file) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
try {
|
|
253
|
+
const checkResult = (0, utils_1.checkFile)(file, constants_1.MAX_PDF_FILE_SIZE, constants_1.ALLOWED_PDF_MIME_TYPES);
|
|
254
|
+
if (checkResult !== true) {
|
|
255
|
+
throw new Error(checkResult);
|
|
256
|
+
}
|
|
257
|
+
const contentHash = await (0, utils_1.calculateHash)(file);
|
|
258
|
+
const filename = file instanceof File ? file.name : file.filename;
|
|
259
|
+
if (!filename) {
|
|
260
|
+
throw new Error('Invalid input: could not extract filename from the provided file or blob.');
|
|
261
|
+
}
|
|
262
|
+
if (/[^a-zA-Z0-9._ -]/.test(filename)) {
|
|
263
|
+
throw new Error('Filename contains invalid characters. Only English letters, numbers, dots, hyphens, and underscores are allowed.');
|
|
264
|
+
}
|
|
265
|
+
const { presignedPost } = (await this.http.post('/api/v1/pdfSlides/request-upload', {
|
|
266
|
+
contentHash,
|
|
267
|
+
filename,
|
|
268
|
+
})).data;
|
|
269
|
+
const formData = new FormData();
|
|
270
|
+
Object.entries(presignedPost.fields).forEach(([key, value]) => {
|
|
271
|
+
formData.append(key, value);
|
|
272
|
+
});
|
|
273
|
+
formData.append('file', file);
|
|
274
|
+
await axios_1.default.post(presignedPost.url, formData, {
|
|
275
|
+
headers: {
|
|
276
|
+
'Content-Type': 'multipart/form-data',
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
/*
|
|
280
|
+
// replace const { presignedPost } with const { presignedPost, objectKey }
|
|
281
|
+
// Uncomment this block if you are testing locally without AWS EventBridge
|
|
282
|
+
await this.http.post('/api/v1/pdfSlides/test-event-bridge', {
|
|
283
|
+
s3Name: objectKey,
|
|
284
|
+
});
|
|
285
|
+
*/
|
|
286
|
+
return 'PDF upload successful';
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
290
|
+
console.error('Error uploading PDF slides:', e.response?.data?.message || e.message);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
console.error('Error uploading PDF slides:', e instanceof Error ? e.message : 'Unknown error');
|
|
294
|
+
}
|
|
295
|
+
throw e;
|
|
296
|
+
}
|
|
254
297
|
}
|
|
255
298
|
async getRecommendations() {
|
|
256
299
|
try {
|
|
@@ -264,6 +307,55 @@ class PlatoApiClient {
|
|
|
264
307
|
throw e;
|
|
265
308
|
}
|
|
266
309
|
}
|
|
310
|
+
async getSlidesAnalysis(queryParams) {
|
|
311
|
+
try {
|
|
312
|
+
const res = await this.http.get('/api/v1/pdfSlides', {
|
|
313
|
+
params: queryParams,
|
|
314
|
+
});
|
|
315
|
+
return res.data;
|
|
316
|
+
}
|
|
317
|
+
catch (e) {
|
|
318
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
319
|
+
console.error('Error getting PDF slides analysis:', e.response?.data.message);
|
|
320
|
+
}
|
|
321
|
+
throw e;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
async getSlideAnalysis(id) {
|
|
325
|
+
try {
|
|
326
|
+
const res = await this.http.get(`/api/v1/pdfSlides/${id}`);
|
|
327
|
+
return res.data;
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
331
|
+
console.error('Error getting PDF slide analysis by ID:', e.response?.data.message);
|
|
332
|
+
}
|
|
333
|
+
throw e;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async deleteSlideAnalysis(id) {
|
|
337
|
+
try {
|
|
338
|
+
await this.http.delete(`/api/v1/pdfSlides/${id}`);
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
342
|
+
console.error('Error deleting PDF slide analysis:', e.response?.data.message);
|
|
343
|
+
}
|
|
344
|
+
throw e;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async getAssistantImages() {
|
|
348
|
+
try {
|
|
349
|
+
const res = await this.http.get('/api/v1/assistant-images');
|
|
350
|
+
return res.data;
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
354
|
+
console.error('Error getting assistant images:', e.response?.data.message);
|
|
355
|
+
}
|
|
356
|
+
throw e;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
267
359
|
}
|
|
268
360
|
exports.PlatoApiClient = PlatoApiClient;
|
|
269
361
|
//# sourceMappingURL=plato-sdk.js.map
|
package/src/lib/plato-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plato-sdk.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/plato-sdk.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;GAYG;AACH,0DAA6C;
|
|
1
|
+
{"version":3,"file":"plato-sdk.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/plato-sdk.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;GAYG;AACH,0DA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BAAkB;QACtB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,0BAA0B,CAAC,CAAC;YACjF,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,eAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1B,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC7E,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF;AAxXD,wCAwXC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 ctcHealth. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the ctcHealth Plato Platform, a proprietary software system developed by ctcHealth.
|
|
5
|
+
*
|
|
6
|
+
* This source code and all related materials are confidential and proprietary to ctcHealth.
|
|
7
|
+
* Unauthorized access, use, copying, modification, distribution, or disclosure is strictly prohibited
|
|
8
|
+
* and may result in disciplinary action and civil and/or criminal penalties.
|
|
9
|
+
*
|
|
10
|
+
* This software is intended solely for authorized use within ctcHealth and its designated partners.
|
|
11
|
+
*
|
|
12
|
+
* For internal use only.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Validates a file against size and type constraints.
|
|
16
|
+
*
|
|
17
|
+
* @param file - The file to check.
|
|
18
|
+
* @param maxFileSize - The maximum allowed file size in bytes.
|
|
19
|
+
* @param allowedMimeTypes - An array of allowed MIME types.
|
|
20
|
+
* @returns true if valid, or a descriptive error message if invalid.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkFile(file: File | Blob, maxFileSize: number, allowedMimeTypes: string[]): true | string;
|
|
23
|
+
/**
|
|
24
|
+
* Calculates the SHA-256 hash of a file or blob.
|
|
25
|
+
*
|
|
26
|
+
* @param file - The file or blob to hash.
|
|
27
|
+
* @returns A promise that resolves to the hexadecimal SHA-256 hash.
|
|
28
|
+
*/
|
|
29
|
+
export declare function calculateHash(file: File | Blob): Promise<string>;
|
package/src/lib/utils.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkFile = checkFile;
|
|
4
|
+
exports.calculateHash = calculateHash;
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) 2025 ctcHealth. All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* This file is part of the ctcHealth Plato Platform, a proprietary software system developed by ctcHealth.
|
|
9
|
+
*
|
|
10
|
+
* This source code and all related materials are confidential and proprietary to ctcHealth.
|
|
11
|
+
* Unauthorized access, use, copying, modification, distribution, or disclosure is strictly prohibited
|
|
12
|
+
* and may result in disciplinary action and civil and/or criminal penalties.
|
|
13
|
+
*
|
|
14
|
+
* This software is intended solely for authorized use within ctcHealth and its designated partners.
|
|
15
|
+
*
|
|
16
|
+
* For internal use only.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Validates a file against size and type constraints.
|
|
20
|
+
*
|
|
21
|
+
* @param file - The file to check.
|
|
22
|
+
* @param maxFileSize - The maximum allowed file size in bytes.
|
|
23
|
+
* @param allowedMimeTypes - An array of allowed MIME types.
|
|
24
|
+
* @returns true if valid, or a descriptive error message if invalid.
|
|
25
|
+
*/
|
|
26
|
+
function checkFile(file, maxFileSize, allowedMimeTypes) {
|
|
27
|
+
if (file.size > maxFileSize) {
|
|
28
|
+
const uploadedSizeMB = (file.size / (1024 * 1024)).toFixed(2);
|
|
29
|
+
const maxSizeMB = (maxFileSize / (1024 * 1024)).toFixed(2);
|
|
30
|
+
return `File size (${uploadedSizeMB} MB) exceeds the maximum allowed size of ${maxSizeMB} MB.`;
|
|
31
|
+
}
|
|
32
|
+
if (!allowedMimeTypes.includes(file.type)) {
|
|
33
|
+
return `Invalid file type: ${file.type}. Allowed types are: ${allowedMimeTypes.join(', ')}.`;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Calculates the SHA-256 hash of a file or blob.
|
|
39
|
+
*
|
|
40
|
+
* @param file - The file or blob to hash.
|
|
41
|
+
* @returns A promise that resolves to the hexadecimal SHA-256 hash.
|
|
42
|
+
*/
|
|
43
|
+
async function calculateHash(file) {
|
|
44
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
45
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', arrayBuffer);
|
|
46
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
47
|
+
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
48
|
+
return hashHex;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/utils.ts"],"names":[],"mappings":";;AAqBA,8BAgBC;AAQD,sCAMC;AAnDD;;;;;;;;;;;;GAYG;AACH;;;;;;;GAOG;AACH,SAAgB,SAAS,CACvB,IAAiB,EACjB,WAAmB,EACnB,gBAA0B;IAE1B,IAAI,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,CAAC;QAC5B,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3D,OAAO,cAAc,cAAc,4CAA4C,SAAS,MAAM,CAAC;IACjG,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,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