@automate.ax/integration-contracts 0.151.0 → 0.152.0
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/dist/close/events.d.ts +2 -2
- package/dist/close/schemas.d.ts +2 -2
- package/dist/elevenlabs/api.d.ts +58 -0
- package/dist/elevenlabs/api.js +237 -0
- package/dist/elevenlabs/events.d.ts +264 -0
- package/dist/elevenlabs/events.js +47 -0
- package/dist/elevenlabs/index.d.ts +3 -0
- package/dist/elevenlabs/index.js +3 -0
- package/dist/elevenlabs/schemas.d.ts +458 -0
- package/dist/elevenlabs/schemas.js +229 -0
- package/dist/krisp/schemas.d.ts +1 -1
- package/dist/triggers.d.ts +2 -1
- package/package.json +8 -2
- package/src/elevenlabs/api.ts +341 -0
- package/src/elevenlabs/events.ts +58 -0
- package/src/elevenlabs/index.ts +3 -0
- package/src/elevenlabs/schemas.ts +253 -0
- package/src/triggers.ts +2 -0
package/dist/close/events.d.ts
CHANGED
|
@@ -124,9 +124,9 @@ export declare const closeTriggerContracts: {
|
|
|
124
124
|
failed: "failed";
|
|
125
125
|
completed: "completed";
|
|
126
126
|
timeout: "timeout";
|
|
127
|
+
"in-progress": "in-progress";
|
|
127
128
|
busy: "busy";
|
|
128
129
|
cancel: "cancel";
|
|
129
|
-
"in-progress": "in-progress";
|
|
130
130
|
"no-answer": "no-answer";
|
|
131
131
|
}>>;
|
|
132
132
|
type: z.ZodOptional<z.ZodLiteral<"Call">>;
|
|
@@ -197,9 +197,9 @@ export declare const closeTriggerContracts: {
|
|
|
197
197
|
failed: "failed";
|
|
198
198
|
completed: "completed";
|
|
199
199
|
timeout: "timeout";
|
|
200
|
+
"in-progress": "in-progress";
|
|
200
201
|
busy: "busy";
|
|
201
202
|
cancel: "cancel";
|
|
202
|
-
"in-progress": "in-progress";
|
|
203
203
|
"no-answer": "no-answer";
|
|
204
204
|
}>>;
|
|
205
205
|
type: z.ZodOptional<z.ZodLiteral<"Call">>;
|
package/dist/close/schemas.d.ts
CHANGED
|
@@ -840,9 +840,9 @@ export declare const CLOSE_CALL_SCHEMA: z.ZodObject<{
|
|
|
840
840
|
failed: "failed";
|
|
841
841
|
completed: "completed";
|
|
842
842
|
timeout: "timeout";
|
|
843
|
+
"in-progress": "in-progress";
|
|
843
844
|
busy: "busy";
|
|
844
845
|
cancel: "cancel";
|
|
845
|
-
"in-progress": "in-progress";
|
|
846
846
|
"no-answer": "no-answer";
|
|
847
847
|
}>;
|
|
848
848
|
type: z.ZodLiteral<"Call">;
|
|
@@ -1070,9 +1070,9 @@ export declare const CLOSE_ACTIVITY_SCHEMA: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
1070
1070
|
failed: "failed";
|
|
1071
1071
|
completed: "completed";
|
|
1072
1072
|
timeout: "timeout";
|
|
1073
|
+
"in-progress": "in-progress";
|
|
1073
1074
|
busy: "busy";
|
|
1074
1075
|
cancel: "cancel";
|
|
1075
|
-
"in-progress": "in-progress";
|
|
1076
1076
|
"no-answer": "no-answer";
|
|
1077
1077
|
}>;
|
|
1078
1078
|
type: z.ZodLiteral<"Call">;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Encodable } from "@automate.ax/codec";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
export interface ElevenLabsRequestOptions<TSchema extends z.ZodType> {
|
|
4
|
+
body?: Encodable;
|
|
5
|
+
method?: "DELETE" | "GET" | "PATCH" | "POST";
|
|
6
|
+
query?: Record<string, boolean | number | readonly string[] | string | undefined>;
|
|
7
|
+
responseSchema: TSchema;
|
|
8
|
+
}
|
|
9
|
+
/** Structured ElevenLabs REST failure. */
|
|
10
|
+
export declare class ElevenLabsApiError extends Error {
|
|
11
|
+
readonly body?: Encodable;
|
|
12
|
+
readonly retryAfter?: number;
|
|
13
|
+
readonly status: number;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a structured ElevenLabs API failure.
|
|
16
|
+
*
|
|
17
|
+
* @param options Failure details.
|
|
18
|
+
* @param options.body Parsed provider response body.
|
|
19
|
+
* @param options.retryAfter Retry delay in seconds.
|
|
20
|
+
* @param options.status HTTP status.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options: {
|
|
23
|
+
body?: Encodable;
|
|
24
|
+
retryAfter?: number;
|
|
25
|
+
status: number;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an authenticated ElevenLabs REST client.
|
|
30
|
+
*
|
|
31
|
+
* @param secret Account secret containing an ElevenLabs API key.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getElevenLabsApi(secret: Record<string, unknown>): {
|
|
34
|
+
request<TSchema extends z.ZodType>(path: string, options: ElevenLabsRequestOptions<TSchema>): Promise<z.output<TSchema>>;
|
|
35
|
+
requestFile(path: string, options: Omit<ElevenLabsRequestOptions<z.ZodType>, "responseSchema"> & {
|
|
36
|
+
filename: string;
|
|
37
|
+
}): Promise<File>;
|
|
38
|
+
requestForm<TSchema extends z.ZodType>(path: string, form: FormData, options: {
|
|
39
|
+
query?: ElevenLabsRequestOptions<TSchema>["query"];
|
|
40
|
+
responseSchema: TSchema;
|
|
41
|
+
}): Promise<z.output<TSchema>>;
|
|
42
|
+
requestFormFile(path: string, form: FormData, options: {
|
|
43
|
+
filename: string;
|
|
44
|
+
query?: ElevenLabsRequestOptions<z.ZodType>["query"];
|
|
45
|
+
}): Promise<File>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Converts camelCase values into ElevenLabs wire names.
|
|
49
|
+
*
|
|
50
|
+
* @param value Public value.
|
|
51
|
+
*/
|
|
52
|
+
export declare function toElevenLabs(value: Encodable): Encodable;
|
|
53
|
+
/**
|
|
54
|
+
* Converts ElevenLabs wire names into camelCase values.
|
|
55
|
+
*
|
|
56
|
+
* @param value Provider value.
|
|
57
|
+
*/
|
|
58
|
+
export declare function fromElevenLabs(value: unknown): unknown;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { encodableSchema } from "@automate.ax/codec";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
const ELEVENLABS_API_BASE_URL = "https://api.elevenlabs.io/";
|
|
4
|
+
const ELEVENLABS_API_ORIGIN = new URL(ELEVENLABS_API_BASE_URL).origin;
|
|
5
|
+
const ELEVENLABS_SECRET_SCHEMA = z.object({ apiKey: z.string().min(1) });
|
|
6
|
+
/** Structured ElevenLabs REST failure. */
|
|
7
|
+
export class ElevenLabsApiError extends Error {
|
|
8
|
+
body;
|
|
9
|
+
retryAfter;
|
|
10
|
+
status;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a structured ElevenLabs API failure.
|
|
13
|
+
*
|
|
14
|
+
* @param options Failure details.
|
|
15
|
+
* @param options.body Parsed provider response body.
|
|
16
|
+
* @param options.retryAfter Retry delay in seconds.
|
|
17
|
+
* @param options.status HTTP status.
|
|
18
|
+
*/
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(getErrorMessage(options.body) ??
|
|
21
|
+
`ElevenLabs API request failed with status ${options.status}.`);
|
|
22
|
+
this.name = "ElevenLabsApiError";
|
|
23
|
+
this.body = options.body;
|
|
24
|
+
this.retryAfter = options.retryAfter;
|
|
25
|
+
this.status = options.status;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an authenticated ElevenLabs REST client.
|
|
30
|
+
*
|
|
31
|
+
* @param secret Account secret containing an ElevenLabs API key.
|
|
32
|
+
*/
|
|
33
|
+
export function getElevenLabsApi(secret) {
|
|
34
|
+
const { apiKey } = ELEVENLABS_SECRET_SCHEMA.parse(secret);
|
|
35
|
+
/**
|
|
36
|
+
* Sends one authenticated provider request and validates HTTP status.
|
|
37
|
+
*
|
|
38
|
+
* @param path Versioned or v1-relative API path.
|
|
39
|
+
* @param options Request options.
|
|
40
|
+
* @param options.body Encoded request body.
|
|
41
|
+
* @param options.headers Additional request headers.
|
|
42
|
+
* @param options.method HTTP method.
|
|
43
|
+
* @param options.query Query parameters.
|
|
44
|
+
*/
|
|
45
|
+
async function fetchResponse(path, options) {
|
|
46
|
+
const headers = new Headers(options.headers);
|
|
47
|
+
headers.set("xi-api-key", apiKey);
|
|
48
|
+
const response = await fetch(createElevenLabsUrl(path, options.query), {
|
|
49
|
+
body: options.body,
|
|
50
|
+
headers,
|
|
51
|
+
method: options.method ?? "GET",
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const body = encodableSchema.safeParse(fromElevenLabs(parseJson(await response.text())));
|
|
55
|
+
throw new ElevenLabsApiError({
|
|
56
|
+
...(body.success && { body: body.data }),
|
|
57
|
+
retryAfter: parseRetryAfter(response.headers.get("retry-after")),
|
|
58
|
+
status: response.status,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
async request(path, options) {
|
|
65
|
+
return options.responseSchema.parse(fromElevenLabs(parseJson(await (await fetchResponse(path, {
|
|
66
|
+
body: options.body === undefined
|
|
67
|
+
? undefined
|
|
68
|
+
: JSON.stringify(toElevenLabs(options.body)),
|
|
69
|
+
headers: options.body === undefined
|
|
70
|
+
? { Accept: "application/json" }
|
|
71
|
+
: {
|
|
72
|
+
Accept: "application/json",
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
},
|
|
75
|
+
method: options.method,
|
|
76
|
+
query: options.query,
|
|
77
|
+
})).text())));
|
|
78
|
+
},
|
|
79
|
+
async requestFile(path, options) {
|
|
80
|
+
const response = await fetchResponse(path, {
|
|
81
|
+
body: options.body === undefined
|
|
82
|
+
? undefined
|
|
83
|
+
: JSON.stringify(toElevenLabs(options.body)),
|
|
84
|
+
headers: options.body === undefined
|
|
85
|
+
? undefined
|
|
86
|
+
: { "Content-Type": "application/json" },
|
|
87
|
+
method: options.method,
|
|
88
|
+
query: options.query,
|
|
89
|
+
});
|
|
90
|
+
const contentType = response.headers.get("content-type") ?? "application/octet-stream";
|
|
91
|
+
return new File([await response.blob()], contentType.startsWith("video/mp4")
|
|
92
|
+
? options.filename.replace(/\.[^.]+$/, ".mp4")
|
|
93
|
+
: options.filename, {
|
|
94
|
+
type: contentType,
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
async requestForm(path, form, options) {
|
|
98
|
+
return options.responseSchema.parse(fromElevenLabs(parseJson(await (await fetchResponse(path, {
|
|
99
|
+
body: form,
|
|
100
|
+
method: "POST",
|
|
101
|
+
query: options.query,
|
|
102
|
+
})).text())));
|
|
103
|
+
},
|
|
104
|
+
async requestFormFile(path, form, options) {
|
|
105
|
+
const response = await fetchResponse(path, {
|
|
106
|
+
body: form,
|
|
107
|
+
method: "POST",
|
|
108
|
+
query: options.query,
|
|
109
|
+
});
|
|
110
|
+
const contentType = response.headers.get("content-type") ?? "application/octet-stream";
|
|
111
|
+
return new File([await response.blob()], contentType.startsWith("video/mp4")
|
|
112
|
+
? options.filename.replace(/\.[^.]+$/, ".mp4")
|
|
113
|
+
: options.filename, { type: contentType });
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Converts camelCase values into ElevenLabs wire names.
|
|
119
|
+
*
|
|
120
|
+
* @param value Public value.
|
|
121
|
+
*/
|
|
122
|
+
export function toElevenLabs(value) {
|
|
123
|
+
return encodeElevenLabsValue(value, false);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Converts one value while optionally preserving opaque object keys.
|
|
127
|
+
*
|
|
128
|
+
* @param value Public value.
|
|
129
|
+
* @param preserveKeys Whether object keys are user-defined identifiers.
|
|
130
|
+
*/
|
|
131
|
+
function encodeElevenLabsValue(value, preserveKeys) {
|
|
132
|
+
if (value instanceof Date)
|
|
133
|
+
return value.toISOString();
|
|
134
|
+
if (Array.isArray(value)) {
|
|
135
|
+
return value.map((item) => encodeElevenLabsValue(item, preserveKeys));
|
|
136
|
+
}
|
|
137
|
+
if (!isPlainObject(value))
|
|
138
|
+
return value;
|
|
139
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => {
|
|
140
|
+
const encodedKey = preserveKeys
|
|
141
|
+
? key
|
|
142
|
+
: key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
143
|
+
return [
|
|
144
|
+
encodedKey,
|
|
145
|
+
encodeElevenLabsValue(item, preserveKeys || encodedKey === "dynamic_variables"),
|
|
146
|
+
];
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Converts ElevenLabs wire names into camelCase values.
|
|
151
|
+
*
|
|
152
|
+
* @param value Provider value.
|
|
153
|
+
*/
|
|
154
|
+
export function fromElevenLabs(value) {
|
|
155
|
+
if (Array.isArray(value))
|
|
156
|
+
return value.map(fromElevenLabs);
|
|
157
|
+
if (!isPlainObject(value))
|
|
158
|
+
return value;
|
|
159
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
160
|
+
key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase()),
|
|
161
|
+
fromElevenLabs(item),
|
|
162
|
+
]));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a same-origin ElevenLabs URL with encoded query parameters.
|
|
166
|
+
*
|
|
167
|
+
* @param path Versioned or v1-relative API path.
|
|
168
|
+
* @param query Query parameters.
|
|
169
|
+
* @throws When a path resolves outside the ElevenLabs API origin.
|
|
170
|
+
*/
|
|
171
|
+
function createElevenLabsUrl(path, query) {
|
|
172
|
+
const requestedPath = path.replace(/^\//, "");
|
|
173
|
+
const url = new URL(/^v\d+\//.test(requestedPath) ? requestedPath : `v1/${requestedPath}`, ELEVENLABS_API_BASE_URL);
|
|
174
|
+
if (url.origin !== ELEVENLABS_API_ORIGIN) {
|
|
175
|
+
throw new Error("ElevenLabs API paths must use the ElevenLabs API origin.");
|
|
176
|
+
}
|
|
177
|
+
for (const [name, value] of Object.entries(query ?? {})) {
|
|
178
|
+
if (value === undefined)
|
|
179
|
+
continue;
|
|
180
|
+
const key = name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
181
|
+
if (Array.isArray(value)) {
|
|
182
|
+
for (const item of value)
|
|
183
|
+
url.searchParams.append(key, item);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
url.searchParams.set(key, String(value));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return url;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Parses a JSON response without masking the original HTTP status.
|
|
193
|
+
*
|
|
194
|
+
* @param value Response text.
|
|
195
|
+
*/
|
|
196
|
+
function parseJson(value) {
|
|
197
|
+
try {
|
|
198
|
+
return JSON.parse(value);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Parses a numeric Retry-After header in seconds.
|
|
206
|
+
*
|
|
207
|
+
* @param value Header value.
|
|
208
|
+
*/
|
|
209
|
+
function parseRetryAfter(value) {
|
|
210
|
+
if (value === null)
|
|
211
|
+
return undefined;
|
|
212
|
+
const seconds = Number(value);
|
|
213
|
+
return Number.isFinite(seconds) ? seconds : undefined;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Extracts the provider's most useful structured error message.
|
|
217
|
+
*
|
|
218
|
+
* @param body Parsed response body.
|
|
219
|
+
*/
|
|
220
|
+
function getErrorMessage(body) {
|
|
221
|
+
if (!isPlainObject(body))
|
|
222
|
+
return undefined;
|
|
223
|
+
if (typeof body.message === "string")
|
|
224
|
+
return body.message;
|
|
225
|
+
if (isPlainObject(body.detail) && typeof body.detail.message === "string") {
|
|
226
|
+
return body.detail.message;
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Checks whether a value is a non-array object.
|
|
232
|
+
*
|
|
233
|
+
* @param value Candidate value.
|
|
234
|
+
*/
|
|
235
|
+
function isPlainObject(value) {
|
|
236
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
237
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const ELEVENLABS_TRIGGER_CONFIG_SCHEMA: z.ZodObject<{}, z.core.$strip>;
|
|
3
|
+
export declare const elevenLabsTriggerContracts: {
|
|
4
|
+
readonly "elevenlabs.event": {
|
|
5
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
6
|
+
readonly eventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
7
|
+
data: z.ZodObject<{
|
|
8
|
+
noticePeriodDays: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
voiceId: z.ZodString;
|
|
10
|
+
voiceName: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
eventTimestamp: z.ZodNumber;
|
|
13
|
+
type: z.ZodEnum<{
|
|
14
|
+
voice_removal_notice: "voice_removal_notice";
|
|
15
|
+
voice_removal_notice_withdrawn: "voice_removal_notice_withdrawn";
|
|
16
|
+
voice_removed: "voice_removed";
|
|
17
|
+
}>;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
+
data: z.ZodObject<{
|
|
20
|
+
requestId: z.ZodString;
|
|
21
|
+
transcription: z.ZodUnion<readonly [z.ZodObject<{
|
|
22
|
+
languageCode: z.ZodString;
|
|
23
|
+
languageProbability: z.ZodNumber;
|
|
24
|
+
text: z.ZodString;
|
|
25
|
+
words: z.ZodArray<z.ZodObject<{
|
|
26
|
+
channelIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
27
|
+
end: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
logprob: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
speakerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
start: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
31
|
+
text: z.ZodString;
|
|
32
|
+
type: z.ZodEnum<{
|
|
33
|
+
audio_event: "audio_event";
|
|
34
|
+
spacing: "spacing";
|
|
35
|
+
word: "word";
|
|
36
|
+
}>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
transcripts: z.ZodArray<z.ZodObject<{
|
|
40
|
+
languageCode: z.ZodString;
|
|
41
|
+
languageProbability: z.ZodNumber;
|
|
42
|
+
text: z.ZodString;
|
|
43
|
+
words: z.ZodArray<z.ZodObject<{
|
|
44
|
+
channelIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
end: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
46
|
+
logprob: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
speakerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
start: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
49
|
+
text: z.ZodString;
|
|
50
|
+
type: z.ZodEnum<{
|
|
51
|
+
audio_event: "audio_event";
|
|
52
|
+
spacing: "spacing";
|
|
53
|
+
word: "word";
|
|
54
|
+
}>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
}, z.core.$strip>]>;
|
|
58
|
+
webhookMetadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
eventTimestamp: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
type: z.ZodLiteral<"speech_to_text_transcription">;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
data: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
64
|
+
contentMimeType: z.ZodString;
|
|
65
|
+
contentUrl: z.ZodURL;
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
status: z.ZodLiteral<"completed">;
|
|
68
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
69
|
+
errorMessage: z.ZodString;
|
|
70
|
+
failureReason: z.ZodEnum<{
|
|
71
|
+
timeout: "timeout";
|
|
72
|
+
charging_failed: "charging_failed";
|
|
73
|
+
dependency_failed: "dependency_failed";
|
|
74
|
+
internal_error: "internal_error";
|
|
75
|
+
invalid_parameters: "invalid_parameters";
|
|
76
|
+
model_error: "model_error";
|
|
77
|
+
moderated: "moderated";
|
|
78
|
+
}>;
|
|
79
|
+
id: z.ZodString;
|
|
80
|
+
status: z.ZodLiteral<"failed">;
|
|
81
|
+
}, z.core.$strip>], "status">;
|
|
82
|
+
eventTimestamp: z.ZodNumber;
|
|
83
|
+
type: z.ZodLiteral<"flows_generation">;
|
|
84
|
+
}, z.core.$strip>]>;
|
|
85
|
+
};
|
|
86
|
+
readonly "elevenlabs.flowGenerationCompleted": {
|
|
87
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
88
|
+
readonly eventSchema: z.ZodObject<{
|
|
89
|
+
data: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
90
|
+
contentMimeType: z.ZodString;
|
|
91
|
+
contentUrl: z.ZodURL;
|
|
92
|
+
id: z.ZodString;
|
|
93
|
+
status: z.ZodLiteral<"completed">;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
errorMessage: z.ZodString;
|
|
96
|
+
failureReason: z.ZodEnum<{
|
|
97
|
+
timeout: "timeout";
|
|
98
|
+
charging_failed: "charging_failed";
|
|
99
|
+
dependency_failed: "dependency_failed";
|
|
100
|
+
internal_error: "internal_error";
|
|
101
|
+
invalid_parameters: "invalid_parameters";
|
|
102
|
+
model_error: "model_error";
|
|
103
|
+
moderated: "moderated";
|
|
104
|
+
}>;
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
status: z.ZodLiteral<"failed">;
|
|
107
|
+
}, z.core.$strip>], "status">;
|
|
108
|
+
eventTimestamp: z.ZodNumber;
|
|
109
|
+
type: z.ZodLiteral<"flows_generation">;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
};
|
|
112
|
+
readonly "elevenlabs.flowGenerationEvent": {
|
|
113
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
114
|
+
readonly eventSchema: z.ZodObject<{
|
|
115
|
+
data: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
116
|
+
contentMimeType: z.ZodString;
|
|
117
|
+
contentUrl: z.ZodURL;
|
|
118
|
+
id: z.ZodString;
|
|
119
|
+
status: z.ZodLiteral<"completed">;
|
|
120
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
121
|
+
errorMessage: z.ZodString;
|
|
122
|
+
failureReason: z.ZodEnum<{
|
|
123
|
+
timeout: "timeout";
|
|
124
|
+
charging_failed: "charging_failed";
|
|
125
|
+
dependency_failed: "dependency_failed";
|
|
126
|
+
internal_error: "internal_error";
|
|
127
|
+
invalid_parameters: "invalid_parameters";
|
|
128
|
+
model_error: "model_error";
|
|
129
|
+
moderated: "moderated";
|
|
130
|
+
}>;
|
|
131
|
+
id: z.ZodString;
|
|
132
|
+
status: z.ZodLiteral<"failed">;
|
|
133
|
+
}, z.core.$strip>], "status">;
|
|
134
|
+
eventTimestamp: z.ZodNumber;
|
|
135
|
+
type: z.ZodLiteral<"flows_generation">;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
};
|
|
138
|
+
readonly "elevenlabs.flowGenerationFailed": {
|
|
139
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
140
|
+
readonly eventSchema: z.ZodObject<{
|
|
141
|
+
data: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
142
|
+
contentMimeType: z.ZodString;
|
|
143
|
+
contentUrl: z.ZodURL;
|
|
144
|
+
id: z.ZodString;
|
|
145
|
+
status: z.ZodLiteral<"completed">;
|
|
146
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
147
|
+
errorMessage: z.ZodString;
|
|
148
|
+
failureReason: z.ZodEnum<{
|
|
149
|
+
timeout: "timeout";
|
|
150
|
+
charging_failed: "charging_failed";
|
|
151
|
+
dependency_failed: "dependency_failed";
|
|
152
|
+
internal_error: "internal_error";
|
|
153
|
+
invalid_parameters: "invalid_parameters";
|
|
154
|
+
model_error: "model_error";
|
|
155
|
+
moderated: "moderated";
|
|
156
|
+
}>;
|
|
157
|
+
id: z.ZodString;
|
|
158
|
+
status: z.ZodLiteral<"failed">;
|
|
159
|
+
}, z.core.$strip>], "status">;
|
|
160
|
+
eventTimestamp: z.ZodNumber;
|
|
161
|
+
type: z.ZodLiteral<"flows_generation">;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
};
|
|
164
|
+
readonly "elevenlabs.transcriptionCompleted": {
|
|
165
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
166
|
+
readonly eventSchema: z.ZodObject<{
|
|
167
|
+
data: z.ZodObject<{
|
|
168
|
+
requestId: z.ZodString;
|
|
169
|
+
transcription: z.ZodUnion<readonly [z.ZodObject<{
|
|
170
|
+
languageCode: z.ZodString;
|
|
171
|
+
languageProbability: z.ZodNumber;
|
|
172
|
+
text: z.ZodString;
|
|
173
|
+
words: z.ZodArray<z.ZodObject<{
|
|
174
|
+
channelIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
175
|
+
end: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
176
|
+
logprob: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
speakerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
178
|
+
start: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
179
|
+
text: z.ZodString;
|
|
180
|
+
type: z.ZodEnum<{
|
|
181
|
+
audio_event: "audio_event";
|
|
182
|
+
spacing: "spacing";
|
|
183
|
+
word: "word";
|
|
184
|
+
}>;
|
|
185
|
+
}, z.core.$strip>>;
|
|
186
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
187
|
+
transcripts: z.ZodArray<z.ZodObject<{
|
|
188
|
+
languageCode: z.ZodString;
|
|
189
|
+
languageProbability: z.ZodNumber;
|
|
190
|
+
text: z.ZodString;
|
|
191
|
+
words: z.ZodArray<z.ZodObject<{
|
|
192
|
+
channelIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
193
|
+
end: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
194
|
+
logprob: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
speakerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
196
|
+
start: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
197
|
+
text: z.ZodString;
|
|
198
|
+
type: z.ZodEnum<{
|
|
199
|
+
audio_event: "audio_event";
|
|
200
|
+
spacing: "spacing";
|
|
201
|
+
word: "word";
|
|
202
|
+
}>;
|
|
203
|
+
}, z.core.$strip>>;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
}, z.core.$strip>]>;
|
|
206
|
+
webhookMetadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
eventTimestamp: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
type: z.ZodLiteral<"speech_to_text_transcription">;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
};
|
|
212
|
+
readonly "elevenlabs.voiceRemovalEvent": {
|
|
213
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
214
|
+
readonly eventSchema: z.ZodObject<{
|
|
215
|
+
data: z.ZodObject<{
|
|
216
|
+
noticePeriodDays: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
voiceId: z.ZodString;
|
|
218
|
+
voiceName: z.ZodOptional<z.ZodString>;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
eventTimestamp: z.ZodNumber;
|
|
221
|
+
type: z.ZodEnum<{
|
|
222
|
+
voice_removal_notice: "voice_removal_notice";
|
|
223
|
+
voice_removal_notice_withdrawn: "voice_removal_notice_withdrawn";
|
|
224
|
+
voice_removed: "voice_removed";
|
|
225
|
+
}>;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
};
|
|
228
|
+
readonly "elevenlabs.voiceRemovalScheduled": {
|
|
229
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
230
|
+
readonly eventSchema: z.ZodObject<{
|
|
231
|
+
data: z.ZodObject<{
|
|
232
|
+
noticePeriodDays: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
voiceId: z.ZodString;
|
|
234
|
+
voiceName: z.ZodOptional<z.ZodString>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
eventTimestamp: z.ZodNumber;
|
|
237
|
+
type: z.ZodLiteral<"voice_removal_notice">;
|
|
238
|
+
}, z.core.$strip>;
|
|
239
|
+
};
|
|
240
|
+
readonly "elevenlabs.voiceRemovalWithdrawn": {
|
|
241
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
242
|
+
readonly eventSchema: z.ZodObject<{
|
|
243
|
+
data: z.ZodObject<{
|
|
244
|
+
noticePeriodDays: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
voiceId: z.ZodString;
|
|
246
|
+
voiceName: z.ZodOptional<z.ZodString>;
|
|
247
|
+
}, z.core.$strip>;
|
|
248
|
+
eventTimestamp: z.ZodNumber;
|
|
249
|
+
type: z.ZodLiteral<"voice_removal_notice_withdrawn">;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
};
|
|
252
|
+
readonly "elevenlabs.voiceRemoved": {
|
|
253
|
+
readonly configSchema: z.ZodObject<{}, z.core.$strip>;
|
|
254
|
+
readonly eventSchema: z.ZodObject<{
|
|
255
|
+
data: z.ZodObject<{
|
|
256
|
+
noticePeriodDays: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
voiceId: z.ZodString;
|
|
258
|
+
voiceName: z.ZodOptional<z.ZodString>;
|
|
259
|
+
}, z.core.$strip>;
|
|
260
|
+
eventTimestamp: z.ZodNumber;
|
|
261
|
+
type: z.ZodLiteral<"voice_removed">;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ELEVENLABS_FLOW_GENERATION_EVENT_SCHEMA, ELEVENLABS_TRANSCRIPTION_EVENT_SCHEMA, ELEVENLABS_VOICE_REMOVAL_EVENT_SCHEMA, ELEVENLABS_WEBHOOK_EVENT_SCHEMA, } from "./schemas.js";
|
|
3
|
+
export const ELEVENLABS_TRIGGER_CONFIG_SCHEMA = z.object({});
|
|
4
|
+
export const elevenLabsTriggerContracts = {
|
|
5
|
+
"elevenlabs.event": {
|
|
6
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
7
|
+
eventSchema: ELEVENLABS_WEBHOOK_EVENT_SCHEMA,
|
|
8
|
+
},
|
|
9
|
+
"elevenlabs.flowGenerationCompleted": {
|
|
10
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
11
|
+
eventSchema: ELEVENLABS_FLOW_GENERATION_EVENT_SCHEMA.refine(({ data }) => data.status === "completed"),
|
|
12
|
+
},
|
|
13
|
+
"elevenlabs.flowGenerationEvent": {
|
|
14
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
15
|
+
eventSchema: ELEVENLABS_FLOW_GENERATION_EVENT_SCHEMA,
|
|
16
|
+
},
|
|
17
|
+
"elevenlabs.flowGenerationFailed": {
|
|
18
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
19
|
+
eventSchema: ELEVENLABS_FLOW_GENERATION_EVENT_SCHEMA.refine(({ data }) => data.status === "failed"),
|
|
20
|
+
},
|
|
21
|
+
"elevenlabs.transcriptionCompleted": {
|
|
22
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
23
|
+
eventSchema: ELEVENLABS_TRANSCRIPTION_EVENT_SCHEMA,
|
|
24
|
+
},
|
|
25
|
+
"elevenlabs.voiceRemovalEvent": {
|
|
26
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
27
|
+
eventSchema: ELEVENLABS_VOICE_REMOVAL_EVENT_SCHEMA,
|
|
28
|
+
},
|
|
29
|
+
"elevenlabs.voiceRemovalScheduled": {
|
|
30
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
31
|
+
eventSchema: ELEVENLABS_VOICE_REMOVAL_EVENT_SCHEMA.extend({
|
|
32
|
+
type: z.literal("voice_removal_notice"),
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
"elevenlabs.voiceRemovalWithdrawn": {
|
|
36
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
37
|
+
eventSchema: ELEVENLABS_VOICE_REMOVAL_EVENT_SCHEMA.extend({
|
|
38
|
+
type: z.literal("voice_removal_notice_withdrawn"),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
"elevenlabs.voiceRemoved": {
|
|
42
|
+
configSchema: ELEVENLABS_TRIGGER_CONFIG_SCHEMA,
|
|
43
|
+
eventSchema: ELEVENLABS_VOICE_REMOVAL_EVENT_SCHEMA.extend({
|
|
44
|
+
type: z.literal("voice_removed"),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
};
|