dsh-plugin-opc 0.1.20 → 0.1.21

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 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
  }
@@ -56725,38 +56726,48 @@ function AppsPanel({
56725
56726
  const detail = job.upgrade || job.published ? parseJson(await api.appDetails(job.slug, contextId).catch(() => "null"), null) : null;
56726
56727
  const detailConfigMap = new Map((detail?.app_config ?? []).map((item) => [item.key, item]));
56727
56728
  const boundResources = detail?.resource_ids?.length ? resources.filter((resource) => detail.resource_ids?.includes(resource.id)) : [];
56728
- const mergedConfigs = !draft && detail ? configs.map((config2) => {
56729
- const online = detailConfigMap.get(config2.key);
56730
- const matchedResource = boundResources.find((resource) => resource.id === online?.resource_id || resource.env_keys.includes(config2.key));
56731
- if (matchedResource) {
56732
- return { ...config2, value: "", value_source: "resource", resource_id: matchedResource.id };
56733
- }
56734
- if (!online) return config2;
56735
- if (config2.key === "PORT") return config2;
56736
- if (online.resource_id) {
56737
- return { ...config2, value: "", value_source: "resource", resource_id: online.resource_id };
56738
- }
56739
- if (config2.secret || online.secret) {
56740
- return {
56741
- ...config2,
56742
- has_value: Boolean(config2.has_value || online.has_value || online.value),
56743
- local_connection_confirmed: Boolean(online.local_connection_confirmed || config2.local_connection_confirmed)
56744
- };
56745
- }
56746
- if (typeof online.value === "string" && online.value !== "") {
56747
- return {
56748
- ...config2,
56749
- value: online.value,
56750
- value_source: "manual",
56751
- has_value: true,
56752
- local_connection_confirmed: Boolean(online.local_connection_confirmed || config2.local_connection_confirmed)
56753
- };
56754
- }
56755
- if (online.local_connection_confirmed) {
56756
- return { ...config2, local_connection_confirmed: true };
56757
- }
56758
- return config2;
56759
- }) : configs;
56729
+ const mergedConfigs = !draft && detail ? [
56730
+ ...configs.map((config2) => {
56731
+ const online = detailConfigMap.get(config2.key);
56732
+ const matchedResource = boundResources.find((resource) => resource.id === online?.resource_id || resource.env_keys.includes(config2.key));
56733
+ if (matchedResource) {
56734
+ return { ...config2, value: "", value_source: "resource", resource_id: matchedResource.id };
56735
+ }
56736
+ if (!online) return config2;
56737
+ if (config2.key === "PORT") return config2;
56738
+ if (online.resource_id) {
56739
+ return { ...config2, value: "", value_source: "resource", resource_id: online.resource_id };
56740
+ }
56741
+ if (typeof online.value === "string" && online.value !== "") {
56742
+ return {
56743
+ ...config2,
56744
+ value: online.value,
56745
+ value_source: online.value_source || "manual",
56746
+ has_value: true,
56747
+ local_connection_confirmed: Boolean(online.local_connection_confirmed || config2.local_connection_confirmed)
56748
+ };
56749
+ }
56750
+ if (config2.secret || online.secret) {
56751
+ return {
56752
+ ...config2,
56753
+ has_value: Boolean(config2.has_value || online.has_value || online.value),
56754
+ local_connection_confirmed: Boolean(online.local_connection_confirmed || config2.local_connection_confirmed)
56755
+ };
56756
+ }
56757
+ if (online.local_connection_confirmed) {
56758
+ return { ...config2, local_connection_confirmed: true };
56759
+ }
56760
+ return config2;
56761
+ }),
56762
+ ...(detail.app_config ?? []).filter((online) => {
56763
+ const key = (online.key || "").trim();
56764
+ if (!key || key === "PORT" || key.startsWith("OPC_STORAGE_")) return false;
56765
+ return !configs.some((cfg) => cfg.key === key);
56766
+ }).map((online) => ({
56767
+ ...online,
56768
+ has_value: Boolean(online.has_value || online.value || online.resource_id)
56769
+ }))
56770
+ ] : configs;
56760
56771
  setConfigDrafts(mergedConfigs);
56761
56772
  setOriginalConfigs(originals);
56762
56773
  setVersionNote(draft?.versionNote ?? job.versionNote ?? "");
@@ -57768,7 +57779,7 @@ function AppsPanel({
57768
57779
  }
57769
57780
  },
57770
57781
  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"))
57782
+ 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
57783
  )));
57773
57784
  })), /* @__PURE__ */ import_react8.default.createElement(
57774
57785
  AppDeliveryConfig,
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 || job.configDraft.artifactHash !== fingerprint(job.hashes)) return null;
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
- if (input.storageBindings !== void 0 && declaredMounts.some((mount) => !storageBindings[mount.container_path])) {
2896
- const existing = job.upgrade || job.published ? (await this.platform("/" + job.slug, expected)).storage_mounts ?? [] : [];
2897
- if (declaredMounts.some((mount) => !storageBindings[mount.container_path] && !existing.some((old) => old.container_path === mount.container_path))) {
2898
- throw new Error("\u8BF7\u4E3A\u65B0\u589E\u6301\u4E45\u5316\u76EE\u5F55\u9009\u62E9 Platform \u5377\u8D44\u6E90");
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
- if (c.required && !selected?.value && !selected?.resource_id) throw new Error(`\u8BF7\u586B\u5199 ${c.key}`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-opc",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "OPC Enterprise Plugin for DeepSeek Harness (DSH)",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -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
- if tbl not in existing_tables:
1836
- dc.execute(ddl)
1837
- rows = sc.execute('SELECT * FROM ' + q(tbl)).fetchall()
1838
- if rows:
1839
- ph = ','.join('?' for _ in rows[0])
1840
- dc.executemany('INSERT OR IGNORE INTO ' + q(tbl) + ' VALUES (' + ph + ')', rows)
1841
- else:
1842
- dst_cols = {r[1] for r in dc.execute('PRAGMA table_info(' + q(tbl) + ')').fetchall()}
1843
- for cid, cname, ctype, notnull, dflt, pk in sc.execute('PRAGMA table_info(' + q(tbl) + ')').fetchall():
1844
- if cname in dst_cols or pk:
1845
- continue
1846
- t = (ctype or 'TEXT').strip() or 'TEXT'
1847
- clause = q(cname) + ' ' + t
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
- clause += ' NOT NULL DEFAULT 0'
1852
+ fallback_dflt = '0'
1854
1853
  elif 'BLOB' in tu:
1855
- clause += " NOT NULL DEFAULT X''"
1854
+ fallback_dflt = "X''"
1856
1855
  else:
1857
- clause += " NOT NULL DEFAULT ''"
1858
- dc.execute('ALTER TABLE ' + q(tbl) + ' ADD COLUMN ' + clause)
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