0.10.3 • Published 25 days ago
kintone-typeguard v0.10.3
kintone-typeguard
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.10.3
25 days ago
0.10.2
1 month ago
0.10.1
1 month ago
0.9.8
2 months ago
0.9.7
2 months ago
0.10.0
2 months ago
0.9.6
2 months ago
0.9.5
3 months ago
0.9.4
3 months ago
0.9.3
3 months ago
0.9.2
3 months ago
0.9.1
4 months ago
0.9.0
5 months ago
0.8.0
5 months ago
0.7.0
5 months ago
0.6.0
6 months ago
0.5.0
6 months ago
0.4.0
6 months ago
0.3.0
6 months ago
0.2.0
6 months ago
0.1.0
6 months ago