Skip to content

Commit d3feb8a

Browse files
committed
Fix type issues
1 parent 506c012 commit d3feb8a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/sdk/src/shared/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import type {
1313
export * from "./component.js";
1414
import { version as sdkVersion } from "../version.js";
1515

16+
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
17+
Pick<T, Exclude<keyof T, Keys>>
18+
& {
19+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>
20+
}[Keys]
21+
1622
type RequestInit = globalThis.RequestInit;
1723

1824
/**
@@ -198,16 +204,16 @@ export type Account = {
198204
credentials?: Record<string, string>;
199205
};
200206

201-
export type ReloadComponentPropsOpts = {
207+
export type ReloadComponentPropsOpts = RequireAtLeastOne<{
202208
/**
203209
* Your end user ID, for whom you're configuring the component.
204210
*/
205-
externalUserId: string;
211+
externalUserId?: string;
206212

207213
/**
208214
* @deprecated Use `externalUserId` instead.
209215
*/
210-
userId: string;
216+
userId?: string;
211217

212218
/**
213219
* The ID of the component you're configuring. This is the key that uniquely
@@ -223,14 +229,14 @@ export type ReloadComponentPropsOpts = {
223229
configuredProps: ConfiguredProps<ConfigurableProps>;
224230

225231
dynamicPropsId?: string;
226-
};
232+
}, "externalUserId" | "userId">;
227233

228234
/**
229235
* @deprecated Use `ReloadComponentPropsOpts` instead.
230236
*/
231237
export type ComponentReloadPropsOpts = ReloadComponentPropsOpts;
232238

233-
export type ConfigureComponentOpts = {
239+
export type ConfigureComponentOpts = RequireAtLeastOne<{
234240
/**
235241
* Your end user ID, for whom you're configuring the component.
236242
*/
@@ -261,7 +267,7 @@ export type ConfigureComponentOpts = {
261267

262268
dynamicPropsId?: string;
263269
query?: string;
264-
};
270+
}, "externalUserId" | "userId">;
265271

266272
/**
267273
* @deprecated Use `ConfigureComponentOpts` instead.
@@ -345,7 +351,7 @@ export type GetComponentResponse = { data: V1Component; };
345351
*/
346352
export type ComponentRequestResponse = GetComponentResponse;
347353

348-
export type RunActionOpts = {
354+
export type RunActionOpts = RequireAtLeastOne<{
349355
/**
350356
* Your end user ID, for whom you're running the action.
351357
*/
@@ -370,7 +376,7 @@ export type RunActionOpts = {
370376
configuredProps: ConfiguredProps<ConfigurableProps>;
371377

372378
dynamicPropsId?: string;
373-
};
379+
}, "externalUserId" | "userId">;
374380

375381
// TODO: Add docstring
376382
export type RunActionResponse = {

0 commit comments

Comments
 (0)