Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: use camelCase instead of snake_case in fields #78

Closed

Conversation

Tigua002
Copy link
Contributor

@Tigua002 Tigua002 commented Feb 8, 2024

Co-authored by Alexander Dorfman

package-lock.json Outdated Show resolved Hide resolved
src/abax-client.ts Outdated Show resolved Hide resolved
src/authentication/decode-abax-profile.ts Outdated Show resolved Hide resolved
src/authentication/decode-abax-profile.ts Outdated Show resolved Hide resolved
@braaar braaar changed the title Endret fra "snake_case" til "camelCase" med Alexander Dorfman. refactor!: use camelCase instead of snake_case in fields Feb 8, 2024
Copy link
Member

@braaar braaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some good changes on the input types, but the zod schemas can't be modified in this way since the Abax API returns JSON objects with snake case field names. We can't change the names of the fields (aka keys) in the zod schema and expect it to still be able to parse the output from Abax. See my suggestion for how we can use a zod transform to get the data out with camel case after parsing the payload with snake cased keys.

src/abax-client.ts Outdated Show resolved Hide resolved
src/abax-client.ts Outdated Show resolved Hide resolved
src/abax-client.ts Outdated Show resolved Hide resolved
src/authentication/__tests__/abax-auth.test.ts Outdated Show resolved Hide resolved
src/authentication/__tests__/abax-auth.test.ts Outdated Show resolved Hide resolved
src/authentication/calls.ts Outdated Show resolved Hide resolved
src/calls/get-equipment.ts Outdated Show resolved Hide resolved
Copy link
Member

@braaar braaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left out a few things, but this is looking good!

src/authentication/__tests__/abax-auth.test.ts Outdated Show resolved Hide resolved
@@ -109,7 +109,7 @@ describe('abax auth', async () => {
expect(auth.getCredentials()).toMatchInlineSnapshot(`
{
"accessToken": "new_access_token",
"expiresAt": 2000-02-01T14:00:00.000Z,
"expiresAt": 2000-02-01T13:00:00.000Z,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"expiresAt": 2000-02-01T13:00:00.000Z,
"expiresAt": 2000-02-01T14:00:00.000Z,

src/calls/list-trips.ts Outdated Show resolved Hide resolved
Comment on lines 58 to 62
}).transform(({commercial_class ,...data}) => ({
...data,
commercialClass: commercial_class,

}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the vehicle field, which is an object, has a field in snake case, so that object must also be transformed.


/** The period cannot be longer than 3 months */
date_to: Date;
dateTo: Date;
}

export const listUsageSummaryResponseSchema = z.object({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This schema should also be converted to camelCase. It's currently in PascalCase.

src/calls/list-vehicles.ts Outdated Show resolved Hide resolved
src/calls/list-vehicles.ts Outdated Show resolved Hide resolved
src/calls/list-vehicles.ts Outdated Show resolved Hide resolved
src/calls/list-vehicles.ts Outdated Show resolved Hide resolved
Tigua002 and others added 9 commits February 12, 2024 09:42
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
@Xillians Xillians changed the base branch from main to xillians/refactor-camelCase May 15, 2024 11:39
@Xillians Xillians changed the base branch from xillians/refactor-camelCase to main May 15, 2024 11:40
@Xillians Xillians changed the base branch from main to xillians/refactor-camelCase May 15, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants