Skip to content

Commit da28c5c

Browse files
committed
chore: bot comments
1 parent 4babb39 commit da28c5c

4 files changed

Lines changed: 38 additions & 27 deletions

File tree

packages/sdk/browser/contract-tests/entity/src/ClientEntity.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ export async function newSdkClientEntity(
7676
const config = new ConfigBuilder(options).set({ fetchGoals: false });
7777

7878
if (options.configuration.dataSystem) {
79-
// FDv2: skip legacy streaming — data system handles connection modes
80-
config.skip('streaming');
79+
config.skip('streaming', 'polling');
8180

8281
const isSet = (x?: unknown) => x !== null && x !== undefined;
8382
const maybeTime = (seconds?: number) => (isSet(seconds) ? seconds! / 1000 : undefined);

packages/sdk/react-native/contract-tests/entity/src/ClientEntity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function newSdkClientEntity(
1515
_id: string,
1616
options: CreateInstanceParams,
1717
): Promise<IClientEntity> {
18-
const config = new ConfigBuilder(options).skip('streaming').set({
18+
const config = new ConfigBuilder(options).omit('streaming').set({
1919
automaticNetworkHandling: false,
2020
automaticBackgroundHandling: false,
2121
...(options.configuration.polling && { initialConnectionMode: 'polling' }),

packages/sdk/react/contract-tests/app/ClientRoot.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import React, { useEffect, useRef, useState } from 'react';
3+
import React, { useEffect, useState } from 'react';
44

55
import {
66
Capability,
@@ -37,16 +37,18 @@ const CAPABILITIES: Capability[] = [
3737
'track-hooks',
3838
];
3939

40-
export default function ClientRoot({ children }: { children: React.ReactNode }) {
41-
const [clients, setClients] = useState<ClientRecord[]>([]);
42-
const commandHandlers = useRef(new Map<string, CommandHandler>());
43-
const handlerReadyMap = useRef(new Map<string, () => void>());
44-
const clientsRef = useRef<ClientRecord[]>([]);
45-
const entityMap = useRef(new Map<string, IClientEntity>());
40+
const commandHandlers = new Map<string, CommandHandler>();
41+
const handlerReadyMap = new Map<string, () => void>();
42+
const entityMap = new Map<string, IClientEntity>();
43+
let clientRecords: ClientRecord[] = [];
44+
45+
function onReady(readyId: string) {
46+
handlerReadyMap.get(readyId)?.();
47+
}
4648

47-
const onReady = (readyId: string) => {
48-
handlerReadyMap.current.get(readyId)?.();
49-
};
49+
export default function ClientRoot({ children }: { children: React.ReactNode }) {
50+
const [, setRenderTick] = useState(0);
51+
const rerender = () => setRenderTick((n) => n + 1);
5052

5153
useEffect(() => {
5254
const ws = new TestHarnessWebSocketBuilder()
@@ -70,25 +72,25 @@ export default function ClientRoot({ children }: { children: React.ReactNode })
7072
const Provider = createLDReactProviderWithClient(client);
7173

7274
const handlerReady = new Promise<void>((resolve) => {
73-
handlerReadyMap.current.set(id, resolve);
75+
handlerReadyMap.set(id, resolve);
7476
});
7577

76-
clientsRef.current = [...clientsRef.current, { id, client, Provider }];
77-
setClients([...clientsRef.current]);
78+
clientRecords = [...clientRecords, { id, client, Provider }];
79+
rerender();
7880

7981
await handlerReady;
80-
handlerReadyMap.current.delete(id);
82+
handlerReadyMap.delete(id);
8183

82-
const entity = createReactClientEntity(id, commandHandlers.current, () => client.close());
83-
entityMap.current.set(id, entity);
84+
const entity = createReactClientEntity(id, commandHandlers, () => client.close());
85+
entityMap.set(id, entity);
8486
return entity;
8587
})
86-
.onGetClient((id) => entityMap.current.get(id))
88+
.onGetClient((id) => entityMap.get(id))
8789
.onDeleteClient((id) => {
88-
entityMap.current.delete(id);
89-
clientsRef.current.find((r) => r.id === id)?.client.close();
90-
clientsRef.current = clientsRef.current.filter((r) => r.id !== id);
91-
setClients((prev) => prev.filter((r) => r.id !== id));
90+
entityMap.delete(id);
91+
clientRecords.find((r) => r.id === id)?.client.close();
92+
clientRecords = clientRecords.filter((r) => r.id !== id);
93+
rerender();
9294
})
9395
.build();
9496

@@ -99,9 +101,9 @@ export default function ClientRoot({ children }: { children: React.ReactNode })
99101
return (
100102
<>
101103
{children}
102-
{clients.map(({ id, Provider }) => (
104+
{clientRecords.map(({ id, Provider }) => (
103105
<Provider key={id}>
104-
<ClientInstance clientId={id} handlers={commandHandlers.current} onReady={onReady} />
106+
<ClientInstance clientId={id} handlers={commandHandlers} onReady={onReady} />
105107
</Provider>
106108
))}
107109
</>

packages/tooling/contract-test-utils/src/client-side/ConfigBuilder.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class ConfigBuilder {
5555
private _configuration: SDKConfigParams;
5656
private _tag: string;
5757
private _skippedSections: Set<ConfigSection> = new Set();
58+
private _omittedKeys: Set<string> = new Set();
5859
private _overrides: Record<string, unknown> = {};
5960

6061
constructor(options: CreateInstanceParams) {
@@ -98,6 +99,13 @@ export class ConfigBuilder {
9899
return this;
99100
}
100101

102+
/** Remove specific keys from the built output. Unlike skip(), the section
103+
* still runs — only the named keys are deleted from the result. */
104+
omit(...keys: string[]): this {
105+
keys.forEach((k) => this._omittedKeys.add(k));
106+
return this;
107+
}
108+
101109
/** Add or override fields on the final config object. Applied last. */
102110
set(values: Record<string, unknown>): this {
103111
Object.assign(this._overrides, values);
@@ -166,7 +174,9 @@ export class ConfigBuilder {
166174
);
167175
}
168176

169-
return { ...cf, ...this._overrides };
177+
const result: ClientSideSdkConfig = { ...cf, ...this._overrides };
178+
this._omittedKeys.forEach((key) => delete result[key]);
179+
return result;
170180
}
171181

172182
private _maybeTime(ms?: number): number | undefined {

0 commit comments

Comments
 (0)