Skip to content

Commit

Permalink
chore(PPDSC-2625): remove optional keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mstuartf committed Jan 19, 2023
1 parent 91d56db commit cfb6819
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
5 changes: 0 additions & 5 deletions site/utils/google-sheet/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,19 @@ describe('parseCMSResponse', () => {
it('should return the parsed content if all keys are valid', () => {
const response = [
['required_key', 'required_value'],
['optional_key', 'optional_value'],
['dynamic_key_0', 'dynamic_value_0'],
['dynamic_key_1', 'dynamic_value_1'],
];
const parsed = parseCMSResponse(response, {
required: {
required_key: 'required_key',
},
optional: {
optional_key: 'optional_key',
},
dynamic: {
dynamic_key_: 'dynamic_key_',
},
});
expect(parsed).toEqual({
required_key: 'required_value',
optional_key: 'optional_value',
dynamic_key_0: 'dynamic_value_0',
dynamic_key_1: 'dynamic_value_1',
});
Expand Down
6 changes: 0 additions & 6 deletions site/utils/google-sheet/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ export type PageCMSRequiredProps<T extends string> = {
[key in T]: string;
};

export type PageCMSOptionalProps<T extends string> = Partial<
{
[key in T]: string;
}
>;

export type PageCMSPrefixedProps<T extends string> = {
[key in `${T}${number}`]: string;
};
Expand Down
4 changes: 1 addition & 3 deletions site/utils/google-sheet/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ export const parseCMSResponse = <T extends CMSProps>(
cmsResponse: CMSResponse,
{
required,
optional = {},
dynamic = {},
}: {
required: Record<string, string>;
optional?: Record<string, string>;
dynamic?: Record<string, string>;
},
): T => {
Expand All @@ -36,7 +34,7 @@ export const parseCMSResponse = <T extends CMSProps>(

const missingKeys = Object.keys(required).filter(key => !content[key]);
const invalidKeys = Object.keys(content).filter(key => {
if (required[key] || optional[key]) {
if (required[key]) {
return false;
}
const prefixMatch = Object.keys(dynamic).find(k =>
Expand Down

0 comments on commit cfb6819

Please sign in to comment.