-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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!
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"expiresAt": 2000-02-01T13:00:00.000Z, | |
"expiresAt": 2000-02-01T14:00:00.000Z, |
src/calls/list-trips.ts
Outdated
}).transform(({commercial_class ,...data}) => ({ | ||
...data, | ||
commercialClass: commercial_class, | ||
|
||
})) |
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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.
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>
Co-authored by Alexander Dorfman