agora-appbuilder-core 4.1.30-beta.2 → 4.1.31-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "4.1.30-beta.2",
3
+ "version": "4.1.31-beta.1",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -77,8 +77,8 @@ const DefaultConfig = {
77
77
  CHAT_ORG_NAME: "",
78
78
  CHAT_APP_NAME: "",
79
79
  CHAT_URL: "",
80
- CLI_VERSION: "3.1.30-beta.2",
81
- CORE_VERSION: "4.1.30-beta.2",
80
+ CLI_VERSION: "3.1.31-beta.1",
81
+ CORE_VERSION: "4.1.31-beta.1",
82
82
  DISABLE_LANDSCAPE_MODE: false,
83
83
  STT_AUTO_START: false,
84
84
  CLOUD_RECORDING_AUTO_START: false,
@@ -47,6 +47,16 @@ target 'HelloWorld' do
47
47
  :mac_catalyst_enabled => false
48
48
  )
49
49
 
50
+ # Work around fmt consteval errors with Xcode 26.5.
51
+ # Keep React Native and all other Pods on their existing C++ standard.
52
+ installer.pods_project.targets.each do |target|
53
+ next unless target.name == 'fmt'
54
+
55
+ target.build_configurations.each do |build_config|
56
+ build_config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17'
57
+ end
58
+ end
59
+
50
60
  # === BEGIN: Bitcode Stripping ===
51
61
  bitcode_strip_path = `xcrun --find bitcode_strip`.chomp
52
62
 
@@ -2270,6 +2270,6 @@ SPEC CHECKSUMS:
2270
2270
  TrustKit: 1050f3ce0595f8ed775f1237b7f590e3a4f93e91
2271
2271
  Yoga: 7d51419602153919f32aec72812e324d495ee49d
2272
2272
 
2273
- PODFILE CHECKSUM: 93b3e50f925043930a67ae6810f4ec44a372c6ae
2273
+ PODFILE CHECKSUM: 0781ad7f317310f7ec97db5a9e9190f800651440
2274
2274
 
2275
2275
  COCOAPODS: 1.16.2
@@ -9,6 +9,11 @@ const mockPresence = {
9
9
  getOnlineUsers: jest.fn<any>(),
10
10
  };
11
11
 
12
+ jest.mock('../../../logger/AppBuilderLogger', () => ({
13
+ LogSource: {Internals: 'Internals'},
14
+ logger: {log: jest.fn()},
15
+ }));
16
+
12
17
  jest.mock('../../../rtm/RTMEngine', () => ({
13
18
  __esModule: true,
14
19
  default: {
@@ -1,5 +1,10 @@
1
1
  import {beforeEach, describe, expect, it, jest} from '@jest/globals';
2
2
 
3
+ jest.mock('../../../logger/AppBuilderLogger', () => ({
4
+ LogSource: {Internals: 'Internals'},
5
+ logger: {log: jest.fn()},
6
+ }));
7
+
3
8
  jest.mock('../../../rtm/RTMEngine', () => ({
4
9
  __esModule: true,
5
10
  default: {
@@ -58,13 +63,15 @@ const createHarness = () => {
58
63
  };
59
64
  const createId = jest.fn(() => 'candidate');
60
65
  const wait = jest.fn(async () => {});
66
+ const log = jest.fn();
61
67
  const coordinator = createSTTSessionCoordinator({
68
+ log,
62
69
  getClient: () => ({storage, presence: rtmPresence} as any),
63
70
  createId,
64
71
  wait,
65
72
  });
66
73
 
67
- return {coordinator, createId, rtmPresence, storage, wait};
74
+ return {coordinator, createId, rtmPresence, storage, wait, log};
68
75
  };
69
76
 
70
77
  describe('web STT session coordinator', () => {
@@ -72,6 +79,96 @@ describe('web STT session coordinator', () => {
72
79
  jest.clearAllMocks();
73
80
  });
74
81
 
82
+ it('two peers converge on one replacement and delayed errors adopt it', async () => {
83
+ const {storage, rtmPresence} = createHarness();
84
+ let value = 'stale';
85
+ let revision = 9;
86
+ storage.getChannelMetadata.mockImplementation(async () =>
87
+ channelMetadata(value, revision),
88
+ );
89
+ storage.setChannelMetadata.mockImplementation(
90
+ async (_channel, _type, data) => {
91
+ if (data.items[0].revision !== revision) {
92
+ throw new Error('revision conflict');
93
+ }
94
+ value = data.items[0].value;
95
+ revision += 1;
96
+ return {};
97
+ },
98
+ );
99
+ const makePeer = (candidate: string, log = jest.fn()) =>
100
+ createSTTSessionCoordinator({
101
+ getClient: () => ({storage, presence: rtmPresence} as any),
102
+ createId: () => candidate,
103
+ wait: async () => {},
104
+ log,
105
+ });
106
+ const logB = jest.fn();
107
+ const a = makePeer('new-a');
108
+ const b = makePeer('new-b', logB);
109
+ const ids = await Promise.all([
110
+ a.rotateSessionId('room', 'stale'),
111
+ b.rotateSessionId('room', 'stale'),
112
+ ]);
113
+ expect(ids).toEqual(['new-a', 'new-a']);
114
+ expect(await a.ensureSTTSessionId('room')).toBe('new-a');
115
+ expect(await b.ensureSTTSessionId('room')).toBe('new-a');
116
+ expect(logB).toHaveBeenCalledWith(
117
+ 'STT session rotation adopted',
118
+ expect.objectContaining({sessionId: 'new-a', staleSessionId: 'stale'}),
119
+ );
120
+ storage.setChannelMetadata.mockClear();
121
+ expect(await b.rotateSessionId('room', 'stale')).toBe('new-a');
122
+ expect(storage.setChannelMetadata).not.toHaveBeenCalled();
123
+ });
124
+
125
+ it('surfaces a failed rotation instead of adopting the unchanged stale value', async () => {
126
+ const {coordinator, storage} = createHarness();
127
+ storage.getChannelMetadata.mockResolvedValue(channelMetadata('stale'));
128
+ storage.setChannelMetadata.mockRejectedValue(
129
+ new Error('permission denied'),
130
+ );
131
+ await expect(coordinator.rotateSessionId('room', 'stale')).rejects.toThrow(
132
+ 'permission denied',
133
+ );
134
+ });
135
+
136
+ it('does not let an older lookup restore a stale value after recovery', async () => {
137
+ const {coordinator, storage} = createHarness();
138
+ let finishRead!: (value: any) => void;
139
+ storage.getChannelMetadata
140
+ .mockImplementationOnce(
141
+ () =>
142
+ new Promise(resolve => {
143
+ finishRead = resolve;
144
+ }),
145
+ )
146
+ .mockResolvedValue(channelMetadata('stale'));
147
+ storage.setChannelMetadata.mockResolvedValue({});
148
+ const lookup = coordinator.ensureSTTSessionId('room');
149
+ const rotation = coordinator.rotateSessionId('room', 'stale');
150
+ finishRead(channelMetadata('stale'));
151
+ await lookup;
152
+ expect(await rotation).toBe('candidate');
153
+ expect(await coordinator.ensureSTTSessionId('room')).toBe('candidate');
154
+ });
155
+
156
+ it('only skips validation until a locally created ID is first used', async () => {
157
+ const {coordinator, storage, log} = createHarness();
158
+ storage.getChannelMetadata.mockResolvedValue(channelMetadata());
159
+ storage.setChannelMetadata.mockResolvedValue({});
160
+ log.mockImplementation(() => {
161
+ throw new Error('transport failed');
162
+ });
163
+ expect(await coordinator.ensureSTTSessionId('room')).toBe('candidate');
164
+ expect(coordinator.wasSessionIdFreshlyCreated('room')).toBe(true);
165
+ coordinator.markSessionIdUsed('room', 'other-id');
166
+ expect(coordinator.wasSessionIdFreshlyCreated('room')).toBe(true);
167
+ coordinator.markSessionIdUsed('room', 'candidate');
168
+ expect(coordinator.wasSessionIdFreshlyCreated('room')).toBe(false);
169
+ expect(await coordinator.ensureSTTSessionId('room')).toBe('candidate');
170
+ });
171
+
75
172
  it('reuses existing channel metadata without writing', async () => {
76
173
  const {coordinator, storage} = createHarness();
77
174
  storage.getChannelMetadata.mockResolvedValue(
@@ -4,6 +4,9 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals';
4
4
 
5
5
  jest.mock('../sttSessionId', () => ({
6
6
  ensureSTTSessionId: jest.fn(),
7
+ rotateSTTSessionId: jest.fn(),
8
+ wasSTTSessionIdFreshlyCreated: jest.fn(() => true),
9
+ markSTTSessionIdUsed: jest.fn(),
7
10
  }));
8
11
 
9
12
  jest.mock('../../../components/StorageContext', () => {
@@ -34,6 +37,7 @@ jest.mock('../../../logger/AppBuilderLogger', () => ({
34
37
  getSessionId: () => 'logging-session',
35
38
  log: jest.fn(),
36
39
  error: jest.fn(),
40
+ warn: jest.fn(),
37
41
  },
38
42
  }));
39
43
 
@@ -43,7 +47,13 @@ jest.mock('../../../utils/getUniqueID', () => ({
43
47
  }));
44
48
 
45
49
  import useSTTAPI from '../useSTTAPI';
46
- import {ensureSTTSessionId} from '../sttSessionId';
50
+ import {
51
+ ensureSTTSessionId,
52
+ rotateSTTSessionId,
53
+ wasSTTSessionIdFreshlyCreated,
54
+ markSTTSessionIdUsed,
55
+ } from '../sttSessionId';
56
+ import {logger} from '../../../logger/AppBuilderLogger';
47
57
 
48
58
  const mockEnsureSTTSessionId = ensureSTTSessionId as jest.Mock<any>;
49
59
 
@@ -73,6 +83,9 @@ const renderHook = async () => {
73
83
  describe('useSTTAPI session coordination', () => {
74
84
  beforeEach(() => {
75
85
  jest.clearAllMocks();
86
+ (wasSTTSessionIdFreshlyCreated as jest.Mock<any>).mockReturnValue(true);
87
+ (rotateSTTSessionId as jest.Mock<any>).mockReset();
88
+ (markSTTSessionIdUsed as jest.Mock<any>).mockReset();
76
89
  global.fetch = jest.fn<any>(async () => ({
77
90
  json: async () => ({}),
78
91
  }));
@@ -107,7 +120,7 @@ describe('useSTTAPI session coordination', () => {
107
120
  });
108
121
 
109
122
  expect(global.fetch).toHaveBeenCalledTimes(3);
110
- expect(mockEnsureSTTSessionId).toHaveBeenCalledTimes(3);
123
+ expect(mockEnsureSTTSessionId).toHaveBeenCalledTimes(4);
111
124
  const fetchCalls = (global.fetch as jest.Mock<any>).mock.calls as [
112
125
  string,
113
126
  {body: string; headers: Record<string, string>},
@@ -126,4 +139,257 @@ describe('useSTTAPI session coordination', () => {
126
139
  ]);
127
140
  renderer.unmount();
128
141
  });
142
+
143
+ it('correlates 631 recovery with the failed request ID even if the cache changed', async () => {
144
+ mockEnsureSTTSessionId.mockResolvedValue('old-session');
145
+ (rotateSTTSessionId as jest.Mock<any>).mockResolvedValue('new-session');
146
+ (global.fetch as jest.Mock<any>)
147
+ .mockImplementationOnce(async () => {
148
+ // A peer replaced the local cached value while the old request was pending.
149
+ mockEnsureSTTSessionId.mockResolvedValue('new-session');
150
+ return {
151
+ ok: false,
152
+ status: 409,
153
+ json: async () => ({error: {code: 631, message: 'session ended'}}),
154
+ };
155
+ })
156
+ .mockResolvedValueOnce({ok: true, status: 200, json: async () => ({})});
157
+ const {api, renderer} = await renderHook();
158
+ let response;
159
+ await act(async () => {
160
+ response = await api.start(900000123, translationConfig);
161
+ });
162
+ expect(rotateSTTSessionId).toHaveBeenCalledWith('room', 'old-session');
163
+ expect(response).toMatchObject({success: true, sessionId: 'new-session'});
164
+ const attempts = (logger.log as jest.Mock<any>).mock.calls.filter(call =>
165
+ call[2].endsWith('STT start attempt'),
166
+ );
167
+ expect(attempts.map(call => call[3])).toEqual([
168
+ expect.objectContaining({
169
+ attempt: 1,
170
+ sessionId: 'old-session',
171
+ channelName: 'room',
172
+ requestId: 'request-id',
173
+ }),
174
+ expect.objectContaining({
175
+ attempt: 2,
176
+ sessionId: 'new-session',
177
+ channelName: 'room',
178
+ requestId: 'request-id',
179
+ }),
180
+ ]);
181
+ expect(JSON.stringify(attempts)).not.toContain('phrase');
182
+ expect(JSON.stringify(attempts)).not.toContain('Bearer');
183
+ expect(logger.error).toHaveBeenCalledWith(
184
+ expect.anything(),
185
+ 'stt',
186
+ expect.stringContaining('STT API Failure'),
187
+ expect.anything(),
188
+ expect.objectContaining({sessionId: 'old-session', httpStatus: 409}),
189
+ );
190
+ renderer.unmount();
191
+ });
192
+
193
+ it('retains the sent session ID when a network request fails', async () => {
194
+ mockEnsureSTTSessionId.mockResolvedValue('sent-session');
195
+ (global.fetch as jest.Mock<any>).mockRejectedValue(new Error('offline'));
196
+ const {api, renderer} = await renderHook();
197
+ let response;
198
+ await act(async () => {
199
+ response = await api.start(900000123, translationConfig);
200
+ });
201
+ expect(response).toMatchObject({success: false, sessionId: 'sent-session'});
202
+ expect(logger.error).toHaveBeenCalledWith(
203
+ expect.anything(),
204
+ 'stt',
205
+ expect.stringContaining('STT API Failure'),
206
+ expect.anything(),
207
+ expect.objectContaining({
208
+ sessionId: 'sent-session',
209
+ requestId: 'request-id',
210
+ }),
211
+ );
212
+ renderer.unmount();
213
+ });
214
+
215
+ it.each([
216
+ 'COMPLETED',
217
+ 'FAILED',
218
+ 'ARTIFACTS_PENDING',
219
+ 'PROCESSING',
220
+ 'STARTED',
221
+ 'INPROGRESS',
222
+ 'NOT_LISTED',
223
+ ])('preflights a reused ID in state %s before start', async status => {
224
+ mockEnsureSTTSessionId.mockResolvedValue('stored-session');
225
+ (wasSTTSessionIdFreshlyCreated as jest.Mock<any>).mockReturnValue(false);
226
+ const shouldRotate = [
227
+ 'COMPLETED',
228
+ 'FAILED',
229
+ 'ARTIFACTS_PENDING',
230
+ 'PROCESSING',
231
+ ].includes(status);
232
+ (rotateSTTSessionId as jest.Mock<any>).mockImplementation(async () => {
233
+ mockEnsureSTTSessionId.mockResolvedValue('replacement');
234
+ return 'replacement';
235
+ });
236
+ (global.fetch as jest.Mock<any>)
237
+ .mockResolvedValueOnce({
238
+ ok: true,
239
+ status: 200,
240
+ json: async () => ({
241
+ stts:
242
+ status === 'NOT_LISTED'
243
+ ? []
244
+ : [{session_id: 'stored-session', status}],
245
+ }),
246
+ })
247
+ .mockResolvedValueOnce({ok: true, status: 200, json: async () => ({})});
248
+ const {api, renderer} = await renderHook();
249
+ await act(async () => {
250
+ await api.start(900000123, translationConfig);
251
+ });
252
+ const calls = (global.fetch as jest.Mock<any>).mock.calls;
253
+ expect(calls[0][0]).toMatch(/\/v1\/stt-transcript$/);
254
+ expect(JSON.parse(calls[0][1].body)).toEqual({
255
+ passphrase: 'phrase',
256
+ page: 1,
257
+ limit: 50,
258
+ });
259
+ expect(JSON.parse(calls[1][1].body).session_id).toBe(
260
+ shouldRotate ? 'replacement' : 'stored-session',
261
+ );
262
+ expect(rotateSTTSessionId).toHaveBeenCalledTimes(shouldRotate ? 1 : 0);
263
+ renderer.unmount();
264
+ });
265
+
266
+ it('checks a locally minted ID on a later start after it has been used', async () => {
267
+ mockEnsureSTTSessionId.mockResolvedValue('minted-session');
268
+ (markSTTSessionIdUsed as jest.Mock<any>).mockImplementation(() => {
269
+ (wasSTTSessionIdFreshlyCreated as jest.Mock<any>).mockReturnValue(false);
270
+ });
271
+ (global.fetch as jest.Mock<any>).mockResolvedValue({
272
+ ok: true,
273
+ status: 200,
274
+ json: async () => ({stts: []}),
275
+ });
276
+ const {api, renderer} = await renderHook();
277
+ await act(async () => {
278
+ await api.start(900000123, translationConfig);
279
+ await api.start(900000123, translationConfig);
280
+ });
281
+ expect(
282
+ (global.fetch as jest.Mock<any>).mock.calls.map(call => call[0]),
283
+ ).toEqual([
284
+ expect.stringMatching(/\/startv7$/),
285
+ expect.stringMatching(/\/stt-transcript$/),
286
+ expect.stringMatching(/\/startv7$/),
287
+ ]);
288
+ renderer.unmount();
289
+ });
290
+
291
+ it('retries start once after a 631 on the last transient retry', async () => {
292
+ jest.useFakeTimers();
293
+ try {
294
+ mockEnsureSTTSessionId.mockResolvedValue('old-session');
295
+ (rotateSTTSessionId as jest.Mock<any>).mockImplementation(async () => {
296
+ mockEnsureSTTSessionId.mockResolvedValue('new-session');
297
+ return 'new-session';
298
+ });
299
+ (global.fetch as jest.Mock<any>)
300
+ .mockResolvedValueOnce({
301
+ ok: false,
302
+ status: 500,
303
+ json: async () => ({error: {code: 610, message: 'temporary'}}),
304
+ })
305
+ .mockResolvedValueOnce({
306
+ ok: false,
307
+ status: 500,
308
+ json: async () => ({error: {code: 610, message: 'temporary'}}),
309
+ })
310
+ .mockResolvedValueOnce({
311
+ ok: false,
312
+ status: 500,
313
+ json: async () => ({error: {code: 610, message: 'temporary'}}),
314
+ })
315
+ .mockResolvedValueOnce({
316
+ ok: false,
317
+ status: 500,
318
+ json: async () => ({error: {code: 610, message: 'temporary'}}),
319
+ })
320
+ .mockResolvedValueOnce({
321
+ ok: false,
322
+ status: 409,
323
+ json: async () => ({error: {code: 631, message: 'session ended'}}),
324
+ })
325
+ .mockResolvedValueOnce({ok: true, status: 200, json: async () => ({})});
326
+ const {api, renderer} = await renderHook();
327
+ let response;
328
+ await act(async () => {
329
+ const pending = api.start(900000123, translationConfig);
330
+ await jest.runAllTimersAsync();
331
+ response = await pending;
332
+ });
333
+ expect(response).toMatchObject({success: true, sessionId: 'new-session'});
334
+ expect(global.fetch).toHaveBeenCalledTimes(6);
335
+ expect(rotateSTTSessionId).toHaveBeenCalledTimes(1);
336
+ renderer.unmount();
337
+ } finally {
338
+ jest.useRealTimers();
339
+ }
340
+ });
341
+
342
+ it('falls through to start when the optional preflight times out', async () => {
343
+ jest.useFakeTimers();
344
+ try {
345
+ mockEnsureSTTSessionId.mockResolvedValue('stored-session');
346
+ (wasSTTSessionIdFreshlyCreated as jest.Mock<any>).mockReturnValue(false);
347
+ (global.fetch as jest.Mock<any>)
348
+ .mockImplementationOnce(
349
+ (_url, options) =>
350
+ new Promise((_resolve, reject) => {
351
+ options.signal.addEventListener('abort', () =>
352
+ reject(new Error('aborted')),
353
+ );
354
+ }),
355
+ )
356
+ .mockResolvedValueOnce({ok: true, status: 200, json: async () => ({})});
357
+ const {api, renderer} = await renderHook();
358
+ let response;
359
+ await act(async () => {
360
+ const pending = api.start(900000123, translationConfig);
361
+ await jest.runAllTimersAsync();
362
+ response = await pending;
363
+ });
364
+ expect(response).toMatchObject({
365
+ success: true,
366
+ sessionId: 'stored-session',
367
+ });
368
+ expect(rotateSTTSessionId).not.toHaveBeenCalled();
369
+ expect(global.fetch).toHaveBeenCalledTimes(2);
370
+ expect(jest.getTimerCount()).toBe(0);
371
+ renderer.unmount();
372
+ } finally {
373
+ jest.useRealTimers();
374
+ }
375
+ });
376
+
377
+ it('returns a repeated 631 after one recovery instead of rotating forever', async () => {
378
+ mockEnsureSTTSessionId.mockResolvedValue('old-session');
379
+ (rotateSTTSessionId as jest.Mock<any>).mockResolvedValue('replacement');
380
+ (global.fetch as jest.Mock<any>).mockResolvedValue({
381
+ ok: false,
382
+ status: 409,
383
+ json: async () => ({error: {code: 631, message: 'session ended'}}),
384
+ });
385
+ const {api, renderer} = await renderHook();
386
+ let response;
387
+ await act(async () => {
388
+ response = await api.start(900000123, translationConfig);
389
+ });
390
+ expect(response).toMatchObject({success: false, error: {code: 631}});
391
+ expect(global.fetch).toHaveBeenCalledTimes(2);
392
+ expect(rotateSTTSessionId).toHaveBeenCalledTimes(1);
393
+ renderer.unmount();
394
+ });
129
395
  });