@volley/recognition-client-sdk 0.1.800 → 0.1.806
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/browser.bundled.d.ts +71 -1
- package/dist/config-builder.d.ts +10 -1
- package/dist/config-builder.d.ts.map +1 -1
- package/dist/index.bundled.d.ts +140 -33
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -14
- package/dist/index.js.map +4 -4
- package/dist/recog-client-sdk.browser.js +38 -9
- package/dist/recog-client-sdk.browser.js.map +4 -4
- package/dist/recognition-client.d.ts.map +1 -1
- package/dist/recognition-client.types.d.ts +9 -1
- package/dist/recognition-client.types.d.ts.map +1 -1
- package/dist/simplified-vgf-recognition-client.d.ts +54 -2
- package/dist/simplified-vgf-recognition-client.d.ts.map +1 -1
- package/dist/utils/url-builder.d.ts +3 -1
- package/dist/utils/url-builder.d.ts.map +1 -1
- package/dist/vgf-recognition-state.d.ts +7 -0
- package/dist/vgf-recognition-state.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/config-builder.spec.ts +14 -0
- package/src/config-builder.ts +19 -1
- package/src/index.ts +7 -0
- package/src/recognition-client.ts +2 -0
- package/src/recognition-client.types.ts +12 -1
- package/src/simplified-vgf-recognition-client.spec.ts +74 -1
- package/src/simplified-vgf-recognition-client.ts +92 -12
- package/src/utils/url-builder.spec.ts +18 -0
- package/src/utils/url-builder.ts +9 -1
- package/src/vgf-recognition-state.ts +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognition-client.d.ts","sourceRoot":"","sources":["../src/recognition-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAML,KAAK,qBAAqB,EAS1B,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAE7B,OAA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
|
* Type definitions and interfaces for the recognition client SDK.
|
|
5
5
|
* These interfaces enable dependency injection, testing, and alternative implementations.
|
|
6
6
|
*/
|
|
7
|
-
import { TranscriptionResultV1, FunctionCallResultV1, MetadataResultV1, ErrorResultV1, SessionConfiguredV1, AudioMetricsResultV1, ASRRequestConfig, GameContextV1, Stage } from '@recog/shared-types';
|
|
7
|
+
import { TranscriptionResultV1, FunctionCallResultV1, MetadataResultV1, ErrorResultV1, SessionConfiguredV1, AudioMetricsResultV1, ASRRequestConfig, GameContextV1, Stage, MicrophoneSourceType } from '@recog/shared-types';
|
|
8
8
|
/**
|
|
9
9
|
* Client connection state enum
|
|
10
10
|
* Represents the various states a recognition client can be in during its lifecycle
|
|
@@ -91,6 +91,14 @@ export interface IRecognitionClientConfig {
|
|
|
91
91
|
accountId?: string;
|
|
92
92
|
/** Question answer identifier for tracking Q&A sessions (optional and tracking purpose only) */
|
|
93
93
|
questionAnswerId?: string;
|
|
94
|
+
/** Client identifier for downstream tracking/audio-labeling (optional and tracking purpose only) */
|
|
95
|
+
clientId?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Client audio capture path (optional). Accepts the {@link MicrophoneSourceType}
|
|
98
|
+
* enum or its string value ('web' | 'native'). Defaults to 'web' on the server
|
|
99
|
+
* when omitted. The service normalizes this to the enum at the boundary.
|
|
100
|
+
*/
|
|
101
|
+
microphoneSourceType?: MicrophoneSourceType | string;
|
|
94
102
|
/** Platform for audio recording device (optional, e.g., 'ios', 'android', 'web', 'unity') */
|
|
95
103
|
platform?: string;
|
|
96
104
|
/** Experiment cohort (optional). Defaults to 'control' if not provided. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognition-client.types.d.ts","sourceRoot":"","sources":["../src/recognition-client.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,KAAK,
|
|
1
|
+
{"version":3,"file":"recognition-client.types.d.ts","sourceRoot":"","sources":["../src/recognition-client.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,oBAAY,WAAW;IACrB,+CAA+C;IAC/C,OAAO,YAAY;IAEnB,iDAAiD;IACjD,UAAU,eAAe;IAEzB,8DAA8D;IAC9D,SAAS,cAAc;IAEvB,mCAAmC;IACnC,KAAK,UAAU;IAEf,qDAAqD;IACrD,QAAQ,aAAa;IAErB,4CAA4C;IAC5C,OAAO,YAAY;IAEnB,6CAA6C;IAC7C,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IAEZ,yFAAyF;IACzF,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACvC;AAGD,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE7D,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;OASG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAEvB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC,qDAAqD;IACrD,WAAW,CAAC,EAAE,aAAa,CAAC;IAE5B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAEx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AI,OAAO,CAAC;IAEvB;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC;IAExB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC;IAEtB;;;OAGG;IACH,uBAAuB,IAAI,OAAO,CAAC;IAEnC;;;OAGG;IACH,mBAAmB,IAAI,OAAO,CAAC;IAE/B;;;OAGG;IACH,QAAQ,IAAI,uBAAuB,CAAC;IAEpC;;;;OAIG;IACH,MAAM,IAAI,MAAM,CAAC;IAEjB;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAE9C;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,uCAAuC;IACvC,cAAc,EAAE,MAAM,CAAC;IAEvB,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IAExB,4CAA4C;IAC5C,mBAAmB,EAAE,MAAM,CAAC;IAE5B,iDAAiD;IACjD,mBAAmB,EAAE,MAAM,CAAC;IAE5B,yCAAyC;IACzC,qBAAqB,EAAE,MAAM,CAAC;IAE9B,iEAAiE;IACjE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AAEH,MAAM,WAAW,8CAA+C,SAAQ,wBAAwB;CAG/F"}
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { RecognitionState } from './vgf-recognition-state.js';
|
|
11
11
|
import { IRecognitionClient, IRecognitionClientConfig, IRecognitionClientStats, ClientState } from './recognition-client.types.js';
|
|
12
|
-
import
|
|
12
|
+
import { ConfigBuilder } from './config-builder.js';
|
|
13
|
+
import { type GameContextV1 } from '@recog/shared-types';
|
|
13
14
|
/**
|
|
14
15
|
* Configuration for SimplifiedVGFRecognitionClient
|
|
15
16
|
*/
|
|
@@ -82,9 +83,42 @@ export declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRec
|
|
|
82
83
|
sendGameContext(context: GameContextV1): void;
|
|
83
84
|
isServerReady(): boolean;
|
|
84
85
|
getVGFState(): RecognitionState;
|
|
85
|
-
private isTerminalStatus;
|
|
86
86
|
private notifyStateChange;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Fluent builder for {@link SimplifiedVGFClientConfig}.
|
|
90
|
+
*
|
|
91
|
+
* Extends {@link ConfigBuilder} with the two VGF-specific fields
|
|
92
|
+
* (`onStateChange`, `initialState`) so the simplified client has the same
|
|
93
|
+
* builder ergonomics as the base RealTimeTwoWayWebSocketRecognitionClient.
|
|
94
|
+
*
|
|
95
|
+
* Example:
|
|
96
|
+
* ```typescript
|
|
97
|
+
* import { STAGES, RecognitionProvider } from '@recog/shared-types';
|
|
98
|
+
*
|
|
99
|
+
* const config = new SimplifiedVGFConfigBuilder()
|
|
100
|
+
* .stage(STAGES.STAGING)
|
|
101
|
+
* .asrRequestConfig({ provider: RecognitionProvider.DEEPGRAM, language: 'en' })
|
|
102
|
+
* .onStateChange((state) => setVGFState(state))
|
|
103
|
+
* .build();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare class SimplifiedVGFConfigBuilder extends ConfigBuilder {
|
|
107
|
+
private vgfConfig;
|
|
108
|
+
/**
|
|
109
|
+
* Set the VGF state-change callback, fired whenever the VGF state updates.
|
|
110
|
+
*/
|
|
111
|
+
onStateChange(callback: (state: RecognitionState) => void): this;
|
|
112
|
+
/**
|
|
113
|
+
* Set the initial VGF state to restore from a previous session.
|
|
114
|
+
* The audioUtteranceId is extracted from it when valid.
|
|
115
|
+
*/
|
|
116
|
+
initialState(state: RecognitionState): this;
|
|
117
|
+
/**
|
|
118
|
+
* Build the SimplifiedVGFClientConfig (base fields + VGF fields).
|
|
119
|
+
*/
|
|
120
|
+
build(): SimplifiedVGFClientConfig;
|
|
121
|
+
}
|
|
88
122
|
/**
|
|
89
123
|
* Factory function for creating simplified client
|
|
90
124
|
* Usage examples:
|
|
@@ -129,4 +163,22 @@ export declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRec
|
|
|
129
163
|
* // VGF state automatically updates based on transcription results
|
|
130
164
|
*/
|
|
131
165
|
export declare function createSimplifiedVGFClient(config: SimplifiedVGFClientConfig): ISimplifiedVGFRecognitionClient;
|
|
166
|
+
/**
|
|
167
|
+
* Create a simplified VGF client using the builder pattern.
|
|
168
|
+
*
|
|
169
|
+
* Mirror of `createClientWithBuilder` for the base client.
|
|
170
|
+
*
|
|
171
|
+
* Example:
|
|
172
|
+
* ```typescript
|
|
173
|
+
* import { STAGES, RecognitionProvider } from '@recog/shared-types';
|
|
174
|
+
*
|
|
175
|
+
* const client = createSimplifiedVGFClientWithBuilder((builder) =>
|
|
176
|
+
* builder
|
|
177
|
+
* .stage(STAGES.STAGING)
|
|
178
|
+
* .asrRequestConfig({ provider: RecognitionProvider.DEEPGRAM, language: 'en' })
|
|
179
|
+
* .onStateChange((state) => setVGFState(state))
|
|
180
|
+
* );
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function createSimplifiedVGFClientWithBuilder(configure: (builder: SimplifiedVGFConfigBuilder) => SimplifiedVGFConfigBuilder): ISimplifiedVGFRecognitionClient;
|
|
132
184
|
//# sourceMappingURL=simplified-vgf-recognition-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplified-vgf-recognition-client.d.ts","sourceRoot":"","sources":["../src/simplified-vgf-recognition-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACH,gBAAgB,
|
|
1
|
+
{"version":3,"file":"simplified-vgf-recognition-client.d.ts","sourceRoot":"","sources":["../src/simplified-vgf-recognition-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACH,gBAAgB,EAKnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,EACd,MAAM,+BAA+B,CAAC;AAEvC,OAAO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vB,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,OAAO;IAIvB,UAAU,IAAI,OAAO;IAIrB,uBAAuB,IAAI,OAAO;IAIlC,mBAAmB,IAAI,OAAO;IAI9B,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAI7C,aAAa,IAAI,OAAO;IAMxB,WAAW,IAAI,gBAAgB;IAI/B,OAAO,CAAC,iBAAiB;CA8B5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,0BAA2B,SAAQ,aAAa;IACzD,OAAO,CAAC,SAAS,CAAyE;IAE1F;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI;IAKhE;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAK3C;;OAEG;IACM,KAAK,IAAI,yBAAyB;CAG9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,yBAAyB,GAAG,+BAA+B,CAE5G;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oCAAoC,CAChD,SAAS,EAAE,CAAC,OAAO,EAAE,0BAA0B,KAAK,0BAA0B,GAC/E,+BAA+B,CAIjC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* URL Builder for Recognition Client
|
|
3
3
|
* Handles WebSocket URL construction with query parameters
|
|
4
4
|
*/
|
|
5
|
-
import type { GameContextV1, Stage } from '@recog/shared-types';
|
|
5
|
+
import type { GameContextV1, Stage, MicrophoneSourceType } from '@recog/shared-types';
|
|
6
6
|
import type { RecognitionCallbackUrl } from '../recognition-client.types.js';
|
|
7
7
|
export interface UrlBuilderConfig {
|
|
8
8
|
url?: string;
|
|
@@ -14,6 +14,8 @@ export interface UrlBuilderConfig {
|
|
|
14
14
|
deviceId?: string;
|
|
15
15
|
accountId?: string;
|
|
16
16
|
questionAnswerId?: string;
|
|
17
|
+
clientId?: string;
|
|
18
|
+
microphoneSourceType?: MicrophoneSourceType | string;
|
|
17
19
|
platform?: string;
|
|
18
20
|
gameContext?: GameContextV1;
|
|
19
21
|
/** Standalone gameId - takes precedence over gameContext.gameId if both provided */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-builder.d.ts","sourceRoot":"","sources":["../../src/utils/url-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"url-builder.d.ts","sourceRoot":"","sources":["../../src/utils/url-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAAC;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC3C,sDAAsD;IACtD,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA6ElE"}
|
|
@@ -64,6 +64,8 @@ export declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
|
64
64
|
functionCallMetadata: z.ZodOptional<z.ZodString>;
|
|
65
65
|
functionCallConfidence: z.ZodOptional<z.ZodNumber>;
|
|
66
66
|
finalFunctionCallTimestamp: z.ZodOptional<z.ZodString>;
|
|
67
|
+
gameId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
gamePhase: z.ZodOptional<z.ZodString>;
|
|
67
69
|
promptSlotMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
68
70
|
promptSTT: z.ZodOptional<z.ZodString>;
|
|
69
71
|
promptSTF: z.ZodOptional<z.ZodString>;
|
|
@@ -118,6 +120,8 @@ export declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
|
118
120
|
functionCallMetadata?: string | undefined;
|
|
119
121
|
functionCallConfidence?: number | undefined;
|
|
120
122
|
finalFunctionCallTimestamp?: string | undefined;
|
|
123
|
+
gameId?: string | undefined;
|
|
124
|
+
gamePhase?: string | undefined;
|
|
121
125
|
promptSlotMap?: Record<string, string[]> | undefined;
|
|
122
126
|
promptSTT?: string | undefined;
|
|
123
127
|
promptSTF?: string | undefined;
|
|
@@ -160,6 +164,8 @@ export declare const RecognitionVGFStateSchema: z.ZodObject<{
|
|
|
160
164
|
functionCallMetadata?: string | undefined;
|
|
161
165
|
functionCallConfidence?: number | undefined;
|
|
162
166
|
finalFunctionCallTimestamp?: string | undefined;
|
|
167
|
+
gameId?: string | undefined;
|
|
168
|
+
gamePhase?: string | undefined;
|
|
163
169
|
promptSlotMap?: Record<string, string[]> | undefined;
|
|
164
170
|
promptSTT?: string | undefined;
|
|
165
171
|
promptSTF?: string | undefined;
|
|
@@ -196,5 +202,6 @@ export declare const RecognitionActionProcessingState: {
|
|
|
196
202
|
};
|
|
197
203
|
export type RecognitionActionProcessingStateType = typeof RecognitionActionProcessingState[keyof typeof RecognitionActionProcessingState];
|
|
198
204
|
export declare function createInitialRecognitionState(audioUtteranceId: string): RecognitionState;
|
|
205
|
+
export declare function isTerminal(state: Pick<RecognitionState, "transcriptionStatus">): boolean;
|
|
199
206
|
export declare function isValidRecordingStatusTransition(from: string | undefined, to: string): boolean;
|
|
200
207
|
//# sourceMappingURL=vgf-recognition-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vgf-recognition-state.d.ts","sourceRoot":"","sources":["../src/vgf-recognition-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"vgf-recognition-state.d.ts","sourceRoot":"","sources":["../src/vgf-recognition-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DpC,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAGxE,eAAO,MAAM,eAAe;;;;;CAKlB,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAA;AAEtF,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAA;AAEV,MAAM,MAAM,uBAAuB,GAAG,OAAO,mBAAmB,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAA;AAElG,eAAO,MAAM,gCAAgC;;;;CAInC,CAAA;AAEV,MAAM,MAAM,oCAAoC,GAAG,OAAO,gCAAgC,CAAC,MAAM,OAAO,gCAAgC,CAAC,CAAA;AAGzI,wBAAgB,6BAA6B,CAAC,gBAAgB,EAAE,MAAM,GAAG,gBAAgB,CAQxF;AAUD,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,GAAG,OAAO,CAMxF;AAGD,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAa9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volley/recognition-client-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.806",
|
|
4
4
|
"description": "Recognition Service TypeScript/Node.js Client SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"ts-jest": "29.2.5",
|
|
56
56
|
"typescript": "5.1.6",
|
|
57
57
|
"@recog/shared-config": "1.0.0",
|
|
58
|
+
"@recog/websocket": "1.0.0",
|
|
58
59
|
"@recog/shared-types": "1.0.0",
|
|
59
|
-
"@recog/shared-utils": "1.0.0"
|
|
60
|
-
"@recog/websocket": "1.0.0"
|
|
60
|
+
"@recog/shared-utils": "1.0.0"
|
|
61
61
|
},
|
|
62
62
|
"keywords": [
|
|
63
63
|
"recognition",
|
|
@@ -96,6 +96,20 @@ describe('ConfigBuilder', () => {
|
|
|
96
96
|
expect(config.questionAnswerId).toBe('qa-xyz');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
it('should set clientId', () => {
|
|
100
|
+
const config = new ConfigBuilder()
|
|
101
|
+
.clientId('client-123')
|
|
102
|
+
.build();
|
|
103
|
+
expect(config.clientId).toBe('client-123');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should set microphoneSourceType', () => {
|
|
107
|
+
const config = new ConfigBuilder()
|
|
108
|
+
.microphoneSourceType('native')
|
|
109
|
+
.build();
|
|
110
|
+
expect(config.microphoneSourceType).toBe('native');
|
|
111
|
+
});
|
|
112
|
+
|
|
99
113
|
it('should set platform', () => {
|
|
100
114
|
const config = new ConfigBuilder()
|
|
101
115
|
.platform('ios')
|
package/src/config-builder.ts
CHANGED
|
@@ -16,7 +16,8 @@ import type {
|
|
|
16
16
|
SessionConfiguredV1,
|
|
17
17
|
AudioMetricsResultV1,
|
|
18
18
|
ErrorResultV1,
|
|
19
|
-
Stage
|
|
19
|
+
Stage,
|
|
20
|
+
MicrophoneSourceType
|
|
20
21
|
} from '@recog/shared-types';
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -145,6 +146,23 @@ export class ConfigBuilder {
|
|
|
145
146
|
return this;
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Set client ID (for downstream tracking/audio-labeling)
|
|
151
|
+
*/
|
|
152
|
+
clientId(id: string): this {
|
|
153
|
+
this.config.clientId = id;
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Set the client audio capture path (MicrophoneSourceType enum or 'web' | 'native' string).
|
|
159
|
+
* Defaults to 'web' on the server when omitted.
|
|
160
|
+
*/
|
|
161
|
+
microphoneSourceType(source: MicrophoneSourceType | string): this {
|
|
162
|
+
this.config.microphoneSourceType = source;
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
|
|
148
166
|
/**
|
|
149
167
|
* Set platform
|
|
150
168
|
*/
|
package/src/index.ts
CHANGED
|
@@ -53,7 +53,9 @@ export {
|
|
|
53
53
|
// Export VGF state management (new simplified interface)
|
|
54
54
|
export {
|
|
55
55
|
SimplifiedVGFRecognitionClient,
|
|
56
|
+
SimplifiedVGFConfigBuilder,
|
|
56
57
|
createSimplifiedVGFClient,
|
|
58
|
+
createSimplifiedVGFClientWithBuilder,
|
|
57
59
|
type ISimplifiedVGFRecognitionClient,
|
|
58
60
|
type SimplifiedVGFClientConfig
|
|
59
61
|
} from './simplified-vgf-recognition-client.js';
|
|
@@ -66,6 +68,7 @@ export {
|
|
|
66
68
|
type RecordingStatusType,
|
|
67
69
|
type TranscriptionStatusType,
|
|
68
70
|
createInitialRecognitionState,
|
|
71
|
+
isTerminal,
|
|
69
72
|
isValidRecordingStatusTransition
|
|
70
73
|
} from './vgf-recognition-state.js';
|
|
71
74
|
|
|
@@ -98,6 +101,7 @@ export {
|
|
|
98
101
|
FinalTranscriptStability,
|
|
99
102
|
createDefaultASRConfig,
|
|
100
103
|
RecognitionProvider,
|
|
104
|
+
AssemblyAIModel,
|
|
101
105
|
DeepgramModel,
|
|
102
106
|
ElevenLabsModel,
|
|
103
107
|
FireworksModel,
|
|
@@ -116,6 +120,9 @@ export {
|
|
|
116
120
|
Language,
|
|
117
121
|
SampleRate,
|
|
118
122
|
|
|
123
|
+
// Audio capture source
|
|
124
|
+
MicrophoneSourceType,
|
|
125
|
+
|
|
119
126
|
// Stage/Environment types
|
|
120
127
|
STAGES,
|
|
121
128
|
type Stage
|
|
@@ -197,6 +197,8 @@ export class RealTimeTwoWayWebSocketRecognitionClient
|
|
|
197
197
|
...(config.deviceId && { deviceId: config.deviceId }),
|
|
198
198
|
...(config.accountId && { accountId: config.accountId }),
|
|
199
199
|
...(config.questionAnswerId && { questionAnswerId: config.questionAnswerId }),
|
|
200
|
+
...(config.clientId && { clientId: config.clientId }),
|
|
201
|
+
...(config.microphoneSourceType && { microphoneSourceType: config.microphoneSourceType }),
|
|
200
202
|
...(config.platform && { platform: config.platform }),
|
|
201
203
|
...(config.gameContext && { gameContext: config.gameContext }),
|
|
202
204
|
...(config.gameId && { gameId: config.gameId }),
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
AudioMetricsResultV1,
|
|
15
15
|
ASRRequestConfig,
|
|
16
16
|
GameContextV1,
|
|
17
|
-
Stage
|
|
17
|
+
Stage,
|
|
18
|
+
MicrophoneSourceType
|
|
18
19
|
} from '@recog/shared-types';
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -126,6 +127,16 @@ export interface IRecognitionClientConfig {
|
|
|
126
127
|
/** Question answer identifier for tracking Q&A sessions (optional and tracking purpose only) */
|
|
127
128
|
questionAnswerId?: string;
|
|
128
129
|
|
|
130
|
+
/** Client identifier for downstream tracking/audio-labeling (optional and tracking purpose only) */
|
|
131
|
+
clientId?: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Client audio capture path (optional). Accepts the {@link MicrophoneSourceType}
|
|
135
|
+
* enum or its string value ('web' | 'native'). Defaults to 'web' on the server
|
|
136
|
+
* when omitted. The service normalizes this to the enum at the boundary.
|
|
137
|
+
*/
|
|
138
|
+
microphoneSourceType?: MicrophoneSourceType | string;
|
|
139
|
+
|
|
129
140
|
/** Platform for audio recording device (optional, e.g., 'ios', 'android', 'web', 'unity') */
|
|
130
141
|
platform?: string;
|
|
131
142
|
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* Unit tests for SimplifiedVGFRecognitionClient
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
SimplifiedVGFRecognitionClient,
|
|
7
|
+
SimplifiedVGFConfigBuilder,
|
|
8
|
+
createSimplifiedVGFClient,
|
|
9
|
+
createSimplifiedVGFClientWithBuilder
|
|
10
|
+
} from './simplified-vgf-recognition-client.js';
|
|
6
11
|
import { RealTimeTwoWayWebSocketRecognitionClient } from './recognition-client.js';
|
|
7
12
|
import { ClientState } from './recognition-client.types.js';
|
|
8
13
|
import { AudioEncoding, RecognitionContextTypeV1, RecognitionResultTypeV1 } from '@recog/shared-types';
|
|
@@ -1495,4 +1500,72 @@ describe('SimplifiedVGFRecognitionClient', () => {
|
|
|
1495
1500
|
expect(stateChangeCallback).not.toHaveBeenCalled();
|
|
1496
1501
|
});
|
|
1497
1502
|
});
|
|
1503
|
+
|
|
1504
|
+
describe('SimplifiedVGFConfigBuilder', () => {
|
|
1505
|
+
const asrConfig = {
|
|
1506
|
+
provider: 'deepgram',
|
|
1507
|
+
language: 'en',
|
|
1508
|
+
sampleRate: 16000,
|
|
1509
|
+
encoding: AudioEncoding.LINEAR16
|
|
1510
|
+
};
|
|
1511
|
+
|
|
1512
|
+
it('should build a config containing both base and VGF-specific fields', () => {
|
|
1513
|
+
const initialState: RecognitionState = {
|
|
1514
|
+
audioUtteranceId: 'restore-123',
|
|
1515
|
+
pendingTranscript: ''
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
const config = new SimplifiedVGFConfigBuilder()
|
|
1519
|
+
.stage('staging')
|
|
1520
|
+
.asrRequestConfig(asrConfig)
|
|
1521
|
+
.onStateChange(stateChangeCallback)
|
|
1522
|
+
.initialState(initialState)
|
|
1523
|
+
.build();
|
|
1524
|
+
|
|
1525
|
+
// Base fields (inherited from ConfigBuilder)
|
|
1526
|
+
expect(config.stage).toBe('staging');
|
|
1527
|
+
expect(config.asrRequestConfig).toEqual(asrConfig);
|
|
1528
|
+
// VGF-specific fields
|
|
1529
|
+
expect(config.onStateChange).toBe(stateChangeCallback);
|
|
1530
|
+
expect(config.initialState).toBe(initialState);
|
|
1531
|
+
});
|
|
1532
|
+
|
|
1533
|
+
it('should allow VGF setters in any order relative to base setters', () => {
|
|
1534
|
+
const config = new SimplifiedVGFConfigBuilder()
|
|
1535
|
+
.onStateChange(stateChangeCallback)
|
|
1536
|
+
.asrRequestConfig(asrConfig)
|
|
1537
|
+
.build();
|
|
1538
|
+
|
|
1539
|
+
expect(config.onStateChange).toBe(stateChangeCallback);
|
|
1540
|
+
expect(config.asrRequestConfig).toEqual(asrConfig);
|
|
1541
|
+
});
|
|
1542
|
+
|
|
1543
|
+
it('should omit VGF fields when their setters are not called', () => {
|
|
1544
|
+
const config = new SimplifiedVGFConfigBuilder()
|
|
1545
|
+
.asrRequestConfig(asrConfig)
|
|
1546
|
+
.build();
|
|
1547
|
+
|
|
1548
|
+
expect(config.onStateChange).toBeUndefined();
|
|
1549
|
+
expect(config.initialState).toBeUndefined();
|
|
1550
|
+
});
|
|
1551
|
+
});
|
|
1552
|
+
|
|
1553
|
+
describe('createSimplifiedVGFClientWithBuilder', () => {
|
|
1554
|
+
it('should create a SimplifiedVGFRecognitionClient with the built config', () => {
|
|
1555
|
+
const client = createSimplifiedVGFClientWithBuilder((builder) =>
|
|
1556
|
+
builder
|
|
1557
|
+
.asrRequestConfig({
|
|
1558
|
+
provider: 'deepgram',
|
|
1559
|
+
language: 'en',
|
|
1560
|
+
sampleRate: 16000,
|
|
1561
|
+
encoding: AudioEncoding.LINEAR16
|
|
1562
|
+
})
|
|
1563
|
+
.onStateChange(stateChangeCallback)
|
|
1564
|
+
);
|
|
1565
|
+
|
|
1566
|
+
expect(client).toBeInstanceOf(SimplifiedVGFRecognitionClient);
|
|
1567
|
+
// VGF wiring is live: getVGFState() works on the constructed client
|
|
1568
|
+
expect(client.getVGFState()).toBeDefined();
|
|
1569
|
+
});
|
|
1570
|
+
});
|
|
1498
1571
|
});
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
RecognitionState,
|
|
13
13
|
TranscriptionStatus,
|
|
14
14
|
RecordingStatus,
|
|
15
|
-
RecognitionActionProcessingState
|
|
15
|
+
RecognitionActionProcessingState,
|
|
16
|
+
isTerminal
|
|
16
17
|
} from './vgf-recognition-state.js';
|
|
17
18
|
import {
|
|
18
19
|
IRecognitionClient,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
ClientState
|
|
22
23
|
} from './recognition-client.types.js';
|
|
23
24
|
import { RealTimeTwoWayWebSocketRecognitionClient } from './recognition-client.js';
|
|
25
|
+
import { ConfigBuilder } from './config-builder.js';
|
|
24
26
|
import {
|
|
25
27
|
createVGFStateFromConfig,
|
|
26
28
|
mapTranscriptionResultToState,
|
|
@@ -29,7 +31,7 @@ import {
|
|
|
29
31
|
updateStateOnStop,
|
|
30
32
|
resetRecognitionVGFState
|
|
31
33
|
} from './vgf-recognition-mapper.js';
|
|
32
|
-
import type
|
|
34
|
+
import { RecognitionContextTypeV1, type GameContextV1 } from '@recog/shared-types';
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* Configuration for SimplifiedVGFRecognitionClient
|
|
@@ -139,6 +141,19 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
139
141
|
// Track the expected UUID for this session
|
|
140
142
|
this.expectedUuid = this.state.audioUtteranceId;
|
|
141
143
|
|
|
144
|
+
// Backfill gameContext from state if the caller didn't pass one in config.
|
|
145
|
+
// Lets RecognitionState carry session identity (gameId + gamePhase) alongside
|
|
146
|
+
// runtime prompt inputs (promptSlotMap, promptSTT/STF/TTF), so a single
|
|
147
|
+
// initialState object is sufficient — no separate gameContext required.
|
|
148
|
+
// Backward-compatible: if both are provided, clientConfig.gameContext wins.
|
|
149
|
+
if (!clientConfig.gameContext && this.state.gameId && this.state.gamePhase) {
|
|
150
|
+
clientConfig.gameContext = {
|
|
151
|
+
type: RecognitionContextTypeV1.GAME_CONTEXT,
|
|
152
|
+
gameId: this.state.gameId,
|
|
153
|
+
gamePhase: this.state.gamePhase,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
142
157
|
// Forward optional VGF inputs (promptSlotMap, promptSTT/STF/TTF) into the GameContext.
|
|
143
158
|
const hasPromptInputs =
|
|
144
159
|
this.state.promptSlotMap !== undefined ||
|
|
@@ -153,10 +168,10 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
153
168
|
}
|
|
154
169
|
|
|
155
170
|
if (!clientConfig.gameContext) {
|
|
156
|
-
//
|
|
157
|
-
//
|
|
171
|
+
// No gameContext from config, and state didn't carry gameId+gamePhase
|
|
172
|
+
// either — prompt inputs have nowhere to ride. Warn and drop.
|
|
158
173
|
if (clientConfig.logger) {
|
|
159
|
-
clientConfig.logger('warn', '[VGF] prompt inputs found but no gameContext provided. They will not be sent.');
|
|
174
|
+
clientConfig.logger('warn', '[VGF] prompt inputs found but no gameContext provided and state has no gameId/gamePhase. They will not be sent.');
|
|
160
175
|
}
|
|
161
176
|
} else {
|
|
162
177
|
if (this.state.promptSlotMap !== undefined) {
|
|
@@ -433,16 +448,10 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
433
448
|
return { ...this.state };
|
|
434
449
|
}
|
|
435
450
|
|
|
436
|
-
private isTerminalStatus(status: string | undefined): boolean {
|
|
437
|
-
return status === TranscriptionStatus.FINALIZED ||
|
|
438
|
-
status === TranscriptionStatus.ABORTED ||
|
|
439
|
-
status === TranscriptionStatus.ERROR;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
451
|
private notifyStateChange(): void {
|
|
443
452
|
|
|
444
453
|
// Block duplicate terminal status emissions for THIS session
|
|
445
|
-
if (
|
|
454
|
+
if (isTerminal(this.state)) {
|
|
446
455
|
if (this.lastSentTerminalUuid === this.expectedUuid) {
|
|
447
456
|
// Already sent a terminal status for this session - suppress duplicate
|
|
448
457
|
if (this.logger) {
|
|
@@ -471,6 +480,52 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
471
480
|
}
|
|
472
481
|
}
|
|
473
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Fluent builder for {@link SimplifiedVGFClientConfig}.
|
|
485
|
+
*
|
|
486
|
+
* Extends {@link ConfigBuilder} with the two VGF-specific fields
|
|
487
|
+
* (`onStateChange`, `initialState`) so the simplified client has the same
|
|
488
|
+
* builder ergonomics as the base RealTimeTwoWayWebSocketRecognitionClient.
|
|
489
|
+
*
|
|
490
|
+
* Example:
|
|
491
|
+
* ```typescript
|
|
492
|
+
* import { STAGES, RecognitionProvider } from '@recog/shared-types';
|
|
493
|
+
*
|
|
494
|
+
* const config = new SimplifiedVGFConfigBuilder()
|
|
495
|
+
* .stage(STAGES.STAGING)
|
|
496
|
+
* .asrRequestConfig({ provider: RecognitionProvider.DEEPGRAM, language: 'en' })
|
|
497
|
+
* .onStateChange((state) => setVGFState(state))
|
|
498
|
+
* .build();
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
export class SimplifiedVGFConfigBuilder extends ConfigBuilder {
|
|
502
|
+
private vgfConfig: Pick<SimplifiedVGFClientConfig, 'onStateChange' | 'initialState'> = {};
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Set the VGF state-change callback, fired whenever the VGF state updates.
|
|
506
|
+
*/
|
|
507
|
+
onStateChange(callback: (state: RecognitionState) => void): this {
|
|
508
|
+
this.vgfConfig.onStateChange = callback;
|
|
509
|
+
return this;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Set the initial VGF state to restore from a previous session.
|
|
514
|
+
* The audioUtteranceId is extracted from it when valid.
|
|
515
|
+
*/
|
|
516
|
+
initialState(state: RecognitionState): this {
|
|
517
|
+
this.vgfConfig.initialState = state;
|
|
518
|
+
return this;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Build the SimplifiedVGFClientConfig (base fields + VGF fields).
|
|
523
|
+
*/
|
|
524
|
+
override build(): SimplifiedVGFClientConfig {
|
|
525
|
+
return { ...super.build(), ...this.vgfConfig };
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
474
529
|
/**
|
|
475
530
|
* Factory function for creating simplified client
|
|
476
531
|
* Usage examples:
|
|
@@ -517,3 +572,28 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
517
572
|
export function createSimplifiedVGFClient(config: SimplifiedVGFClientConfig): ISimplifiedVGFRecognitionClient {
|
|
518
573
|
return new SimplifiedVGFRecognitionClient(config);
|
|
519
574
|
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Create a simplified VGF client using the builder pattern.
|
|
578
|
+
*
|
|
579
|
+
* Mirror of `createClientWithBuilder` for the base client.
|
|
580
|
+
*
|
|
581
|
+
* Example:
|
|
582
|
+
* ```typescript
|
|
583
|
+
* import { STAGES, RecognitionProvider } from '@recog/shared-types';
|
|
584
|
+
*
|
|
585
|
+
* const client = createSimplifiedVGFClientWithBuilder((builder) =>
|
|
586
|
+
* builder
|
|
587
|
+
* .stage(STAGES.STAGING)
|
|
588
|
+
* .asrRequestConfig({ provider: RecognitionProvider.DEEPGRAM, language: 'en' })
|
|
589
|
+
* .onStateChange((state) => setVGFState(state))
|
|
590
|
+
* );
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
export function createSimplifiedVGFClientWithBuilder(
|
|
594
|
+
configure: (builder: SimplifiedVGFConfigBuilder) => SimplifiedVGFConfigBuilder
|
|
595
|
+
): ISimplifiedVGFRecognitionClient {
|
|
596
|
+
const builder = new SimplifiedVGFConfigBuilder();
|
|
597
|
+
const config = configure(builder).build();
|
|
598
|
+
return new SimplifiedVGFRecognitionClient(config);
|
|
599
|
+
}
|
|
@@ -130,6 +130,24 @@ describe('buildWebSocketUrl', () => {
|
|
|
130
130
|
expect(url).toContain('questionAnswerId=qa-xyz');
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
+
it('should add clientId to query parameters', () => {
|
|
134
|
+
const config = {
|
|
135
|
+
...baseConfig,
|
|
136
|
+
clientId: 'client-123'
|
|
137
|
+
};
|
|
138
|
+
const url = buildWebSocketUrl(config);
|
|
139
|
+
expect(url).toContain('clientId=client-123');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should add microphoneSourceType to query parameters', () => {
|
|
143
|
+
const config = {
|
|
144
|
+
...baseConfig,
|
|
145
|
+
microphoneSourceType: 'native'
|
|
146
|
+
};
|
|
147
|
+
const url = buildWebSocketUrl(config);
|
|
148
|
+
expect(url).toContain('microphoneSourceType=native');
|
|
149
|
+
});
|
|
150
|
+
|
|
133
151
|
it('should add platform to query parameters', () => {
|
|
134
152
|
const config = {
|
|
135
153
|
...baseConfig,
|