Escola LMS (Wellms) TypeScript Definitions
Automatic transformation of Eloquent Models and Request rules to TypeScript Definition
This package transforms all Eloquent Models defined in
- main composer.json
- config typescript.php
to Typescript definitions
- pure definitions
- generated typedoc
Installing
- install dependencies
npm i @escolalms/ts-models
oryarn add @escolalms/ts-models
- import in main
index.d.ts
(if you have one)
js
import "@escolalms/ts-models";
- add this to
tsconfig
in include section
json
"include": ["node_modules/@escolalms/ts-models"]
The above is declaring namespaces, example ns EscolaLms.StationaryEvents.Models.StationaryEvent
that are take from PHP namespace.
Below is example
ts
export async function stationaryEvents(
params: API.PaginationParams & {
name?: string;
},
options?: Record<string, any>
) {
return request<
API.DefaultMetaResponse<EscolaLms.StationaryEvents.Models.StationaryEvent>
>(`/api/admin/stationary-events`, {
method: "GET",
params: {
...params,
},
...(options || {}),
});
}
Adding new packages
- Add new package to composer.json
- Set proper namespace and package path in the config typescript.php
Releasing new version to npm
- Run generate action on main branch by pressing
re-run all jobs
- Wait until it's finished, new models.d.ts should be pushed automatically to the repository
- Once new models.d.ts You create new release rest should be handled by the script
- Release version on GH is the same as on npm (done automatically)