Skip to content

Commit 47f9692

Browse files
committed
feat: merge
1 parent c12361c commit 47f9692

File tree

2 files changed

+38
-60
lines changed

2 files changed

+38
-60
lines changed

packages/schemas/src/lib/schemas.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -710,34 +710,45 @@ export const IpfsOptionsSchema = z.object({
710710
gatewayUrl: z.string().startsWith('https://').endsWith('/ipfs/').optional(),
711711
});
712712

713-
export const JsonExecutionSdkParamsSchema = LitActionSdkParamsSchema.pick({
714-
jsParams: true,
715-
}).extend({
716-
/**
717-
* JS code to run on the nodes
718-
*/
719-
code: z.string().optional(), // TODO one or the other
720-
/**
721-
* The IPFS ID of some JS code to run on the nodes
722-
*/
723-
ipfsId: z.string().optional(), // TODO one or the other
724-
/**
725-
* the session signatures to use to authorize the user with the nodes
726-
*/
727-
sessionSigs: SessionSigsSchema,
728-
/**
729-
* auth methods to resolve
730-
*/
731-
authMethods: z.array(AuthMethodSchema).optional(),
713+
export const ExecuteJsAdvancedOptionsSchema = z.object({
732714
/**
733715
* a strategy for processing `response` objects returned from the
734716
* Lit Action execution context
735717
*/
736718
responseStrategy: LitActionResponseStrategySchema.optional(),
737-
719+
/**
720+
* Allow overriding the default `code` property in the `JsonExecutionSdkParams`
721+
*/
738722
ipfsOptions: IpfsOptionsSchema.optional(),
723+
/**
724+
* Only run the action on a single node; this will only work if all code in your action is non-interactive
725+
*/
726+
useSingleNode: z.boolean().optional(),
739727
});
740728

729+
export const JsonExecutionSdkParamsSchema = LitActionSdkParamsSchema.pick({
730+
jsParams: true,
731+
})
732+
.merge(ExecuteJsAdvancedOptionsSchema)
733+
.extend({
734+
/**
735+
* JS code to run on the nodes
736+
*/
737+
code: z.string().optional(), // TODO one or the other
738+
/**
739+
* The IPFS ID of some JS code to run on the nodes
740+
*/
741+
ipfsId: z.string().optional(), // TODO one or the other
742+
/**
743+
* the session signatures to use to authorize the user with the nodes
744+
*/
745+
sessionSigs: SessionSigsSchema,
746+
/**
747+
* auth methods to resolve
748+
*/
749+
authMethods: z.array(AuthMethodSchema).optional(),
750+
});
751+
741752
export const SigResponseSchema = z.object({
742753
r: z.string(),
743754
s: z.string(),

packages/types/src/lib/interfaces.ts

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
NodeErrorV1Schema,
4242
RejectedNodePromisesSchema,
4343
NodeAttestationSchema,
44+
ExecuteJsAdvancedOptionsSchema,
4445
} from '@lit-protocol/schemas';
4546

4647
import { ILitNodeClient } from './ILitNodeClient';
@@ -355,47 +356,13 @@ export interface JsonExecutionSdkParamsTargetNode
355356
targetNodeRange: number;
356357
}
357358

358-
export interface JsonExecutionSdkParams
359-
extends Pick<LitActionSdkParams, 'jsParams'>,
360-
ExecuteJsAdvancedOptions {
361-
/**
362-
* JS code to run on the nodes
363-
*/
364-
code?: string;
365-
366-
/**
367-
* The IPFS ID of some JS code to run on the nodes
368-
*/
369-
ipfsId?: string;
370-
371-
/**
372-
* the session signatures to use to authorize the user with the nodes
373-
*/
374-
sessionSigs: SessionSigsMap;
375-
376-
/**
377-
* auth methods to resolve
378-
*/
379-
authMethods?: AuthMethod[];
380-
}
381-
382-
export interface ExecuteJsAdvancedOptions {
383-
/**
384-
* a strategy for proccessing `reponse` objects returned from the
385-
* Lit Action execution context
386-
*/
387-
responseStrategy?: LitActionResponseStrategy;
388-
389-
/**
390-
* Allow overriding the default `code` property in the `JsonExecutionSdkParams`
391-
*/
392-
ipfsOptions?: IpfsOptions;
359+
export type JsonExecutionSdkParams = z.infer<
360+
typeof JsonExecutionSdkParamsSchema
361+
>;
393362

394-
/**
395-
* Only run the action on a single node; this will only work if all code in your action is non-interactive
396-
*/
397-
useSingleNode?: boolean;
398-
}
363+
export type ExecuteJsAdvancedOptions = z.infer<
364+
typeof ExecuteJsAdvancedOptionsSchema
365+
>;
399366

400367
export interface JsonExecutionRequestTargetNode extends JsonExecutionRequest {
401368
targetNodeRange: number;

0 commit comments

Comments
 (0)