star8-cli 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16,6 +16,21 @@ function redactSensitiveValues(value) {
16
16
  SENSITIVE_FIELD_PATTERN.test(key) ? "[REDACTED]" : redactSensitiveValues(child)
17
17
  ]));
18
18
  }
19
+ function retryAfterSeconds(response) {
20
+ if (response.status !== 429)
21
+ return void 0;
22
+ const value = response.headers.get("retry-after");
23
+ if (value === null || !/^\d+$/.test(value))
24
+ return void 0;
25
+ const seconds = Number(value);
26
+ if (!Number.isSafeInteger(seconds))
27
+ return void 0;
28
+ return seconds;
29
+ }
30
+ function retryAfterGuidance(response) {
31
+ const seconds = retryAfterSeconds(response);
32
+ return seconds === void 0 ? void 0 : `\u518D\u8A66\u884C\u307E\u3067\u306E\u76EE\u5B89: ${seconds}\u79D2`;
33
+ }
19
34
  var ApiError = class extends Error {
20
35
  httpStatus;
21
36
  errorCode;
@@ -47,6 +62,27 @@ var ApiClient = class {
47
62
  return `/v1/server/${encodeURIComponent(this.servername)}`;
48
63
  }
49
64
  // ================================================================
65
+ // サーバーサービスAPI(/v1/server・servername非依存)
66
+ // ================================================================
67
+ async listServerPlans(params) {
68
+ return this.get("/v1/server/plans", params);
69
+ }
70
+ async registerServer(data, idempotencyKey) {
71
+ return this.post("/v1/server", data, idempotencyHeaders(idempotencyKey));
72
+ }
73
+ async listServers() {
74
+ return this.get("/v1/server");
75
+ }
76
+ async getServerSignupStatus(servername2) {
77
+ return this.get(`/v1/server/${enc(servername2)}/signup-status`);
78
+ }
79
+ async getServerMemo(servername2) {
80
+ return this.get(`/v1/server/${enc(servername2)}/memo`);
81
+ }
82
+ async updateServerMemo(servername2, data) {
83
+ return this.put(`/v1/server/${enc(servername2)}/memo`, data);
84
+ }
85
+ // ================================================================
50
86
  // サーバー情報
51
87
  // ================================================================
52
88
  async getServerInfo() {
@@ -553,6 +589,21 @@ var ApiClient = class {
553
589
  wphostingSitePath(contractId2, servername2) {
554
590
  return `${this.wphostingPath(contractId2)}/sites/${enc(servername2)}`;
555
591
  }
592
+ async listWphostingPlans(params) {
593
+ return this.get("/v1/wphosting/plans", params);
594
+ }
595
+ async registerWphosting(data, idempotencyKey) {
596
+ return this.post("/v1/wphosting", data, idempotencyHeaders(idempotencyKey));
597
+ }
598
+ async listWphostingContracts() {
599
+ return this.get("/v1/wphosting");
600
+ }
601
+ async getWphostingMemo(contractId2) {
602
+ return this.get(`${this.wphostingPath(contractId2)}/memo`);
603
+ }
604
+ async updateWphostingMemo(contractId2, data) {
605
+ return this.put(`${this.wphostingPath(contractId2)}/memo`, data);
606
+ }
556
607
  async listWphostingSites(contractId2) {
557
608
  return this.get(`${this.wphostingPath(contractId2)}/sites`);
558
609
  }
@@ -725,6 +776,78 @@ var ApiClient = class {
725
776
  return this.put(`${this.wphostingSitePath(contractId2, servername2)}/security/${enc(key)}`, data);
726
777
  }
727
778
  // ================================================================
779
+ // VPS API(/v1/vps)
780
+ // ================================================================
781
+ vpsServerPath(uuid) {
782
+ return `/v1/vps/servers/${enc(uuid)}`;
783
+ }
784
+ async listVpsServers() {
785
+ return this.get("/v1/vps/servers");
786
+ }
787
+ async getVpsServer(uuid) {
788
+ return this.get(this.vpsServerPath(uuid));
789
+ }
790
+ async updateVpsMemo(uuid, data) {
791
+ return this.put(`${this.vpsServerPath(uuid)}/memo`, data);
792
+ }
793
+ async updateVpsName(uuid, data) {
794
+ return this.put(`${this.vpsServerPath(uuid)}/name`, data);
795
+ }
796
+ async updateVpsReverseDns(uuid, data) {
797
+ return this.put(`${this.vpsServerPath(uuid)}/reverse-dns`, data);
798
+ }
799
+ async getVpsPower(uuid) {
800
+ return this.get(`${this.vpsServerPath(uuid)}/power`);
801
+ }
802
+ async startVpsPower(uuid) {
803
+ return this.post(`${this.vpsServerPath(uuid)}/power/start`);
804
+ }
805
+ async rebootVpsPower(uuid, data) {
806
+ return this.post(`${this.vpsServerPath(uuid)}/power/reboot`, data);
807
+ }
808
+ async stopVpsPower(uuid) {
809
+ return this.post(`${this.vpsServerPath(uuid)}/power/stop`);
810
+ }
811
+ async getVpsPacketFilter(uuid) {
812
+ return this.get(`${this.vpsServerPath(uuid)}/packet-filter`);
813
+ }
814
+ async updateVpsPacketFilter(uuid, data) {
815
+ return this.put(`${this.vpsServerPath(uuid)}/packet-filter`, data);
816
+ }
817
+ async addVpsPacketFilterRule(uuid, data) {
818
+ return this.post(`${this.vpsServerPath(uuid)}/packet-filter/rules`, data);
819
+ }
820
+ async updateVpsPacketFilterRule(uuid, ruleId, data) {
821
+ return this.put(`${this.vpsServerPath(uuid)}/packet-filter/rules/${enc(ruleId)}`, data);
822
+ }
823
+ async deleteVpsPacketFilterRule(uuid, ruleId) {
824
+ return this.delete(`${this.vpsServerPath(uuid)}/packet-filter/rules/${enc(ruleId)}`);
825
+ }
826
+ async listVpsOsImages(uuid) {
827
+ return this.get(`${this.vpsServerPath(uuid)}/os-images`);
828
+ }
829
+ async reinstallVpsOs(uuid, data) {
830
+ return this.post(`${this.vpsServerPath(uuid)}/os-reinstall`, data);
831
+ }
832
+ async getVpsOsReinstall(uuid) {
833
+ return this.get(`${this.vpsServerPath(uuid)}/os-reinstall`);
834
+ }
835
+ async getVpsProtection(uuid) {
836
+ return this.get(`${this.vpsServerPath(uuid)}/protection`);
837
+ }
838
+ async updateVpsProtection(uuid, data) {
839
+ return this.put(`${this.vpsServerPath(uuid)}/protection`, data);
840
+ }
841
+ async listVpsPlans() {
842
+ return this.get("/v1/vps/plans");
843
+ }
844
+ async registerVps(data, idempotencyKey) {
845
+ return this.post("/v1/vps/servers", data, idempotencyHeaders(idempotencyKey));
846
+ }
847
+ async getVpsSignupStatus(id) {
848
+ return this.get(`/v1/vps/signup-status/${enc(id)}`);
849
+ }
850
+ // ================================================================
728
851
  // HTTP 基盤
729
852
  // ================================================================
730
853
  async get(path2, params) {
@@ -775,12 +898,23 @@ var ApiClient = class {
775
898
  const dbg = (msg) => process.stderr.write(`[DEBUG] ${msg}
776
899
  `);
777
900
  dbg(`HTTP ${response.status} ${response.statusText}`);
778
- const debugHeaders = ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-concurrent-limit", "x-concurrent-remaining", "content-type"];
901
+ const debugHeaders = [
902
+ "x-ratelimit-limit",
903
+ "x-ratelimit-remaining",
904
+ "x-ratelimit-reset",
905
+ "x-concurrent-limit",
906
+ "x-concurrent-remaining",
907
+ "content-type",
908
+ "location"
909
+ ];
779
910
  for (const h of debugHeaders) {
780
911
  const v = response.headers.get(h);
781
912
  if (v !== null)
782
913
  dbg(` ${h}: ${v}`);
783
914
  }
915
+ const retryAfter = retryAfterSeconds(response);
916
+ if (retryAfter !== void 0)
917
+ dbg(` retry-after: ${retryAfter}`);
784
918
  }
785
919
  const rateLimitHeader = response.headers.get("x-ratelimit-limit");
786
920
  if (rateLimitHeader) {
@@ -791,12 +925,17 @@ var ApiClient = class {
791
925
  };
792
926
  }
793
927
  const text = await response.text();
928
+ if (response.status === 202 && text.trim() === "") {
929
+ const location = response.headers.get("location");
930
+ return { accepted: true, location };
931
+ }
794
932
  let data;
795
933
  try {
796
934
  data = JSON.parse(text);
797
935
  } catch {
798
936
  if (this.debug) {
799
- process.stderr.write(`[DEBUG] Raw response: ${text.substring(0, 500)}
937
+ const bodyBytes = Buffer.byteLength(text, "utf8");
938
+ process.stderr.write(`[DEBUG] Response body omitted because it is not valid JSON (${bodyBytes} bytes)
800
939
  `);
801
940
  }
802
941
  throw new ApiError(`Response parse error (HTTP ${response.status})`, response.status, "PARSE_ERROR", []);
@@ -805,7 +944,10 @@ var ApiClient = class {
805
944
  const err = data;
806
945
  const errorCode = err?.error?.code || "UNKNOWN_ERROR";
807
946
  const errorMessage = err?.error?.message || "\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F";
808
- const errors = err?.error?.errors || [];
947
+ const errors = [...err?.error?.errors || []];
948
+ const retryGuidance = retryAfterGuidance(response);
949
+ if (retryGuidance)
950
+ errors.push(retryGuidance);
809
951
  throw new ApiError(errorMessage, response.status, errorCode, errors);
810
952
  }
811
953
  return data;
@@ -818,13 +960,135 @@ function idempotencyHeaders(idempotencyKey) {
818
960
  return idempotencyKey === void 0 ? void 0 : { "Idempotency-Key": idempotencyKey };
819
961
  }
820
962
 
963
+ // ../../shared/dist/billing-confirmation.js
964
+ function formatYen(value) {
965
+ return `${String(value).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}\u5186`;
966
+ }
967
+ function planLabel(planId, planName) {
968
+ return planName === void 0 || planName === planId ? `\u30D7\u30E9\u30F3 ${planId}` : `${planName}\u30D7\u30E9\u30F3\uFF08${planId}\uFF09`;
969
+ }
970
+ function planNameFromPlans(plans, planId) {
971
+ const list = plans?.plans;
972
+ if (!Array.isArray(list))
973
+ return void 0;
974
+ for (const plan of list) {
975
+ const record3 = plan;
976
+ if (record3?.plan_id !== planId)
977
+ continue;
978
+ if (typeof record3.plan_name !== "string" || record3.plan_name === "") {
979
+ return void 0;
980
+ }
981
+ return record3.plan_name;
982
+ }
983
+ return void 0;
984
+ }
985
+ async function resolvePlanName(fetchPlans, planId) {
986
+ try {
987
+ return planNameFromPlans(await fetchPlans(), planId);
988
+ } catch {
989
+ return void 0;
990
+ }
991
+ }
992
+ function billingConfirmationDetailLines(details) {
993
+ const lines = [];
994
+ for (const detail of details) {
995
+ lines.push(`${detail.label}: ${detail.value}`);
996
+ if (detail.note !== void 0)
997
+ lines.push(` \u203B ${detail.note}`);
998
+ }
999
+ return lines;
1000
+ }
1001
+ function billingPaymentLines(totalPrice) {
1002
+ return [
1003
+ `\u304A\u652F\u6255\u3044\u91D1\u984D: ${formatYen(totalPrice)}\uFF08\u7A0E\u8FBC\u30FB\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u9069\u7528\u5F8C\u306E\u5B9F\u652F\u6255\u984D\uFF09`,
1004
+ "\u304A\u652F\u6255\u3044\u65B9\u6CD5: \u30D7\u30EA\u30DA\u30A4\u30C9\u6B8B\u9AD8\u304B\u3089\u306E\u5F15\u304D\u843D\u3068\u3057"
1005
+ ];
1006
+ }
1007
+ function autoRenewDetail(autoRenew, options = {}) {
1008
+ if (!autoRenew) {
1009
+ return {
1010
+ label: "\u81EA\u52D5\u66F4\u65B0",
1011
+ value: "\u7121\u52B9",
1012
+ note: "\u5951\u7D04\u671F\u9650\u307E\u3067\u306B\u624B\u52D5\u3067\u66F4\u65B0\u3057\u306A\u3044\u5834\u5408\u306F\u5931\u52B9\u3057\u307E\u3059\u3002"
1013
+ };
1014
+ }
1015
+ return {
1016
+ label: "\u81EA\u52D5\u66F4\u65B0",
1017
+ value: "\u6709\u52B9\uFF08\u6B21\u56DE\u4EE5\u964D\u306E\u66F4\u65B0\u3082\u81EA\u52D5\u3067\u8AB2\u91D1\u3055\u308C\u307E\u3059\uFF09",
1018
+ note: options.fromDefault ? `${options.optionName ?? "--auto-renew"} \u3092\u6307\u5B9A\u3057\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u65E2\u5B9A\u5024\u306E\u6709\u52B9\u304C\u9069\u7528\u3055\u308C\u307E\u3059\u3002` : void 0
1019
+ };
1020
+ }
1021
+ function partnerCodeDetail(partnerCode) {
1022
+ if (partnerCode === void 0)
1023
+ return void 0;
1024
+ return {
1025
+ label: "\u304A\u53D6\u6B21\u5E97\u30B3\u30FC\u30C9",
1026
+ value: partnerCode,
1027
+ note: "\u5B58\u5728\u3057\u306A\u3044\u30B3\u30FC\u30C9\u3067\u3082\u7533\u8FBC\u306F\u6210\u7ACB\u3057\u3001\u30A8\u30E9\u30FC\u306B\u306A\u308A\u307E\u305B\u3093\u3002\u8868\u8A18\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
1028
+ };
1029
+ }
1030
+ function serverIdDetail(serverId) {
1031
+ return {
1032
+ label: "\u5E0C\u671B\u30B5\u30FC\u30D0\u30FCID",
1033
+ value: serverId ?? "\u6307\u5B9A\u306A\u3057\uFF08\u81EA\u52D5\u3067\u63A1\u756A\u3055\u308C\u307E\u3059\uFF09"
1034
+ };
1035
+ }
1036
+ function compactDetails(details) {
1037
+ return details.filter((detail) => detail !== void 0);
1038
+ }
1039
+
821
1040
  // ../../shared/dist/brand-config.js
1041
+ function resolveServerPlanBrand(brand, service, planId) {
1042
+ if (service === "vps") {
1043
+ return {
1044
+ serviceName: brand.vpsServiceName,
1045
+ termsUrl: brand.vpsTermsUrl,
1046
+ privacyUrl: brand.vpsPrivacyUrl
1047
+ };
1048
+ }
1049
+ if (service === "server" && planId !== void 0) {
1050
+ const override = brand.serverPlanOverrides?.find((o) => planId.startsWith(o.planIdPrefix));
1051
+ if (override !== void 0) {
1052
+ return {
1053
+ serviceName: override.serviceName,
1054
+ termsUrl: override.termsUrl,
1055
+ privacyUrl: override.privacyUrl
1056
+ };
1057
+ }
1058
+ }
1059
+ return service === "server" ? {
1060
+ serviceName: brand.serverServiceName,
1061
+ termsUrl: brand.serverTermsUrl,
1062
+ privacyUrl: brand.serverPrivacyUrl
1063
+ } : {
1064
+ serviceName: brand.wphostingServiceName,
1065
+ termsUrl: brand.wphostingTermsUrl,
1066
+ privacyUrl: brand.wphostingPrivacyUrl
1067
+ };
1068
+ }
822
1069
  function domainLegalNoticeLines(brand) {
823
1070
  return [
824
1071
  `\u30B5\u30FC\u30D3\u30B9\u5229\u7528\u898F\u7D04: ${brand.domainTermsUrl}`,
825
1072
  `\u500B\u4EBA\u60C5\u5831\u306E\u53D6\u308A\u6271\u3044\u306B\u3064\u3044\u3066: ${brand.domainPrivacyUrl}`
826
1073
  ];
827
1074
  }
1075
+ function signupOperationName(brand, service, planId) {
1076
+ const { serviceName } = resolveServerPlanBrand(brand, service, planId);
1077
+ if (serviceName === void 0) {
1078
+ throw new Error(`${service}\u306E\u30B5\u30FC\u30D3\u30B9\u540D\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093`);
1079
+ }
1080
+ return `${serviceName} \u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F`;
1081
+ }
1082
+ function signupLegalNoticeLines(brand, service, planId) {
1083
+ const { termsUrl, privacyUrl } = resolveServerPlanBrand(brand, service, planId);
1084
+ if (termsUrl === void 0 || privacyUrl === void 0) {
1085
+ throw new Error(`${service}\u306E\u5229\u7528\u898F\u7D04\u30FB\u500B\u4EBA\u60C5\u5831URL\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093`);
1086
+ }
1087
+ return [
1088
+ `\u30B5\u30FC\u30D3\u30B9\u5229\u7528\u898F\u7D04: ${termsUrl}`,
1089
+ `\u500B\u4EBA\u60C5\u5831\u306E\u53D6\u308A\u6271\u3044\u306B\u3064\u3044\u3066: ${privacyUrl}`
1090
+ ];
1091
+ }
828
1092
 
829
1093
  // ../../shared/dist/domain-acquisition-permission.js
830
1094
  function record(value) {
@@ -858,8 +1122,11 @@ async function withDomainAcquisitionPermissionDiagnosis(client2, request) {
858
1122
  }
859
1123
  }
860
1124
 
861
- // ../core/dist/commands/auth/login.js
862
- import { password, select } from "@inquirer/prompts";
1125
+ // ../core/dist/lib/command-helper.js
1126
+ import { createInterface } from "readline/promises";
1127
+ import { randomUUID } from "crypto";
1128
+ import { stdin as input, stderr as output } from "process";
1129
+ import { confirm } from "@inquirer/prompts";
863
1130
 
864
1131
  // ../core/dist/lib/config.js
865
1132
  import fs from "fs";
@@ -887,6 +1154,10 @@ function saveConfig(brand, config) {
887
1154
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
888
1155
  }
889
1156
  function getActiveProfile(brand, profileName) {
1157
+ if (profileName) {
1158
+ const config2 = loadConfig(brand);
1159
+ return config2.profiles[profileName] || null;
1160
+ }
890
1161
  const envPrefix = brand.brand.toUpperCase();
891
1162
  const envApiKey = process.env[`${envPrefix}_API_KEY`] || process.env["XSERVER_API_KEY"];
892
1163
  const envServername = process.env[`${envPrefix}_SERVERNAME`] || process.env["XSERVER_SERVERNAME"];
@@ -897,7 +1168,7 @@ function getActiveProfile(brand, profileName) {
897
1168
  };
898
1169
  }
899
1170
  const config = loadConfig(brand);
900
- const name = profileName || config.defaultProfile || "default";
1171
+ const name = config.defaultProfile || "default";
901
1172
  return config.profiles[name] || null;
902
1173
  }
903
1174
 
@@ -907,114 +1178,6 @@ function resolveApiBase(brand) {
907
1178
  return (process.env[`${envPrefix}_API_BASE_URL`] ?? process.env.XSERVER_API_BASE_URL ?? brand.apiBase).replace(/\/+$/, "");
908
1179
  }
909
1180
 
910
- // ../core/dist/lib/auth-service-info.js
911
- var SERVICE_ORDER = ["server", "domain", "wphosting"];
912
- var NO_DEFAULT_SERVER = "__XSERVER_NO_DEFAULT_SERVER__";
913
- function servernameChoices(targets) {
914
- return [
915
- ...targets.map((target) => ({ value: target, name: target })),
916
- {
917
- value: NO_DEFAULT_SERVER,
918
- name: "\u56FA\u5B9A\u3057\u306A\u3044\uFF08\u30B3\u30DE\u30F3\u30C9\u5B9F\u884C\u6642\u306B --servername \u3067\u6307\u5B9A\uFF09"
919
- }
920
- ];
921
- }
922
- function record2(value) {
923
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
924
- }
925
- function strings(value) {
926
- return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
927
- }
928
- function stringValue(value, fallback) {
929
- return typeof value === "string" && value !== "" ? value : fallback;
930
- }
931
- function parseAuthApiKeyInfo(meData) {
932
- const rawServices = record2(meData.services);
933
- const services = [];
934
- for (const name of SERVICE_ORDER) {
935
- const block = record2(rawServices?.[name]);
936
- if (!block)
937
- continue;
938
- const service = {
939
- name,
940
- permissionType: stringValue(block.permission_type, "unknown"),
941
- targetMode: stringValue(block.target_mode, "unknown"),
942
- targets: strings(block.targets)
943
- };
944
- if (name === "domain" && typeof block.allow_acquisition === "boolean") {
945
- service.allowAcquisition = block.allow_acquisition;
946
- }
947
- if (name === "wphosting") {
948
- service.siteTargetMode = stringValue(block.site_target_mode, "unknown");
949
- service.sites = strings(block.sites);
950
- }
951
- services.push(service);
952
- }
953
- return {
954
- expiresAt: typeof meData.expires_at === "string" ? meData.expires_at : null,
955
- services
956
- };
957
- }
958
- function hasAuthService(info, name) {
959
- return info.services.some((service) => service.name === name);
960
- }
961
- function permissionLabel(value) {
962
- if (value === "full")
963
- return "\u3059\u3079\u3066\u306E\u64CD\u4F5C";
964
- if (value === "read")
965
- return "\u8AAD\u307F\u53D6\u308A\u5C02\u7528";
966
- if (value === "custom")
967
- return "\u30AB\u30B9\u30BF\u30E0";
968
- return value === "unknown" ? "\u4E0D\u660E" : value;
969
- }
970
- function targetLines(service) {
971
- if (service.name === "wphosting") {
972
- if (service.targetMode === "all")
973
- return [" \u5BFE\u8C61\u5951\u7D04: \u3059\u3079\u3066"];
974
- return [" \u5BFE\u8C61\u5951\u7D04:", ...service.targets.map((target) => ` - ${target}`)];
975
- }
976
- const label = service.name === "server" ? "\u5BFE\u8C61\u30B5\u30FC\u30D0\u30FC" : "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3";
977
- if (service.targetMode === "all") {
978
- return [` ${label}: \u3059\u3079\u3066`];
979
- }
980
- const lines = [` ${label}:`];
981
- lines.push(...service.targets.map((target) => ` - ${target}`));
982
- return lines;
983
- }
984
- function siteTargetLines(service) {
985
- if (service.name !== "wphosting")
986
- return [];
987
- if (service.siteTargetMode === "all")
988
- return [" \u5BFE\u8C61\u30B5\u30A4\u30C8: \u3059\u3079\u3066"];
989
- const sites = service.sites ?? [];
990
- return [" \u5BFE\u8C61\u30B5\u30A4\u30C8:", ...sites.map((site) => ` - ${site}`)];
991
- }
992
- function formatAuthApiKeyInfo(info) {
993
- const lines = ["\u5229\u7528\u53EF\u80FD\u306A\u30B5\u30FC\u30D3\u30B9:"];
994
- if (info.services.length === 0) {
995
- lines.push(" \u306A\u3057");
996
- }
997
- for (const service of info.services) {
998
- const label = service.name === "server" ? "Server" : service.name === "domain" ? "Domain" : "XServer for WordPress";
999
- lines.push(` ${label}`);
1000
- lines.push(` \u6A29\u9650: ${permissionLabel(service.permissionType)}`);
1001
- lines.push(...targetLines(service));
1002
- lines.push(...siteTargetLines(service));
1003
- if (service.name === "domain" && service.allowAcquisition !== void 0) {
1004
- lines.push(` \u53D6\u5F97\u30FB\u79FB\u7BA1\u30FB\u66F4\u65B0: ${service.allowAcquisition ? "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u3059" : "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}`);
1005
- }
1006
- }
1007
- if (info.expiresAt) {
1008
- lines.push("", `API\u30AD\u30FC\u6709\u52B9\u671F\u9650: ${info.expiresAt}`);
1009
- }
1010
- return lines;
1011
- }
1012
-
1013
- // ../core/dist/lib/command-helper.js
1014
- import { createInterface } from "readline/promises";
1015
- import { stdin as input, stderr as output } from "process";
1016
- import { confirm } from "@inquirer/prompts";
1017
-
1018
1181
  // ../core/dist/lib/output.js
1019
1182
  function formatOutput(data, format) {
1020
1183
  if (format === "json") {
@@ -1115,6 +1278,134 @@ function padRight(str, targetWidth) {
1115
1278
  return str + " ".repeat(padding);
1116
1279
  }
1117
1280
 
1281
+ // ../core/dist/lib/domain-validation.js
1282
+ var DNS_TYPES = /* @__PURE__ */ new Set(["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV"]);
1283
+ var IDEMPOTENCY_KEY_PATTERN = /^[A-Za-z0-9_-]{8,64}$/;
1284
+ function isObject(value) {
1285
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1286
+ }
1287
+ function parseInteger(value, optionName, minimum, maximum) {
1288
+ if (!/^\d+$/.test(value)) {
1289
+ throw new Error(`${optionName} \u306F\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1290
+ }
1291
+ const parsed = Number(value);
1292
+ if (!Number.isSafeInteger(parsed) || parsed < minimum || maximum !== void 0 && parsed > maximum) {
1293
+ const range = maximum === void 0 ? `${minimum}\u4EE5\u4E0A` : `${minimum}\uFF5E${maximum}`;
1294
+ throw new Error(`${optionName} \u306F${range}\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1295
+ }
1296
+ return parsed;
1297
+ }
1298
+ function parseStrictBoolean(value, optionName) {
1299
+ if (value === "true")
1300
+ return true;
1301
+ if (value === "false")
1302
+ return false;
1303
+ throw new Error(`${optionName} \u306F true \u307E\u305F\u306F false \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1304
+ }
1305
+ function parseNameservers(value) {
1306
+ const nameservers = value.split(",").map((item) => item.trim()).filter(Boolean);
1307
+ if (nameservers.length < 1 || nameservers.length > 13) {
1308
+ throw new Error("--nameservers \u306F1\uFF5E13\u4EF6\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1309
+ }
1310
+ validateNameserverHostnames(nameservers, 253);
1311
+ if (new Set(nameservers.map((item) => item.toLowerCase())).size !== nameservers.length) {
1312
+ throw new Error("\u30CD\u30FC\u30E0\u30B5\u30FC\u30D0\u30FC\u3092\u91CD\u8907\u3057\u3066\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
1313
+ }
1314
+ return nameservers;
1315
+ }
1316
+ function parseRegistrationNameservers(value) {
1317
+ const nameservers = value.split(",").map((item) => item.trim()).filter(Boolean);
1318
+ if (nameservers.length < 1 || nameservers.length > 6) {
1319
+ throw new Error("--nameservers \u306F1\uFF5E6\u4EF6\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1320
+ }
1321
+ validateNameserverHostnames(nameservers, 255);
1322
+ if (new Set(nameservers.map((item) => item.toLowerCase())).size !== nameservers.length) {
1323
+ throw new Error("\u30CD\u30FC\u30E0\u30B5\u30FC\u30D0\u30FC\u3092\u91CD\u8907\u3057\u3066\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
1324
+ }
1325
+ return nameservers;
1326
+ }
1327
+ function validateNameserverHostnames(nameservers, maximumLength) {
1328
+ const hostnamePattern = /^[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?$/;
1329
+ for (const nameserver of nameservers) {
1330
+ if (nameserver.length > maximumLength || !hostnamePattern.test(nameserver)) {
1331
+ throw new Error(`\u30CD\u30FC\u30E0\u30B5\u30FC\u30D0\u30FC\u306F\u5404${maximumLength}\u6587\u5B57\u4EE5\u5185\u306E\u30DB\u30B9\u30C8\u540D\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1332
+ }
1333
+ }
1334
+ }
1335
+ function parseWhoisData(value) {
1336
+ let parsed;
1337
+ try {
1338
+ parsed = JSON.parse(value);
1339
+ } catch {
1340
+ throw new Error("--data \u306F\u6709\u52B9\u306AJSON\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1341
+ }
1342
+ if (!isObject(parsed)) {
1343
+ throw new Error("--data \u306FJSON\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1344
+ }
1345
+ if (Object.prototype.hasOwnProperty.call(parsed, "whois_privacy_flag")) {
1346
+ throw new Error("whois_privacy_flag \u306F\u5EC3\u6B62\u3055\u308C\u3066\u3044\u307E\u3059\u3002whois_privacy \u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044");
1347
+ }
1348
+ const hasPrivacy = Object.prototype.hasOwnProperty.call(parsed, "whois_privacy");
1349
+ const hasFields = Object.prototype.hasOwnProperty.call(parsed, "fields");
1350
+ if (!hasPrivacy && !hasFields) {
1351
+ throw new Error("--data \u306B\u306F whois_privacy \u307E\u305F\u306F fields \u306E\u3044\u305A\u308C\u304B\u304C\u5FC5\u8981\u3067\u3059");
1352
+ }
1353
+ if (hasPrivacy && typeof parsed.whois_privacy !== "boolean") {
1354
+ throw new Error("whois_privacy \u306Fboolean\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1355
+ }
1356
+ if (hasFields && !isObject(parsed.fields)) {
1357
+ throw new Error("fields \u306FJSON\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1358
+ }
1359
+ return parsed;
1360
+ }
1361
+ function validateDnsType(value) {
1362
+ const type = value.toUpperCase();
1363
+ if (!DNS_TYPES.has(type)) {
1364
+ throw new Error("--type \u306F A / AAAA / CNAME / MX / TXT / NS / SRV \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1365
+ }
1366
+ return type;
1367
+ }
1368
+ function validateDnsHost(value) {
1369
+ if (value.length === 0 || value.length > 64) {
1370
+ throw new Error("--host \u306F1\uFF5E64\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1371
+ }
1372
+ return value;
1373
+ }
1374
+ function validateDnsContent(value) {
1375
+ if (value.length === 0 || value.length > 1024) {
1376
+ throw new Error("--content \u306F1\uFF5E1024\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1377
+ }
1378
+ return value;
1379
+ }
1380
+ function validateDnsId(value) {
1381
+ if (!/^[1-9]\d*$/.test(value)) {
1382
+ throw new Error("dns_id \u306F\u6B63\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1383
+ }
1384
+ return value;
1385
+ }
1386
+ function validateIdempotencyKey(value) {
1387
+ if (!IDEMPOTENCY_KEY_PATTERN.test(value)) {
1388
+ throw new Error("--idempotency-key \u306F\u82F1\u6570\u5B57\u30FB_\u30FB-\u306E8\uFF5E64\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1389
+ }
1390
+ return value;
1391
+ }
1392
+ function validateDate(value, optionName) {
1393
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
1394
+ throw new Error(`${optionName} \u306FYYYY-MM-DD\u5F62\u5F0F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1395
+ }
1396
+ const [year, month, day] = value.split("-").map(Number);
1397
+ const date = new Date(Date.UTC(year, month - 1, day));
1398
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
1399
+ throw new Error(`${optionName} \u306B\u5B58\u5728\u3059\u308B\u65E5\u4ED8\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1400
+ }
1401
+ return value;
1402
+ }
1403
+ function requireAtLeastOneField(data, message) {
1404
+ if (Object.keys(data).length === 0) {
1405
+ throw new Error(message);
1406
+ }
1407
+ }
1408
+
1118
1409
  // ../core/dist/lib/command-helper.js
1119
1410
  function findRoot(cmd) {
1120
1411
  let root = cmd;
@@ -1169,41 +1460,190 @@ async function confirmDestructiveAction(cmd, message) {
1169
1460
  process.exit(1);
1170
1461
  }
1171
1462
  }
1172
- function billingPurchasePhrase(domain, totalPrice) {
1173
- return `${domain} \u3092\u7A0E\u8FBC${totalPrice}\u5186\u3067\u627F\u8A8D`;
1463
+ function osReinstallPhrase(uuid) {
1464
+ return `${uuid} \u306EOS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u627F\u8A8D`;
1465
+ }
1466
+ function vpsOsImageName(response, imageId) {
1467
+ const images = Array.isArray(response) ? response : typeof response === "object" && response !== null ? response.os_images : void 0;
1468
+ if (!Array.isArray(images))
1469
+ return void 0;
1470
+ const image = images.find((candidate) => typeof candidate === "object" && candidate !== null && candidate.image_id === imageId);
1471
+ return typeof image?.name === "string" && image.name.length > 0 ? image.name : void 0;
1472
+ }
1473
+ function osReinstallConfirmationMessage(uuid, imageId, imageName) {
1474
+ const phrase = osReinstallPhrase(uuid);
1475
+ return [
1476
+ "OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306F\u30B5\u30FC\u30D0\u30FC\u5185\u306E\u30C7\u30FC\u30BF\u30FB\u8A2D\u5B9A\u3092\u3059\u3079\u3066\u524A\u9664\u3057\u307E\u3059\u3002",
1477
+ `\u5BFE\u8C61 uuid: ${uuid}`,
1478
+ `\u30A4\u30E1\u30FC\u30B8ID: ${imageId}`,
1479
+ `OS\u30A4\u30E1\u30FC\u30B8: ${imageName}`,
1480
+ "\u8AA4\u64CD\u4F5C\u9632\u6B62: vps protection get/set \u3067 API \u304B\u3089\u306E\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u62D2\u5426\u3067\u304D\u307E\u3059\u3002",
1481
+ `\u7D9A\u884C\u3059\u308B\u5834\u5408\u306F\u6B21\u3092\u6B63\u78BA\u306B\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044: ${phrase}`,
1482
+ ""
1483
+ ].join("\n");
1484
+ }
1485
+ function isInteractiveTerminal() {
1486
+ return !!(input.isTTY && output.isTTY);
1487
+ }
1488
+ function hasYesFlag(cmd) {
1489
+ const root = findRoot(cmd);
1490
+ return !!(root.opts().yes || process.argv.includes("--yes") || process.argv.includes("-y"));
1491
+ }
1492
+ async function confirmOsReinstall(cmd, uuid, confirmReinstall, imageId, imageName, io = { input, output }) {
1493
+ if (!confirmReinstall) {
1494
+ throw new Error("OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u306F --confirm-reinstall \u304C\u5FC5\u8981\u3067\u3059\uFF08--yes \u5358\u72EC\u3067\u306F\u5B9F\u884C\u3067\u304D\u307E\u305B\u3093\uFF09\u3002\u8AA4\u64CD\u4F5C\u9632\u6B62\u306B\u306F vps protection set \u3067 os_reinstall \u3092\u6709\u52B9\u306B\u3067\u304D\u307E\u3059\u3002");
1495
+ }
1496
+ const tty = !!(io.input.isTTY && io.output.isTTY);
1497
+ if (!tty) {
1498
+ if (!hasYesFlag(cmd)) {
1499
+ throw new Error("\u975E\u5BFE\u8A71\u3067\u306EOS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u306F --yes \u3068 --confirm-reinstall \u306E\u4E21\u65B9\u304C\u5FC5\u8981\u3067\u3059\u3002");
1500
+ }
1501
+ return;
1502
+ }
1503
+ const phrase = osReinstallPhrase(uuid);
1504
+ io.output.write(osReinstallConfirmationMessage(uuid, imageId, imageName));
1505
+ const rl = createInterface({
1506
+ input: io.input,
1507
+ output: io.output,
1508
+ terminal: true
1509
+ });
1510
+ try {
1511
+ const answer = (await rl.question("> ")).trim();
1512
+ if (answer !== phrase) {
1513
+ throw new BillingCancelledError("\u78BA\u8A8D\u6587\u5B57\u5217\u304C\u4E00\u81F4\u3057\u306A\u3044\u305F\u3081\u3001OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002");
1514
+ }
1515
+ } finally {
1516
+ rl.close();
1517
+ }
1518
+ }
1519
+ var defaultBillingConfirmationIo = { input, output };
1520
+ function billingPurchasePhrase(subject, totalPrice) {
1521
+ return `${subject} \u3092\u7A0E\u8FBC${formatYen(totalPrice)}\u3067\u627F\u8A8D`;
1174
1522
  }
1175
- function billingPurchaseMessage(params) {
1176
- const phrase = billingPurchasePhrase(params.domain, params.totalPrice);
1523
+ function billingConfirmationMessage(params) {
1524
+ const phrase = billingPurchasePhrase(params.confirmSubject, params.totalPrice);
1177
1525
  return [
1178
1526
  `\u8AB2\u91D1\u78BA\u8A8D: ${params.operation}`,
1179
- `\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3: ${params.domain}`,
1180
- `\u7A0E\u8FBC\u5408\u8A08: ${params.totalPrice}\u5186`,
1181
- ...domainLegalNoticeLines(params.brand),
1182
- "\u7533\u8ACB\u5F8C\u306F\u8AB2\u91D1\u3055\u308C\u3001\u539F\u5247\u53D6\u308A\u6D88\u3057\u3067\u304D\u307E\u305B\u3093\u3002",
1527
+ `${params.targetLabel}: ${params.target}`,
1528
+ ...billingConfirmationDetailLines(params.details ?? []),
1529
+ ...billingPaymentLines(params.totalPrice),
1530
+ ...params.legalNoticeLines,
1531
+ "\u7533\u8ACB\u3059\u308B\u3068\u8AB2\u91D1\u3055\u308C\u3001\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002",
1183
1532
  `\u7D9A\u884C\u3059\u308B\u5834\u5408\u306F\u6B21\u3092\u6B63\u78BA\u306B\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044: ${phrase}`,
1184
1533
  ""
1185
1534
  ].join("\n");
1186
1535
  }
1187
- async function confirmBillingPurchase(params) {
1188
- if (!input.isTTY || !output.isTTY) {
1536
+ function assertBillingTty(io) {
1537
+ if (!io.input.isTTY || !io.output.isTTY) {
1189
1538
  throw new Error("\u8AB2\u91D1\u3092\u4F34\u3046\u5B9F\u7533\u8ACB\u306F\u5BFE\u8A71\u7AEF\u672B\uFF08TTY\uFF09\u3067\u306E\u307F\u5B9F\u884C\u3067\u304D\u307E\u3059\u3002\u975E\u5BFE\u8A71\u74B0\u5883\u3067\u306F --dry-run \u306E\u307F\u5229\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
1190
1539
  }
1191
- const phrase = billingPurchasePhrase(params.domain, params.totalPrice);
1192
- output.write(billingPurchaseMessage(params));
1193
- const rl = createInterface({ input, output, terminal: true });
1540
+ }
1541
+ var BillingCancelledError = class extends Error {
1542
+ constructor(message) {
1543
+ super(message);
1544
+ this.name = "BillingCancelledError";
1545
+ }
1546
+ };
1547
+ var RESEND_GUIDANCE = /* @__PURE__ */ Symbol.for("xnp.cli.billingResendGuidance");
1548
+ function attachResendGuidance(error, lines) {
1549
+ if (typeof error === "object" && error !== null) {
1550
+ error[RESEND_GUIDANCE] = lines;
1551
+ }
1552
+ }
1553
+ function billingResendGuidance(error) {
1554
+ if (typeof error === "object" && error !== null) {
1555
+ const lines = error[RESEND_GUIDANCE];
1556
+ if (Array.isArray(lines))
1557
+ return lines;
1558
+ }
1559
+ return void 0;
1560
+ }
1561
+ async function confirmBillingPurchase(params, io = defaultBillingConfirmationIo) {
1562
+ assertBillingTty(io);
1563
+ io.output.write(billingConfirmationMessage(params));
1564
+ const phrase = billingPurchasePhrase(params.confirmSubject, params.totalPrice);
1565
+ const rl = createInterface({
1566
+ input: io.input,
1567
+ output: io.output,
1568
+ terminal: true
1569
+ });
1194
1570
  try {
1195
1571
  const answer = (await rl.question("> ")).trim();
1196
1572
  if (answer !== phrase) {
1197
- throw new Error("\u78BA\u8A8D\u6587\u5B57\u5217\u304C\u4E00\u81F4\u3057\u306A\u3044\u305F\u3081\u3001\u5B9F\u7533\u8ACB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002");
1573
+ throw new BillingCancelledError("\u78BA\u8A8D\u6587\u5B57\u5217\u304C\u4E00\u81F4\u3057\u306A\u3044\u305F\u3081\u3001\u5B9F\u7533\u8ACB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002");
1198
1574
  }
1199
1575
  } finally {
1200
1576
  rl.close();
1201
1577
  }
1202
1578
  }
1203
- function printIdempotencyKeyNotice(idempotencyKey, domain) {
1204
- console.error(`Idempotency-Key: ${idempotencyKey}`);
1205
- console.error("\u5165\u529B\u4E0D\u5099\u30FB\u6B8B\u9AD8\u4E0D\u8DB3\u30FB\u4FA1\u683C\u4E0D\u4E00\u81F4\u306A\u3069\u3067\u5374\u4E0B\u3055\u308C\u305F\u5834\u5408\u306F\u3001\u3053\u306E\u30AD\u30FC\u306E\u307E\u307E\u518D\u5B9F\u884C\u3067\u304D\u307E\u3059\u3002");
1206
- console.error(`\u5FDC\u7B54\u3092\u53D7\u3051\u53D6\u308C\u306A\u304B\u3063\u305F\u5834\u5408\u3084\u30B5\u30FC\u30D0\u30FC\u30A8\u30E9\u30FC\u306E\u5834\u5408\u306F\u3001\u540C\u3058\u30AD\u30FC\u3067\u306E\u518D\u9001\u306F48\u6642\u9593 409 DUPLICATE_REQUEST \u306B\u306A\u308A\u307E\u3059\u3002domain show ${domain} \u3068\u8ACB\u6C42\u5C65\u6B74\u3067\u72B6\u614B\u3092\u78BA\u8A8D\u3057\u3001\u672A\u5B9F\u884C\u3068\u78BA\u8A8D\u3067\u304D\u305F\u3068\u304D\u306E\u307F\u65B0\u3057\u3044\u30AD\u30FC\u3067\u518D\u7533\u8ACB\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
1579
+ async function executeBillingPurchase(params) {
1580
+ console.error(`Idempotency-Key: ${params.idempotencyKey}`);
1581
+ try {
1582
+ const result = await params.execute();
1583
+ console.error(`${params.operation}\u304C\u5B8C\u4E86\u3057\u307E\u3057\u305F\u3002`);
1584
+ return result;
1585
+ } catch (error) {
1586
+ attachResendGuidance(error, [
1587
+ "\u5165\u529B\u4E0D\u5099\u30FB\u6B8B\u9AD8\u4E0D\u8DB3\u30FB\u4FA1\u683C\u4E0D\u4E00\u81F4\u306A\u3069\u3067\u5374\u4E0B\u3055\u308C\u305F\u5834\u5408\u306F\u3001\u3053\u306E\u30AD\u30FC\u306E\u307E\u307E\u518D\u5B9F\u884C\u3067\u304D\u307E\u3059\u3002",
1588
+ `\u5FDC\u7B54\u3092\u53D7\u3051\u53D6\u308C\u306A\u304B\u3063\u305F\u5834\u5408\u3084\u30B5\u30FC\u30D0\u30FC\u30A8\u30E9\u30FC\u306E\u5834\u5408\u306F\u3001\u307E\u305A\u540C\u3058\u30AD\u30FC\u3067\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u5B8C\u4E86\u6E08\u307F\u306A\u3089\u524D\u56DE\u306E\u7D50\u679C\u3092\u53D6\u5F97\u3067\u304D\u307E\u3059\u3002\u51E6\u7406\u304C\u5B8C\u4E86\u3057\u3066\u3044\u306A\u3044\u5834\u5408\u306F48\u6642\u9593 409 DUPLICATE_REQUEST \u306B\u306A\u308B\u305F\u3081\u3001${params.statusCommand ?? `domain show ${params.subject}`} \u3068\u8ACB\u6C42\u5C65\u6B74\u3067\u72B6\u614B\u3092\u78BA\u8A8D\u3057\u3001\u672A\u5B9F\u884C\u3068\u78BA\u8A8D\u3067\u304D\u305F\u3068\u304D\u306E\u307F\u65B0\u3057\u3044\u30AD\u30FC\u3067\u518D\u7533\u8ACB\u3057\u3066\u304F\u3060\u3055\u3044\u3002`
1589
+ ]);
1590
+ throw error;
1591
+ }
1592
+ }
1593
+ async function runBillingPurchase(flow) {
1594
+ if (!flow.options.agreeToTerms) {
1595
+ throw new Error("\u7533\u8FBC\u306Edry-run\u304A\u3088\u3073\u5B9F\u7533\u8ACB\u306B\u306F --agree-to-terms \u306B\u3088\u308B\u5229\u7528\u898F\u7D04\u3078\u306E\u660E\u793A\u540C\u610F\u304C\u5FC5\u8981\u3067\u3059");
1596
+ }
1597
+ const preview = await flow.preview();
1598
+ if (flow.options.dryRun) {
1599
+ printResult(preview, flow.format);
1600
+ return;
1601
+ }
1602
+ const expectedTotalPrice = parseNonnegativeInteger(flow.options.expectedTotalPrice, "--expected-total-price");
1603
+ const idempotencyKey = validateIdempotencyKey(flow.options.idempotencyKey ?? randomUUID());
1604
+ const totalPrice = totalPriceFromPreview(preview, expectedTotalPrice);
1605
+ if (!flow.options.confirmPurchase) {
1606
+ throw new Error("\u5B9F\u7533\u8ACB\u306B\u306F --confirm-purchase \u304C\u5FC5\u8981\u3067\u3059\uFF08--yes \u3067\u306F\u7701\u7565\u3067\u304D\u307E\u305B\u3093\uFF09\u3002\u7D9A\u3051\u3066TTY\u3067\u78BA\u8A8D\u6587\u5B57\u5217\u306E\u5165\u529B\u3082\u5FC5\u8981\u3067\u3059");
1607
+ }
1608
+ const confirmationIo = flow.confirmationIo ?? defaultBillingConfirmationIo;
1609
+ assertBillingTty(confirmationIo);
1610
+ const { target, confirmSubject } = await flow.resolveTarget();
1611
+ await confirmBillingPurchase({
1612
+ operation: flow.operation,
1613
+ target,
1614
+ targetLabel: flow.targetLabel,
1615
+ details: flow.details,
1616
+ totalPrice,
1617
+ legalNoticeLines: flow.legalNoticeLines,
1618
+ confirmSubject
1619
+ }, confirmationIo);
1620
+ const result = await executeBillingPurchase({
1621
+ idempotencyKey,
1622
+ operation: flow.operation,
1623
+ subject: target,
1624
+ statusCommand: flow.statusCommand,
1625
+ execute: () => flow.execute(idempotencyKey)
1626
+ });
1627
+ printResult(result, flow.format);
1628
+ }
1629
+ function parseNonnegativeInteger(value, optionName) {
1630
+ if (!/^\d+$/.test(value))
1631
+ throw new Error(`${optionName} \u306F\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1632
+ const parsed = Number(value);
1633
+ if (!Number.isSafeInteger(parsed) || parsed < 0) {
1634
+ throw new Error(`${optionName} \u306F0\u4EE5\u4E0A\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
1635
+ }
1636
+ return parsed;
1637
+ }
1638
+ function totalPriceFromPreview(preview, expectedTotalPrice) {
1639
+ const totalPrice = Number(preview?.total_price);
1640
+ if (!Number.isFinite(totalPrice)) {
1641
+ throw new Error("dry-run\u7D50\u679C\u304B\u3089\u5408\u8A08\u91D1\u984D\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
1642
+ }
1643
+ if (totalPrice !== expectedTotalPrice) {
1644
+ throw new Error(`\u4FA1\u683C\u4E0D\u4E00\u81F4\u306E\u305F\u3081\u5B9F\u7533\u8ACB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\uFF08\u898B\u7A4D ${totalPrice}\u5186 / \u6307\u5B9A ${expectedTotalPrice}\u5186\uFF09\u3002`);
1645
+ }
1646
+ return totalPrice;
1207
1647
  }
1208
1648
  function pickDefined(obj) {
1209
1649
  const result = {};
@@ -1214,6 +1654,136 @@ function pickDefined(obj) {
1214
1654
  return result;
1215
1655
  }
1216
1656
 
1657
+ // ../core/dist/lib/terminal-output.js
1658
+ import { stripVTControlCharacters } from "util";
1659
+ var LINE_BREAK_PATTERN = /[\r\n\u2028\u2029]+/g;
1660
+ var CONTROL_CHARACTER_PATTERN = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
1661
+ function sanitizeTerminalText(value) {
1662
+ return stripVTControlCharacters(String(value)).replace(LINE_BREAK_PATTERN, " ").replace(CONTROL_CHARACTER_PATTERN, "");
1663
+ }
1664
+
1665
+ // ../core/dist/commands/auth/login.js
1666
+ import { password, select } from "@inquirer/prompts";
1667
+
1668
+ // ../core/dist/lib/auth-service-info.js
1669
+ var SERVICE_ORDER = ["server", "domain", "wphosting", "vps"];
1670
+ var NO_DEFAULT_SERVER = "__XSERVER_NO_DEFAULT_SERVER__";
1671
+ function servernameChoices(targets) {
1672
+ return [
1673
+ ...targets.map((target) => ({ value: target, name: target })),
1674
+ {
1675
+ value: NO_DEFAULT_SERVER,
1676
+ name: "\u56FA\u5B9A\u3057\u306A\u3044\uFF08\u30B3\u30DE\u30F3\u30C9\u5B9F\u884C\u6642\u306B --servername \u3067\u6307\u5B9A\uFF09"
1677
+ }
1678
+ ];
1679
+ }
1680
+ function record2(value) {
1681
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
1682
+ }
1683
+ function strings(value) {
1684
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
1685
+ }
1686
+ function stringValue(value, fallback) {
1687
+ return typeof value === "string" && value !== "" ? value : fallback;
1688
+ }
1689
+ function parseAuthApiKeyInfo(meData) {
1690
+ const rawServices = record2(meData.services);
1691
+ const services = [];
1692
+ for (const name of SERVICE_ORDER) {
1693
+ const block = record2(rawServices?.[name]);
1694
+ if (!block)
1695
+ continue;
1696
+ const service = {
1697
+ name,
1698
+ permissionType: stringValue(block.permission_type, "unknown"),
1699
+ targetMode: stringValue(block.target_mode, "unknown"),
1700
+ targets: strings(block.targets)
1701
+ };
1702
+ if (name === "domain" && typeof block.allow_acquisition === "boolean") {
1703
+ service.allowAcquisition = block.allow_acquisition;
1704
+ }
1705
+ if ((name === "server" || name === "wphosting" || name === "vps") && typeof block.allow_signup === "boolean") {
1706
+ service.allowSignup = block.allow_signup;
1707
+ }
1708
+ if (name === "wphosting") {
1709
+ service.siteTargetMode = stringValue(block.site_target_mode, "unknown");
1710
+ service.sites = strings(block.sites);
1711
+ }
1712
+ services.push(service);
1713
+ }
1714
+ return {
1715
+ expiresAt: typeof meData.expires_at === "string" ? meData.expires_at : null,
1716
+ services
1717
+ };
1718
+ }
1719
+ function hasAuthService(info, name) {
1720
+ return info.services.some((service) => service.name === name);
1721
+ }
1722
+ function permissionLabel(value) {
1723
+ if (value === "full")
1724
+ return "\u3059\u3079\u3066\u306E\u64CD\u4F5C";
1725
+ if (value === "read")
1726
+ return "\u8AAD\u307F\u53D6\u308A\u5C02\u7528";
1727
+ if (value === "custom")
1728
+ return "\u30AB\u30B9\u30BF\u30E0";
1729
+ return value === "unknown" ? "\u4E0D\u660E" : value;
1730
+ }
1731
+ function serviceLabel(name) {
1732
+ if (name === "server")
1733
+ return "Server";
1734
+ if (name === "domain")
1735
+ return "Domain";
1736
+ if (name === "wphosting")
1737
+ return "XServer for WordPress";
1738
+ return "VPS";
1739
+ }
1740
+ function targetLabel(name) {
1741
+ if (name === "server")
1742
+ return "\u5BFE\u8C61\u30B5\u30FC\u30D0\u30FC";
1743
+ if (name === "wphosting")
1744
+ return "\u5BFE\u8C61\u5951\u7D04";
1745
+ if (name === "vps")
1746
+ return "\u5BFE\u8C61VPS";
1747
+ return "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3";
1748
+ }
1749
+ function targetLines(service) {
1750
+ const label = targetLabel(service.name);
1751
+ if (service.targetMode === "all") {
1752
+ return [` ${label}: \u3059\u3079\u3066`];
1753
+ }
1754
+ return [` ${label}:`, ...service.targets.map((target) => ` - ${target}`)];
1755
+ }
1756
+ function siteTargetLines(service) {
1757
+ if (service.name !== "wphosting")
1758
+ return [];
1759
+ if (service.siteTargetMode === "all")
1760
+ return [" \u5BFE\u8C61\u30B5\u30A4\u30C8: \u3059\u3079\u3066"];
1761
+ const sites = service.sites ?? [];
1762
+ return [" \u5BFE\u8C61\u30B5\u30A4\u30C8:", ...sites.map((site) => ` - ${site}`)];
1763
+ }
1764
+ function formatAuthApiKeyInfo(info) {
1765
+ const lines = ["\u5229\u7528\u53EF\u80FD\u306A\u30B5\u30FC\u30D3\u30B9:"];
1766
+ if (info.services.length === 0) {
1767
+ lines.push(" \u306A\u3057");
1768
+ }
1769
+ for (const service of info.services) {
1770
+ lines.push(` ${serviceLabel(service.name)}`);
1771
+ lines.push(` \u6A29\u9650: ${permissionLabel(service.permissionType)}`);
1772
+ lines.push(...targetLines(service));
1773
+ lines.push(...siteTargetLines(service));
1774
+ if (service.name === "domain" && service.allowAcquisition !== void 0) {
1775
+ lines.push(` \u53D6\u5F97\u30FB\u79FB\u7BA1\u30FB\u66F4\u65B0: ${service.allowAcquisition ? "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u3059" : "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}`);
1776
+ }
1777
+ if (service.allowSignup !== void 0) {
1778
+ lines.push(` \u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F: ${service.allowSignup ? "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u3059" : "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}`);
1779
+ }
1780
+ }
1781
+ if (info.expiresAt) {
1782
+ lines.push("", `API\u30AD\u30FC\u6709\u52B9\u671F\u9650: ${info.expiresAt}`);
1783
+ }
1784
+ return lines;
1785
+ }
1786
+
1217
1787
  // ../core/dist/lib/resolve-servername-from-me.js
1218
1788
  function resolveServernameFromMe(meData) {
1219
1789
  const services = meData.services;
@@ -1422,9 +1992,116 @@ function registerServerInfoCommands(parent, brand) {
1422
1992
  const client2 = resolveClient(parent, brand);
1423
1993
  printResult(await client2.getServerInfo(), getFormat(parent));
1424
1994
  });
1425
- parent.command("usage").description("\u30B5\u30FC\u30D0\u30FC\u5229\u7528\u72B6\u6CC1\u3092\u53D6\u5F97").action(async () => {
1995
+ parent.command("usage").description("\u30B5\u30FC\u30D0\u30FC\u5229\u7528\u72B6\u6CC1\u3092\u53D6\u5F97").action(async () => {
1996
+ const client2 = resolveClient(parent, brand);
1997
+ printResult(await client2.getServerUsage(), getFormat(parent));
1998
+ });
1999
+ }
2000
+
2001
+ // ../core/dist/lib/signup-validation.js
2002
+ function parsePlanIds(value) {
2003
+ const plans = value.split(",").map((item) => item.trim()).filter(Boolean);
2004
+ if (plans.length === 0)
2005
+ throw new Error("--plan-id \u306F1\u4EF6\u4EE5\u4E0A\u306E\u30D7\u30E9\u30F3ID\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2006
+ return plans.join(",");
2007
+ }
2008
+ function parseSignupPeriod(value) {
2009
+ return parseInteger(value, "--period", 1, 60);
2010
+ }
2011
+ function parseWphostingSignupPeriod(value) {
2012
+ return parseSignupPeriod(value);
2013
+ }
2014
+ function parseAutoRenew(value) {
2015
+ return parseStrictBoolean(value, "--auto-renew");
2016
+ }
2017
+ function validatePartnerCode(value) {
2018
+ if (value.length === 0 || value.length > 50 || !/^[A-Za-z0-9]+$/.test(value)) {
2019
+ throw new Error("--partner-code \u306F50\u6587\u5B57\u4EE5\u5185\u306EASCII\u82F1\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2020
+ }
2021
+ return value;
2022
+ }
2023
+ function validateSignupServerId(value) {
2024
+ if (!/^[a-z][0-9a-z]+$/.test(value)) {
2025
+ throw new Error("--server-id \u306F\u5C0F\u6587\u5B57\u82F1\u5B57\u3067\u59CB\u307E\u308B2\u6587\u5B57\u4EE5\u4E0A\u306E\u5C0F\u6587\u5B57\u82F1\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2026
+ }
2027
+ return value;
2028
+ }
2029
+ function validateSignupMemo(value) {
2030
+ if (value.length > 500)
2031
+ throw new Error("--memo \u306F500\u6587\u5B57\u4EE5\u5185\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2032
+ return value;
2033
+ }
2034
+
2035
+ // ../core/dist/commands/server/account.js
2036
+ function explicitServername(parent) {
2037
+ const value = parent.opts().servername;
2038
+ if (typeof value !== "string" || value.length === 0) {
2039
+ throw new Error("--servername \u3067\u5BFE\u8C61\u30B5\u30FC\u30D0\u30FC\u540D\u3092\u660E\u793A\u3057\u3066\u304F\u3060\u3055\u3044");
2040
+ }
2041
+ return value;
2042
+ }
2043
+ function registerServerAccountCommands(parent, brand) {
2044
+ parent.command("plans").description("\u7533\u8FBC\u53EF\u80FD\u306A\u30B5\u30FC\u30D0\u30FC\u30D7\u30E9\u30F3\u3092\u53D6\u5F97").option("--plan-id <list>", "\u30D7\u30E9\u30F3ID\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09").action(async (opts) => {
2045
+ const params = opts.planId === void 0 ? void 0 : { plan_id: parsePlanIds(opts.planId) };
2046
+ printResult(await resolveClient(parent, brand).listServerPlans(params), getFormat(parent));
2047
+ });
2048
+ parent.command("contracts").description("\u30B5\u30FC\u30D0\u30FC\u5951\u7D04").command("list").description("\u30B5\u30FC\u30D0\u30FC\u5951\u7D04\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
2049
+ printResult(await resolveClient(parent, brand).listServers(), getFormat(parent));
2050
+ });
2051
+ parent.command("signup-status").description("\u30B5\u30FC\u30D0\u30FC\u7533\u8FBC\u51E6\u7406\u72B6\u6CC1\u3092\u53D6\u5F97").action(async () => {
2052
+ printResult(await resolveClient(parent, brand).getServerSignupStatus(explicitServername(parent)), getFormat(parent));
2053
+ });
2054
+ const memo = parent.command("memo").description("\u30B5\u30FC\u30D0\u30FC\u5951\u7D04\u30E1\u30E2");
2055
+ memo.command("show").description("\u30E1\u30E2\u3092\u53D6\u5F97").action(async () => {
2056
+ printResult(await resolveClient(parent, brand).getServerMemo(explicitServername(parent)), getFormat(parent));
2057
+ });
2058
+ memo.command("update").description("\u30E1\u30E2\u3092\u66F4\u65B0").requiredOption("--memo <memo>", "\u30E1\u30E2\uFF08\u7A7A\u6587\u5B57\u53EF\u3001500\u6587\u5B57\u4EE5\u5185\uFF09").action(async (opts) => {
2059
+ printResult(await resolveClient(parent, brand).updateServerMemo(explicitServername(parent), {
2060
+ memo: validateSignupMemo(opts.memo)
2061
+ }), getFormat(parent));
2062
+ });
2063
+ parent.command("signup").description("\u30B5\u30FC\u30D0\u30FC\u3092\u65B0\u898F\u5951\u7D04").requiredOption("--plan-id <id>", "\u30D7\u30E9\u30F3ID").requiredOption("--period <months>", "\u5951\u7D04\u671F\u9593\uFF08\u6708\u6570\u3002server plans \u304C\u8FD4\u3057\u305F months \u304B\u3089\u6307\u5B9A\uFF09").requiredOption("--expected-total-price <yen>", "\u4E8B\u524D\u78BA\u8A8D\u3057\u305F\u7A0E\u8FBC\u5408\u8A08\u91D1\u984D\uFF080\u4EE5\u4E0A\u306E\u6574\u6570\uFF09").option("--server-id <id>", "\u5E0C\u671B\u30B5\u30FC\u30D0\u30FCID").option("--partner-code <code>", "\u30D1\u30FC\u30C8\u30CA\u30FC\u30B3\u30FC\u30C9\uFF08ASCII\u82F1\u6570\u5B57\u300150\u6587\u5B57\u4EE5\u5185\uFF09").option("--auto-renew <bool>", "\u81EA\u52D5\u66F4\u65B0\uFF08true / false\uFF09").option("--dry-run", "\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u307F\u5B9F\u884C").option("--confirm-purchase", "\u8AB2\u91D1\u3092\u4F34\u3046\u7533\u8ACB\u3092\u660E\u793A\u7684\u306B\u78BA\u8A8D").option("--agree-to-terms", "\u5229\u7528\u898F\u7D04\u306B\u540C\u610F").option("--idempotency-key <key>", "\u5B9F\u7533\u8ACB\u306E\u51AA\u7B49\u6027\u30AD\u30FC\uFF08\u82F1\u6570\u5B57\u30FB_\u30FB-\u306E8\uFF5E64\u6587\u5B57\uFF09").action(async (opts) => {
2064
+ const expectedTotalPrice = parseInteger(opts.expectedTotalPrice, "--expected-total-price", 0);
2065
+ const period = parseSignupPeriod(opts.period);
2066
+ const serverId = opts.serverId === void 0 ? void 0 : validateSignupServerId(opts.serverId);
2067
+ const partnerCode = opts.partnerCode === void 0 ? void 0 : validatePartnerCode(opts.partnerCode);
2068
+ const autoRenew = opts.autoRenew === void 0 ? void 0 : parseAutoRenew(opts.autoRenew);
2069
+ const baseData = {
2070
+ plan_id: opts.planId,
2071
+ period,
2072
+ expected_total_price: expectedTotalPrice,
2073
+ agree_to_terms: true,
2074
+ ...pickDefined({
2075
+ server_id: serverId,
2076
+ partner_code: partnerCode,
2077
+ auto_renew: autoRenew
2078
+ })
2079
+ };
1426
2080
  const client2 = resolveClient(parent, brand);
1427
- printResult(await client2.getServerUsage(), getFormat(parent));
2081
+ await runBillingPurchase({
2082
+ format: getFormat(parent),
2083
+ options: opts,
2084
+ operation: signupOperationName(brand, "server", opts.planId),
2085
+ targetLabel: "\u7533\u8FBC\u5185\u5BB9",
2086
+ resolveTarget: async () => {
2087
+ const planName = await resolvePlanName(() => client2.listServerPlans({ plan_id: opts.planId }), opts.planId);
2088
+ return {
2089
+ target: `${planLabel(opts.planId, planName)} / \u5951\u7D04\u671F\u9593 ${period}\u304B\u6708`,
2090
+ confirmSubject: `${planName ?? opts.planId} ${period}\u304B\u6708`
2091
+ };
2092
+ },
2093
+ details: compactDetails([
2094
+ serverIdDetail(serverId),
2095
+ autoRenewDetail(autoRenew ?? true, {
2096
+ fromDefault: autoRenew === void 0
2097
+ }),
2098
+ partnerCodeDetail(partnerCode)
2099
+ ]),
2100
+ legalNoticeLines: signupLegalNoticeLines(brand, "server", opts.planId),
2101
+ statusCommand: `${brand.commandName} server contracts list`,
2102
+ preview: () => client2.registerServer({ ...baseData, dry_run: true }),
2103
+ execute: (idempotencyKey) => client2.registerServer({ ...baseData, dry_run: false }, idempotencyKey)
2104
+ });
1428
2105
  });
1429
2106
  }
1430
2107
 
@@ -2637,137 +3314,7 @@ function registerMeCommand(program, brand) {
2637
3314
  }
2638
3315
 
2639
3316
  // ../core/dist/commands/domain/index.js
2640
- import { randomUUID } from "crypto";
2641
-
2642
- // ../core/dist/lib/domain-validation.js
2643
- var DNS_TYPES = /* @__PURE__ */ new Set(["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV"]);
2644
- var IDEMPOTENCY_KEY_PATTERN = /^[A-Za-z0-9_-]{8,64}$/;
2645
- function isObject(value) {
2646
- return typeof value === "object" && value !== null && !Array.isArray(value);
2647
- }
2648
- function parseInteger(value, optionName, minimum, maximum) {
2649
- if (!/^\d+$/.test(value)) {
2650
- throw new Error(`${optionName} \u306F\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
2651
- }
2652
- const parsed = Number(value);
2653
- if (!Number.isSafeInteger(parsed) || parsed < minimum || maximum !== void 0 && parsed > maximum) {
2654
- const range = maximum === void 0 ? `${minimum}\u4EE5\u4E0A` : `${minimum}\uFF5E${maximum}`;
2655
- throw new Error(`${optionName} \u306F${range}\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
2656
- }
2657
- return parsed;
2658
- }
2659
- function parseStrictBoolean(value, optionName) {
2660
- if (value === "true")
2661
- return true;
2662
- if (value === "false")
2663
- return false;
2664
- throw new Error(`${optionName} \u306F true \u307E\u305F\u306F false \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
2665
- }
2666
- function parseNameservers(value) {
2667
- const nameservers = value.split(",").map((item) => item.trim()).filter(Boolean);
2668
- if (nameservers.length < 1 || nameservers.length > 13) {
2669
- throw new Error("--nameservers \u306F1\uFF5E13\u4EF6\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2670
- }
2671
- validateNameserverHostnames(nameservers, 253);
2672
- if (new Set(nameservers.map((item) => item.toLowerCase())).size !== nameservers.length) {
2673
- throw new Error("\u30CD\u30FC\u30E0\u30B5\u30FC\u30D0\u30FC\u3092\u91CD\u8907\u3057\u3066\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
2674
- }
2675
- return nameservers;
2676
- }
2677
- function parseRegistrationNameservers(value) {
2678
- const nameservers = value.split(",").map((item) => item.trim()).filter(Boolean);
2679
- if (nameservers.length < 1 || nameservers.length > 6) {
2680
- throw new Error("--nameservers \u306F1\uFF5E6\u4EF6\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2681
- }
2682
- validateNameserverHostnames(nameservers, 255);
2683
- if (new Set(nameservers.map((item) => item.toLowerCase())).size !== nameservers.length) {
2684
- throw new Error("\u30CD\u30FC\u30E0\u30B5\u30FC\u30D0\u30FC\u3092\u91CD\u8907\u3057\u3066\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
2685
- }
2686
- return nameservers;
2687
- }
2688
- function validateNameserverHostnames(nameservers, maximumLength) {
2689
- const hostnamePattern = /^[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?$/;
2690
- for (const nameserver of nameservers) {
2691
- if (nameserver.length > maximumLength || !hostnamePattern.test(nameserver)) {
2692
- throw new Error(`\u30CD\u30FC\u30E0\u30B5\u30FC\u30D0\u30FC\u306F\u5404${maximumLength}\u6587\u5B57\u4EE5\u5185\u306E\u30DB\u30B9\u30C8\u540D\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
2693
- }
2694
- }
2695
- }
2696
- function parseWhoisData(value) {
2697
- let parsed;
2698
- try {
2699
- parsed = JSON.parse(value);
2700
- } catch {
2701
- throw new Error("--data \u306F\u6709\u52B9\u306AJSON\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2702
- }
2703
- if (!isObject(parsed)) {
2704
- throw new Error("--data \u306FJSON\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2705
- }
2706
- if (Object.prototype.hasOwnProperty.call(parsed, "whois_privacy_flag")) {
2707
- throw new Error("whois_privacy_flag \u306F\u5EC3\u6B62\u3055\u308C\u3066\u3044\u307E\u3059\u3002whois_privacy \u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044");
2708
- }
2709
- const hasPrivacy = Object.prototype.hasOwnProperty.call(parsed, "whois_privacy");
2710
- const hasFields = Object.prototype.hasOwnProperty.call(parsed, "fields");
2711
- if (!hasPrivacy && !hasFields) {
2712
- throw new Error("--data \u306B\u306F whois_privacy \u307E\u305F\u306F fields \u306E\u3044\u305A\u308C\u304B\u304C\u5FC5\u8981\u3067\u3059");
2713
- }
2714
- if (hasPrivacy && typeof parsed.whois_privacy !== "boolean") {
2715
- throw new Error("whois_privacy \u306Fboolean\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2716
- }
2717
- if (hasFields && !isObject(parsed.fields)) {
2718
- throw new Error("fields \u306FJSON\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2719
- }
2720
- return parsed;
2721
- }
2722
- function validateDnsType(value) {
2723
- const type = value.toUpperCase();
2724
- if (!DNS_TYPES.has(type)) {
2725
- throw new Error("--type \u306F A / AAAA / CNAME / MX / TXT / NS / SRV \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2726
- }
2727
- return type;
2728
- }
2729
- function validateDnsHost(value) {
2730
- if (value.length === 0 || value.length > 64) {
2731
- throw new Error("--host \u306F1\uFF5E64\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2732
- }
2733
- return value;
2734
- }
2735
- function validateDnsContent(value) {
2736
- if (value.length === 0 || value.length > 1024) {
2737
- throw new Error("--content \u306F1\uFF5E1024\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2738
- }
2739
- return value;
2740
- }
2741
- function validateDnsId(value) {
2742
- if (!/^[1-9]\d*$/.test(value)) {
2743
- throw new Error("dns_id \u306F\u6B63\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2744
- }
2745
- return value;
2746
- }
2747
- function validateIdempotencyKey(value) {
2748
- if (!IDEMPOTENCY_KEY_PATTERN.test(value)) {
2749
- throw new Error("--idempotency-key \u306F\u82F1\u6570\u5B57\u30FB_\u30FB-\u306E8\uFF5E64\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
2750
- }
2751
- return value;
2752
- }
2753
- function validateDate(value, optionName) {
2754
- if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
2755
- throw new Error(`${optionName} \u306FYYYY-MM-DD\u5F62\u5F0F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
2756
- }
2757
- const [year, month, day] = value.split("-").map(Number);
2758
- const date = new Date(Date.UTC(year, month - 1, day));
2759
- if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
2760
- throw new Error(`${optionName} \u306B\u5B58\u5728\u3059\u308B\u65E5\u4ED8\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
2761
- }
2762
- return value;
2763
- }
2764
- function requireAtLeastOneField(data, message) {
2765
- if (Object.keys(data).length === 0) {
2766
- throw new Error(message);
2767
- }
2768
- }
2769
-
2770
- // ../core/dist/commands/domain/index.js
3317
+ import { randomUUID as randomUUID2 } from "crypto";
2771
3318
  function dnsData(opts) {
2772
3319
  return pickDefined({
2773
3320
  host: opts.host === void 0 ? void 0 : validateDnsHost(opts.host),
@@ -2782,7 +3329,7 @@ function addPurchaseOptions(command) {
2782
3329
  }
2783
3330
  function purchaseValues(opts) {
2784
3331
  const expectedTotalPrice = parseInteger(opts.expectedTotalPrice, "--expected-total-price", 0);
2785
- const idempotencyKey = validateIdempotencyKey(opts.idempotencyKey ?? randomUUID());
3332
+ const idempotencyKey = validateIdempotencyKey(opts.idempotencyKey ?? randomUUID2());
2786
3333
  return { expectedTotalPrice, idempotencyKey };
2787
3334
  }
2788
3335
  function requirePurchaseConfirmation(opts) {
@@ -2795,16 +3342,7 @@ function requireTermsAgreement(opts) {
2795
3342
  throw new Error("\u65B0\u898F\u53D6\u5F97\u30FB\u79FB\u7BA1\u306B\u306F --agree-to-terms \u306B\u3088\u308B\u300C\u30B5\u30FC\u30D3\u30B9\u5229\u7528\u898F\u7D04\u300D\u304A\u3088\u3073\u300C\u500B\u4EBA\u60C5\u5831\u306E\u53D6\u308A\u6271\u3044\u306B\u3064\u3044\u3066\u300D\u3078\u306E\u660E\u793A\u540C\u610F\u304C\u5FC5\u8981\u3067\u3059");
2796
3343
  }
2797
3344
  }
2798
- function printPurchaseWarning(operation, domain, totalPrice, brand) {
2799
- console.error([
2800
- `\u8AB2\u91D1\u64CD\u4F5C: ${operation}`,
2801
- `\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3: ${domain}`,
2802
- `\u7A0E\u8FBC\u5408\u8A08\u91D1\u984D: ${totalPrice}\u5186`,
2803
- ...domainLegalNoticeLines(brand),
2804
- "\u5B9F\u7533\u8ACB\u5F8C\u306F\u539F\u5247\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002"
2805
- ].join("\n"));
2806
- }
2807
- function totalPriceFromPreview(preview, expectedTotalPrice) {
3345
+ function totalPriceFromPreview2(preview, expectedTotalPrice) {
2808
3346
  const totalPrice = Number(preview?.total_price);
2809
3347
  if (!Number.isFinite(totalPrice)) {
2810
3348
  throw new Error("dry-run\u7D50\u679C\u304B\u3089\u5408\u8A08\u91D1\u984D\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
@@ -2905,18 +3443,23 @@ function registerDomainCommands(parent, brand) {
2905
3443
  printResult(preview, getFormat(parent));
2906
3444
  return;
2907
3445
  }
2908
- printPreview(preview, getFormat(parent));
2909
- const totalPrice = totalPriceFromPreview(preview, expectedTotalPrice);
2910
- printPurchaseWarning("\u30C9\u30E1\u30A4\u30F3\u65B0\u898F\u53D6\u5F97", domain, totalPrice, brand);
3446
+ const totalPrice = totalPriceFromPreview2(preview, expectedTotalPrice);
2911
3447
  requirePurchaseConfirmation(opts);
2912
3448
  await confirmBillingPurchase({
2913
3449
  operation: "\u30C9\u30E1\u30A4\u30F3\u65B0\u898F\u53D6\u5F97",
2914
- domain,
3450
+ target: domain,
3451
+ targetLabel: "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3",
2915
3452
  totalPrice,
2916
- brand
3453
+ legalNoticeLines: domainLegalNoticeLines(brand),
3454
+ confirmSubject: domain
2917
3455
  });
2918
- printIdempotencyKeyNotice(idempotencyKey, domain);
2919
- printResult(await withDomainAcquisitionPermissionDiagnosis(client2, () => client2.registerDomain({ ...baseData, dry_run: false }, idempotencyKey)), getFormat(parent));
3456
+ const result = await executeBillingPurchase({
3457
+ idempotencyKey,
3458
+ operation: "\u30C9\u30E1\u30A4\u30F3\u65B0\u898F\u53D6\u5F97",
3459
+ subject: domain,
3460
+ execute: () => withDomainAcquisitionPermissionDiagnosis(client2, () => client2.registerDomain({ ...baseData, dry_run: false }, idempotencyKey))
3461
+ });
3462
+ printResult(result, getFormat(parent));
2920
3463
  });
2921
3464
  addPurchaseOptions(parent.command("transfer <domain>").description("\u30C9\u30E1\u30A4\u30F3\u79FB\u7BA1\u3092\u7533\u8ACB").option("--agree-to-terms", "\u30C9\u30E1\u30A4\u30F3\u79FB\u7BA1\u306E\u300C\u30B5\u30FC\u30D3\u30B9\u5229\u7528\u898F\u7D04\u300D\u304A\u3088\u3073\u300C\u500B\u4EBA\u60C5\u5831\u306E\u53D6\u308A\u6271\u3044\u306B\u3064\u3044\u3066\u300D\u306B\u540C\u610F").requiredOption("--auth-code <code>", "\u79FB\u7BA1\u5143\u3067\u53D6\u5F97\u3057\u305FAuthCode")).action(async (domain, opts) => {
2922
3465
  requireTermsAgreement(opts);
@@ -2932,18 +3475,23 @@ function registerDomainCommands(parent, brand) {
2932
3475
  printResult(preview, getFormat(parent));
2933
3476
  return;
2934
3477
  }
2935
- printPreview(preview, getFormat(parent));
2936
- const totalPrice = totalPriceFromPreview(preview, expectedTotalPrice);
2937
- printPurchaseWarning("\u30C9\u30E1\u30A4\u30F3\u79FB\u7BA1", domain, totalPrice, brand);
3478
+ const totalPrice = totalPriceFromPreview2(preview, expectedTotalPrice);
2938
3479
  requirePurchaseConfirmation(opts);
2939
3480
  await confirmBillingPurchase({
2940
3481
  operation: "\u30C9\u30E1\u30A4\u30F3\u79FB\u7BA1",
2941
- domain,
3482
+ target: domain,
3483
+ targetLabel: "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3",
2942
3484
  totalPrice,
2943
- brand
3485
+ legalNoticeLines: domainLegalNoticeLines(brand),
3486
+ confirmSubject: domain
3487
+ });
3488
+ const result = await executeBillingPurchase({
3489
+ idempotencyKey,
3490
+ operation: "\u30C9\u30E1\u30A4\u30F3\u79FB\u7BA1",
3491
+ subject: domain,
3492
+ execute: () => withDomainAcquisitionPermissionDiagnosis(client2, () => client2.transferDomain(domain, { ...baseData, dry_run: false }, idempotencyKey))
2944
3493
  });
2945
- printIdempotencyKeyNotice(idempotencyKey, domain);
2946
- printResult(await withDomainAcquisitionPermissionDiagnosis(client2, () => client2.transferDomain(domain, { ...baseData, dry_run: false }, idempotencyKey)), getFormat(parent));
3494
+ printResult(result, getFormat(parent));
2947
3495
  });
2948
3496
  addPurchaseOptions(parent.command("renew <domain>").description("\u30C9\u30E1\u30A4\u30F3\u5951\u7D04\u3092\u66F4\u65B0").requiredOption("--years <n>", "\u66F4\u65B0\u5E74\u6570\uFF081\uFF5E5\uFF09").requiredOption("--current-expiry-date <date>", "\u73FE\u5728\u306E\u6709\u52B9\u671F\u9650\uFF08YYYY-MM-DD\uFF09")).action(async (domain, opts) => {
2949
3497
  const { expectedTotalPrice, idempotencyKey } = purchaseValues(opts);
@@ -2958,23 +3506,28 @@ function registerDomainCommands(parent, brand) {
2958
3506
  printResult(preview, getFormat(parent));
2959
3507
  return;
2960
3508
  }
2961
- printPreview(preview, getFormat(parent));
2962
- const totalPrice = totalPriceFromPreview(preview, expectedTotalPrice);
2963
- printPurchaseWarning("\u30C9\u30E1\u30A4\u30F3\u5951\u7D04\u66F4\u65B0", domain, totalPrice, brand);
3509
+ const totalPrice = totalPriceFromPreview2(preview, expectedTotalPrice);
2964
3510
  requirePurchaseConfirmation(opts);
2965
3511
  await confirmBillingPurchase({
2966
3512
  operation: "\u30C9\u30E1\u30A4\u30F3\u5951\u7D04\u66F4\u65B0",
2967
- domain,
3513
+ target: domain,
3514
+ targetLabel: "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3",
2968
3515
  totalPrice,
2969
- brand
3516
+ legalNoticeLines: domainLegalNoticeLines(brand),
3517
+ confirmSubject: domain
3518
+ });
3519
+ const result = await executeBillingPurchase({
3520
+ idempotencyKey,
3521
+ operation: "\u30C9\u30E1\u30A4\u30F3\u5951\u7D04\u66F4\u65B0",
3522
+ subject: domain,
3523
+ execute: () => withDomainAcquisitionPermissionDiagnosis(client2, () => client2.renewDomain(domain, { ...baseData, dry_run: false }, idempotencyKey))
2970
3524
  });
2971
- printIdempotencyKeyNotice(idempotencyKey, domain);
2972
- printResult(await withDomainAcquisitionPermissionDiagnosis(client2, () => client2.renewDomain(domain, { ...baseData, dry_run: false }, idempotencyKey)), getFormat(parent));
3525
+ printResult(result, getFormat(parent));
2973
3526
  });
2974
3527
  }
2975
3528
 
2976
3529
  // ../core/dist/commands/wphosting/index.js
2977
- import { randomUUID as randomUUID2 } from "crypto";
3530
+ import { randomUUID as randomUUID3 } from "crypto";
2978
3531
 
2979
3532
  // ../core/dist/lib/wphosting-validation.js
2980
3533
  var DNS_TYPES2 = /* @__PURE__ */ new Set(["A", "AAAA", "CNAME", "MX", "TXT", "SRV"]);
@@ -3116,7 +3669,7 @@ function siteCategory(parent, name, description) {
3116
3669
  return category;
3117
3670
  }
3118
3671
  function asyncKey(opts) {
3119
- const key = validateWphostingIdempotencyKey(String(opts.idempotencyKey ?? randomUUID2()));
3672
+ const key = validateWphostingIdempotencyKey(String(opts.idempotencyKey ?? randomUUID3()));
3120
3673
  console.error(`Idempotency-Key: ${key}\uFF08\u518D\u5B9F\u884C\u6642\u306F\u540C\u3058\u30AD\u30FC\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF09`);
3121
3674
  return key;
3122
3675
  }
@@ -3540,8 +4093,301 @@ function registerWphostingUsers(parent, brand) {
3540
4093
  });
3541
4094
  }
3542
4095
 
4096
+ // ../core/dist/commands/wphosting/account.js
4097
+ function explicitContractId(parent) {
4098
+ return validateWphostingContractId(String(parent.opts().contractId));
4099
+ }
4100
+ function registerWphostingAccountCommands(parent, brand) {
4101
+ parent.command("plans").description("\u7533\u8FBC\u53EF\u80FD\u306AWPhosting\u30D7\u30E9\u30F3\u3092\u53D6\u5F97").option("--plan-id <list>", "\u30D7\u30E9\u30F3ID\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09").action(async (opts) => {
4102
+ const params = opts.planId === void 0 ? void 0 : { plan_id: parsePlanIds(opts.planId) };
4103
+ printResult(await resolveClient(parent, brand).listWphostingPlans(params), getFormat(parent));
4104
+ });
4105
+ parent.command("contracts").description("WPhosting\u5951\u7D04").command("list").description("WPhosting\u5951\u7D04\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
4106
+ printResult(await resolveClient(parent, brand).listWphostingContracts(), getFormat(parent));
4107
+ });
4108
+ const memo = parent.command("memo").description("WPhosting\u5951\u7D04\u30E1\u30E2");
4109
+ memo.command("show").description("\u30E1\u30E2\u3092\u53D6\u5F97").action(async () => {
4110
+ const contractId2 = explicitContractId(parent);
4111
+ printResult(await resolveClient(parent, brand).getWphostingMemo(contractId2), getFormat(parent));
4112
+ });
4113
+ memo.command("update").description("\u30E1\u30E2\u3092\u66F4\u65B0").requiredOption("--memo <memo>", "\u30E1\u30E2\uFF08\u7A7A\u6587\u5B57\u53EF\u3001500\u6587\u5B57\u4EE5\u5185\uFF09").action(async (opts) => {
4114
+ const contractId2 = explicitContractId(parent);
4115
+ printResult(await resolveClient(parent, brand).updateWphostingMemo(contractId2, {
4116
+ memo: validateSignupMemo(opts.memo)
4117
+ }), getFormat(parent));
4118
+ });
4119
+ parent.command("signup").description("WPhosting\u3092\u65B0\u898F\u5951\u7D04").requiredOption("--plan-id <id>", "\u30D7\u30E9\u30F3ID").requiredOption("--period <months>", "\u5951\u7D04\u671F\u9593\uFF08\u6708\u6570\u3002wphosting plans \u304C\u8FD4\u3057\u305F months \u304B\u3089\u6307\u5B9A\uFF09").requiredOption("--expected-total-price <yen>", "\u4E8B\u524D\u78BA\u8A8D\u3057\u305F\u7A0E\u8FBC\u5408\u8A08\u91D1\u984D\uFF080\u4EE5\u4E0A\u306E\u6574\u6570\uFF09").option("--partner-code <code>", "\u30D1\u30FC\u30C8\u30CA\u30FC\u30B3\u30FC\u30C9\uFF08ASCII\u82F1\u6570\u5B57\u300150\u6587\u5B57\u4EE5\u5185\uFF09").option("--auto-renew <bool>", "\u81EA\u52D5\u66F4\u65B0\uFF08true / false\uFF09").option("--dry-run", "\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u307F\u5B9F\u884C").option("--confirm-purchase", "\u8AB2\u91D1\u3092\u4F34\u3046\u7533\u8ACB\u3092\u660E\u793A\u7684\u306B\u78BA\u8A8D").option("--agree-to-terms", "\u5229\u7528\u898F\u7D04\u306B\u540C\u610F").option("--idempotency-key <key>", "\u5B9F\u7533\u8ACB\u306E\u51AA\u7B49\u6027\u30AD\u30FC\uFF08\u82F1\u6570\u5B57\u30FB_\u30FB-\u306E8\uFF5E64\u6587\u5B57\uFF09").action(async (opts) => {
4120
+ const expectedTotalPrice = parseInteger(opts.expectedTotalPrice, "--expected-total-price", 0);
4121
+ const period = parseWphostingSignupPeriod(opts.period);
4122
+ const partnerCode = opts.partnerCode === void 0 ? void 0 : validatePartnerCode(opts.partnerCode);
4123
+ const autoRenew = opts.autoRenew === void 0 ? void 0 : parseAutoRenew(opts.autoRenew);
4124
+ const baseData = {
4125
+ plan_id: opts.planId,
4126
+ period,
4127
+ expected_total_price: expectedTotalPrice,
4128
+ agree_to_terms: true,
4129
+ ...pickDefined({
4130
+ partner_code: partnerCode,
4131
+ auto_renew: autoRenew
4132
+ })
4133
+ };
4134
+ const client2 = resolveClient(parent, brand);
4135
+ await runBillingPurchase({
4136
+ format: getFormat(parent),
4137
+ options: opts,
4138
+ operation: signupOperationName(brand, "wphosting"),
4139
+ targetLabel: "\u7533\u8FBC\u5185\u5BB9",
4140
+ resolveTarget: async () => {
4141
+ const planName = await resolvePlanName(() => client2.listWphostingPlans({ plan_id: opts.planId }), opts.planId);
4142
+ return {
4143
+ target: `${planLabel(opts.planId, planName)} / \u5951\u7D04\u671F\u9593 ${period}\u304B\u6708`,
4144
+ confirmSubject: `${planName ?? opts.planId} ${period}\u304B\u6708`
4145
+ };
4146
+ },
4147
+ details: compactDetails([
4148
+ autoRenewDetail(autoRenew ?? true, {
4149
+ fromDefault: autoRenew === void 0
4150
+ }),
4151
+ partnerCodeDetail(partnerCode)
4152
+ ]),
4153
+ legalNoticeLines: signupLegalNoticeLines(brand, "wphosting"),
4154
+ statusCommand: `${brand.commandName} wphosting contracts list`,
4155
+ preview: () => client2.registerWphosting({ ...baseData, dry_run: true }),
4156
+ execute: (idempotencyKey) => client2.registerWphosting({ ...baseData, dry_run: false }, idempotencyKey)
4157
+ });
4158
+ });
4159
+ }
4160
+
4161
+ // ../core/dist/lib/vps-validation.js
4162
+ var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4163
+ var PACKET_FILTER_TYPES = [
4164
+ "ssh",
4165
+ "web",
4166
+ "web_http",
4167
+ "mysql",
4168
+ "postgresql",
4169
+ "mail",
4170
+ "rdp",
4171
+ "custom"
4172
+ ];
4173
+ var PACKET_FILTER_PROTOCOLS = ["tcp", "udp", "icmp"];
4174
+ function isVpsSupportedBrand(brand) {
4175
+ return brand.brand === "xserver" || brand.brand === "shincloud";
4176
+ }
4177
+ function validateVpsUuid(value, optionName = "uuid") {
4178
+ if (!UUID_PATTERN.test(value)) {
4179
+ throw new Error(`${optionName} \u306F uuid\uFF088-4-4-4-12 \u306E\u5341\u516D\u9032\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
4180
+ }
4181
+ return value;
4182
+ }
4183
+ function validateVpsSignupId(value) {
4184
+ if (!/^[1-9]\d*$/.test(value)) {
4185
+ throw new Error("\u7533\u8FBC\u72B6\u6CC1\u306E id \u306F\u6B63\u306E\u6574\u6570\uFF08\u30B5\u30FC\u30D3\u30B9\u30B3\u30FC\u30C9\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
4186
+ }
4187
+ return value;
4188
+ }
4189
+ function validateVpsRuleId(value) {
4190
+ if (!/^[1-9]\d*$/.test(value)) {
4191
+ throw new Error("rule_id \u306F\u6B63\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
4192
+ }
4193
+ return value;
4194
+ }
4195
+ function parseVpsBoolean(value, optionName) {
4196
+ return parseStrictBoolean(value, optionName);
4197
+ }
4198
+ function validateVpsPacketFilterType(value) {
4199
+ if (!PACKET_FILTER_TYPES.includes(value)) {
4200
+ throw new Error(`--type \u306F ${PACKET_FILTER_TYPES.join(" / ")} \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
4201
+ }
4202
+ return value;
4203
+ }
4204
+ function validateVpsPacketFilterProtocol(value) {
4205
+ if (!PACKET_FILTER_PROTOCOLS.includes(value)) {
4206
+ throw new Error("--protocol \u306F tcp / udp / icmp \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
4207
+ }
4208
+ return value;
4209
+ }
4210
+ function validateVpsLength(value, optionName, maximum, minimum = 1) {
4211
+ if (value.length < minimum || value.length > maximum) {
4212
+ throw new Error(`${optionName} \u306F${minimum}\uFF5E${maximum}\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
4213
+ }
4214
+ return value;
4215
+ }
4216
+
4217
+ // ../core/dist/commands/vps/index.js
4218
+ function uuidArg(uuid) {
4219
+ return validateVpsUuid(uuid);
4220
+ }
4221
+ function registerVpsCommands(parent, brand) {
4222
+ parent.command("list").description("VPS\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
4223
+ printResult(await resolveClient(parent, brand).listVpsServers(), getFormat(parent));
4224
+ });
4225
+ parent.command("info <uuid>").description("VPS\u8A73\u7D30\u3092\u53D6\u5F97").action(async (uuid) => {
4226
+ printResult(await resolveClient(parent, brand).getVpsServer(uuidArg(uuid)), getFormat(parent));
4227
+ });
4228
+ const memo = parent.command("memo").description("VPS\u30E1\u30E2");
4229
+ memo.command("update <uuid>").description("\u30E1\u30E2\u3092\u5909\u66F4\uFF08\u7A7A\u6587\u5B57\u3067\u524A\u9664\uFF09").requiredOption("--memo <memo>", "\u30E1\u30E2\uFF08\u6700\u5927500\u6587\u5B57\uFF09").action(async (uuid, opts) => {
4230
+ printResult(await resolveClient(parent, brand).updateVpsMemo(uuidArg(uuid), {
4231
+ memo: validateVpsLength(opts.memo, "--memo", 500, 0)
4232
+ }), getFormat(parent));
4233
+ });
4234
+ const name = parent.command("name").description("VPS\u30B5\u30FC\u30D0\u30FC\u540D");
4235
+ name.command("update <uuid>").description("\u30B5\u30FC\u30D0\u30FC\u540D\u3092\u5909\u66F4").requiredOption("--name <name>", "\u30B5\u30FC\u30D0\u30FC\u540D\uFF08\u6700\u592750\u6587\u5B57\uFF09").action(async (uuid, opts) => {
4236
+ printResult(await resolveClient(parent, brand).updateVpsName(uuidArg(uuid), {
4237
+ name: validateVpsLength(opts.name, "--name", 50)
4238
+ }), getFormat(parent));
4239
+ });
4240
+ const reverseDns = parent.command("reverse-dns").description("\u9006\u5F15\u304D\u30DB\u30B9\u30C8\u540D");
4241
+ reverseDns.command("update <uuid>").description("\u9006\u5F15\u304D\u30DB\u30B9\u30C8\u540D\u3092\u5909\u66F4").requiredOption("--hostname <hostname>", "\u9006\u5F15\u304D\u30DB\u30B9\u30C8\u540D").action(async (uuid, opts) => {
4242
+ printResult(await resolveClient(parent, brand).updateVpsReverseDns(uuidArg(uuid), {
4243
+ hostname: validateVpsLength(opts.hostname, "--hostname", 253)
4244
+ }), getFormat(parent));
4245
+ });
4246
+ const power = parent.command("power").description("\u96FB\u6E90\u64CD\u4F5C\uFF08start/reboot/stop \u306F 202 Accepted\u3002\u9032\u6357\u306F power status \u3067\u78BA\u8A8D\uFF09");
4247
+ power.command("status <uuid>").description("\u96FB\u6E90\u72B6\u614B\u3092\u53D6\u5F97").action(async (uuid) => {
4248
+ printResult(await resolveClient(parent, brand).getVpsPower(uuidArg(uuid)), getFormat(parent));
4249
+ });
4250
+ power.command("start <uuid>").description("VPS\u3092\u8D77\u52D5").action(async (uuid) => {
4251
+ printResult(await resolveClient(parent, brand).startVpsPower(uuidArg(uuid)), getFormat(parent));
4252
+ });
4253
+ power.command("reboot <uuid>").description("VPS\u3092\u518D\u8D77\u52D5").option("--force", "\u5F37\u5236\u518D\u8D77\u52D5\uFF08\u96FB\u6E90\u65AD\u76F8\u5F53\u3002\u901A\u5E38\u306E\u518D\u8D77\u52D5\u3067\u5FDC\u7B54\u304C\u306A\u3044\u5834\u5408\uFF09").action(async (uuid, opts) => {
4254
+ const id = uuidArg(uuid);
4255
+ if (opts.force) {
4256
+ await confirmDestructiveAction(parent, `VPS ${id} \u3092\u5F37\u5236\u518D\u8D77\u52D5\u3057\u307E\u3059\uFF08\u96FB\u6E90\u65AD\u76F8\u5F53\uFF09\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
4257
+ }
4258
+ printResult(await resolveClient(parent, brand).rebootVpsPower(id, opts.force ? { force: true } : void 0), getFormat(parent));
4259
+ });
4260
+ power.command("stop <uuid>").description("VPS\u3092\u505C\u6B62").action(async (uuid) => {
4261
+ printResult(await resolveClient(parent, brand).stopVpsPower(uuidArg(uuid)), getFormat(parent));
4262
+ });
4263
+ const packetFilter = parent.command("packet-filter").description("\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC");
4264
+ packetFilter.command("get <uuid>").description("\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async (uuid) => {
4265
+ printResult(await resolveClient(parent, brand).getVpsPacketFilter(uuidArg(uuid)), getFormat(parent));
4266
+ });
4267
+ packetFilter.command("update <uuid>").description("\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC\u306E\u6709\u52B9/\u7121\u52B9\u3092\u5207\u66FF").requiredOption("--enabled <bool>", "true \u3067\u6709\u52B9 / false \u3067\u7121\u52B9").action(async (uuid, opts) => {
4268
+ printResult(await resolveClient(parent, brand).updateVpsPacketFilter(uuidArg(uuid), {
4269
+ enabled: parseVpsBoolean(opts.enabled, "--enabled")
4270
+ }), getFormat(parent));
4271
+ });
4272
+ packetFilter.command("add-rule <uuid>").description("\u30EB\u30FC\u30EB\u3092\u8FFD\u52A0").requiredOption("--type <type>", "ssh / web / web_http / mysql / postgresql / mail / rdp / custom").option("--protocol <protocol>", "tcp / udp / icmp\uFF08custom \u306F\u5FC5\u9808\uFF09").option("--port <port>", "\u30DD\u30FC\u30C8\u307E\u305F\u306F\u7BC4\u56F2\uFF08custom \u306F icmp \u4EE5\u5916\u3067\u5FC5\u9808\uFF09").option("--allowed-ip <cidr>", "\u8A31\u53EF\u3059\u308B\u63A5\u7D9A\u5143\uFF08custom \u306E\u307F\uFF09").option("--memo <memo>", "\u30E1\u30E2\uFF08custom \u306E\u307F\uFF09").action(async (uuid, opts) => {
4273
+ printResult(await resolveClient(parent, brand).addVpsPacketFilterRule(uuidArg(uuid), {
4274
+ type: validateVpsPacketFilterType(opts.type),
4275
+ ...pickDefined({
4276
+ protocol: opts.protocol === void 0 ? void 0 : validateVpsPacketFilterProtocol(opts.protocol),
4277
+ port: opts.port,
4278
+ allowed_ip: opts.allowedIp,
4279
+ memo: opts.memo
4280
+ })
4281
+ }), getFormat(parent));
4282
+ });
4283
+ packetFilter.command("update-rule <uuid> <ruleId>").description("\u30EB\u30FC\u30EB\u3092\u5909\u66F4").option("--protocol <protocol>", "tcp / udp / icmp").option("--port <port>", "\u30DD\u30FC\u30C8\u307E\u305F\u306F\u7BC4\u56F2").option("--allowed-ip <cidr>", "\u8A31\u53EF\u3059\u308B\u63A5\u7D9A\u5143").option("--memo <memo>", "\u30E1\u30E2").action(async (uuid, ruleId, opts) => {
4284
+ const data = pickDefined({
4285
+ protocol: opts.protocol === void 0 ? void 0 : validateVpsPacketFilterProtocol(opts.protocol),
4286
+ port: opts.port,
4287
+ allowed_ip: opts.allowedIp,
4288
+ memo: opts.memo
4289
+ });
4290
+ if (Object.keys(data).length === 0) {
4291
+ throw new Error("\u66F4\u65B0\u9805\u76EE\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
4292
+ }
4293
+ printResult(await resolveClient(parent, brand).updateVpsPacketFilterRule(uuidArg(uuid), validateVpsRuleId(ruleId), data), getFormat(parent));
4294
+ });
4295
+ packetFilter.command("delete-rule <uuid> <ruleId>").description("\u30EB\u30FC\u30EB\u3092\u524A\u9664").action(async (uuid, ruleId) => {
4296
+ const id = validateVpsRuleId(ruleId);
4297
+ await confirmDestructiveAction(parent, `\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC\u306E\u30EB\u30FC\u30EB ${id} \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
4298
+ printResult(await resolveClient(parent, brand).deleteVpsPacketFilterRule(uuidArg(uuid), id), getFormat(parent));
4299
+ });
4300
+ parent.command("os-images").description("\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3067\u304D\u308B\u30A4\u30E1\u30FC\u30B8\u4E00\u89A7\u3092\u53D6\u5F97").argument("<uuid>", "VPS\u306E uuid").action(async (uuid) => {
4301
+ printResult(await resolveClient(parent, brand).listVpsOsImages(uuidArg(uuid)), getFormat(parent));
4302
+ });
4303
+ const osReinstall = parent.command("os-reinstall").description("OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\uFF08\u30C7\u30FC\u30BF\u5168\u6D88\u53BB\u3002protection \u3067\u62D2\u5426\u3067\u304D\u307E\u3059\uFF09");
4304
+ osReinstall.command("run <uuid>").description("OS\u3092\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\uFF08\u505C\u6B62\u4E2D\u306EVPS\u304C\u5BFE\u8C61\u3002--yes \u5358\u72EC\u3067\u306F\u5B9F\u884C\u4E0D\u53EF\uFF09").requiredOption("--image-id <id>", "\u30A4\u30E1\u30FC\u30B8ID\uFF08os-images \u306E image_id\uFF09").requiredOption("--root-password <password>", "\u7BA1\u7406\u8005\u30D1\u30B9\u30EF\u30FC\u30C9\uFF089\u301C70\u6587\u5B57\uFF09").option("--ssh-key-name <name>", "\u767B\u9332\u6E08\u307FSSH\u30AD\u30FC\u540D").option("--ssh-public-key <key>", "\u767B\u9332\u3059\u308B\u516C\u958B\u9375\uFF08ssh-key-name \u3068\u4F75\u7528\uFF09").option("--basic-password <password>", "\u7BA1\u7406\u30C4\u30FC\u30EBBasic\u8A8D\u8A3C\uFF08requires_basic_password \u306E\u30A4\u30E1\u30FC\u30B8\u306E\u307F\uFF09").option("--confirm-reinstall", "\u30C7\u30FC\u30BF\u5168\u6D88\u53BB\u3092\u627F\u8A8D\uFF08\u5FC5\u9808\u3002--yes \u3067\u306F\u7701\u7565\u4E0D\u53EF\uFF09").action(async (uuid, opts) => {
4305
+ const id = uuidArg(uuid);
4306
+ const rootPassword = validateVpsLength(opts.rootPassword, "--root-password", 70, 9);
4307
+ const client2 = resolveClient(parent, brand);
4308
+ let imageName = opts.imageId;
4309
+ if (opts.confirmReinstall === true && isInteractiveTerminal()) {
4310
+ imageName = vpsOsImageName(await client2.listVpsOsImages(id), opts.imageId) ?? "";
4311
+ if (!imageName) {
4312
+ throw new Error(`--image-id ${opts.imageId} \u306EOS\u30A4\u30E1\u30FC\u30B8\u540D\u3092\u53D6\u5F97\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002`);
4313
+ }
4314
+ }
4315
+ await confirmOsReinstall(parent, id, opts.confirmReinstall === true, opts.imageId, imageName);
4316
+ printResult(await client2.reinstallVpsOs(id, {
4317
+ image_id: opts.imageId,
4318
+ root_password: rootPassword,
4319
+ ...pickDefined({
4320
+ ssh_key_name: opts.sshKeyName,
4321
+ ssh_public_key: opts.sshPublicKey,
4322
+ basic_password: opts.basicPassword
4323
+ })
4324
+ }), getFormat(parent));
4325
+ });
4326
+ osReinstall.command("status <uuid>").description("OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306E\u72B6\u6CC1\u3092\u78BA\u8A8D").action(async (uuid) => {
4327
+ printResult(await resolveClient(parent, brand).getVpsOsReinstall(uuidArg(uuid)), getFormat(parent));
4328
+ });
4329
+ const protection = parent.command("protection").description("\u64CD\u4F5C\u4FDD\u8B77\uFF08API\u304B\u3089\u306EOS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092VPS\u5358\u4F4D\u3067\u62D2\u5426\uFF09");
4330
+ protection.command("get <uuid>").description("\u64CD\u4F5C\u4FDD\u8B77\u306E\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async (uuid) => {
4331
+ printResult(await resolveClient(parent, brand).getVpsProtection(uuidArg(uuid)), getFormat(parent));
4332
+ });
4333
+ protection.command("set <uuid>").description("\u64CD\u4F5C\u4FDD\u8B77\u306E\u8A2D\u5B9A\u3092\u5909\u66F4").requiredOption("--os-reinstall <bool>", "true \u3067\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u62D2\u5426 / false \u3067\u89E3\u9664").action(async (uuid, opts) => {
4334
+ printResult(await resolveClient(parent, brand).updateVpsProtection(uuidArg(uuid), {
4335
+ os_reinstall: parseVpsBoolean(opts.osReinstall, "--os-reinstall")
4336
+ }), getFormat(parent));
4337
+ });
4338
+ parent.command("plans").description("\u304A\u7533\u3057\u8FBC\u307F\u53EF\u80FD\u306A\u30D7\u30E9\u30F3\u30FB\u6599\u91D1\u3092\u53D6\u5F97").action(async () => {
4339
+ printResult(await resolveClient(parent, brand).listVpsPlans(), getFormat(parent));
4340
+ });
4341
+ parent.command("signup-status <id>").description("\u304A\u7533\u3057\u8FBC\u307F\u72B6\u6CC1\u3092\u78BA\u8A8D\uFF08id \u306F\u7533\u8FBC\u5FDC\u7B54\u306E\u30B5\u30FC\u30D3\u30B9\u30B3\u30FC\u30C9\uFF09").action(async (id) => {
4342
+ printResult(await resolveClient(parent, brand).getVpsSignupStatus(validateVpsSignupId(id)), getFormat(parent));
4343
+ });
4344
+ parent.command("signup").description(brand.brand === "shincloud" ? "\u30B7\u30F3VPS\u3092\u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F\uFF08\u30B9\u30BF\u30F3\u30C0\u30FC\u30C9\u30FB\u5927\u5BB9\u91CF\u30E1\u30E2\u30EA\u3002\u30D7\u30EA\u30DA\u30A4\u30C9\u306E\u307F\uFF09" : "VPS\u3092\u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F\uFF08VPS\u30FB\u30D3\u30B8\u30CD\u30B9VPS\u3002\u30D7\u30EA\u30DA\u30A4\u30C9\u306E\u307F\uFF09").requiredOption("--plan-id <id>", brand.brand === "shincloud" ? "\u30D7\u30E9\u30F3ID\uFF08vps-2gb / vps-highmem-4gb \u306A\u3069\uFF09" : "\u30D7\u30E9\u30F3ID\uFF08vps-4gb / business-4gb \u306A\u3069\uFF09").requiredOption("--period <months>", "\u5951\u7D04\u671F\u9593\uFF08\u6708\u6570\u3002plans \u304C\u8FD4\u3057\u305F months \u304B\u3089\u6307\u5B9A\uFF09").requiredOption("--image-id <id>", "OS\u30A4\u30E1\u30FC\u30B8ID\uFF08plans \u306E os_images[].image_id\uFF09").requiredOption("--root-password <password>", "root\u30D1\u30B9\u30EF\u30FC\u30C9\uFF089\u301C70\u6587\u5B57\uFF09").requiredOption("--expected-total-price <yen>", "plans \u304C\u8FD4\u3057\u305F\u7A0E\u8FBC\u5408\u8A08\u91D1\u984D").option("--name <name>", "\u30B5\u30FC\u30D0\u30FC\u540D").option("--ssh-key-name <name>", "\u767B\u9332\u6E08\u307FSSH\u30AD\u30FC\u540D").option("--ssh-public-key <key>", "\u767B\u9332\u3059\u308B\u516C\u958B\u9375\uFF08ssh-key-name \u3068\u4F75\u7528\uFF09").option("--partner-code <code>", "\u304A\u53D6\u6B21\u5E97\u30B3\u30FC\u30C9").option("--auto-renew <bool>", "\u81EA\u52D5\u66F4\u65B0\uFF08true / false\u3002\u7701\u7565\u6642\u306F true\uFF09").option("--dry-run", "\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u307F\u5B9F\u884C").option("--confirm-purchase", "\u8AB2\u91D1\u3092\u4F34\u3046\u7533\u8ACB\u3092\u660E\u793A\u7684\u306B\u78BA\u8A8D").option("--agree-to-terms", "\u5229\u7528\u898F\u7D04\u306B\u540C\u610F").option("--idempotency-key <key>", "\u5B9F\u7533\u8ACB\u306E\u51AA\u7B49\u6027\u30AD\u30FC\uFF08\u82F1\u6570\u5B57\u30FB_\u30FB-\u306E8\uFF5E64\u6587\u5B57\uFF09").action(async (opts) => {
4345
+ const expectedTotalPrice = parseInteger(opts.expectedTotalPrice, "--expected-total-price", 0);
4346
+ const period = parseSignupPeriod(opts.period);
4347
+ const partnerCode = opts.partnerCode === void 0 ? void 0 : validatePartnerCode(opts.partnerCode);
4348
+ const autoRenew = opts.autoRenew === void 0 ? void 0 : parseAutoRenew(opts.autoRenew);
4349
+ const baseData = {
4350
+ plan_id: opts.planId,
4351
+ period,
4352
+ image_id: opts.imageId,
4353
+ root_password: validateVpsLength(opts.rootPassword, "--root-password", 70, 9),
4354
+ expected_total_price: expectedTotalPrice,
4355
+ agree_to_terms: true,
4356
+ ...pickDefined({
4357
+ name: opts.name,
4358
+ ssh_key_name: opts.sshKeyName,
4359
+ ssh_public_key: opts.sshPublicKey,
4360
+ partner_code: partnerCode,
4361
+ auto_renew: autoRenew
4362
+ })
4363
+ };
4364
+ const client2 = resolveClient(parent, brand);
4365
+ await runBillingPurchase({
4366
+ format: getFormat(parent),
4367
+ options: opts,
4368
+ operation: signupOperationName(brand, "vps", opts.planId),
4369
+ targetLabel: "\u7533\u8FBC\u5185\u5BB9",
4370
+ resolveTarget: async () => {
4371
+ const planName = await resolvePlanName(() => client2.listVpsPlans(), opts.planId);
4372
+ return {
4373
+ target: `${planLabel(opts.planId, planName)} / \u5951\u7D04\u671F\u9593 ${period}\u304B\u6708 / ${opts.imageId}`,
4374
+ confirmSubject: `${planName ?? opts.planId} ${period}\u304B\u6708`
4375
+ };
4376
+ },
4377
+ details: compactDetails([
4378
+ autoRenewDetail(autoRenew ?? true, { fromDefault: autoRenew === void 0 }),
4379
+ partnerCodeDetail(partnerCode)
4380
+ ]),
4381
+ legalNoticeLines: signupLegalNoticeLines(brand, "vps", opts.planId),
4382
+ statusCommand: `${brand.commandName} vps signup-status <id>`,
4383
+ preview: () => client2.registerVps({ ...baseData, dry_run: true }),
4384
+ execute: (idempotencyKey) => client2.registerVps({ ...baseData, dry_run: false }, idempotencyKey)
4385
+ });
4386
+ });
4387
+ }
4388
+
3543
4389
  // ../core/dist/index.js
3544
- function run(brand, version = "0.0.0") {
4390
+ function createProgram(brand, version = "0.0.0") {
3545
4391
  const program = new Command();
3546
4392
  program.name(brand.commandName).description(`${brand.displayName} CLI`).version(version).option("--format <format>", "\u51FA\u529B\u5F62\u5F0F (json, table)", (value) => {
3547
4393
  if (!["json", "table"].includes(value)) {
@@ -3552,12 +4398,18 @@ function run(brand, version = "0.0.0") {
3552
4398
  registerAuthCommands(program, brand);
3553
4399
  registerMeCommand(program, brand);
3554
4400
  if (isWphostingSupportedBrand(brand)) {
3555
- const wphosting = program.command("wphosting").description("XServer for WordPress API").requiredOption("--contract-id <id>", "WPhosting\u5951\u7D04ID\uFF08\u4F8B: WP-AB234567\uFF09");
4401
+ const wphosting = program.command("wphosting").description("XServer for WordPress API").option("--contract-id <id>", "WPhosting\u5951\u7D04ID\uFF08\u4F8B: WP-AB234567\uFF09");
4402
+ registerWphostingAccountCommands(wphosting, brand);
3556
4403
  registerWphostingCommands(wphosting, brand);
3557
4404
  }
4405
+ if (isVpsSupportedBrand(brand)) {
4406
+ const vps = program.command("vps").description(brand.brand === "shincloud" ? "VPS API\uFF08\u30B7\u30F3VPS\uFF09" : "VPS API\uFF08XServer VPS\uFF09");
4407
+ registerVpsCommands(vps, brand);
4408
+ }
3558
4409
  const domain = program.command("domain").description("\u30C9\u30E1\u30A4\u30F3\u30B5\u30FC\u30D3\u30B9API\uFF08\u53D6\u5F97\u30FB\u5951\u7D04\u30FBDNS\u30FBWhois\u306A\u3069\uFF09");
3559
4410
  registerDomainCommands(domain, brand);
3560
4411
  const server = program.command("server").description("\u30B5\u30FC\u30D0\u30FC\u7BA1\u7406API\uFF08WordPress\u30FB\u30E1\u30FC\u30EB\u30FBDB\u306A\u3069\uFF09").option("--servername <name>", "\u30B5\u30FC\u30D0\u30FC\u540D\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u4E0A\u66F8\u304D\uFF09");
4412
+ registerServerAccountCommands(server, brand);
3561
4413
  registerServerInfoCommands(server, brand);
3562
4414
  registerCronCommands(server, brand);
3563
4415
  registerSshCommands(server, brand);
@@ -3590,23 +4442,41 @@ function run(brand, version = "0.0.0") {
3590
4442
  registerXPageSpeedCommands(server, brand);
3591
4443
  registerAutoBackupCommands(server, brand);
3592
4444
  registerMysqlBackupCommands(server, brand);
4445
+ return program;
4446
+ }
4447
+ function run(brand, version = "0.0.0") {
4448
+ const program = createProgram(brand, version);
3593
4449
  program.parseAsync(process.argv).catch((err) => {
4450
+ const resendGuidance = billingResendGuidance(err);
4451
+ const printResendGuidance = () => {
4452
+ for (const line of resendGuidance ?? []) {
4453
+ console.error(line);
4454
+ }
4455
+ };
3594
4456
  if (err instanceof ApiError) {
3595
- console.error(`\u30A8\u30E9\u30FC [${err.errorCode}]: ${err.message}`);
4457
+ console.error(`\u30A8\u30E9\u30FC [${sanitizeTerminalText(err.errorCode)}]: ${sanitizeTerminalText(err.message)}`);
3596
4458
  if (err.errors.length > 0) {
3597
4459
  for (const e of err.errors) {
3598
- console.error(` - ${e}`);
4460
+ console.error(` - ${sanitizeTerminalText(e)}`);
3599
4461
  }
3600
4462
  }
4463
+ printResendGuidance();
4464
+ process.exitCode = 1;
4465
+ return;
4466
+ }
4467
+ if (err instanceof BillingCancelledError) {
4468
+ console.error(err.message);
3601
4469
  process.exitCode = 1;
3602
4470
  return;
3603
4471
  }
3604
4472
  if (err instanceof Error) {
3605
4473
  console.error(`\u30A8\u30E9\u30FC: ${err.message}`);
4474
+ printResendGuidance();
3606
4475
  process.exitCode = 1;
3607
4476
  return;
3608
4477
  }
3609
4478
  console.error("\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F");
4479
+ printResendGuidance();
3610
4480
  process.exitCode = 1;
3611
4481
  });
3612
4482
  }
@@ -3614,7 +4484,7 @@ function run(brand, version = "0.0.0") {
3614
4484
  // package.json
3615
4485
  var package_default = {
3616
4486
  name: "star8-cli",
3617
- version: "1.3.0",
4487
+ version: "1.5.0",
3618
4488
  description: "Official CLI for Star8 API \u2014 manage your Star8 hosting from the terminal",
3619
4489
  type: "module",
3620
4490
  bin: {
@@ -3661,8 +4531,11 @@ run({
3661
4531
  brand: "star8",
3662
4532
  apiBase: "https://api.star.ne.jp",
3663
4533
  displayName: "Star8 API",
4534
+ serverServiceName: "\u30B9\u30BF\u30FC\u30EC\u30F3\u30BF\u30EB\u30B5\u30FC\u30D0\u30FC",
3664
4535
  domainTermsUrl: "https://www.star-domain.jp/rule/rule.php",
3665
4536
  domainPrivacyUrl: "https://www.star-domain.jp/privacy_announcement.php",
4537
+ serverTermsUrl: "https://www.star.ne.jp/rule/rule.php",
4538
+ serverPrivacyUrl: "https://www.star.ne.jp/privacy_announcement.php",
3666
4539
  commandName: "star8",
3667
4540
  configDir: "star8-cli"
3668
4541
  }, package_default.version);