This commit is contained in:
2026-03-12 15:53:37 +08:00
parent 51ccd265ba
commit 4ae451fc73
6 changed files with 60 additions and 43 deletions

View File

@@ -106,15 +106,18 @@ export class SelfKintoneClient {
| Awaited<AppCustomizeResponse>["desktop"]["js"][number]
| Awaited<AppCustomizeResponse>["desktop"]["css"][number],
): JSFileConfig | CSSFileConfig {
if (resource.type === "FILE") {
return {
type: "FILE",
file: {
fileKey: resource.file.fileKey,
name: resource.file.name,
size: parseInt(resource.file.size, 10),
},
};
}
return {
type: resource.type,
file: resource.file
? {
fileKey: resource.file.fileKey,
name: resource.file.name,
size: parseInt(resource.file.size, 10),
}
: undefined,
type: "URL",
url: resource.url,
};
}
@@ -122,20 +125,19 @@ export class SelfKintoneClient {
private buildCustomizeSection(
js?: JSFileConfig[],
css?: CSSFileConfig[],
): Parameters<KintoneClient["app"]["updateAppCustomize"]>[0] | undefined {
): Parameters<KintoneClient["app"]["updateAppCustomize"]>[0]["desktop"] {
if (!js && !css) return undefined;
const mapItem = (item: JSFileConfig | CSSFileConfig) => {
if (item.type === "FILE" && item.file) {
return { type: "FILE" as const, file: { fileKey: item.file.fileKey } };
}
return { type: "URL" as const, url: item.url || "" };
};
return {
js: js?.map((item) => ({
type: item.type,
file: item.file ? { fileKey: item.file.fileKey } : undefined,
url: item.url,
})),
css: css?.map((item) => ({
type: item.type,
file: item.file ? { fileKey: item.file.fileKey } : undefined,
url: item.url,
})),
js: js?.map(mapItem),
css: css?.map(mapItem),
};
}
@@ -259,10 +261,14 @@ export class SelfKintoneClient {
return this.withErrorHandling(async () => {
await this.client.app.updateAppCustomize({
app: appId,
...this.buildCustomizeSection(
desktop: this.buildCustomizeSection(
config.javascript?.pc,
config.stylesheet?.pc,
),
mobile: this.buildCustomizeSection(
config.javascript?.mobile,
config.stylesheet?.mobile,
),
scope: "ALL",
});
});