Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rest-api-client): add new properties to get/updateAppSettings #2949

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 12 additions & 56 deletions packages/rest-api-client/src/client/AppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>;
Expand Down Expand Up @@ -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<GetAppSettingsForResponse> {
const { preview, ...rest } = params;
const path = this.buildPathWithGuestSpaceId({
endpointName: "app/settings",
Expand All @@ -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<UpdateAppSettingsForResponse> {
const path = this.buildPathWithGuestSpaceId({
endpointName: "app/settings",
preview: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
83 changes: 83 additions & 0 deletions packages/rest-api-client/src/client/types/app/setting.ts
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shabaraba
今回追加するパラメータはすべて省略可のようです。
https://cybozu.dev/ja/kintone/docs/rest-api/apps/settings/update-general-settings/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正しました。
0e75c38

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;
};