-
Notifications
You must be signed in to change notification settings - Fork 1
v2.0 - TS rewrite #28
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
base: main
Are you sure you want to change the base?
Conversation
|
That's weird that the pipeline doesn't fully fail when the tests doesn't pass 🤔 |
it's because the js:test and php:test dont use the mocha return value compared to the tests in docker container |
|
The breaking change doesn't have to be one, would it be possible to add a method called Start by making sure all tests run in js, then you can consider changing them in TS. The weird axios import was made to have a single js file you could import for browser and before you have a for |
TheRolfFR
left a comment
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 won't review the js code itself, tests will, it's now some TDD
| import { GET, ID_FIELD_NAME, token, POST } from "./settings.js"; | ||
| import { extractData } from "./utils.js"; | ||
|
|
||
| import type { SearchOption } from "./types/searchOption.js"; |
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.
52bd803 to
1fe0cfe
Compare
| * @param req - The request promise to extract data from. | ||
| * @returns The extracted data. | ||
| */ | ||
| export async function extractData<R>(req: Promise<any> | any): Promise<R> { |
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.
| export async function extractData<R>(req: Promise<any> | any): Promise<R> { | |
| export async function extractData<T>(req: Promise<T> | T): Promise<Awaited<T>> { |
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.
Awaited recursively unwraps promises so it's safe to make types with
|
I think the php and typescript folders in src should be renamed server/ and client/ to more accurately express intent |
| * @param methods - Optional methods to add to the collection elements when retrieved. | ||
| */ | ||
| constructor( | ||
| private readonly name: 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.
possibly unintentionally breaking change—current firestorm calls this field collectionName and it's also public readonly rather than private (no harm in accessing it)
Let's stop messing with JS and use TS instead so we don't have to maintain
d.tsfilesTODO:
Add build script in
package.jsonmainis set todist/index.jsinstead ofsrc/index.jstypesis set todist/index.d.tsinstead oftypings/index.d.tstypings/index.d.tsBump version to 2.0.0
Update README
Rewrite
index.jsin TS and split it into multiple files_address&_token& setup methods →settings.ts__extract_data→utils.tsinextractDatasha1()get()searchKeys()search()readRaw()read_raw()deleted (deprecated for a while)writeRaw()write_raw()deleted (same as above)select()values(), working but not yet typed properly (need help)random()add()addBulk()remove()removeBulk()set()setBulk()editField()editFieldBulk()Update tests
tests-files.spec.mjstests-get.spec.mjstests-post.spec.mjstests-setup.spec.mjsMake sure the library still works in a browser
Make sure methods are properly added to the Collection item
Breaking changes:
Collectionclass now requires up to two generic types instead of 1:firestorm.addressreturns_addressinstead of_address + "get.php", which shouldn't be that much of an issue as firestorm resolves_addressas the/get.phpendpoint