@ctchealth/plato-sdk 0.0.8 → 0.0.9

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.
@@ -1,215 +0,0 @@
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 enum YearOfExperience {
15
- '1-5' = "1-5 years",
16
- '6-10' = "6-10 years",
17
- '11-20' = "16-20 years",
18
- '20+' = "20+ years"
19
- }
20
- export declare enum PracticeType {
21
- Private = "Private Practice",
22
- Hospital = "Hospital",
23
- AcademicMedicalCenter = "Academic Medical Center",
24
- Clinic = "Clinic"
25
- }
26
- export declare enum SegmentType {
27
- Traditionalist = "The Traditionalist",
28
- Innovator = "The Innovator",
29
- PatientOrientedPhysician = "The Patient-Oriented Physician",
30
- FinanciallyDrivenPrescriber = "The Financially-Driven Prescriber",
31
- EvidencePurist = "The Evidence-Purist",
32
- CostConsciousPrescriber = "The Cost-Conscious Prescriber"
33
- }
34
- export declare enum AssistantVoiceGender {
35
- Male = "Male",
36
- Female = "Female"
37
- }
38
- export declare class PersonalityAndBehaviourDto {
39
- riskTolerance: number;
40
- researchOrientation: number;
41
- recognitionNeed: number;
42
- brandLoyalty: number;
43
- patientEmpathy: number;
44
- }
45
- export declare class ProfessionalProfileDto {
46
- practiceSettings: string;
47
- yearOfExperience: number;
48
- specialityAndDepartment: string;
49
- location: string;
50
- }
51
- export declare class ContextDto {
52
- subSpecialityOrTherapyFocus: string;
53
- typicalPatientMix: string;
54
- keyClinicalDrivers: string;
55
- }
56
- export declare class CharacterCreateDto {
57
- name: string;
58
- professionalProfile: ProfessionalProfileDto;
59
- segment: SegmentType;
60
- personalityAndBehaviour: PersonalityAndBehaviourDto;
61
- context: ContextDto;
62
- assistantGender?: AssistantVoiceGender;
63
- }
64
- export declare class ProductConfig {
65
- name: string;
66
- description: string;
67
- }
68
- export declare class CreateSimulationDto {
69
- persona: CharacterCreateDto;
70
- product: ProductConfig;
71
- presentation?: string;
72
- scenario: string;
73
- objectives?: string[];
74
- anticipatedObjections?: string[];
75
- }
76
- export type RecordingsLimit = 5 | 10 | 25;
77
- export declare class SimulationRecordingsQueryDto {
78
- limit?: RecordingsLimit;
79
- page?: number;
80
- sort?: SortOrder;
81
- }
82
- export declare enum SortOrder {
83
- ASC = "asc",
84
- DESC = "desc"
85
- }
86
- export declare enum RecordingStatus {
87
- STARTED = "STARTED",
88
- PROCESSING = "PROCESSING",
89
- FINISHED = "FINISHED",
90
- FAILED = "FAILED"
91
- }
92
- export declare class SimulationRecordingsDto {
93
- _id: string;
94
- createdAt: Date;
95
- recordingStatus?: RecordingStatus;
96
- }
97
- export interface CallCreateDto {
98
- /**
99
- * Call ID obtained
100
- */
101
- callId: string;
102
- /**
103
- * Call Assistant ID
104
- */
105
- assistantId: string;
106
- }
107
- export interface CallDTO {
108
- /**
109
- * call ID
110
- */
111
- _id: string;
112
- /**
113
- * call ID obtained
114
- */
115
- callId: string;
116
- /**
117
- * call User ID
118
- */
119
- platoUserId: string;
120
- /**
121
- * call Assistant ID
122
- */
123
- assistantId: string;
124
- /**
125
- * call summary of the conversation
126
- */
127
- summary: string;
128
- /**
129
- * call transcript of the conversation
130
- */
131
- transcript: string;
132
- /**
133
- * call feedback provided by the user
134
- */
135
- feedback: string;
136
- /**
137
- * Success Evaluation returned by model
138
- */
139
- successEvaluation: boolean;
140
- /**
141
- * call Recording URL
142
- */
143
- recordingUrl: string;
144
- /**
145
- * Status of recording processing (e.g., 'STARTED', 'PROCESSING', 'FINISHED', 'FAILED')
146
- */
147
- recordingStatus?: RecordingStatus;
148
- /**
149
- * Date and Time of the creation of the message
150
- */
151
- createdAt: Date;
152
- /**
153
- * Date and Time of the creation of the message
154
- */
155
- endedAt: Date;
156
- /**
157
- * Rating of the call given by the user
158
- */
159
- rating: number;
160
- /**
161
- * Main strenghts of the user conversation based on the analysis of the AI
162
- */
163
- strengths: Array<string>;
164
- /**
165
- * Main weak points of the user conversation based on the analysis of the AI
166
- */
167
- weaknesses: Array<string>;
168
- /**
169
- * Name of Metric for the AI feedback report
170
- */
171
- metric1: string;
172
- /**
173
- * Name of Metric for the AI feedback report
174
- */
175
- metric2: string;
176
- /**
177
- * Name of Metric for the AI feedback report
178
- */
179
- metric3: string;
180
- /**
181
- * AI feedback value for Metric 1
182
- */
183
- metric1Value: number;
184
- /**
185
- * AI feedback value for Metric 2
186
- */
187
- metric2Value: number;
188
- /**
189
- * AI feedback value for Metric 3
190
- */
191
- metric3Value: number;
192
- /**
193
- * AI feedback value for the call score
194
- */
195
- score?: number;
196
- /**
197
- * Defines if the calls will be consider for the memory feature
198
- */
199
- inMemory: boolean;
200
- }
201
- export declare enum CreationStatus {
202
- CREATING = "CREATING",
203
- READY = "READY",
204
- ERROR = "ERROR"
205
- }
206
- export declare enum CreationPhase {
207
- STARTING = "STARTING",
208
- CORE = "CORE",
209
- BOUNDARIES = "BOUNDARIES",
210
- SPEECH_AND_THOUGHT = "SPEECH_AND_THOUGHT",
211
- CONVERSATION_EVOLUTION = "CONVERSATION_EVOLUTION",
212
- MEMORY = "MEMORY",
213
- FINISHED = "FINISHED",
214
- ERROR = "ERROR"
215
- }
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreationPhase = exports.CreationStatus = 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;
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
- var YearOfExperience;
18
- (function (YearOfExperience) {
19
- YearOfExperience["1-5"] = "1-5 years";
20
- YearOfExperience["6-10"] = "6-10 years";
21
- YearOfExperience["11-20"] = "16-20 years";
22
- YearOfExperience["20+"] = "20+ years";
23
- })(YearOfExperience || (exports.YearOfExperience = YearOfExperience = {}));
24
- var PracticeType;
25
- (function (PracticeType) {
26
- PracticeType["Private"] = "Private Practice";
27
- PracticeType["Hospital"] = "Hospital";
28
- PracticeType["AcademicMedicalCenter"] = "Academic Medical Center";
29
- PracticeType["Clinic"] = "Clinic";
30
- })(PracticeType || (exports.PracticeType = PracticeType = {}));
31
- var SegmentType;
32
- (function (SegmentType) {
33
- SegmentType["Traditionalist"] = "The Traditionalist";
34
- SegmentType["Innovator"] = "The Innovator";
35
- SegmentType["PatientOrientedPhysician"] = "The Patient-Oriented Physician";
36
- SegmentType["FinanciallyDrivenPrescriber"] = "The Financially-Driven Prescriber";
37
- SegmentType["EvidencePurist"] = "The Evidence-Purist";
38
- SegmentType["CostConsciousPrescriber"] = "The Cost-Conscious Prescriber";
39
- })(SegmentType || (exports.SegmentType = SegmentType = {}));
40
- var AssistantVoiceGender;
41
- (function (AssistantVoiceGender) {
42
- AssistantVoiceGender["Male"] = "Male";
43
- AssistantVoiceGender["Female"] = "Female";
44
- })(AssistantVoiceGender || (exports.AssistantVoiceGender = AssistantVoiceGender = {}));
45
- class PersonalityAndBehaviourDto {
46
- riskTolerance;
47
- researchOrientation;
48
- recognitionNeed;
49
- brandLoyalty;
50
- patientEmpathy;
51
- }
52
- exports.PersonalityAndBehaviourDto = PersonalityAndBehaviourDto;
53
- class ProfessionalProfileDto {
54
- practiceSettings;
55
- yearOfExperience;
56
- specialityAndDepartment;
57
- location;
58
- }
59
- exports.ProfessionalProfileDto = ProfessionalProfileDto;
60
- class ContextDto {
61
- subSpecialityOrTherapyFocus;
62
- typicalPatientMix;
63
- keyClinicalDrivers;
64
- }
65
- exports.ContextDto = ContextDto;
66
- class CharacterCreateDto {
67
- name;
68
- professionalProfile;
69
- segment;
70
- personalityAndBehaviour;
71
- context;
72
- assistantGender;
73
- }
74
- exports.CharacterCreateDto = CharacterCreateDto;
75
- class ProductConfig {
76
- name;
77
- description;
78
- }
79
- exports.ProductConfig = ProductConfig;
80
- class CreateSimulationDto {
81
- persona;
82
- product;
83
- presentation;
84
- scenario;
85
- objectives;
86
- anticipatedObjections;
87
- }
88
- exports.CreateSimulationDto = CreateSimulationDto;
89
- class SimulationRecordingsQueryDto {
90
- limit;
91
- page;
92
- sort;
93
- }
94
- exports.SimulationRecordingsQueryDto = SimulationRecordingsQueryDto;
95
- var SortOrder;
96
- (function (SortOrder) {
97
- SortOrder["ASC"] = "asc";
98
- SortOrder["DESC"] = "desc";
99
- })(SortOrder || (exports.SortOrder = SortOrder = {}));
100
- var RecordingStatus;
101
- (function (RecordingStatus) {
102
- RecordingStatus["STARTED"] = "STARTED";
103
- RecordingStatus["PROCESSING"] = "PROCESSING";
104
- RecordingStatus["FINISHED"] = "FINISHED";
105
- RecordingStatus["FAILED"] = "FAILED";
106
- })(RecordingStatus || (exports.RecordingStatus = RecordingStatus = {}));
107
- class SimulationRecordingsDto {
108
- _id;
109
- createdAt;
110
- recordingStatus;
111
- }
112
- exports.SimulationRecordingsDto = SimulationRecordingsDto;
113
- var CreationStatus;
114
- (function (CreationStatus) {
115
- CreationStatus["CREATING"] = "CREATING";
116
- CreationStatus["READY"] = "READY";
117
- CreationStatus["ERROR"] = "ERROR";
118
- })(CreationStatus || (exports.CreationStatus = CreationStatus = {}));
119
- var CreationPhase;
120
- (function (CreationPhase) {
121
- CreationPhase["STARTING"] = "STARTING";
122
- CreationPhase["CORE"] = "CORE";
123
- CreationPhase["BOUNDARIES"] = "BOUNDARIES";
124
- CreationPhase["SPEECH_AND_THOUGHT"] = "SPEECH_AND_THOUGHT";
125
- CreationPhase["CONVERSATION_EVOLUTION"] = "CONVERSATION_EVOLUTION";
126
- CreationPhase["MEMORY"] = "MEMORY";
127
- CreationPhase["FINISHED"] = "FINISHED";
128
- CreationPhase["ERROR"] = "ERROR";
129
- })(CreationPhase || (exports.CreationPhase = CreationPhase = {}));
130
- //# sourceMappingURL=plato-intefaces.js.map
@@ -1 +0,0 @@
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,oC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X;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,iCAAe,CAAA;IACf,iCAAe,CAAA;AACjB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AACD,IAAY,aASX;AATD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,8BAAa,CAAA;IACb,0CAAyB,CAAA;IACzB,0DAAyC,CAAA;IACzC,kEAAiD,CAAA;IACjD,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;AACjB,CAAC,EATW,aAAa,6BAAb,aAAa,QASxB"}
@@ -1,84 +0,0 @@
1
- import { CallDTO, CreateSimulationDto, CreationPhase, SimulationRecordingsDto, SimulationRecordingsQueryDto } from './plato-intefaces';
2
- export interface ApiClientConfig {
3
- baseUrl: string;
4
- token?: string;
5
- user?: string;
6
- }
7
- /**
8
- * Event map for call events, providing strict typing for each event's payload.
9
- */
10
- export interface CallEventMap {
11
- 'call-start': void;
12
- 'call-end': void;
13
- 'speech-start': void;
14
- 'speech-end': void;
15
- error: Error;
16
- message: {
17
- type: string;
18
- role: string;
19
- transcript?: string;
20
- transcriptType: 'final' | 'partial';
21
- toolCallList?: any[];
22
- toolCalls?: any[];
23
- [key: string]: any;
24
- };
25
- 'volume-level': number;
26
- }
27
- export type CallEventNames = keyof CallEventMap;
28
- export type CallEventListener<K extends CallEventNames> = (payload: CallEventMap[K]) => void;
29
- export declare class PlatoApiClient {
30
- private config;
31
- private http;
32
- private eventListeners;
33
- private callControllerInstance?;
34
- private eventsAttached;
35
- eventNames: CallEventNames[];
36
- constructor(config: ApiClientConfig);
37
- /**
38
- * Register a listener for a call event with strict typing.
39
- * @param event Event name
40
- * @param listener Listener function
41
- */
42
- private on;
43
- /**
44
- * Remove a listener for a call event with strict typing.
45
- * @param event Event name
46
- * @param listener Listener function
47
- */
48
- private off;
49
- /**
50
- * Internal: Attach event listeners and propagate to registered listeners.
51
- */
52
- private attachEvents;
53
- createSimulation(createSimulationParams: CreateSimulationDto): Promise<{
54
- simulationId: string;
55
- phase: CreationPhase;
56
- }>;
57
- checkSimulationStatus(simulationId: string): Promise<{
58
- phase: CreationPhase;
59
- }>;
60
- getCallDetails(callId: string): Promise<CallDTO>;
61
- getCallRecordings(queryParams: SimulationRecordingsQueryDto): Promise<SimulationRecordingsDto[]>;
62
- getCallRecording(callId: string): Promise<string>;
63
- /**
64
- * Remove all listeners for all call events.
65
- */
66
- private removeAllEventListeners;
67
- startCall(simulationId: string): Promise<{
68
- stopCall: () => void;
69
- callId: string;
70
- /**
71
- * Subscribe to call events for this call with strict typing.
72
- * @param event Event name
73
- * @param listener Listener function
74
- */
75
- on: <K extends CallEventNames>(event: K, listener: CallEventListener<K>) => void;
76
- /**
77
- * Unsubscribe from call events for this call with strict typing.
78
- * @param event Event name
79
- * @param listener Listener function
80
- */
81
- off: <K extends CallEventNames>(event: K, listener: CallEventListener<K>) => void;
82
- }>;
83
- private createCall;
84
- }
@@ -1,210 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatoApiClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
- const web_1 = tslib_1.__importDefault(require("@vapi-ai/web"));
7
- class PlatoApiClient {
8
- config;
9
- http;
10
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
11
- eventListeners = {};
12
- callControllerInstance;
13
- eventsAttached = false;
14
- eventNames = [
15
- 'call-start',
16
- 'call-end',
17
- 'speech-start',
18
- 'speech-end',
19
- 'error',
20
- 'message',
21
- 'volume-level',
22
- ];
23
- constructor(config) {
24
- this.config = config;
25
- if (!config.baseUrl) {
26
- throw new Error('baseUrl is required');
27
- }
28
- if (!config.token) {
29
- throw new Error('token is required');
30
- }
31
- if (!config.user) {
32
- throw new Error('user is required');
33
- }
34
- if (config.baseUrl.endsWith('/')) {
35
- config.baseUrl = config.baseUrl.slice(0, -1);
36
- }
37
- this.http = axios_1.default.create({
38
- baseURL: config.baseUrl,
39
- headers: {
40
- 'x-api-key': config.token,
41
- 'x-api-key-user': config.user,
42
- },
43
- });
44
- }
45
- /**
46
- * Register a listener for a call event with strict typing.
47
- * @param event Event name
48
- * @param listener Listener function
49
- */
50
- on(event, listener) {
51
- if (!this.eventListeners[event]) {
52
- this.eventListeners[event] = [];
53
- }
54
- this.eventListeners[event].push(listener);
55
- if (this.callControllerInstance && !this.eventsAttached) {
56
- this.attachEvents();
57
- }
58
- }
59
- /**
60
- * Remove a listener for a call event with strict typing.
61
- * @param event Event name
62
- * @param listener Listener function
63
- */
64
- off(event, listener) {
65
- if (!this.eventListeners[event])
66
- return;
67
- this.eventListeners[event] = this.eventListeners[event].filter(l => l !== listener);
68
- }
69
- /**
70
- * Internal: Attach event listeners and propagate to registered listeners.
71
- */
72
- attachEvents() {
73
- if (this.eventsAttached || !this.callControllerInstance)
74
- return;
75
- this.eventsAttached = true;
76
- const vapi = this.callControllerInstance;
77
- this.eventNames.forEach(event => {
78
- vapi.on(event, (payload) => {
79
- (this.eventListeners[event] || []).forEach(listener => listener(payload));
80
- });
81
- });
82
- }
83
- async createSimulation(createSimulationParams) {
84
- try {
85
- const res = await this.http.post('/api/v1/simulation', {
86
- ...createSimulationParams,
87
- });
88
- return {
89
- simulationId: res.data.simulationId,
90
- phase: res.data.phase,
91
- };
92
- }
93
- catch (e) {
94
- if (axios_1.default.isAxiosError(e)) {
95
- console.error('Error creating simulation:', e.response?.data.message);
96
- }
97
- throw e;
98
- }
99
- }
100
- async checkSimulationStatus(simulationId) {
101
- const res = await this.http.get(`/api/v1/simulation/status/${simulationId}`);
102
- return res.data;
103
- }
104
- async getCallDetails(callId) {
105
- try {
106
- const res = await this.http.get(`/api/v1/simulation/call/${callId}`);
107
- return res.data;
108
- }
109
- catch (e) {
110
- if (axios_1.default.isAxiosError(e)) {
111
- console.error('Error getting call details:', e.response?.data.message);
112
- }
113
- throw e;
114
- }
115
- }
116
- async getCallRecordings(queryParams) {
117
- try {
118
- const res = await this.http.get(`/api/v1/simulation/call/recordings`, {
119
- params: queryParams,
120
- });
121
- return res.data;
122
- }
123
- catch (e) {
124
- if (axios_1.default.isAxiosError(e)) {
125
- console.error('Error getting call recordings:', e.response?.data.message);
126
- }
127
- throw e;
128
- }
129
- }
130
- async getCallRecording(callId) {
131
- try {
132
- const res = await this.http.get(`/api/v1/simulation/call/recordings/${callId}`);
133
- return res.data;
134
- }
135
- catch (e) {
136
- if (axios_1.default.isAxiosError(e)) {
137
- console.error('Error getting call recording:', e.response?.data.message);
138
- }
139
- throw e;
140
- }
141
- }
142
- /**
143
- * Remove all listeners for all call events.
144
- */
145
- removeAllEventListeners() {
146
- if (!this.callControllerInstance)
147
- return;
148
- this.eventNames.forEach(event => {
149
- (this.eventListeners[event] || []).forEach(listener => {
150
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
151
- // @ts-expect-error
152
- this.callControllerInstance?.off(event, listener);
153
- });
154
- this.eventListeners[event] = [];
155
- });
156
- this.eventsAttached = false;
157
- }
158
- async startCall(simulationId) {
159
- this.callControllerInstance = new web_1.default('f07d17ec-d4e6-487d-a0b9-0539c01aecbb', 'https://db41aykk1gw9e.cloudfront.net' // base url
160
- );
161
- if (!this.eventsAttached) {
162
- this.attachEvents();
163
- }
164
- const { data } = await this.http.get(`/api/v1/simulation/${simulationId}`);
165
- const assistantId = data;
166
- const call = await this.callControllerInstance.start(assistantId);
167
- if (!call || !call.assistantId) {
168
- throw new Error('Cannot start a call, please try again later');
169
- }
170
- try {
171
- const apiCall = await this.createCall({
172
- callId: call.id,
173
- assistantId: call.assistantId,
174
- });
175
- // Return stopCall, callId, and event subscription methods with strict typing
176
- return {
177
- stopCall: () => {
178
- this.callControllerInstance?.stop();
179
- this.removeAllEventListeners();
180
- },
181
- callId: apiCall._id,
182
- /**
183
- * Subscribe to call events for this call with strict typing.
184
- * @param event Event name
185
- * @param listener Listener function
186
- */
187
- on: (event, listener) => this.on(event, listener),
188
- /**
189
- * Unsubscribe from call events for this call with strict typing.
190
- * @param event Event name
191
- * @param listener Listener function
192
- */
193
- off: (event, listener) => this.off(event, listener),
194
- };
195
- }
196
- catch (e) {
197
- this.callControllerInstance?.stop();
198
- this.removeAllEventListeners();
199
- throw e;
200
- }
201
- }
202
- async createCall(payload) {
203
- const response = await this.http.post('/api/v1/simulation/call', {
204
- ...payload,
205
- });
206
- return response.data;
207
- }
208
- }
209
- exports.PlatoApiClient = PlatoApiClient;
210
- //# sourceMappingURL=plato-sdk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plato-sdk.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/plato-sdk.ts"],"names":[],"mappings":";;;;AAAA,0DAA6C;AAS7C,+DAAgC;AAkChC,MAAa,cAAc;IAgBL;IAfZ,IAAI,CAAgB;IAC5B,sEAAsE;IAC9D,cAAc,GAAgD,EAAE,CAAC;IACjE,sBAAsB,CAAQ;IAC9B,cAAc,GAAG,KAAK,CAAC;IAC/B,UAAU,GAAqB;QAC7B,YAAY;QACZ,UAAU;QACV,cAAc;QACd,YAAY;QACZ,OAAO;QACP,SAAS;QACT,cAAc;KACf,CAAC;IAEF,YAAoB,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;QACzC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,C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