From fc6747082f126d8c31ccf80e9f167d7fd071d504 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 13 Aug 2024 16:30:40 +0400 Subject: [PATCH 1/2] fix(builtins): add support string and number types for `from` of copy-param plugin --- src/if-run/builtins/copy-param/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/if-run/builtins/copy-param/index.ts b/src/if-run/builtins/copy-param/index.ts index 7f10bf696..0cfe81d3b 100644 --- a/src/if-run/builtins/copy-param/index.ts +++ b/src/if-run/builtins/copy-param/index.ts @@ -36,7 +36,7 @@ export const Copy = ( const globalConfigSchema = z.object({ 'keep-existing': z.boolean(), - from: z.string().min(1), + from: z.string().min(1).or(z.number()), to: z.string().min(1), }); @@ -51,7 +51,7 @@ export const Copy = ( */ const validateSingleInput = ( input: PluginParams, - inputParameters: string[] + inputParameters: (string | number)[] ) => { const inputData = inputParameters.reduce( (acc, param) => { @@ -59,10 +59,10 @@ export const Copy = ( return acc; }, - {} as Record + {} as Record ); - const validationSchema = z.record(z.string(), z.string()); + const validationSchema = z.record(z.string(), z.string().or(z.number())); validate(validationSchema, inputData); From 8f1b2f6d66586500176ea074196b09cebfced0b8 Mon Sep 17 00:00:00 2001 From: manushak Date: Tue, 13 Aug 2024 16:32:56 +0400 Subject: [PATCH 2/2] test(builtins): update copy-param test error message --- src/__tests__/if-run/builtins/copy-param.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/if-run/builtins/copy-param.test.ts b/src/__tests__/if-run/builtins/copy-param.test.ts index 952546505..e6e197d2e 100644 --- a/src/__tests__/if-run/builtins/copy-param.test.ts +++ b/src/__tests__/if-run/builtins/copy-param.test.ts @@ -91,7 +91,7 @@ describe('builtins/copy: ', () => { } catch (error) { expect(error).toStrictEqual( new InputValidationError( - '"original" parameter is required. Error code: invalid_type.' + '"original" parameter is required. Error code: invalid_union.' ) ); }