diff --git a/packages/rest-api-client/docs/app.md b/packages/rest-api-client/docs/app.md index 6006e03f26..3ef4013740 100644 --- a/packages/rest-api-client/docs/app.md +++ b/packages/rest-api-client/docs/app.md @@ -897,20 +897,32 @@ Gets the description, name, icon, revision and color theme of an app. #### Returns -| Name | Type | Description | -| --------------------- | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| name | String | The app name. | -| description | String | The app description in HTML format. | -| icon | Object | An object containing data of the app icon. | -| icon.file | Object | An object containing data of uploaded icon files. | -| icon.file.contentType | String | The MIME type of the uploaded icon file. | -| icon.file.fileKey | String | The fileKey of the uploaded icon file. | -| icon.file.name | String | The file name of the uploaded icon file. | -| icon.file.size | String | The byte size of the uploaded icon file. | -| icon.key | String | The key identifier of the icon.
Responded, if the preset icons within Kintone are used. | -| icon.type | String | The icon type: | -| revision | String | The revision number of the app settings. | -| theme | String | The color theme. Possible values are: `WHITE`, `RED`, `BLUE`, `GREEN`, `YELLOW`, `BLACK`.
Apps created before February 2017 may respond with the following classic themes: `CLIPBOARD`, `BINDER`, `PENCIL`, `CLIPS`. | +| Name | Type | Description | +| ----------------------------- | :-----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| name | String | The app name. | +| description | String | The app description in HTML format. | +| icon | Object | An object containing data of the app icon. | +| icon.file | Object | An object containing data of uploaded icon files. | +| icon.file.contentType | String | The MIME type of the uploaded icon file. | +| icon.file.fileKey | String | The fileKey of the uploaded icon file. | +| icon.file.name | String | The file name of the uploaded icon file. | +| icon.file.size | String | The byte size of the uploaded icon file. | +| icon.key | String | The key identifier of the icon.
Responded, if the preset icons within Kintone are used. | +| icon.type | String | The icon type: | +| theme | String | The color theme. Possible values are: `WHITE`, `RED`, `BLUE`, `GREEN`, `YELLOW`, `BLACK`.
Apps created before February 2017 may respond with the following classic themes: `CLIPBOARD`, `BINDER`, `PENCIL`, `CLIPS`. | +| titleField | Object | The record title. | +| titleField.selectionMode | String | The option of The field to be used as the record title settings. | +| titleField.code | String | The field code of the field used as the title of the record. | +| enableThumbnails | Boolean | The Show thumbnails setting. | +| enableBulkDeletion | Boolean | The Enable bulk deletion of records setting. | +| enableComments | Boolean | The Enable comments setting. | +| enableDuplicateRecord | Boolean | The Enable the feature to \`duplicate record\` setting. | +| numberPrecision | Object | The Precision of numbers and calculations setting. | +| numberPrecision.digits | String | The Total Number of Digits setting. | +| numberPrecision.decimalPlaces | String | The Number of Decimal Places to Round setting. | +| numberPrecision.roundingMode | String | The Rounding setting | +| firstMonthOfFiscalYear | String | The First month of Fiscal Year setting. The number of the month will be returned. | +| revision | String | The revision number of the app settings. | #### Reference @@ -922,18 +934,30 @@ Updates the description, name, icon, revision and color theme of an app. #### Parameters -| Name | Type | Required | Description | -| ----------------- | :--------------: | :-------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| app | Number or String | Yes | The app ID. | -| name | String | | The app name. | -| description | String | | The app description. The maximum character limit is 10,000. HTML tags can be used. | -| icon | Object | | An object containing information of the app icon. | -| icon.type | String | Conditionally
Required | The icon type. Specify one of the following: Required, if the "icon" parameter will be set. | -| icon.key | String | Conditionally
Required | The key identifier of the icon.
Required, if the `icon.type` parameter is set as `PRESET`.
(Preset icons have key identifiers that can be obtained using the [getAppSettings()](#getAppSettings)) | -| icon.file | Object | Conditionally
Required | An object containing data of uploaded icon files.
Required, if the `icon.type` parameter is set as `FILE`. | -| icon.file.fileKey | String | Conditionally
Required | The fileKey of the icon.
To attach a file, specify the fileKey responded when using [File#uploadFile()](https://github.com/kintone/js-sdk/blob/main/packages/rest-api-client/docs/file.md#uploadFile).
The maximum file size limit is 800KB.
Required, if the `icon.type` parameter is set as `FILE`. | -| theme | String | | The color theme.
The following can be specified: `WHITE`, `RED`, `BLUE`, `GREEN`, `YELLOW`, `BLACK`

If you specify values correspond to classic themes(`CLIPBOARD`, `BINDER`, `PENCIL`, `CLIPS`), the app is displayed as `WHITE` theme. | -| revision | Number or String | | Specify the revision number of the settings that will be deployed. The request will fail if the revision number is not the latest revision. The revision will not be checked if this parameter is ignored, or `-1` is specified. | +| Name | Type | Required | Description | +| ----------------------------- | :---------------: | :-------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| app | Number or String | Yes | The app ID. | +| name | String | | The app name. | +| description | String | | The app description. The maximum character limit is 10,000. HTML tags can be used. | +| icon | Object | | An object containing information of the app icon. | +| icon.type | String | Conditionally
Required | The icon type. Specify one of the following: Required, if the "icon" parameter will be set. | +| icon.key | String | Conditionally
Required | The key identifier of the icon.
Required, if the `icon.type` parameter is set as `PRESET`.
(Preset icons have key identifiers that can be obtained using the [getAppSettings()](#getAppSettings)) | +| icon.file | Object | Conditionally
Required | An object containing data of uploaded icon files.
Required, if the `icon.type` parameter is set as `FILE`. | +| icon.file.fileKey | String | Conditionally
Required | The fileKey of the icon.
To attach a file, specify the fileKey responded when using [File#uploadFile()](https://github.com/kintone/js-sdk/blob/main/packages/rest-api-client/docs/file.md#uploadFile).
The maximum file size limit is 800KB.
Required, if the `icon.type` parameter is set as `FILE`. | +| theme | String | | The color theme.
The following can be specified: `WHITE`, `RED`, `BLUE`, `GREEN`, `YELLOW`, `BLACK`

If you specify values correspond to classic themes(`CLIPBOARD`, `BINDER`, `PENCIL`, `CLIPS`), the app is displayed as `WHITE` theme. | +| titleField | Object | | The record title. | +| titleField.selectionMode | String | Conditional | The option of "The field to be used as the record title" settings. Required if `titleField` is specified. | +| titleField.code | String | Conditional | The field code of the field used as the title of the record. Required, if `MANUAL` is set for the `titleField.selectionMode` parameter. | +| enableThumbnails | Boolean | | The Show thumbnails setting. | +| enableBulkDeletion | Boolean | | The Enable bulk deletion of records setting. | +| enableComments | Boolean | | The Enable comments setting. | +| enableDuplicateRecord | Boolean | | The Enable the feature to "duplicate record" setting. | +| numberPrecision | Object | | The Precision of numbers and calculations setting. | +| numberPrecision.digits | String or Integer | | The Total Number of Digits setting. | +| numberPrecision.decimalPlaces | String or Integer | | The Number of Decimal Places to Round setting. | +| numberPrecision.roundingMode | String | | The Rounding setting | +| firstMonthOfFiscalYear | String or Integer | | The First month of Fiscal Year setting. Specify the number of the month. | +| revision | Number or String | | Specify the revision number of the settings that will be deployed. The request will fail if the revision number is not the latest revision. The revision will not be checked if this parameter is ignored, or `-1` is specified. | #### Returns diff --git a/packages/rest-api-client/src/client/AppClient.ts b/packages/rest-api-client/src/client/AppClient.ts index 832a7a56a1..9b360acc41 100644 --- a/packages/rest-api-client/src/client/AppClient.ts +++ b/packages/rest-api-client/src/client/AppClient.ts @@ -40,6 +40,12 @@ import type { } from "./types"; import { BaseClient } from "./BaseClient"; import type { AppPlugin } from "./types/app/plugin"; +import type { + GetAppSettingsForRequest, + GetAppSettingsForResponse, + UpdateAppSettingsForRequest, + UpdateAppSettingsForResponse, +} from "./types/app/setting"; type RowLayoutForParameter = { type: "ROW"; fields: Array<{ [key: string]: unknown }>; @@ -224,37 +230,9 @@ export class AppClient extends BaseClient { return this.client.post(path, { name }); } - public getAppSettings(params: { - app: AppID; - lang?: AppLang; - preview?: boolean; - }): Promise<{ - name: string; - description: string; - icon: - | { - type: "FILE"; - file: { - contentType: string; - fileKey: string; - name: string; - size: string; - }; - } - | { type: "PRESET"; key: string }; - theme: - | "WHITE" - | "CLIPBOARD" - | "BINDER" - | "PENCIL" - | "CLIPS" - | "RED" - | "BLUE" - | "GREEN" - | "YELLOW" - | "BLACK"; - revision: string; - }> { + public getAppSettings( + params: GetAppSettingsForRequest, + ): Promise { const { preview, ...rest } = params; const path = this.buildPathWithGuestSpaceId({ endpointName: "app/settings", @@ -263,31 +241,9 @@ export class AppClient extends BaseClient { return this.client.get(path, rest); } - public updateAppSettings(params: { - app: AppID; - name?: string; - description?: string; - icon?: - | { - type: "FILE"; - file: { - fileKey: string; - }; - } - | { type: "PRESET"; key: string }; - theme?: - | "WHITE" - | "CLIPBOARD" - | "BINDER" - | "PENCIL" - | "CLIPS" - | "RED" - | "BLUE" - | "GREEN" - | "YELLOW" - | "BLACK"; - revision?: Revision; - }): Promise<{ revision: string }> { + public updateAppSettings( + params: UpdateAppSettingsForRequest, + ): Promise { const path = this.buildPathWithGuestSpaceId({ endpointName: "app/settings", preview: true, diff --git a/packages/rest-api-client/src/client/__tests__/app/AppSettings.test.ts b/packages/rest-api-client/src/client/__tests__/app/AppSettings.test.ts index 28d68da55e..d910aa78c9 100644 --- a/packages/rest-api-client/src/client/__tests__/app/AppSettings.test.ts +++ b/packages/rest-api-client/src/client/__tests__/app/AppSettings.test.ts @@ -60,6 +60,20 @@ describe("AppSettings", () => { }, }, theme: "WHITE" as const, + titleField: { + selectionMode: "MANUAL" as const, + code: "titleFieldCode", + }, + enableThumbnails: true, + enableBulkDeletion: true, + enableComments: true, + enableDuplicateRecord: true, + numberPrecision: { + digits: 30, + decimalPlaces: "10", + roundingMode: "HALF_EVEN" as const, + }, + firstMonthOfFiscalYear: 12, }; beforeEach(async () => { await appClient.updateAppSettings(params); diff --git a/packages/rest-api-client/src/client/types/app/setting.ts b/packages/rest-api-client/src/client/types/app/setting.ts new file mode 100644 index 0000000000..c089b8fc03 --- /dev/null +++ b/packages/rest-api-client/src/client/types/app/setting.ts @@ -0,0 +1,87 @@ +import type { AppID, AppLang, Revision } from ".."; +type Theme = + | "WHITE" + | "CLIPBOARD" + | "BINDER" + | "PENCIL" + | "CLIPS" + | "RED" + | "BLUE" + | "GREEN" + | "YELLOW" + | "BLACK"; + +type TitleField = + | { + selectionMode: "AUTO"; + } + | { + selectionMode: "MANUAL"; + code: string; + }; + +export type GetAppSettingsForRequest = { + app: AppID; + lang?: AppLang; + preview?: boolean; +}; + +export type GetAppSettingsForResponse = { + name: string; + description: string; + icon: + | { + type: "FILE"; + file: { + contentType: string; + fileKey: string; + name: string; + size: string; + }; + } + | { type: "PRESET"; key: string }; + theme: Theme; + titleField: TitleField; + enableThumbnails: boolean; + enableBulkDeletion: boolean; + enableComments: boolean; + enableDuplicateRecord: boolean; + numberPrecision: { + digits: string; + decimalPlaces: string; + roundingMode: "HALF_EVEN" | "UP" | "DOWN"; + }; + firstMonthOfFiscalYear: string; + revision: string; +}; + +export type UpdateAppSettingsForRequest = { + app: AppID; + name?: string; + description?: string; + icon?: + | { + type: "FILE"; + file: { + fileKey: string; + }; + } + | { type: "PRESET"; key: string }; + theme?: Theme; + titleField?: TitleField; + enableThumbnails?: boolean; + enableBulkDeletion?: boolean; + enableComments?: boolean; + enableDuplicateRecord?: boolean; + numberPrecision?: { + digits?: string | number; + decimalPlaces?: string | number; + roundingMode?: "HALF_EVEN" | "UP" | "DOWN"; + }; + firstMonthOfFiscalYear?: string | number; + revision?: Revision; +}; + +export type UpdateAppSettingsForResponse = { + revision: string; +};