@absolutejs/voice 0.0.4 → 0.0.6
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 +4 -6
- package/dist/index.js +1 -1
- package/dist/plugin.d.ts +9 -2
- package/dist/types.d.ts +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,12 +62,10 @@ app.use(
|
|
|
62
62
|
voice({
|
|
63
63
|
path: '/voice/intake',
|
|
64
64
|
htmx: {
|
|
65
|
-
|
|
66
|
-
result
|
|
67
|
-
result
|
|
68
|
-
|
|
69
|
-
: '<p>No structured result yet.</p>'
|
|
70
|
-
}
|
|
65
|
+
result: ({ result }) =>
|
|
66
|
+
result
|
|
67
|
+
? `<pre>${JSON.stringify(result, null, 2)}</pre>`
|
|
68
|
+
: '<p>No structured result yet.</p>'
|
|
71
69
|
},
|
|
72
70
|
onComplete: async () => {},
|
|
73
71
|
onTurn: async ({ turn }) => ({
|
package/dist/index.js
CHANGED
|
@@ -680,7 +680,7 @@ var voice = (config) => {
|
|
|
680
680
|
};
|
|
681
681
|
const htmxConfig = typeof config.htmx === "object" ? config.htmx : undefined;
|
|
682
682
|
const htmxRoute = htmxConfig?.route ?? `${config.path}/htmx/session`;
|
|
683
|
-
const htmxRenderers = resolveVoiceHTMXRenderers(htmxConfig
|
|
683
|
+
const htmxRenderers = resolveVoiceHTMXRenderers(htmxConfig);
|
|
684
684
|
const htmxTargets = resolveVoiceHTMXTargets(htmxConfig?.targets);
|
|
685
685
|
const htmxRoutes = () => {
|
|
686
686
|
if (!config.htmx) {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import type { VoicePluginConfig, VoiceSessionRecord } from './types';
|
|
3
|
-
|
|
2
|
+
import type { VoicePluginConfig, VoiceRouteConfig, VoiceSessionRecord } from './types';
|
|
3
|
+
type InferVoiceResult<TOnTurn extends (...args: any) => any> = Exclude<Awaited<ReturnType<TOnTurn>>, void> extends {
|
|
4
|
+
result?: infer TResult;
|
|
5
|
+
} ? TResult : unknown;
|
|
6
|
+
type VoiceOnTurnHandler<TContext, TSession extends VoiceSessionRecord> = VoiceRouteConfig<TContext, TSession, unknown>['onTurn'];
|
|
7
|
+
export declare const voice: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TOnTurn extends VoiceOnTurnHandler<TContext, TSession> = VoiceOnTurnHandler<TContext, TSession>>(config: Omit<VoicePluginConfig<TContext, TSession, InferVoiceResult<TOnTurn>>, "onTurn"> & {
|
|
8
|
+
onTurn: TOnTurn;
|
|
9
|
+
}) => Elysia<"", {
|
|
4
10
|
decorator: {};
|
|
5
11
|
store: {};
|
|
6
12
|
derive: {};
|
|
@@ -66,3 +72,4 @@ export declare const voice: <TContext = unknown, TSession extends VoiceSessionRe
|
|
|
66
72
|
standaloneSchema: {};
|
|
67
73
|
response: {};
|
|
68
74
|
}>;
|
|
75
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -182,7 +182,7 @@ export type VoiceRouteConfig<TContext = unknown, TSession extends VoiceSessionRe
|
|
|
182
182
|
onTurn: (input: {
|
|
183
183
|
context: TContext;
|
|
184
184
|
session: TSession;
|
|
185
|
-
turn: VoiceTurnRecord
|
|
185
|
+
turn: VoiceTurnRecord;
|
|
186
186
|
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
187
187
|
}) => Promise<VoiceRouteResult<TResult> | void> | VoiceRouteResult<TResult> | void;
|
|
188
188
|
onComplete: (input: {
|
|
@@ -306,8 +306,7 @@ export type VoiceHTMXTargets = {
|
|
|
306
306
|
status: string;
|
|
307
307
|
turns: string;
|
|
308
308
|
};
|
|
309
|
-
export type VoiceHTMXConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
310
|
-
render?: VoiceHTMXRenderConfig<TSession, TResult>;
|
|
309
|
+
export type VoiceHTMXConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderConfig<TSession, TResult> & {
|
|
311
310
|
route?: string;
|
|
312
311
|
targets?: Partial<VoiceHTMXTargets>;
|
|
313
312
|
};
|