1.1.6 • Published 12 months ago

@lincs.project/lincs-api-contracts v1.1.6

Weekly downloads
-
License
GPL
Repository
gitlab
Last release
12 months ago

LINCS-API Contracts

Defines the contract for the LINCS API. It uses TS-REST in combination with Zod to determine the request and response objects. These objects can be used to validate calls to each endpoint.

This contract package can be used to build a TypeScript helper to access the endpoints of the LINCS API using a standardized fetcher. It allows for better endpoint discoverability and fully typed request parameters and responses. The API contract is also available to create a custom fetcher.

It must be used in conjunction with @ts-rest/core

How to use the client helper

Install

npm install @lincs.project/lincs-api-contracts @ts-rest/core

Create the client Adapter and use it

import { contracts } from '@lincs.project/lincs-api-contracts';
import { initClient } from '@ts-rest/core';

const lincsAdapter = initClient(contracts, {
  baseUrl: 'https://lincs-api.lincsproject.ca',
  baseHeaders: {}
});

const response = await lincsAdapter.api.language.getLanguages();

if (response === 200) {
  console.log(response.body);
  // ["en", "fr"]

Endpoints

Here is a list of the endpoints that can be accessed under .api with this contract client:

annotations
dataset
entity
group
language
link
linked
links
ner
person
place
readToken
work

Exported types

Here is a list of types exported by the package:

Annotation
AnnotationsResponse
DigitalObject
EntityQuery
EntityResponse
Entity
FilteredEntityQuery
GroupResponse
LinksQuery
LinkMatch
LinkRequest
LinkResult
NerEntities
SimpleEntity
SimpleEntityQuery
SimpleStatement
SimpleStatementResponse
Statement
PersonResponse
PlaceResponse
Resource
TokenResponse
WorkResponse

Development

This package is maintained in the LINCS API repository.

1.1.6

12 months ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.1

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago