From 4270bb29755cb18f778f23e15e0f59db61d25a0f Mon Sep 17 00:00:00 2001
From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com>
Date: Thu, 29 Aug 2024 14:53:51 +0900
Subject: [PATCH 1/3] feat(rest-api-client): add property for get/update app
settings
---
packages/rest-api-client/docs/app.md | 76 ++++++++++++++++++----------
1 file changed, 50 insertions(+), 26 deletions(-)
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:
- `FILE`: An uploaded image.
- `PRESET`: A preset icon within Kintone.
|
-| 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: - `FILE`: An uploaded image.
- `PRESET`: A preset icon within Kintone.
|
+| 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. - `AUTO`: The Set automatically option.
- `MANUAL`: The Set manually option.
|
+| 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 - `HALF_EVEN`: Round to nearest even number
- `UP`: Round up
- `DOWN`: Round down
|
+| 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: - `FILE`: An uploaded image.
- `PRESET`: A preset icon within Kintone.
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: - `FILE`: An uploaded image.
- `PRESET`: A preset icon within Kintone.
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. - `AUTO`: The "Set automatically" option.
- `MANUAL`: The "Set manually" option.
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 - `HALF_EVEN`: Round to nearest even number
- `UP`: Round up
- `DOWN`: Round down
|
+| 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
From b869767c37046afb24f7e3c17091e042dbdbd420 Mon Sep 17 00:00:00 2001
From: shabaraba
Date: Mon, 2 Sep 2024 12:09:29 +0900
Subject: [PATCH 2/3] feat(rest-api-client): Change the request parameters and
response parameters
---
.../rest-api-client/src/client/AppClient.ts | 68 +++------------
.../client/__tests__/app/AppSettings.test.ts | 14 ++++
.../src/client/types/app/setting.ts | 83 +++++++++++++++++++
3 files changed, 109 insertions(+), 56 deletions(-)
create mode 100644 packages/rest-api-client/src/client/types/app/setting.ts
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..33117e616a 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: "AUTO" 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..50516a532b
--- /dev/null
+++ b/packages/rest-api-client/src/client/types/app/setting.ts
@@ -0,0 +1,83 @@
+import type { AppID, AppLang, Revision } from "..";
+type Theme =
+ | "WHITE"
+ | "CLIPBOARD"
+ | "BINDER"
+ | "PENCIL"
+ | "CLIPS"
+ | "RED"
+ | "BLUE"
+ | "GREEN"
+ | "YELLOW"
+ | "BLACK";
+
+type TitleField = {
+ selectionMode: "AUTO" | "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;
+};
From 0e75c38061430e479704eb756802e9243734bfc0 Mon Sep 17 00:00:00 2001
From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com>
Date: Tue, 3 Sep 2024 11:47:16 +0900
Subject: [PATCH 3/3] feat(rest-api-client): Change to optional parameter
---
.../client/__tests__/app/AppSettings.test.ts | 2 +-
.../src/client/types/app/setting.ts | 32 +++++++++++--------
2 files changed, 19 insertions(+), 15 deletions(-)
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 33117e616a..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
@@ -61,7 +61,7 @@ describe("AppSettings", () => {
},
theme: "WHITE" as const,
titleField: {
- selectionMode: "AUTO" as const,
+ selectionMode: "MANUAL" as const,
code: "titleFieldCode",
},
enableThumbnails: true,
diff --git a/packages/rest-api-client/src/client/types/app/setting.ts b/packages/rest-api-client/src/client/types/app/setting.ts
index 50516a532b..c089b8fc03 100644
--- a/packages/rest-api-client/src/client/types/app/setting.ts
+++ b/packages/rest-api-client/src/client/types/app/setting.ts
@@ -11,10 +11,14 @@ type Theme =
| "YELLOW"
| "BLACK";
-type TitleField = {
- selectionMode: "AUTO" | "MANUAL";
- code: string;
-};
+type TitleField =
+ | {
+ selectionMode: "AUTO";
+ }
+ | {
+ selectionMode: "MANUAL";
+ code: string;
+ };
export type GetAppSettingsForRequest = {
app: AppID;
@@ -64,17 +68,17 @@ export type UpdateAppSettingsForRequest = {
}
| { 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";
+ 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;
+ firstMonthOfFiscalYear?: string | number;
revision?: Revision;
};