-
Notifications
You must be signed in to change notification settings - Fork 88
TypeScript SDK API improvements #101
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
Conversation
sdk/typescript/src/errors.ts
Outdated
| } | ||
|
|
||
| export function createFsError(params: { | ||
| code: string; |
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.
I think our lives would be easier if these were string unions like type FsErrorCode = 'ENOENT' | 'EISDIR' | 'EINVAL' ..., same for syscall. TypeScript type system is really powerful, let's use it
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.
btw you can just tell claude to do this and it'll do it in 1 minute
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.
@jussisaurio - that makes sense. I have added the type definitions.
- added two new APIs - mkdir and rm - renamed deleteFile API to unlink for consistency with node APIs. Keeping deleteFile API for backward compatability - added better error checking across all exisitng APIs - added guards.ts file to keep all assertion functions in one place - minor refactoring in filesystem.ts file Signed-off-by: Prateek Singh Rathore <[email protected]>
Signed-off-by: Prateek Singh Rathore <[email protected]>
- used copyfile as syscall as node API uses it - updated metadata in the copy process - if destination exists, it is overwritten Signed-off-by: Prateek Singh Rathore <[email protected]>
It only checks if path exists and doesn't check for permissions. Signed-off-by: Prateek Singh Rathore <[email protected]>
abace67 to
3acca97
Compare
Signed-off-by: Prateek Singh Rathore <[email protected]>
Adjust Python bindings with new changes - #101
Closes #76
guards.tsfile to keep all assertion functions in one placefilesystem.tsfileFollowing table summarizes changes I have made and existing parity gaps with node APIs:
readFile(path, options?)readFile(path, options?)writeFile(path, data, options?)writeFile(path, content, options?)ENOENT)readdir(path, options?)readdir(path)unlink(path)unlink(path)(alias:deleteFile(path))stat(path, options?)stat(path)mkdir(path, options?)mkdir(path)rm(path, options)rm(path, options)force+recursiveoptions, error handlingmaxRetries,retryDelay)rmdir(path, options?)rmdir(path)rename(oldPath, newPath)rename(oldPath, newPath)copyFile(src, dest, mode?)copyFile(src, dest)access(path, mode?)access(path)appendFile(path, data, options?)open(path, flags, mode?)truncate(path, len?)I decided to skip appendFile, open and truncate APIs as it felt like an overkill for current usage. I have left it here for documentation reasons. Please let me know if you disagree.