2.3.3 • Published 3 years ago

@byu-oit/uapi-ts v2.3.3

Weekly downloads
12
License
Apache-2.0
Repository
github
Last release
3 years ago

University API Typescript Definitions

npm (scoped) Deployment

Home of the official TypeScript definitions for 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.

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.

interface MyModel extends UAPI.PropertyDictionary {
    id: UAPI.Scalar.String
}
type MyUAPICollectionResponse = UAPI.Response.Collection<MyModel>
type MyUAPISimpleResponse = UAPI.Response.Simple<MyModel>

For organizational purposes, you can use namespaces to organize the different endpoints you wish to group together:

namespace MyNamespace {
    export type MultipleModelsEndpointResponse = UAPI.Response.Collection<MultipleModels>
    
    export type FirstEndpointResponse = UAPI.Response.Simple<FirstModel>
    
    export type SecondEndpointResponse = UAPI.Response.Simple<SecondModel>
    
    type FirstModel = {
        foo: UAPI.Scalar.String
    }
    
    type SecondModel = {
        bar: UAPI.Scalar.String
    }
    
    type MultipleModels = {
        first: UAPI.Object<FirstModel>
        second: UAPI.Object<SecondModel>
    }
}

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:

type MyModel = {
    id: UAPI.Lite.Scalar.String
}

Contributing

Please open a Pull Request or submit an Issue.

2.3.2

3 years ago

2.3.3

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago