@cord-sdk/api-types
TypeScript icon, indicating that this package has built-in type declarations

1.47.2 • Public • Published

This package contains TypeScript type definitions and JSON schema objects for the data types used by the Cord REST API.

Installation

npm install @cord-sdk/api-types

TypeScript Type Definitions

To use proper type definitions for the data structures send to and received from the Cord REST API, import them from this package, e.g.:

import { PlatformUserVariables } from '@cord-sdk/api-types';

Run-Time Validation

You can use the JSON schema shipped in this package to validate data structures send to or received from the Cord REST API at run-time.

For example, to do run-time validation using the AJV package in TypeScript:

import Ajv from "ajv";
import { schema } from '@cord-sdk/api-types';
import type { PlatformUserVariables } from '@cord-sdk/api-types';

const ajv = new Ajv();

const validatePlatformUserVariables = ajv.compile<PlatformUserVariables>(schema['PlatformUserVariables']);

The validatePlatformUserVariables function takes data as an argument and returns a boolean indicating whether the given data conforms to the schema for PlatformUserVariables. The function is declared as a type guard, so if you use it as the conditional in an if statement, TypeScript understands that within the true-branch, the data is of type PlatformUserVariables.

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @cord-sdk/api-types

    Weekly Downloads

    2,115

    Version

    1.47.2

    License

    MIT

    Unpacked Size

    504 kB

    Total Files

    25

    Last publish

    Collaborators

    • nimster
    • jgbbrd
    • maylynn-ng
    • elenaperezrioja
    • khadija-nur
    • ludocord
    • dmmiller
    • mhtien
    • jwatzman
    • netceer
    • albert-moro
    • flooey