From 62d424fd33d945df177b3f9a6d443a105c8392c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Sat, 3 Feb 2024 08:49:46 +0100 Subject: [PATCH 1/3] Update ignore files --- .gitignore | 1 + .prettierignore | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 63b496d..63dffef 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ coverage/ # IDE specific files .idea .vscode +.DS_Store diff --git a/.prettierignore b/.prettierignore index f21480a..63dffef 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,5 +7,7 @@ # Test files coverage/ -# Jetbrains +# IDE specific files .idea +.vscode +.DS_Store From 4629b608b90c893a4dfc5835608fbe89a791635e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Sat, 3 Feb 2024 08:53:41 +0100 Subject: [PATCH 2/3] Add failing tests --- src/ois.test.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/ois.test.ts b/src/ois.test.ts index 4e912d0..715e10c 100644 --- a/src/ois.test.ts +++ b/src/ois.test.ts @@ -706,6 +706,32 @@ describe('API call skip validation', () => { ]) ); }); + + it('allows skipping API call with pre-processing v2', () => { + const ois = loadOisFixture(); + ois.endpoints[0].operation = undefined; + ois.endpoints[0].fixedOperationParameters = []; + ois.endpoints[0].preProcessingSpecificationV2 = { + environment: 'Node', + timeoutMs: 5000, + value: 'output = input;', + }; + + expect(() => oisSchema.parse(ois)).not.toThrow(); + }); + + it('allows skipping API call with post-processing v2', () => { + const ois = loadOisFixture(); + ois.endpoints[0].operation = undefined; + ois.endpoints[0].fixedOperationParameters = []; + ois.endpoints[0].postProcessingSpecificationV2 = { + environment: 'Node', + timeoutMs: 5000, + value: 'output = input;', + }; + + expect(() => oisSchema.parse(ois)).not.toThrow(); + }); }); describe('fixedOperationParameters', () => { From 1f4184b885915752d09063c5bf33695a753d6c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Sat, 3 Feb 2024 08:57:07 +0100 Subject: [PATCH 3/3] Allow skipping a call with processing V2 --- src/ois.test.ts | 4 ++-- src/ois.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ois.test.ts b/src/ois.test.ts index 715e10c..ef96ac8 100644 --- a/src/ois.test.ts +++ b/src/ois.test.ts @@ -609,7 +609,7 @@ describe('API call skip validation', () => { new ZodError([ { code: 'custom', - message: `"postProcessingSpecifications" or "preProcessingSpecifications" must not be empty or undefined when "operation" is not specified and "fixedOperationParameters" is empty array.`, + message: `At least one processing schema must be defined when "operation" is not specified and "fixedOperationParameters" is empty array.`, path: ['endpoints', 0], }, ]) @@ -626,7 +626,7 @@ describe('API call skip validation', () => { new ZodError([ { code: 'custom', - message: `"postProcessingSpecifications" or "preProcessingSpecifications" must not be empty or undefined when "operation" is not specified and "fixedOperationParameters" is empty array.`, + message: `At least one processing schema must be defined when "operation" is not specified and "fixedOperationParameters" is empty array.`, path: ['endpoints', 0], }, ]) diff --git a/src/ois.ts b/src/ois.ts index 646e360..54ed612 100644 --- a/src/ois.ts +++ b/src/ois.ts @@ -423,11 +423,13 @@ const ensureApiCallSkipRequirements: SuperRefinement<{ !endpoint.operation && endpoint.fixedOperationParameters.length === 0 && (!endpoint.postProcessingSpecifications || endpoint.postProcessingSpecifications?.length === 0) && - (!endpoint.preProcessingSpecifications || endpoint.preProcessingSpecifications?.length === 0) + (!endpoint.preProcessingSpecifications || endpoint.preProcessingSpecifications?.length === 0) && + !endpoint.preProcessingSpecificationV2 && + !endpoint.postProcessingSpecificationV2 ) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: `"postProcessingSpecifications" or "preProcessingSpecifications" must not be empty or undefined when "operation" is not specified and "fixedOperationParameters" is empty array.`, + message: `At least one processing schema must be defined when "operation" is not specified and "fixedOperationParameters" is empty array.`, path: ['endpoints', endpoints.indexOf(endpoint)], }); }