From 4488477f3b23ab8a73668c3e8d8ec8d47327a22b Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 15 Nov 2022 15:38:59 -0500 Subject: [PATCH] refactor(striker-ui): don't export test input types --- striker-ui/components/GeneralInitForm.tsx | 4 --- striker-ui/components/NetworkInitForm.tsx | 4 --- .../components/ProvisionServerDialog.tsx | 4 --- .../lib/test_input/createTestInputFunction.ts | 5 ---- striker-ui/lib/test_input/testInput.ts | 10 ------- striker-ui/lib/test_input/testLength.ts | 2 -- striker-ui/lib/test_input/testMax.ts | 2 -- striker-ui/lib/test_input/testNotBlank.ts | 2 -- striker-ui/lib/test_input/testRange.ts | 2 -- ...nputFunction.ts => TestInputFunction.d.ts} | 30 ++++++++----------- 10 files changed, 12 insertions(+), 53 deletions(-) rename striker-ui/types/{TestInputFunction.ts => TestInputFunction.d.ts} (65%) diff --git a/striker-ui/components/GeneralInitForm.tsx b/striker-ui/components/GeneralInitForm.tsx index 6b146bfb..d166007a 100644 --- a/striker-ui/components/GeneralInitForm.tsx +++ b/striker-ui/components/GeneralInitForm.tsx @@ -23,10 +23,6 @@ import OutlinedInputWithLabel, { import pad from '../lib/pad'; import SuggestButton from './SuggestButton'; import { createTestInputFunction, testNotBlank } from '../lib/test_input'; -import { - InputTestBatches, - TestInputFunctionOptions, -} from '../types/TestInputFunction'; import { BodyText, InlineMonoText } from './Text'; type GeneralInitFormValues = { diff --git a/striker-ui/components/NetworkInitForm.tsx b/striker-ui/components/NetworkInitForm.tsx index 0f9844f3..d9f55206 100644 --- a/striker-ui/components/NetworkInitForm.tsx +++ b/striker-ui/components/NetworkInitForm.tsx @@ -51,10 +51,6 @@ import SelectWithLabel from './SelectWithLabel'; import Spinner from './Spinner'; import sumstring from '../lib/sumstring'; import { createTestInputFunction, testNotBlank } from '../lib/test_input'; -import { - InputTestBatches, - TestInputFunctionOptions, -} from '../types/TestInputFunction'; import { BodyText, MonoText, SmallText } from './Text'; type NetworkInput = { diff --git a/striker-ui/components/ProvisionServerDialog.tsx b/striker-ui/components/ProvisionServerDialog.tsx index 28d8dc26..09bae8fe 100644 --- a/striker-ui/components/ProvisionServerDialog.tsx +++ b/striker-ui/components/ProvisionServerDialog.tsx @@ -32,10 +32,6 @@ import { testNotBlank, testRange, } from '../lib/test_input'; -import { - InputTestBatches, - TestInputFunction, -} from '../types/TestInputFunction'; import { BodyText, HeaderText, InlineMonoText } from './Text'; type InputMessage = Partial>; diff --git a/striker-ui/lib/test_input/createTestInputFunction.ts b/striker-ui/lib/test_input/createTestInputFunction.ts index 1ee2c844..600e2e05 100644 --- a/striker-ui/lib/test_input/createTestInputFunction.ts +++ b/striker-ui/lib/test_input/createTestInputFunction.ts @@ -1,9 +1,4 @@ import testInput from './testInput'; -import { - InputTestBatches, - TestInputFunction, - TestInputFunctionOptions, -} from '../../types/TestInputFunction'; const createTestInputFunction = ( diff --git a/striker-ui/lib/test_input/testInput.ts b/striker-ui/lib/test_input/testInput.ts index 27ee07c7..d4d1c478 100644 --- a/striker-ui/lib/test_input/testInput.ts +++ b/striker-ui/lib/test_input/testInput.ts @@ -1,13 +1,3 @@ -import { - InputTest, - InputTestInputs, - CallbackAppendArgs, - TestInputFunction, - InputTestBatchFinishCallback, - InputTestFailureCallback, - InputTestSuccessCallback, -} from '../../types/TestInputFunction'; - type TestCallbacks = Pick; const cbEmptySetter = () => ({}); diff --git a/striker-ui/lib/test_input/testLength.ts b/striker-ui/lib/test_input/testLength.ts index cb0d3a42..9dd17c8d 100644 --- a/striker-ui/lib/test_input/testLength.ts +++ b/striker-ui/lib/test_input/testLength.ts @@ -1,5 +1,3 @@ -import { MinimalInputTestArgs } from '../../types/TestInputFunction'; - const testLength: ( args: Pick & Partial>, diff --git a/striker-ui/lib/test_input/testMax.ts b/striker-ui/lib/test_input/testMax.ts index 3047e74e..ac2e03d6 100644 --- a/striker-ui/lib/test_input/testMax.ts +++ b/striker-ui/lib/test_input/testMax.ts @@ -1,5 +1,3 @@ -import { MinimalInputTestArgs } from '../../types/TestInputFunction'; - const testMax: (args: MinimalInputTestArgs) => boolean = ({ max, min }) => max >= min; diff --git a/striker-ui/lib/test_input/testNotBlank.ts b/striker-ui/lib/test_input/testNotBlank.ts index 7f3d67d5..a8bce52a 100644 --- a/striker-ui/lib/test_input/testNotBlank.ts +++ b/striker-ui/lib/test_input/testNotBlank.ts @@ -1,5 +1,3 @@ -import { MinimalInputTestArgs } from '../../types/TestInputFunction'; - const testNotBlank: (args: MinimalInputTestArgs) => boolean = ({ value }) => value ? String(value).length > 0 : false; diff --git a/striker-ui/lib/test_input/testRange.ts b/striker-ui/lib/test_input/testRange.ts index e21003f7..a4689914 100644 --- a/striker-ui/lib/test_input/testRange.ts +++ b/striker-ui/lib/test_input/testRange.ts @@ -1,5 +1,3 @@ -import { MinimalInputTestArgs } from '../../types/TestInputFunction'; - const testRange: (args: MinimalInputTestArgs) => boolean = ({ max, min, diff --git a/striker-ui/types/TestInputFunction.ts b/striker-ui/types/TestInputFunction.d.ts similarity index 65% rename from striker-ui/types/TestInputFunction.ts rename to striker-ui/types/TestInputFunction.d.ts index 3c23d9a0..fea1dd8a 100644 --- a/striker-ui/types/TestInputFunction.ts +++ b/striker-ui/types/TestInputFunction.d.ts @@ -1,12 +1,6 @@ -export type InputTestValue = - | bigint - | boolean - | number - | null - | string - | undefined; +type InputTestValue = bigint | boolean | number | null | string | undefined; -export type InputTestArgs = { +type InputTestArgs = { compare?: InputTestValue[]; displayMax?: string; displayMin?: string; @@ -18,7 +12,7 @@ export type InputTestArgs = { value?: InputTestValue; }; -export type MinimalInputTestArgs = Required< +type MinimalInputTestArgs = Required< Omit< InputTestArgs, | 'displayMax' @@ -29,31 +23,31 @@ export type MinimalInputTestArgs = Required< > >; -export type CallbackAppendArgs = { +type CallbackAppendArgs = { append: { [arg: string]: InputTestValue; }; }; -export type InputTestFailureCallback = ( +type InputTestFailureCallback = ( args: InputTestArgs & CallbackAppendArgs, ) => void; -export type InputTestSuccessCallback = (args: CallbackAppendArgs) => void; +type InputTestSuccessCallback = (args: CallbackAppendArgs) => void; -export type InputTest = { +type InputTest = { onFailure?: InputTestFailureCallback; onSuccess?: InputTestSuccessCallback; test: (args: MinimalInputTestArgs & CallbackAppendArgs) => boolean; }; -export type InputTestInputs = { +type InputTestInputs = { [id: string]: Partial; }; -export type InputTestBatchFinishCallback = () => void; +type InputTestBatchFinishCallback = () => void; -export type InputTestBatches = { +type InputTestBatches = { [id: string]: { defaults?: InputTestArgs & { onSuccess?: InputTestSuccessCallback; @@ -64,7 +58,7 @@ export type InputTestBatches = { }; }; -export type TestInputFunctionOptions = { +type TestInputFunctionOptions = { excludeTestIds?: string[]; excludeTestIdsRe?: RegExp; inputs?: InputTestInputs; @@ -74,4 +68,4 @@ export type TestInputFunctionOptions = { tests?: InputTestBatches; }; -export type TestInputFunction = (options?: TestInputFunctionOptions) => boolean; +type TestInputFunction = (options?: TestInputFunctionOptions) => boolean;