Skip to content

rksan/kintone-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

overview

kintone JavaScript API の TypeScript 型定義

install

npm install -D @rksan/kintone-type

Requirement

Node.js - v18.x

usage

// [TypeScript]
import type kintone from "@rksan/kintone-type";

(async (kintone: kintone) => {
  try {
    const url = kintone.api.url("/k/v1/record");

    const response = await kintone.api(url, "GET", {
      app: "100",
      id: "1",
    });

    const record: kintone.Record = response.record;

    const field: kintone.Field = record["field_code"];

    if (field.type === "SINGLE_LINE_TEXT") {
      const value = field.value;
      console.log("[INFO]", field.type, value);
    } else if (field.type === "CHECK_BOX") {
      const values = field.value;
      console.log("[INFO]", field.type, values);
    } else if (field.type === "USER_SELECT") {
      const users = field.value;
      console.log("[INFO]", field.type, users);
    } else {
      console.log("[INFO]", field.type, field.value);
    }
  } catch (err) {
    console.error("[ERR]", err);
  }

  // @ts-ignore
})(window.kintone);
// [JavaScript]
// @ts-check

/** @typedef {import("@rksan/kintone-type")} kintone */
/** @typedef {import("@rksan/kintone-type").Record} kintone.Record */
/** @typedef {import("@rksan/kintone-type").Field} kintone.Field */

(async (/** @type {kintone} */ kintone) => {
  try {
    const url = kintone.api.url("/k/v1/record");

    const response = await kintone.api(url, "GET", {
      app: "100",
      id: "1",
    });

    /** @type {kintone.Record} */
    const record = response.record;

    /** @type {kintone.Field} */
    const field = record["field_code"];

    if (field.type === "SINGLE_LINE_TEXT") {
      const value = field.value;
      console.log("[INFO]", field.type, value);
    } else if (field.type === "CHECK_BOX") {
      const values = field.value;
      console.log("[INFO]", field.type, values);
    } else if (field.type === "USER_SELECT") {
      const users = field.value;
      console.log("[INFO]", field.type, users);
    } else {
      console.log("[INFO]", field.type, field.value);
    }
  } catch (err) {
    console.error("[ERR]", err);
  }

  // @ts-ignore
})(window.kintone);

History

Author

@rksan https://github.com/rksan | github

Licence

MIT

About

Typescript type definition for kintone javascript api

Resources

Stars

Watchers

Forks

Contributors