import { KintoneRestAPIClient } from '@kintone/rest-api-client'; export const client = new KintoneRestAPIClient(); export type App = { appId: string; name: string; }; export type Properties = Awaited>['properties']; export type Layout = Awaited>['layout']; type OneOf = Properties[string]; export type FieldType = OneOf['type']; const typeNames = [ 'RECORD_NUMBER', 'CREATOR', 'CREATED_TIME', 'MODIFIER', 'UPDATED_TIME', 'CATEGORY', 'STATUS', 'STATUS_ASSIGNEE', 'SINGLE_LINE_TEXT', 'NUMBER', 'CALC', 'MULTI_LINE_TEXT', 'RICH_TEXT', 'LINK', 'CHECK_BOX', 'RADIO_BUTTON', 'DROP_DOWN', 'MULTI_SELECT', 'FILE', 'DATE', 'TIME', 'DATETIME', 'USER_SELECT', 'ORGANIZATION_SELECT', 'GROUP_SELECT', 'GROUP', 'REFERENCE_TABLE', 'SUBTABLE', ] as const satisfies readonly FieldType[]; export const types = typeNames.reduce( (acc, name) => { acc[name] = name; return acc; }, {} as Record<(typeof typeNames)[number], (typeof typeNames)[number]>, ); type ExtractOneOf = Extract; function createTypeGuard(type: T) { return (value: OneOf): value is ExtractOneOf => value.type === type; } export const isType = Object.fromEntries( typeNames.map((typeName) => [typeName, createTypeGuard(typeName as FieldType)]), ) as { [K in (typeof typeNames)[number]]: (value: OneOf) => value is ExtractOneOf };