ken_nogi/ClaudePleasanter/営業積算システム/apply-335411-full.js
Kenichiro NOGI ed33892f08 chore: 作業中の変更を整理しコミット(複数プロジェクト分)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-02 11:09:50 +09:00

90 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* apply-335411-full.js
* ------------------------------------------------------------
* 一回限りの直接実行スクリプト2026-07-30、SiteId 335411 見積回答ファイル転記一括DL追加
* ユーザーが「反映させてください」と明示許可したため作成。
*
* updatesitesettings部分更新はこのPleasanterデプロイでは200を返しつつ
* 実際には永続化されないケースが確認されているためproject-pleasanter-updatesitesettings-noop
* updatesiteMode:"full")で送信する。
*
* デフォルトはプレビューのみ(送信なし)。--execute を付けたときだけ実送信する。
* ------------------------------------------------------------
*/
const fs = require("fs");
const path = require("path");
const baseDir = __dirname;
const config = JSON.parse(fs.readFileSync(path.join(baseDir, "config.json"), "utf-8"));
const desired = JSON.parse(fs.readFileSync(path.join(baseDir, "desired_config.json"), "utf-8"));
const siteId = 335411;
const currentPath = path.join(baseDir, "siteSettingJsons", `site-${siteId}_latest.json`);
const current = JSON.parse(fs.readFileSync(currentPath, "utf-8")).Response.Data;
// SiteSettingsは現状を丸ごとベースにし、Scriptsのみdesired_config.json編集済みで置き換える
const siteSettings = JSON.parse(JSON.stringify(current.SiteSettings));
siteSettings.Scripts = desired.SiteSettings.Scripts;
const body = {
ApiVersion: config.ApiVersion || "1.1",
ApiKey: config.ApiKey,
SiteId: siteId,
Title: current.Title,
ReferenceType: current.ReferenceType,
ParentId: current.ParentId,
InheritPermission: current.InheritPermission,
Permissions: current.Permissions || [],
SiteSettings: siteSettings,
};
const url = `${config.BaseUrl.replace(/\/+$/, "")}/api/items/${siteId}/updatesite`;
function maskApiKey(key) {
return key && key.length > 8 ? key.slice(0, 4) + "****" + key.slice(-4) : "****";
}
const execute = process.argv.includes("--execute");
console.log("========================================");
console.log(` Mode: full (updatesite) execute=${execute}`);
console.log("========================================");
console.log(`URL : ${url}`);
console.log(`SiteId: ${siteId}`);
console.log("Scripts Id1/Id3 本文差分ありtranscribeEstimateAttachments/estimateAttachmentsDLButton追加。Styles/ServerScripts/Processesは現状のまま。");
console.log("");
const maskedBody = { ...body, ApiKey: maskApiKey(body.ApiKey) };
const outDir = path.join(
baseDir,
"configs",
"site-335411_②問い合わせ内容管理 Ver0.3",
"modify",
"2026-07-30T1000_見積回答ファイル転記_一括DL追加"
);
fs.writeFileSync(path.join(outDir, "send_body_full_masked.json"), JSON.stringify(maskedBody, null, 2), "utf-8");
console.log(`送信予定Bodyマスク済みを保存しました: ${path.join(outDir, "send_body_full_masked.json")}`);
if (!execute) {
console.log("\n[プレビューのみ] 実際の送信は行っていません。--execute を付けて再実行すると送信します。");
process.exit(0);
}
(async () => {
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
const text = await res.text();
console.log(`HTTP ${res.status}`);
console.log(text);
fs.writeFileSync(
path.join(outDir, `site-335411_full_update_result_${new Date().toISOString().replace(/[:.]/g, "-")}.json`),
JSON.stringify({ status: res.status, body: text }, null, 2),
"utf-8"
);
})();