@huaqiu/dsh-artifacts 0.3.9 → 0.3.11

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/service.d.mts CHANGED
@@ -54,6 +54,12 @@ interface HuaqiuArtifacts {
54
54
  onlyExpired?: boolean;
55
55
  }): Promise<number>;
56
56
  }
57
+ /**
58
+ * Minimal, dependency-free facade every internal call site uses. Delegates to
59
+ * the unified `@huaqiu/dsh-plugin-log` so all plugin diagnostics land in one
60
+ * file (`<DSH_HOME>/logs/dsh-plugins.log`) — preserved verbatim across deps
61
+ * for the (test) callers that construct mock services around it.
62
+ */
57
63
  declare function log(level: 'debug' | 'warn', msg: string, extra?: Record<string, unknown>): void;
58
64
  declare class HuaqiuArtifactService implements HuaqiuArtifacts {
59
65
  private readonly baseDir;
package/lib/service.mjs CHANGED
@@ -3,6 +3,7 @@ import * as path from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
6
+ import { getLogger } from "@huaqiu/dsh-plugin-log";
6
7
  //#region src/service.ts
7
8
  /**
8
9
  * `@huaqiu/dsh-artifacts` — user-wide, flat storage for ECAD preview artifacts
@@ -56,12 +57,23 @@ function toBytes(content, encoding) {
56
57
  if (typeof content === "string") return encoding === "base64" ? Buffer.from(content, "base64") : Buffer.from(content, "utf8");
57
58
  return content instanceof Uint8Array ? content : new Uint8Array(content);
58
59
  }
60
+ /** Unified DSH-plugin logger for the artifacts plugin (see dsh-plugin-log).
61
+ * Lazy — see dsh-auth/src/host.ts for the rationale (mocked DSH-home tests). */
62
+ let pluginLog = null;
63
+ function getPluginLog() {
64
+ if (pluginLog === null) pluginLog = getLogger("dsh-artifacts");
65
+ return pluginLog;
66
+ }
67
+ /**
68
+ * Minimal, dependency-free facade every internal call site uses. Delegates to
69
+ * the unified `@huaqiu/dsh-plugin-log` so all plugin diagnostics land in one
70
+ * file (`<DSH_HOME>/logs/dsh-plugins.log`) — preserved verbatim across deps
71
+ * for the (test) callers that construct mock services around it.
72
+ */
59
73
  function log(level, msg, extra) {
60
- if (level === "warn" || process.env.DSH_ARTIFACTS_DEBUG) {
61
- const line = `[dsh-artifacts] ${msg}${extra ? " " + JSON.stringify(extra) : ""}`;
62
- if (level === "warn") console.warn(line);
63
- else console.debug(line);
64
- }
74
+ const l = getPluginLog();
75
+ if (level === "warn") l.warn(msg, extra);
76
+ else l.debug(msg, extra);
65
77
  }
66
78
  var HuaqiuArtifactService = class {
67
79
  baseDir;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huaqiu/dsh-artifacts",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "main": "./lib/index.mjs",
6
6
  "types": "./lib/index.d.mts",
@@ -30,7 +30,8 @@
30
30
  "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.0"
31
31
  },
32
32
  "dependencies": {
33
- "@deepseek-ai/dsh-home-paths": "^0.1.0-rc.0"
33
+ "@deepseek-ai/dsh-home-paths": "^0.1.0-rc.0",
34
+ "@huaqiu/dsh-plugin-log": "0.3.11"
34
35
  },
35
36
  "files": [
36
37
  "lib",
package/src/service.ts CHANGED
@@ -22,6 +22,7 @@ import * as path from 'node:path'
22
22
  import { pathToFileURL } from 'node:url'
23
23
  import { randomUUID } from 'node:crypto'
24
24
  import { dshHomePath } from '@deepseek-ai/dsh-home-paths'
25
+ import { getLogger, type PluginLogger } from '@huaqiu/dsh-plugin-log'
25
26
 
26
27
  // ── Public types ────────────────────────────────────────────────────────────
27
28
 
@@ -122,13 +123,24 @@ function toBytes(content: string | Uint8Array, encoding: 'utf8' | 'base64' | und
122
123
  return content instanceof Uint8Array ? content : new Uint8Array(content)
123
124
  }
124
125
 
126
+ /** Unified DSH-plugin logger for the artifacts plugin (see dsh-plugin-log).
127
+ * Lazy — see dsh-auth/src/host.ts for the rationale (mocked DSH-home tests). */
128
+ let pluginLog: PluginLogger | null = null
129
+ function getPluginLog(): PluginLogger {
130
+ if (pluginLog === null) pluginLog = getLogger('dsh-artifacts')
131
+ return pluginLog
132
+ }
133
+
134
+ /**
135
+ * Minimal, dependency-free facade every internal call site uses. Delegates to
136
+ * the unified `@huaqiu/dsh-plugin-log` so all plugin diagnostics land in one
137
+ * file (`<DSH_HOME>/logs/dsh-plugins.log`) — preserved verbatim across deps
138
+ * for the (test) callers that construct mock services around it.
139
+ */
125
140
  export function log(level: 'debug' | 'warn', msg: string, extra?: Record<string, unknown>): void {
126
- // Minimal, dependency-free logger. DSH plugins should not pull a logger lib.
127
- if (level === 'warn' || process.env.DSH_ARTIFACTS_DEBUG) {
128
- const line = `[dsh-artifacts] ${msg}${extra ? ' ' + JSON.stringify(extra) : ''}`
129
- if (level === 'warn') console.warn(line)
130
- else console.debug(line)
131
- }
141
+ const l = getPluginLog()
142
+ if (level === 'warn') l.warn(msg, extra)
143
+ else l.debug(msg, extra)
132
144
  }
133
145
 
134
146
  // ── Service ─────────────────────────────────────────────────────────────────