@volley/recognition-client-sdk 0.1.803 → 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 +133 -32
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -9
- 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 +53 -0
- 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/package.json +4 -4
- package/src/config-builder.spec.ts +14 -0
- package/src/config-builder.ts +19 -1
- package/src/index.ts +6 -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 +72 -0
- package/src/utils/url-builder.spec.ts +18 -0
- package/src/utils/url-builder.ts +9 -1
|
@@ -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,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB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/C,gBAAgB,EAAE,MAAM,GACvB,IAAI;IAsBP,OAAO,CAAC,iBAAiB;IAsCzB;;;OAGG;IAEG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAoCpC,cAAc,IAAI,IAAI;IAwBtB,mBAAmB,IAAI,MAAM;IAI7B,MAAM,IAAI,MAAM;IAIhB,QAAQ,IAAI,WAAW;IAIvB,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,OAAO;IAIvB,UAAU,IAAI,OAAO;IAIrB,uBAAuB,IAAI,OAAO;IAIlC,mBAAmB,IAAI,OAAO;IAI9B,aAAa,IAAI,OAAO;IAIxB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAmB7C,QAAQ,IAAI,uBAAuB;IAgBnC,SAAS,CAAC,WAAW,IAAI,IAAI;IAwF7B,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA8C5D;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAwB/B,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;cAYlB,SAAS,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI;IAQ/E;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAiC5B;;;OAGG;IACH,OAAO,CAAC,YAAY;IAwBpB;;;;;;;;;OASG;IACH,eAAe,CAAC,SAAS,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,GAAG,IAAI;IAiBtE;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAiC/B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CA2B3B"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 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.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AAO,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,6 +9,7 @@
|
|
|
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 { ConfigBuilder } from './config-builder.js';
|
|
12
13
|
import { type GameContextV1 } from '@recog/shared-types';
|
|
13
14
|
/**
|
|
14
15
|
* Configuration for SimplifiedVGFRecognitionClient
|
|
@@ -84,6 +85,40 @@ export declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRec
|
|
|
84
85
|
getVGFState(): RecognitionState;
|
|
85
86
|
private notifyStateChange;
|
|
86
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
|
+
}
|
|
87
122
|
/**
|
|
88
123
|
* Factory function for creating simplified client
|
|
89
124
|
* Usage examples:
|
|
@@ -128,4 +163,22 @@ export declare class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRec
|
|
|
128
163
|
* // VGF state automatically updates based on transcription results
|
|
129
164
|
*/
|
|
130
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;
|
|
131
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,EAKnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,EACd,MAAM,+BAA+B,CAAC;
|
|
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,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,qBAAqB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I,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"}
|
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",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"semantic-release": "25.0.1",
|
|
55
55
|
"ts-jest": "29.2.5",
|
|
56
56
|
"typescript": "5.1.6",
|
|
57
|
-
"@recog/shared-utils": "1.0.0",
|
|
58
|
-
"@recog/shared-types": "1.0.0",
|
|
59
57
|
"@recog/shared-config": "1.0.0",
|
|
60
|
-
"@recog/websocket": "1.0.0"
|
|
58
|
+
"@recog/websocket": "1.0.0",
|
|
59
|
+
"@recog/shared-types": "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';
|
|
@@ -99,6 +101,7 @@ export {
|
|
|
99
101
|
FinalTranscriptStability,
|
|
100
102
|
createDefaultASRConfig,
|
|
101
103
|
RecognitionProvider,
|
|
104
|
+
AssemblyAIModel,
|
|
102
105
|
DeepgramModel,
|
|
103
106
|
ElevenLabsModel,
|
|
104
107
|
FireworksModel,
|
|
@@ -117,6 +120,9 @@ export {
|
|
|
117
120
|
Language,
|
|
118
121
|
SampleRate,
|
|
119
122
|
|
|
123
|
+
// Audio capture source
|
|
124
|
+
MicrophoneSourceType,
|
|
125
|
+
|
|
120
126
|
// Stage/Environment types
|
|
121
127
|
STAGES,
|
|
122
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
|
});
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
ClientState
|
|
23
23
|
} from './recognition-client.types.js';
|
|
24
24
|
import { RealTimeTwoWayWebSocketRecognitionClient } from './recognition-client.js';
|
|
25
|
+
import { ConfigBuilder } from './config-builder.js';
|
|
25
26
|
import {
|
|
26
27
|
createVGFStateFromConfig,
|
|
27
28
|
mapTranscriptionResultToState,
|
|
@@ -479,6 +480,52 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
479
480
|
}
|
|
480
481
|
}
|
|
481
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
|
+
|
|
482
529
|
/**
|
|
483
530
|
* Factory function for creating simplified client
|
|
484
531
|
* Usage examples:
|
|
@@ -525,3 +572,28 @@ export class SimplifiedVGFRecognitionClient implements ISimplifiedVGFRecognition
|
|
|
525
572
|
export function createSimplifiedVGFClient(config: SimplifiedVGFClientConfig): ISimplifiedVGFRecognitionClient {
|
|
526
573
|
return new SimplifiedVGFRecognitionClient(config);
|
|
527
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,
|
package/src/utils/url-builder.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { getRecognitionServiceBase } from '@recog/shared-config';
|
|
7
|
-
import type { GameContextV1, Stage } from '@recog/shared-types';
|
|
7
|
+
import type { GameContextV1, Stage, MicrophoneSourceType } from '@recog/shared-types';
|
|
8
8
|
import type { RecognitionCallbackUrl } from '../recognition-client.types.js';
|
|
9
9
|
|
|
10
10
|
export interface UrlBuilderConfig {
|
|
@@ -17,6 +17,8 @@ export interface UrlBuilderConfig {
|
|
|
17
17
|
deviceId?: string;
|
|
18
18
|
accountId?: string;
|
|
19
19
|
questionAnswerId?: string;
|
|
20
|
+
clientId?: string;
|
|
21
|
+
microphoneSourceType?: MicrophoneSourceType | string;
|
|
20
22
|
platform?: string;
|
|
21
23
|
gameContext?: GameContextV1;
|
|
22
24
|
/** Standalone gameId - takes precedence over gameContext.gameId if both provided */
|
|
@@ -77,6 +79,12 @@ export function buildWebSocketUrl(config: UrlBuilderConfig): string {
|
|
|
77
79
|
if (config.questionAnswerId) {
|
|
78
80
|
url.searchParams.set('questionAnswerId', config.questionAnswerId);
|
|
79
81
|
}
|
|
82
|
+
if (config.clientId) {
|
|
83
|
+
url.searchParams.set('clientId', config.clientId);
|
|
84
|
+
}
|
|
85
|
+
if (config.microphoneSourceType) {
|
|
86
|
+
url.searchParams.set('microphoneSourceType', config.microphoneSourceType);
|
|
87
|
+
}
|
|
80
88
|
if (config.platform) {
|
|
81
89
|
url.searchParams.set('platform', config.platform);
|
|
82
90
|
}
|