https://github.com/byu-oit/uapi-ts
TypeScript Definitions for UAPI elements
https://github.com/byu-oit/uapi-ts
types typescript uapi uapi-interface
Last synced: 11 months ago
JSON representation
TypeScript Definitions for UAPI elements
- Host: GitHub
- URL: https://github.com/byu-oit/uapi-ts
- Owner: byu-oit
- License: apache-2.0
- Created: 2019-12-09T20:58:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-13T18:10:20.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T02:55:24.991Z (over 1 year ago)
- Topics: types, typescript, uapi, uapi-interface
- Language: TypeScript
- Size: 58.6 KB
- Stars: 0
- Watchers: 28
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# University API Typescript Definitions

[](https://github.com/byu-oit/uapi-ts/actions/workflows/deploy.yml)
Home of the official TypeScript definitions for
[UAPI Specification](https://github.com/byu-oit/UAPI-Specification)
elements.
### Install
> Note: Only GitHub Package Manager support offered for versions >=
> 2.2.0 as these type definitions are intended for internal use. See the
> GitHub Docs for
> [Installing a package from GitHub](https://docs.github.com/en/packages/guides/configuring-npm-for-use-with-github-packages#installing-a-package).
```
npm install --save-dev @byu-oit/uapi-ts
```
### Usage
Define your models as types (**not interfaces**) and pass them into the
Simple or Collection UAPI Response types. Interfaces tend to cause
problems because of how they interact with index types in typescript.
```ts
interface MyModel extends UAPI.PropertyDictionary {
id: UAPI.Scalar.String
}
type MyUAPICollectionResponse = UAPI.Response.Collection
type MyUAPISimpleResponse = UAPI.Response.Simple
```
For organizational purposes, you can use namespaces to organize the
different endpoints you wish to group together:
```ts
namespace MyNamespace {
export type MultipleModelsEndpointResponse = UAPI.Response.Collection
export type FirstEndpointResponse = UAPI.Response.Simple
export type SecondEndpointResponse = UAPI.Response.Simple
type FirstModel = {
foo: UAPI.Scalar.String
}
type SecondModel = {
bar: UAPI.Scalar.String
}
type MultipleModels = {
first: UAPI.Object
second: UAPI.Object
}
}
```
#### UAPI Lite Support
UAPI Lite is not an official part of the UAPI Specification (yet) but
these types provide UAPI Lite support as an experimental feature. Use it
the same way you would the other UAPI types but prefix the types with
`UAPI.Lite.` instead of `UAPI.` For example:
```ts
type MyModel = {
id: UAPI.Lite.Scalar.String
}
```
### Contributing
Please open a Pull Request or submit an Issue.