0.15.2 • Published 12 months ago

kintone-typeguard v0.15.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

kintone-typeguard

npm version

Typeguard for @kintone/rest-api-client fields.

Installation

1. Install with npm

This library is distributed on npm.

npm install kintone-typeguard

You can then use import to import the library.

// ES modules
import { guardFormField, guardFormLayout, guardRecord } from "kintone-typeguard";

Usage

Here is a sample code that retrieves form fields of an app.

import { KintoneRestAPIClient } from "@kintone/rest-api-client";
import { guardFormField } from "kintone-typeguard";

const client = new KintoneRestAPIClient();
const { properties } = await client.app.getFormFields({ app: 1 });
if (guardFormField.isSingleLineText(properties.xxx)) {
  properties.xxx.unique; // unique property exists
}
if (guardFormField.isLookup(properties.xxx)) {
  properties.xxx.lookup; // lookup property exists
}

Here is a sample code that retrieves form layout of an app.

import { KintoneRestAPIClient } from "@kintone/rest-api-client";
import { guardFormLayout } from "kintone-typeguard";

const client = new KintoneRestAPIClient();
const { layout } = await client.app.getFormLayout({ app: 1 });
if (guardFormLayout.isRow(layout[0])) {
  layout[0].fields; // fields property exists
}
if (guardFormLayout.isSubtable(layout[0])) {
  layout[0].code; // code property exists
}

Here is a sample code that retrieves records of an app.

import { KintoneRestAPIClient } from "@kintone/rest-api-client";
import { guardRecord } from "kintone-typeguard";

const client = new KintoneRestAPIClient();
const { record } = await client.record.getRecord({ app: 1, id: 1 });
if (guardRecord.isSingleLineText(record.xxx)) {
  record.xxx.value; // string
}
if (guardRecord.isCheckBox(record.xxx)) {
  record.xxx.value; // string[]
}

License

0.11.0

1 year ago

0.12.0

1 year ago

0.13.0

1 year ago

0.12.1

1 year ago

0.14.0

1 year ago

0.15.0

12 months ago

0.10.5

1 year ago

0.15.1

12 months ago

0.15.2

12 months ago

0.10.4

1 year ago

0.10.3

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.9.8

1 year ago

0.9.7

1 year ago

0.10.0

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.9.4

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago