dsh-plugin-opc 0.1.20 → 0.1.22
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/lib/client.js +49 -66
- package/lib/index.js +37 -8
- package/package.json +1 -1
- package/runtime/app_delivery_migration.py +33 -21
package/lib/client.js
CHANGED
|
@@ -56451,6 +56451,7 @@ function sanitizeConfigRowsForApi(configs) {
|
|
|
56451
56451
|
key: (c.key || "").trim(),
|
|
56452
56452
|
value: c.resource_id ? "" : c.value ?? "",
|
|
56453
56453
|
resource_id: c.resource_id || void 0,
|
|
56454
|
+
has_value: !c.resource_id && !(c.value ?? "") && c.has_value === true ? true : void 0,
|
|
56454
56455
|
local_connection_confirmed: c.local_connection_confirmed === true ? true : void 0
|
|
56455
56456
|
})).filter((c) => c.key.length > 0);
|
|
56456
56457
|
}
|
|
@@ -56523,7 +56524,6 @@ function AppsPanel({
|
|
|
56523
56524
|
const [appName, setAppName] = (0, import_react8.useState)("");
|
|
56524
56525
|
const [appSlug, setAppSlug] = (0, import_react8.useState)("");
|
|
56525
56526
|
const [slugManual, setSlugManual] = (0, import_react8.useState)(false);
|
|
56526
|
-
const [containerPort, setContainerPort] = (0, import_react8.useState)("8080");
|
|
56527
56527
|
const [appDescription, setAppDescription] = (0, import_react8.useState)("");
|
|
56528
56528
|
const [zipFile, setZipFile] = (0, import_react8.useState)(null);
|
|
56529
56529
|
const [sourcePath, setSourcePath] = (0, import_react8.useState)("");
|
|
@@ -56625,11 +56625,6 @@ function AppsPanel({
|
|
|
56625
56625
|
(0, import_react8.useEffect)(() => {
|
|
56626
56626
|
void loadWorkspaceData(false);
|
|
56627
56627
|
}, [loadWorkspaceData, refreshSignal]);
|
|
56628
|
-
(0, import_react8.useEffect)(() => {
|
|
56629
|
-
if (viewMode === "wizard" && wizardStep === 1 && !wizardJob && !upgradeTarget) {
|
|
56630
|
-
setContainerPort(String(opcConfig.defaultPort));
|
|
56631
|
-
}
|
|
56632
|
-
}, [opcConfig.defaultPort, upgradeTarget, viewMode, wizardJob, wizardStep]);
|
|
56633
56628
|
(0, import_react8.useEffect)(() => {
|
|
56634
56629
|
if (modelGroups.length === 0) return;
|
|
56635
56630
|
const currentGroup = modelGroups.find((g) => g.id === selectedProvider) ?? modelGroups[0];
|
|
@@ -56725,38 +56720,48 @@ function AppsPanel({
|
|
|
56725
56720
|
const detail = job.upgrade || job.published ? parseJson(await api.appDetails(job.slug, contextId).catch(() => "null"), null) : null;
|
|
56726
56721
|
const detailConfigMap = new Map((detail?.app_config ?? []).map((item) => [item.key, item]));
|
|
56727
56722
|
const boundResources = detail?.resource_ids?.length ? resources.filter((resource) => detail.resource_ids?.includes(resource.id)) : [];
|
|
56728
|
-
const mergedConfigs = !draft && detail ?
|
|
56729
|
-
|
|
56730
|
-
|
|
56731
|
-
|
|
56732
|
-
|
|
56733
|
-
|
|
56734
|
-
|
|
56735
|
-
|
|
56736
|
-
|
|
56737
|
-
|
|
56738
|
-
|
|
56739
|
-
|
|
56740
|
-
|
|
56741
|
-
|
|
56742
|
-
|
|
56743
|
-
|
|
56744
|
-
|
|
56745
|
-
|
|
56746
|
-
|
|
56747
|
-
|
|
56748
|
-
|
|
56749
|
-
|
|
56750
|
-
|
|
56751
|
-
|
|
56752
|
-
|
|
56753
|
-
|
|
56754
|
-
|
|
56755
|
-
|
|
56756
|
-
|
|
56757
|
-
|
|
56758
|
-
|
|
56759
|
-
|
|
56723
|
+
const mergedConfigs = !draft && detail ? [
|
|
56724
|
+
...configs.map((config2) => {
|
|
56725
|
+
const online = detailConfigMap.get(config2.key);
|
|
56726
|
+
const matchedResource = boundResources.find((resource) => resource.id === online?.resource_id || resource.env_keys.includes(config2.key));
|
|
56727
|
+
if (matchedResource) {
|
|
56728
|
+
return { ...config2, value: "", value_source: "resource", resource_id: matchedResource.id };
|
|
56729
|
+
}
|
|
56730
|
+
if (!online) return config2;
|
|
56731
|
+
if (config2.key === "PORT") return config2;
|
|
56732
|
+
if (online.resource_id) {
|
|
56733
|
+
return { ...config2, value: "", value_source: "resource", resource_id: online.resource_id };
|
|
56734
|
+
}
|
|
56735
|
+
if (typeof online.value === "string" && online.value !== "") {
|
|
56736
|
+
return {
|
|
56737
|
+
...config2,
|
|
56738
|
+
value: online.value,
|
|
56739
|
+
value_source: online.value_source || "manual",
|
|
56740
|
+
has_value: true,
|
|
56741
|
+
local_connection_confirmed: Boolean(online.local_connection_confirmed || config2.local_connection_confirmed)
|
|
56742
|
+
};
|
|
56743
|
+
}
|
|
56744
|
+
if (config2.secret || online.secret) {
|
|
56745
|
+
return {
|
|
56746
|
+
...config2,
|
|
56747
|
+
has_value: Boolean(config2.has_value || online.has_value || online.value),
|
|
56748
|
+
local_connection_confirmed: Boolean(online.local_connection_confirmed || config2.local_connection_confirmed)
|
|
56749
|
+
};
|
|
56750
|
+
}
|
|
56751
|
+
if (online.local_connection_confirmed) {
|
|
56752
|
+
return { ...config2, local_connection_confirmed: true };
|
|
56753
|
+
}
|
|
56754
|
+
return config2;
|
|
56755
|
+
}),
|
|
56756
|
+
...(detail.app_config ?? []).filter((online) => {
|
|
56757
|
+
const key = (online.key || "").trim();
|
|
56758
|
+
if (!key || key === "PORT" || key.startsWith("OPC_STORAGE_")) return false;
|
|
56759
|
+
return !configs.some((cfg) => cfg.key === key);
|
|
56760
|
+
}).map((online) => ({
|
|
56761
|
+
...online,
|
|
56762
|
+
has_value: Boolean(online.has_value || online.value || online.resource_id)
|
|
56763
|
+
}))
|
|
56764
|
+
] : configs;
|
|
56760
56765
|
setConfigDrafts(mergedConfigs);
|
|
56761
56766
|
setOriginalConfigs(originals);
|
|
56762
56767
|
setVersionNote(draft?.versionNote ?? job.versionNote ?? "");
|
|
@@ -56900,7 +56905,6 @@ function AppsPanel({
|
|
|
56900
56905
|
setAppName(upgradeApp?.name ?? prevJob?.name ?? "");
|
|
56901
56906
|
setAppSlug(upgradeApp?.slug ?? prevJob?.slug ?? "");
|
|
56902
56907
|
setSlugManual(Boolean(upgradeApp || prevJob));
|
|
56903
|
-
setContainerPort(String(upgradeApp?.container_port ?? prevJob?.port ?? opcConfig.defaultPort));
|
|
56904
56908
|
setAppDescription(upgradeApp?.description ?? prevJob?.description ?? "");
|
|
56905
56909
|
sourceSelection.current++;
|
|
56906
56910
|
setDragActive(false);
|
|
@@ -56910,7 +56914,7 @@ function AppsPanel({
|
|
|
56910
56914
|
setVerifyCredentials({});
|
|
56911
56915
|
setRememberCredentials(false);
|
|
56912
56916
|
},
|
|
56913
|
-
[
|
|
56917
|
+
[]
|
|
56914
56918
|
);
|
|
56915
56919
|
const resumeWizardJob = (0, import_react8.useCallback)(
|
|
56916
56920
|
async (job, overrideStep, useSnapshot = false) => {
|
|
@@ -56930,13 +56934,12 @@ function AppsPanel({
|
|
|
56930
56934
|
setAppName(fresh.name);
|
|
56931
56935
|
setAppSlug(fresh.slug);
|
|
56932
56936
|
setSlugManual(true);
|
|
56933
|
-
setContainerPort(String(fresh.port ?? opcConfig.defaultPort));
|
|
56934
56937
|
setAppDescription(fresh.description ?? "");
|
|
56935
56938
|
} else if (targetStep === 3) {
|
|
56936
56939
|
await syncStep3Drafts(fresh);
|
|
56937
56940
|
}
|
|
56938
56941
|
},
|
|
56939
|
-
[apps,
|
|
56942
|
+
[apps, refreshWizardJob, syncStep3Drafts]
|
|
56940
56943
|
);
|
|
56941
56944
|
const openLinkedJob = (0, import_react8.useCallback)(async (job, refresh = true) => {
|
|
56942
56945
|
const fresh = refresh ? await refreshWizardJob(job.id) ?? job : job;
|
|
@@ -56986,11 +56989,6 @@ function AppsPanel({
|
|
|
56986
56989
|
setWizardError("\u8BE5\u5E94\u7528\u6807\u8BC6\u5DF2\u88AB\u5360\u7528\uFF0C\u8BF7\u66F4\u6362\u5176\u4ED6\u6807\u8BC6");
|
|
56987
56990
|
return;
|
|
56988
56991
|
}
|
|
56989
|
-
const parsedPort = Number.parseInt(containerPort, 10);
|
|
56990
|
-
if (!Number.isInteger(parsedPort) || parsedPort < 1 || parsedPort > 65535) {
|
|
56991
|
-
setWizardError("\u5BB9\u5668\u7AEF\u53E3\u5FC5\u987B\u4E3A 1 \u81F3 65535 \u4E4B\u95F4\u7684\u6574\u6570");
|
|
56992
|
-
return;
|
|
56993
|
-
}
|
|
56994
56992
|
if (!zipFile && !sourcePath.trim()) {
|
|
56995
56993
|
setWizardError("\u8BF7\u9009\u62E9\u6E90\u7801\u6587\u4EF6\u5939\u6216 ZIP\uFF0C\u6216\u8005\u586B\u5199\u5B8C\u6574\u8DEF\u5F84");
|
|
56996
56994
|
return;
|
|
@@ -57001,7 +56999,6 @@ function AppsPanel({
|
|
|
57001
56999
|
const payload = {
|
|
57002
57000
|
name: cleanName,
|
|
57003
57001
|
slug: cleanSlug,
|
|
57004
|
-
container_port: parsedPort,
|
|
57005
57002
|
description: appDescription.trim(),
|
|
57006
57003
|
upgrade: upgradingStep1,
|
|
57007
57004
|
previousJobId: previousJobId || void 0,
|
|
@@ -57520,9 +57517,9 @@ function AppsPanel({
|
|
|
57520
57517
|
{ id: 4, label: "\u90E8\u7F72\u4E0E\u4F7F\u7528" }
|
|
57521
57518
|
];
|
|
57522
57519
|
const upgrading = Boolean(upgradeTarget || wizardJob?.upgrade || wizardJob?.published);
|
|
57523
|
-
const
|
|
57520
|
+
const effectiveStep1Port = upgradeTarget?.container_port ?? wizardJob?.port ?? opcConfig.defaultPort;
|
|
57524
57521
|
const slugValid = SLUG_RE.test(toAppSlug(appSlug, { allowTrailingDash: false }));
|
|
57525
|
-
const canSubmitStep1 = !wizardBusy && appName.trim().length > 0 && slugValid && (upgradingStep1 || slugCheck.available !== false) &&
|
|
57522
|
+
const canSubmitStep1 = !wizardBusy && appName.trim().length > 0 && slugValid && (upgradingStep1 || slugCheck.available !== false) && Boolean(zipFile || sourcePath.trim());
|
|
57526
57523
|
const missingConfigAlert = wizardJob ? validateConfigsForPublish(configDrafts, wizardJob.port ?? opcConfig.defaultPort) || (Object.values(storageSelections).some((id) => !id) ? "\u65B0\u589E\u6301\u4E45\u5316\u76EE\u5F55\u9700\u8981\u5DF2\u542F\u7528\u7684 Platform \u5377\u8D44\u6E90" : null) : null;
|
|
57527
57524
|
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-overlay-view" }, /* @__PURE__ */ import_react8.default.createElement("header", { className: "oa-overlay-header oa-wizard-header" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-wizard-heading" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-wizard-identity" }, /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-wizard-icon" }, /* @__PURE__ */ import_react8.default.createElement(AppIcon, { name: upgrading ? "refresh" : "plus", size: 16 })), /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-wizard-title" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-wizard-title-line" }, /* @__PURE__ */ import_react8.default.createElement("h2", null, upgrading ? "\u5347\u7EA7\u5E94\u7528\u5E76\u90E8\u7F72\u65B0\u7248\u672C" : "\u65B0\u5EFA\u5E76\u90E8\u7F72\u5E94\u7528"), (wizardJob?.slug || appSlug) && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-code", title: wizardJob?.slug || appSlug }, wizardJob?.slug || appSlug)), /* @__PURE__ */ import_react8.default.createElement("p", null, upgrading ? "\u9009\u62E9\u65B0\u7248\u6E90\u7801\uFF0C\u7531 AI \u68C0\u67E5\u6539\u9020\u65B9\u6848\uFF0C\u518D\u6838\u5BF9\u5E76\u90E8\u7F72\u3002" : "\u9009\u62E9\u5E94\u7528\uFF0CAI \u5B8C\u6210\u6280\u672F\u51C6\u5907\uFF0C\u4F60\u53EA\u9700\u5904\u7406\u5FC5\u8981\u95EE\u9898\u5E76\u786E\u8BA4\u90E8\u7F72\u3002"))), /* @__PURE__ */ import_react8.default.createElement(
|
|
57528
57525
|
"button",
|
|
@@ -57608,19 +57605,7 @@ function AppsPanel({
|
|
|
57608
57605
|
appSlug.trim() || "your-app",
|
|
57609
57606
|
".",
|
|
57610
57607
|
opcConfig.appDomainRoot
|
|
57611
|
-
), !upgradingStep1 && slugCheck.checking && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill" }, "\u6B63\u5728\u6821\u9A8C\u2026"), !upgradingStep1 && !slugCheck.checking && !slugCheck.error && slugCheck.available && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill oa-pill-ok" }, "\u6807\u8BC6\u53EF\u7528")), /* @__PURE__ */ import_react8.default.createElement("span", { style: { fontSize: 11.5, color: "#64748b", flexShrink: 0 } }, "(\u5BB9\u5668\u7AEF\u53E3: ",
|
|
57612
|
-
"input",
|
|
57613
|
-
{
|
|
57614
|
-
id: `${formId}-container-port`,
|
|
57615
|
-
className: "oa-input oa-mono",
|
|
57616
|
-
type: "number",
|
|
57617
|
-
min: 1,
|
|
57618
|
-
max: 65535,
|
|
57619
|
-
value: containerPort,
|
|
57620
|
-
placeholder: String(opcConfig.defaultPort),
|
|
57621
|
-
onChange: (e) => setContainerPort(e.target.value)
|
|
57622
|
-
}
|
|
57623
|
-
), /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-hint" }, "\u9ED8\u8BA4 ", opcConfig.defaultPort, "\uFF1B\u82E5\u6E90\u7801\u6216 Dockerfile \u76D1\u542C\u5176\u4ED6\u7AEF\u53E3\u53EF\u5728\u6B64\u8C03\u6574\u3002")), /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-field" }, /* @__PURE__ */ import_react8.default.createElement("label", { className: "oa-label", htmlFor: `${formId}-description` }, "\u5E94\u7528\u63CF\u8FF0"), /* @__PURE__ */ import_react8.default.createElement(
|
|
57608
|
+
), !upgradingStep1 && slugCheck.checking && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill" }, "\u6B63\u5728\u6821\u9A8C\u2026"), !upgradingStep1 && !slugCheck.checking && !slugCheck.error && slugCheck.available && /* @__PURE__ */ import_react8.default.createElement("span", { className: "oa-pill oa-pill-ok" }, "\u6807\u8BC6\u53EF\u7528")), /* @__PURE__ */ import_react8.default.createElement("span", { style: { fontSize: 11.5, color: "#64748b", flexShrink: 0 } }, "(\u5BB9\u5668\u7AEF\u53E3: ", effectiveStep1Port, ")")), !upgradingStep1 && slugCheck.error && /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-hint", style: { color: "#dc2626", marginTop: 4 } }, slugCheck.error)), /* @__PURE__ */ import_react8.default.createElement("div", { className: "oa-field" }, /* @__PURE__ */ import_react8.default.createElement("label", { className: "oa-label", htmlFor: `${formId}-description` }, "\u5E94\u7528\u63CF\u8FF0"), /* @__PURE__ */ import_react8.default.createElement(
|
|
57624
57609
|
"textarea",
|
|
57625
57610
|
{
|
|
57626
57611
|
id: `${formId}-description`,
|
|
@@ -57707,7 +57692,6 @@ function AppsPanel({
|
|
|
57707
57692
|
setAppName(wizardJob.name);
|
|
57708
57693
|
setAppSlug(wizardJob.slug);
|
|
57709
57694
|
setSlugManual(true);
|
|
57710
|
-
setContainerPort(String(wizardJob.port ?? opcConfig.defaultPort));
|
|
57711
57695
|
setAppDescription(wizardJob.description ?? "");
|
|
57712
57696
|
if (wizardJob.upgrade || wizardJob.published) {
|
|
57713
57697
|
const target = apps.find((a) => a.slug === wizardJob.slug && a.can_manage === true);
|
|
@@ -57768,7 +57752,7 @@ function AppsPanel({
|
|
|
57768
57752
|
}
|
|
57769
57753
|
},
|
|
57770
57754
|
options.length === 0 && /* @__PURE__ */ import_react8.default.createElement("option", { value: "" }, mount.kind === "sqlite" ? "\u7B49\u5F85\u7BA1\u7406\u5458\u914D\u7F6E\u672C\u5730\u78C1\u76D8\u5377" : "\u7B49\u5F85\u7BA1\u7406\u5458\u914D\u7F6E\u5B58\u50A8"),
|
|
57771
|
-
options.map((resource) => /* @__PURE__ */ import_react8.default.createElement("option", { key: resource.id, value: resource.id }, resource.name, " \xB7 ", resource.type === "aliyun-oss-volume" ? "\u963F\u91CC\u4E91 OSS" : "\u672C\u5730\u78C1\u76D8"))
|
|
57755
|
+
options.map((resource) => /* @__PURE__ */ import_react8.default.createElement("option", { key: resource.id, value: resource.id }, resource.name, " \xB7 ", resource.type === "aliyun-oss-volume" ? "\u963F\u91CC\u4E91 OSS" : "\u672C\u5730\u78C1\u76D8", resource.is_default ? "\uFF08\u9ED8\u8BA4\uFF09" : ""))
|
|
57772
57756
|
)));
|
|
57773
57757
|
})), /* @__PURE__ */ import_react8.default.createElement(
|
|
57774
57758
|
AppDeliveryConfig,
|
|
@@ -57881,7 +57865,6 @@ function AppsPanel({
|
|
|
57881
57865
|
setAppName(wizardJob.name);
|
|
57882
57866
|
setAppSlug(wizardJob.slug);
|
|
57883
57867
|
setSlugManual(true);
|
|
57884
|
-
setContainerPort(String(wizardJob.port ?? opcConfig.defaultPort));
|
|
57885
57868
|
setAppDescription(wizardJob.description ?? "");
|
|
57886
57869
|
if (wizardJob.upgrade || wizardJob.published) {
|
|
57887
57870
|
const target = apps.find((a) => a.slug === wizardJob.slug && a.can_manage === true);
|
package/lib/index.js
CHANGED
|
@@ -2534,6 +2534,7 @@ ${combinedLog}` : combinedLog).slice(-24e3);
|
|
|
2534
2534
|
};
|
|
2535
2535
|
job.confirmationToken = void 0;
|
|
2536
2536
|
job.status = "ready";
|
|
2537
|
+
if (job.published) job.upgrade = true;
|
|
2537
2538
|
job.published = void 0;
|
|
2538
2539
|
job.superseded = void 0;
|
|
2539
2540
|
job.events.push("\u5DF2\u6062\u590D\u5931\u8D25\u7248\u672C\u7684\u4EA4\u4ED8\u5305\u548C\u8FD0\u884C\u914D\u7F6E\uFF0C\u8BF7\u6838\u5BF9\u540E\u91CD\u65B0\u90E8\u7F72");
|
|
@@ -2677,7 +2678,7 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
2677
2678
|
async configDraft(id, expected) {
|
|
2678
2679
|
const scope = this.scope(expected);
|
|
2679
2680
|
const { job } = await this.open(scope.directory, id);
|
|
2680
|
-
if (job.status !== "ready" || !job.configDraft
|
|
2681
|
+
if (job.status !== "ready" || !job.configDraft) return null;
|
|
2681
2682
|
const values = await this.credentials.read(`draft-${id}`);
|
|
2682
2683
|
scope.assertCurrent();
|
|
2683
2684
|
return { ...job.configDraft, rows: job.configDraft.rows.map((row) => ({ ...row, value: values[row.key] ?? "" })) };
|
|
@@ -2865,6 +2866,25 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
2865
2866
|
assertCurrent();
|
|
2866
2867
|
job.autoPrepared = autoPrepared;
|
|
2867
2868
|
job.status = "ready";
|
|
2869
|
+
if (job.published) {
|
|
2870
|
+
job.upgrade = true;
|
|
2871
|
+
if (!job.configDraft && job.requestId) {
|
|
2872
|
+
const priorPublished = await this.credentials.read(`publish-config-${job.requestId}`);
|
|
2873
|
+
const rows = priorPublished.rows ? JSON.parse(priorPublished.rows) : [];
|
|
2874
|
+
if (rows.length > 0) {
|
|
2875
|
+
await this.credentials.write(`draft-${job.id}`, Object.fromEntries(rows.map((row) => [row.key, row.value ?? ""])));
|
|
2876
|
+
job.configDraft = {
|
|
2877
|
+
artifactHash: fingerprint(job.hashes),
|
|
2878
|
+
rows: rows.map(({ value: _value, ...row }) => ({
|
|
2879
|
+
key: row.key,
|
|
2880
|
+
resource_id: row.resource_id,
|
|
2881
|
+
local_connection_confirmed: row.local_connection_confirmed === true
|
|
2882
|
+
})),
|
|
2883
|
+
versionNote: job.versionNote ?? ""
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2868
2888
|
job.version = void 0;
|
|
2869
2889
|
job.published = void 0;
|
|
2870
2890
|
job.restoredVersion = void 0;
|
|
@@ -2892,14 +2912,21 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
2892
2912
|
if (Object.keys(storageBindings).some((path) => !declaredMounts.some((mount) => mount.container_path === path))) {
|
|
2893
2913
|
throw new Error("\u5B58\u50A8\u9009\u62E9\u5FC5\u987B\u5BF9\u5E94\u5DF2\u786E\u8BA4\u7684\u6301\u4E45\u5316\u76EE\u5F55");
|
|
2894
2914
|
}
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2915
|
+
const existingMounts = (job.upgrade || job.published) && declaredMounts.length ? (await this.platform("/" + job.slug, expected)).storage_mounts ?? [] : [];
|
|
2916
|
+
const needsDefaultMountResolution = input.storageBindings !== void 0 && declaredMounts.some((mount) => !storageBindings[mount.container_path] && !existingMounts.some((old) => old.container_path === mount.container_path));
|
|
2917
|
+
const ids = [...new Set(configs.flatMap((c) => c.resource_id ? [c.resource_id] : []))].sort();
|
|
2918
|
+
const available = ids.length || Object.keys(storageBindings).length || needsDefaultMountResolution ? (await this.platform("/resources", expected)).resources ?? [] : [];
|
|
2919
|
+
if (needsDefaultMountResolution) {
|
|
2920
|
+
for (const mount of declaredMounts) {
|
|
2921
|
+
if (storageBindings[mount.container_path] || existingMounts.some((old) => old.container_path === mount.container_path)) continue;
|
|
2922
|
+
const compatibleDefault = available.find((resource) => resource.is_default === true && (resource.type === "local-directory" || resource.type === "aliyun-oss-volume" && mount.kind !== "sqlite"));
|
|
2923
|
+
if (compatibleDefault) {
|
|
2924
|
+
storageBindings[mount.container_path] = compatibleDefault.id;
|
|
2925
|
+
} else {
|
|
2926
|
+
throw new Error("\u8BF7\u4E3A\u65B0\u589E\u6301\u4E45\u5316\u76EE\u5F55\u9009\u62E9 Platform \u5377\u8D44\u6E90");
|
|
2927
|
+
}
|
|
2899
2928
|
}
|
|
2900
2929
|
}
|
|
2901
|
-
const ids = [...new Set(configs.flatMap((c) => c.resource_id ? [c.resource_id] : []))].sort();
|
|
2902
|
-
const available = ids.length || Object.keys(storageBindings).length ? (await this.platform("/resources", expected)).resources ?? [] : [];
|
|
2903
2930
|
for (const [path, id] of Object.entries(storageBindings)) {
|
|
2904
2931
|
const resource = available.find((resource2) => resource2.id === id && ["local-directory", "aliyun-oss-volume", "docker-volume"].includes(resource2.type));
|
|
2905
2932
|
if (!resource) throw new Error(`\u6301\u4E45\u5316\u76EE\u5F55\u7684\u5B58\u50A8\u8D44\u6E90\u4E0D\u53EF\u7528\uFF1A${path}`);
|
|
@@ -2925,12 +2952,14 @@ ${trimmedFeedback}` : trimmedFeedback || prevFailure).slice(-24e3);
|
|
|
2925
2952
|
const declarations = job.proposal.contract.configs ?? [];
|
|
2926
2953
|
for (const c of declarations) {
|
|
2927
2954
|
const selected = configs.find((i) => i.key === c.key);
|
|
2928
|
-
|
|
2955
|
+
const preservedOnlineSecret = Boolean((job.upgrade || job.published) && selected?.has_value);
|
|
2956
|
+
if (c.required && !selected?.value && !selected?.resource_id && !preservedOnlineSecret) throw new Error(`\u8BF7\u586B\u5199 ${c.key}`);
|
|
2929
2957
|
}
|
|
2930
2958
|
const bindings = configs.map((c) => ({
|
|
2931
2959
|
key: c.key,
|
|
2932
2960
|
value: c.value,
|
|
2933
2961
|
value_source: c.value_source,
|
|
2962
|
+
...c.has_value === true && !c.value && !c.resource_id ? { has_value: true } : {},
|
|
2934
2963
|
resource_id: c.resource_id,
|
|
2935
2964
|
required: declarations.some((item) => item.key === c.key && item.required)
|
|
2936
2965
|
}));
|
package/package.json
CHANGED
|
@@ -1717,6 +1717,8 @@ def _normalize_resource_type_group(raw_type: str) -> str:
|
|
|
1717
1717
|
return "postgres"
|
|
1718
1718
|
if t == "mssql":
|
|
1719
1719
|
return "sqlserver"
|
|
1720
|
+
if t in {"local-directory", "aliyun-oss-volume"}:
|
|
1721
|
+
return "application-volume"
|
|
1720
1722
|
return t
|
|
1721
1723
|
|
|
1722
1724
|
|
|
@@ -1831,31 +1833,41 @@ for root, dirs, files in os.walk(seed_root):
|
|
|
1831
1833
|
dc = sqlite3.connect(dp, timeout=10.0)
|
|
1832
1834
|
dc.execute('PRAGMA busy_timeout=10000')
|
|
1833
1835
|
existing_tables = {r[0] for r in dc.execute("SELECT name FROM sqlite_master WHERE type='table'")}
|
|
1834
|
-
for tbl, ddl in sc.execute("SELECT name, sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND sql IS NOT NULL"):
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
if dflt is not None:
|
|
1849
|
-
clause += ' DEFAULT ' + str(dflt)
|
|
1850
|
-
elif notnull:
|
|
1836
|
+
for tbl, ddl in sc.execute("SELECT name, sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND sql IS NOT NULL").fetchall():
|
|
1837
|
+
try:
|
|
1838
|
+
if tbl not in existing_tables:
|
|
1839
|
+
dc.execute(ddl)
|
|
1840
|
+
rows = sc.execute('SELECT * FROM ' + q(tbl)).fetchall()
|
|
1841
|
+
if rows:
|
|
1842
|
+
ph = ','.join('?' for _ in rows[0])
|
|
1843
|
+
dc.executemany('INSERT OR IGNORE INTO ' + q(tbl) + ' VALUES (' + ph + ')', rows)
|
|
1844
|
+
else:
|
|
1845
|
+
dst_cols = {r[1] for r in dc.execute('PRAGMA table_info(' + q(tbl) + ')').fetchall()}
|
|
1846
|
+
for cid, cname, ctype, notnull, dflt, pk in sc.execute('PRAGMA table_info(' + q(tbl) + ')').fetchall():
|
|
1847
|
+
if cname in dst_cols or pk:
|
|
1848
|
+
continue
|
|
1849
|
+
t = (ctype or 'TEXT').strip() or 'TEXT'
|
|
1851
1850
|
tu = t.upper()
|
|
1852
1851
|
if 'INT' in tu or 'NUM' in tu or 'REAL' in tu or 'FLOA' in tu or 'DOUB' in tu:
|
|
1853
|
-
|
|
1852
|
+
fallback_dflt = '0'
|
|
1854
1853
|
elif 'BLOB' in tu:
|
|
1855
|
-
|
|
1854
|
+
fallback_dflt = "X''"
|
|
1856
1855
|
else:
|
|
1857
|
-
|
|
1858
|
-
|
|
1856
|
+
fallback_dflt = "''"
|
|
1857
|
+
clause = q(cname) + ' ' + t
|
|
1858
|
+
if dflt is not None:
|
|
1859
|
+
clause += ' DEFAULT ' + str(dflt)
|
|
1860
|
+
elif notnull:
|
|
1861
|
+
clause += ' NOT NULL DEFAULT ' + fallback_dflt
|
|
1862
|
+
try:
|
|
1863
|
+
dc.execute('ALTER TABLE ' + q(tbl) + ' ADD COLUMN ' + clause)
|
|
1864
|
+
except Exception:
|
|
1865
|
+
try:
|
|
1866
|
+
dc.execute('ALTER TABLE ' + q(tbl) + ' ADD COLUMN ' + q(cname) + ' ' + t + ' DEFAULT ' + fallback_dflt)
|
|
1867
|
+
except Exception:
|
|
1868
|
+
pass
|
|
1869
|
+
except Exception:
|
|
1870
|
+
pass
|
|
1859
1871
|
for idx_name, idx_sql in sc.execute("SELECT name, sql FROM sqlite_master WHERE type='index' AND sql IS NOT NULL"):
|
|
1860
1872
|
try:
|
|
1861
1873
|
stmt = idx_sql
|