universal-picgo 2.0.1 → 3.0.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.
Files changed (32) hide show
  1. package/dist/index.js +7670 -6716
  2. package/dist/package.json +4 -3
  3. package/dist/src/config/DefaultRecognition.d.ts +55 -0
  4. package/dist/src/config/DefaultRecognition.spec.d.ts +1 -0
  5. package/dist/src/config/ExternalPicgoDefaultSurvival.spec.d.ts +1 -0
  6. package/dist/src/config/MaskUtils.d.ts +51 -0
  7. package/dist/src/config/MaskUtils.spec.d.ts +1 -0
  8. package/dist/src/config/SettingsStorePattern.spec.d.ts +1 -0
  9. package/dist/src/config/UnifiedConfigFacade.d.ts +21 -0
  10. package/dist/src/config/UnifiedConfigFacade.integration.spec.d.ts +1 -0
  11. package/dist/src/config/UnifiedConfigFacade.spec.d.ts +1 -0
  12. package/dist/src/config/UnifiedConfigTypes.d.ts +323 -0
  13. package/dist/src/config/UnifiedConfigTypes.spec.d.ts +1 -0
  14. package/dist/src/config/V3MigrationService.d.ts +36 -0
  15. package/dist/src/config/V3MigrationService.spec.d.ts +1 -0
  16. package/dist/src/config/index.d.ts +11 -0
  17. package/dist/src/core/ExternalPicgo.d.ts +4 -4
  18. package/dist/src/core/PicListUploader.d.ts +50 -0
  19. package/dist/src/core/PicListUploader.spec.d.ts +1 -0
  20. package/dist/src/core/UniversalPicGo.d.ts +15 -6
  21. package/dist/src/db/config/index.d.ts +5 -0
  22. package/dist/src/db/externalPicGo/index.d.ts +18 -0
  23. package/dist/src/headless/UniversalPicGoHeadlessManager.d.ts +6 -5
  24. package/dist/src/headless/types.d.ts +5 -5
  25. package/dist/src/headless/uploaderSchemas.d.ts +1 -1
  26. package/dist/src/index.d.ts +3 -1
  27. package/dist/src/lib/PicGoRequest.d.ts +0 -1
  28. package/dist/src/lib/PicGoRequest.spec.d.ts +1 -0
  29. package/dist/src/plugins/uploader/aliyun/web.d.ts +5 -2
  30. package/dist/src/plugins/uploader/aliyun/web.spec.d.ts +1 -0
  31. package/dist/src/utils/common.d.ts +6 -4
  32. package/package.json +4 -3
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-picgo",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "description": "picgo lib for node, browser and electron",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,8 @@
22
22
  "dev": "vite build --watch",
23
23
  "build": "vite build",
24
24
  "start": "vite preview",
25
- "test": "npx vitest --watch"
25
+ "test": "vitest run",
26
+ "test:watch": "npx vitest --watch"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@terwer/eslint-config-custom": "^1.3.6",
@@ -50,4 +51,4 @@
50
51
  "publishConfig": {
51
52
  "access": "public"
52
53
  }
53
- }
54
+ }
@@ -0,0 +1,55 @@
1
+ import { IConfig, IExternalPicgoConfig } from '../types';
2
+ import { ConfigDomain, SiyuanConfigLike } from './UnifiedConfigTypes';
3
+
4
+ /**
5
+ * Default-generated recognition for v3 migration.
6
+ *
7
+ * During migration, each domain's owner file is classified as:
8
+ * - "user-data": contains real user values → authoritative, do not overwrite
9
+ * - "generated-default": only contains auto-generated defaults → can import legacy data
10
+ * - "missing": does not exist → can import legacy data
11
+ *
12
+ * @module DefaultRecognition
13
+ * @since 3.0.0
14
+ */
15
+ export type DefaultClassification = "user-data" | "generated-default" | "missing";
16
+ /**
17
+ * Check if a PicGo main config contains only generated defaults.
18
+ *
19
+ * A config is "generated-default" when:
20
+ * - Root keys are limited to {"picBed", "picgoPlugins", "siyuan"}
21
+ * - picBed has only uploader="smms", current="smms" (no real uploader config)
22
+ * - picgoPlugins is empty
23
+ * - siyuan matches initial defaults exactly
24
+ */
25
+ export declare function isPicgoMainGeneratedDefault(cfg: IConfig | null | undefined): boolean;
26
+ /**
27
+ * Check if an external/PicList config contains only generated defaults.
28
+ *
29
+ * A config is "generated-default" when:
30
+ * - Matches the default shape
31
+ * - picListApiUrl is empty (non-empty = user data)
32
+ * - picListApiKey is empty (non-empty = user data)
33
+ */
34
+ export declare function isExternalPicgoGeneratedDefault(cfg: IExternalPicgoConfig | null | undefined): boolean;
35
+ /**
36
+ * Check if a SiYuan connection config contains only generated defaults.
37
+ *
38
+ * A config is "generated-default" when:
39
+ * - apiUrl matches default "http://127.0.0.1:6806"
40
+ * - password is empty
41
+ * - cookie is missing
42
+ * - No user-edited optional fields
43
+ */
44
+ export declare function isSiyuanConnectionGeneratedDefault(cfg: SiyuanConfigLike | null | undefined): boolean;
45
+ /**
46
+ * Check if Lsky token state contains only generated defaults.
47
+ *
48
+ * Returns "generated-default" when uploader.lsky.token is absent.
49
+ * Any non-empty legacy token is user data.
50
+ */
51
+ export declare function isLskyStateGeneratedDefault(tokenValue: string | null | undefined): boolean;
52
+ /**
53
+ * Classify a domain's current owner file data as user-data, generated-default, or missing.
54
+ */
55
+ export declare function classifyDomainDefaults(domain: ConfigDomain, data: any): DefaultClassification;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ import { UnifiedConfigSnapshot } from './UnifiedConfigTypes';
2
+
3
+ /**
4
+ * Mask utilities for sensitive configuration fields.
5
+ *
6
+ * Sensitive fields (passwords, tokens, keys, cookies) MUST be rendered
7
+ * as "******" in logs, errors, migration reports, diagnostics, and any
8
+ * non-persistence output. Real values MUST only exist in owner files
9
+ * and runtime memory needed for API calls.
10
+ *
11
+ * @module MaskUtils
12
+ * @since 3.0.0
13
+ */
14
+ /**
15
+ * Determine whether a field name matches any sensitive field pattern.
16
+ */
17
+ export declare function isSensitiveField(fieldName: string): boolean;
18
+ /**
19
+ * Deep-clone and mask all sensitive fields in an object tree.
20
+ *
21
+ * Recursively walks the object. When a key matches a sensitive field
22
+ * pattern and the value is a non-empty string, replaces it with MASK_VALUE.
23
+ * Arrays are traversed element by element.
24
+ *
25
+ * IMPORTANT: The mask is applied to a deep CLONE — the original object
26
+ * is NEVER mutated. Masked values MUST NOT be written back to owner files.
27
+ *
28
+ * @param obj - Any JSON-serializable value.
29
+ * @returns Deep-cloned copy with sensitive string values replaced by "******".
30
+ */
31
+ export declare function maskSensitiveFields<T = any>(obj: T): T;
32
+ /**
33
+ * Mask sensitive fields in a unified config snapshot.
34
+ *
35
+ * Returns a deep-cloned copy with all passwords, tokens, cookies, and
36
+ * API keys replaced by "******". Safe for logging, diagnostics, and
37
+ * audit evidence.
38
+ *
39
+ * @param snapshot - The raw unified config snapshot.
40
+ * @returns Deep-cloned snapshot with all sensitive fields masked.
41
+ */
42
+ export declare function maskSnapshot(snapshot: UnifiedConfigSnapshot): UnifiedConfigSnapshot;
43
+ /**
44
+ * Mask a single config value if it is a string that matches a known
45
+ * sensitive field name context.
46
+ *
47
+ * @param value - The value string (or undefined).
48
+ * @param fieldName - The field name for sensitivity detection.
49
+ * @returns The original value if field is not sensitive or value is empty; "******" otherwise.
50
+ */
51
+ export declare function maskIfSensitive(value: string | undefined, fieldName: string): string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { ReadyUnifiedPicGoConfigFacade, UnifiedPicGoConfigFacadeOptions } from './UnifiedConfigTypes';
2
+
3
+ /**
4
+ * Create and initialize the unified async configuration facade.
5
+ *
6
+ * This async factory:
7
+ * 1. Resolves storage adapters for each unique owner file
8
+ * 2. Reads all owner files
9
+ * 3. Checks/executes v3 migration
10
+ * 4. Merges defaults where data is missing
11
+ * 5. Constructs the ready snapshot
12
+ * 6. Returns the ready facade
13
+ *
14
+ * The returned Promise MUST be awaited before any configuration access.
15
+ * Reading user config before resolve throws ConfigNotReadyError.
16
+ *
17
+ * @param options - Runtime options including SiYuan connection config,
18
+ * paths, and optional storage adapter factory.
19
+ * @returns A Promise resolving to the ready facade.
20
+ */
21
+ export declare function createUnifiedPicGoConfigFacade(options: UnifiedPicGoConfigFacadeOptions): Promise<ReadyUnifiedPicGoConfigFacade>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,323 @@
1
+ import { IConfig, IExternalPicgoConfig } from '../types';
2
+
3
+ /**
4
+ * Minimal SiYuan connection configuration.
5
+ *
6
+ * Defined locally to avoid circular dependency between universal-picgo
7
+ * and zhi-siyuan-picgo. The actual type in zhi-siyuan-picgo has the
8
+ * same shape and is used by the factory layer.
9
+ */
10
+ export interface SiyuanConfigLike {
11
+ apiUrl?: string;
12
+ password?: string;
13
+ cookie?: string;
14
+ home?: string;
15
+ previewUrl?: string;
16
+ notebook?: string;
17
+ picgoUploadTimeout?: number;
18
+ passwordType?: unknown;
19
+ }
20
+ /**
21
+ * Per-domain routing key for the unified configuration facade.
22
+ *
23
+ * Each domain maps to a specific owner file and migration priority.
24
+ * @see design.md § Complete Configuration Domain Mapping
25
+ */
26
+ export type ConfigDomain = "picgoMain" | "picgoSettings" | "siyuanBehavior" | "siyuanConnection" | "externalPicList" | "pluginValues" | "uploaderConfig" | "lskyState" | "pasteBootstrap";
27
+ /** All configuration domains as a readonly array for iteration. */
28
+ export declare const ALL_CONFIG_DOMAINS: readonly ConfigDomain[];
29
+ /**
30
+ * Options passed to `createUnifiedPicGoConfigFacade`.
31
+ *
32
+ * Specifies runtime environment, storage resolution, and migration
33
+ * behavior for the unified async configuration facade.
34
+ */
35
+ export interface UnifiedPicGoConfigFacadeOptions {
36
+ /** SiYuan connection config used to create the Kernel API wrapper. */
37
+ siyuanConfig: SiyuanConfigLike;
38
+ /** Logical paths / overrides for owner file resolution. */
39
+ paths: UnifiedConfigPaths;
40
+ /** Whether to run in dev mode (enables debug logging). */
41
+ isDev?: boolean;
42
+ /**
43
+ * Optional storage adapter factory.
44
+ * When provided, overrides the L1-L4 decision tree for all owner files.
45
+ */
46
+ storageAdapterFactory?: (dbPath: string) => import('universal-picgo-store').StorageAdapter;
47
+ /**
48
+ * Optional logger factory.
49
+ * When omitted, a simple console logger is used.
50
+ */
51
+ getLogger?: (name: string) => {
52
+ info: (...args: any[]) => void;
53
+ error: (...args: any[]) => void;
54
+ warn: (...args: any[]) => void;
55
+ debug: (...args: any[]) => void;
56
+ };
57
+ }
58
+ /**
59
+ * Path overrides for owner file resolution.
60
+ *
61
+ * All paths default to the environment-appropriate locations derived
62
+ * from the SiYuan workspace and host runtime.
63
+ */
64
+ export interface UnifiedConfigPaths {
65
+ /** Override for PicGo main owner file path. */
66
+ configPath?: string;
67
+ /** Override/diagnostic identity for external/PicList owner file path. */
68
+ externalConfigPath?: string;
69
+ /** Override/diagnostic identity for SiYuan connection owner file path. */
70
+ siyuanConnectionConfigPath?: string;
71
+ /** Optional SiYuan workspace directory used by host factories/migration readers. */
72
+ workspaceDir?: string;
73
+ /** Optional user home/local PicGo directory used by migration readers. */
74
+ homeDir?: string;
75
+ /** Device-local runtime directory. */
76
+ baseDir?: string;
77
+ /** Alias for baseDir. */
78
+ runtimeDir?: string;
79
+ /** Device-local third-party plugin directory. */
80
+ pluginBaseDir?: string;
81
+ /** zhi npm helper path. */
82
+ zhiNpmPath?: string;
83
+ }
84
+ /**
85
+ * Paste takeover snapshot derived from ready owner file data.
86
+ *
87
+ * Constructed during facade initialization for synchronous paste
88
+ * event decisions without async boundary crossing.
89
+ */
90
+ export interface PasteTakeoverSnapshot {
91
+ /** Whether auto-upload on paste is enabled. */
92
+ autoUpload: boolean;
93
+ /** Whether picture+text mixed paste is allowed (txtImageSwitch). */
94
+ allowPicAndText: boolean;
95
+ /** Whether replace link on upload is enabled. */
96
+ replaceLink: boolean;
97
+ }
98
+ /**
99
+ * Complete unified configuration snapshot assembled from all owner files.
100
+ *
101
+ * Returned by `ReadyUnifiedPicGoConfigFacade.getSnapshot()` and
102
+ * `reload()`. Contains pure serializable data — no Vue reactivity,
103
+ * no framework bindings.
104
+ */
105
+ export interface UnifiedConfigSnapshot {
106
+ /** PicGo main config (uploader, picBed, siyuan behavior, etc.). */
107
+ picgo: IConfig;
108
+ /** External PicGo App / PicList route configuration. */
109
+ externalPicgo: IExternalPicgoConfig;
110
+ /** SiYuan connection configuration (apiUrl, password, cookie). */
111
+ siyuanConnection: SiyuanConfigLike;
112
+ /** Pre-warmed snapshot for synchronous paste takeover decisions. */
113
+ pasteTakeover: PasteTakeoverSnapshot;
114
+ /** V3 migration state tracker. */
115
+ migration: UnifiedConfigMigrationState;
116
+ }
117
+ /**
118
+ * Resolved unified async configuration facade.
119
+ *
120
+ * This is the ONLY production boundary for PicGo/plugin user
121
+ * configuration access in PicGo 3.0. All configuration reads,
122
+ * writes, and mutations must go through this interface.
123
+ *
124
+ * The facade is never half-ready: `createUnifiedPicGoConfigFacade()`
125
+ * returns a Promise that only resolves when all owner files are
126
+ * loaded, migration is complete (or skipped), and defaults are merged.
127
+ */
128
+ export interface ReadyUnifiedPicGoConfigFacade {
129
+ /** Whether the underlying storage backends are sync or async. */
130
+ readonly storageMode: "sync" | "async";
131
+ /** Unique key identifying this facade instance. */
132
+ readonly instanceKey: string;
133
+ /**
134
+ * Return the full in-memory configuration snapshot.
135
+ * Synchronous — returns the last loaded state.
136
+ */
137
+ getSnapshot(): UnifiedConfigSnapshot;
138
+ /**
139
+ * Read the PicGo main configuration domain.
140
+ * Returns a deep-cloned snapshot to prevent accidental mutation.
141
+ */
142
+ getPicGoConfig(): Promise<IConfig>;
143
+ /**
144
+ * Read the external/PicList configuration domain.
145
+ */
146
+ getExternalPicGoConfig(): Promise<IExternalPicgoConfig>;
147
+ /**
148
+ * Read the SiYuan connection configuration domain.
149
+ * Note: password and cookie are real values in the returned object;
150
+ * callers must mask before displaying or logging.
151
+ */
152
+ getSiyuanConnectionConfig(): Promise<SiyuanConfigLike>;
153
+ /**
154
+ * Read the pre-warmed paste takeover snapshot.
155
+ * Synchronous — designed for paste event handlers.
156
+ */
157
+ getPasteTakeoverSnapshot(): Promise<PasteTakeoverSnapshot>;
158
+ /**
159
+ * Mutate the PicGo main configuration in-memory.
160
+ * The change is applied immediately; persistence is deferred.
161
+ * Mark the picgoMain (and any sub-domain) as dirty.
162
+ */
163
+ updatePicGoConfig(mutator: (draft: IConfig) => void): Promise<void>;
164
+ /**
165
+ * Mutate the external/PicList configuration in-memory.
166
+ */
167
+ updateExternalPicGoConfig(mutator: (draft: IExternalPicgoConfig) => void): Promise<void>;
168
+ /**
169
+ * Mutate the SiYuan connection configuration in-memory.
170
+ */
171
+ updateSiyuanConnectionConfig(mutator: (draft: SiyuanConfigLike) => void): Promise<void>;
172
+ /**
173
+ * Flush dirty domains to their owner files.
174
+ * If no domains specified, flushes all dirty domains.
175
+ * Throws ConfigFlushError on any write failure.
176
+ */
177
+ flush(domains?: ConfigDomain[]): Promise<void>;
178
+ /**
179
+ * Flush, then re-read from storage, then return refreshed snapshot.
180
+ * Uses writeVersion to avoid overwriting local changes with stale remote data.
181
+ */
182
+ reload(domains?: ConfigDomain[]): Promise<UnifiedConfigSnapshot>;
183
+ /**
184
+ * Return the current v3 migration state.
185
+ */
186
+ getMigrationState(): Promise<UnifiedConfigMigrationState>;
187
+ /**
188
+ * Explicitly retry failed domain migrations.
189
+ * Does not clear already-successful domains.
190
+ */
191
+ retryMigration(domains?: ConfigDomain[]): Promise<UnifiedConfigMigrationState>;
192
+ /**
193
+ * Return a deep-cloned snapshot with all sensitive fields masked as "******".
194
+ * Safe for logging, error messages, diagnostics, and audit evidence.
195
+ */
196
+ maskSnapshot(snapshot: UnifiedConfigSnapshot): UnifiedConfigSnapshot;
197
+ }
198
+ /** Per-domain migration status. */
199
+ export type MigrationDomainStatus = "not-started" | "imported" | "skipped" | "failed";
200
+ /** Global migration status. */
201
+ export type MigrationGlobalStatus = "not-started" | "running" | "done" | "failed";
202
+ /** Per-domain migration record. */
203
+ export interface MigrationDomainState {
204
+ status: MigrationDomainStatus;
205
+ /** Identifiers of imported legacy sources (e.g., "v2-workspace-picgo.cfg.json"). */
206
+ importedSources: string[];
207
+ updatedAt?: number;
208
+ error?: string;
209
+ }
210
+ /**
211
+ * V3 unified async config source migration marker.
212
+ *
213
+ * Stored at `picgo.cfg.json:siyuan.picgoMigration` with
214
+ * version = "v3.0-unified-async-config-source".
215
+ */
216
+ export interface UnifiedConfigMigrationState {
217
+ /** Fixed version marker for PicGo 3.0. */
218
+ version: "v3.0-unified-async-config-source";
219
+ /** Global migration status. */
220
+ status: MigrationGlobalStatus;
221
+ /** Unix timestamp of last status update. */
222
+ updatedAt?: number;
223
+ /** Error message if global status is "failed". */
224
+ error?: string;
225
+ /** Number of migration attempts. */
226
+ attempts: number;
227
+ /** Per-domain migration progress. */
228
+ domains: Record<ConfigDomain, MigrationDomainState>;
229
+ }
230
+ /** Fixed PicGo 3.0 unified async config migration marker version. */
231
+ export declare const UNIFIED_CONFIG_MIGRATION_VERSION: "v3.0-unified-async-config-source";
232
+ /** Initial migration state before any migration runs. */
233
+ export declare const INITIAL_MIGRATION_STATE: UnifiedConfigMigrationState;
234
+ /**
235
+ * Thrown when production code attempts to read user configuration
236
+ * before the unified facade has resolved (ready barrier not passed).
237
+ */
238
+ export declare class ConfigNotReadyError extends Error {
239
+ constructor(message?: string);
240
+ }
241
+ /**
242
+ * Thrown when flush() encounters a write failure for one or more domains.
243
+ * Contains per-domain failure details with owner file information.
244
+ */
245
+ export declare class ConfigFlushError extends Error {
246
+ /** Per-domain flush failure details. */
247
+ readonly failures: ConfigFlushFailure[];
248
+ constructor(failures: ConfigFlushFailure[], message?: string);
249
+ }
250
+ /** Single domain flush failure detail. */
251
+ export interface ConfigFlushFailure {
252
+ domain: ConfigDomain;
253
+ ownerFile: string;
254
+ storageKind?: string;
255
+ error: string;
256
+ }
257
+ /**
258
+ * Thrown when an owner file cannot be read.
259
+ *
260
+ * Async/remote backends (SiYuan Kernel, proxy storage, etc.) MUST fail
261
+ * explicitly instead of returning generated defaults. The details are
262
+ * intentionally serializable so UI/headless callers can surface the domain,
263
+ * owner file and backend kind.
264
+ */
265
+ export declare class ConfigReadError extends Error {
266
+ readonly domain: ConfigDomain;
267
+ readonly ownerFile: string;
268
+ readonly storageKind: string;
269
+ readonly causeError?: unknown;
270
+ constructor(input: {
271
+ domain: ConfigDomain;
272
+ ownerFile: string;
273
+ storageKind: string;
274
+ error: unknown;
275
+ message?: string;
276
+ });
277
+ }
278
+ /**
279
+ * Regular expression patterns for detecting sensitive field names
280
+ * that must be masked in non-persistence outputs.
281
+ *
282
+ * These fields are stored as real values in owner files but MUST
283
+ * be rendered as "******" in logs, errors, migration reports,
284
+ * diagnostics, and smoke evidence.
285
+ */
286
+ export declare const SENSITIVE_FIELD_PATTERNS: readonly RegExp[];
287
+ /** Mask value used for all sensitive field outputs. */
288
+ export declare const MASK_VALUE: "******";
289
+ /**
290
+ * Owner file name for each configuration domain.
291
+ *
292
+ * Domains sharing the same owner file are flushed together
293
+ * when any of them is dirty.
294
+ */
295
+ export declare const OWNER_FILE_MAP: Record<ConfigDomain, string>;
296
+ /**
297
+ * Logical key prefix used for browser localStorage fallback.
298
+ */
299
+ export declare const DEFAULT_LOGICAL_KEY_PREFIX: "universal-picgo";
300
+ /** Logical key for PicGo main config in browser fallback. */
301
+ export declare const MAIN_CONFIG_LOGICAL_KEY: "universal-picgo/picgo.cfg.json";
302
+ /** Logical key for external/PicList config in browser fallback. */
303
+ export declare const EXTERNAL_CONFIG_LOGICAL_KEY: "universal-picgo/external-picgo-cfg.json";
304
+ /** Logical key for SiYuan connection config in browser fallback. */
305
+ export declare const SIYUAN_CONNECTION_LOGICAL_KEY: "siyuan-cfg";
306
+ /** Kernel-backed workspace path for PicGo main config. */
307
+ export declare const KERNEL_MAIN_CONFIG_PATH: "/data/storage/syp/picgo/picgo.cfg.json";
308
+ /** Kernel-backed workspace path for external/PicList config. */
309
+ export declare const KERNEL_EXTERNAL_CONFIG_PATH: "/data/storage/syp/picgo/external-picgo-cfg.json";
310
+ /** Kernel-backed workspace path for SiYuan connection config. */
311
+ export declare const KERNEL_SIYUAN_CONNECTION_PATH: "/data/storage/syp/siyuan-cfg.json";
312
+ /** Default values for PicGo main config. Matches ConfigDb.initialValue exactly. */
313
+ export declare const PICGO_MAIN_DEFAULTS: Partial<IConfig>;
314
+ /** Default values for external/PicList config. */
315
+ export declare const EXTERNAL_PICGO_DEFAULTS: IExternalPicgoConfig;
316
+ /** Default values for SiYuan connection config. */
317
+ export declare const SIYUAN_CONNECTION_DEFAULTS: SiyuanConfigLike;
318
+ /**
319
+ * Per-domain default factories.
320
+ *
321
+ * Each factory returns a fresh default object to avoid shared-mutation bugs.
322
+ */
323
+ export declare const DOMAIN_DEFAULTS: Record<ConfigDomain, () => any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { ConfigDomain, UnifiedConfigMigrationState } from './UnifiedConfigTypes';
2
+
3
+ export interface V3MigrationOptions {
4
+ /** Current in-memory data for each owner file. */
5
+ ownerFileData: Map<string, Record<string, any>>;
6
+ /** Existing migration state (from picgo.cfg.json:siyuan.picgoMigration). */
7
+ existingState?: Partial<UnifiedConfigMigrationState>;
8
+ /** Whether we're in a Node environment (for filesystem access). */
9
+ hasNodeEnv: boolean;
10
+ /** SiYuan workspace directory (if available). */
11
+ workspaceDir?: string;
12
+ /** Legacy home/local PicGo directory (if available). */
13
+ homeDir?: string;
14
+ /** Logger. */
15
+ logger?: {
16
+ info: (...args: any[]) => void;
17
+ warn: (...args: any[]) => void;
18
+ error: (...args: any[]) => void;
19
+ };
20
+ }
21
+ /**
22
+ * Execute or resume PicGo 3.0 unified async config migration.
23
+ *
24
+ * Implements per-domain idempotent migration with:
25
+ * - Domain granularity: successes are never rolled back
26
+ * - Default-generated recognition: only generated defaults can be replaced
27
+ * - Priority: workspace > home > browser
28
+ * - importedSources tracking
29
+ * - Retry via retryMigration(domains?)
30
+ */
31
+ export declare function runV3Migration(options: V3MigrationOptions): Promise<UnifiedConfigMigrationState>;
32
+ /**
33
+ * Retry failed domain migrations.
34
+ * Does NOT clear already-successful domains.
35
+ */
36
+ export declare function retryV3Migration(options: V3MigrationOptions, domains?: ConfigDomain[]): Promise<UnifiedConfigMigrationState>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * PicGo 3.0 Unified Configuration barrel export.
3
+ *
4
+ * @module config
5
+ * @since 3.0.0
6
+ */
7
+ export { createUnifiedPicGoConfigFacade } from './UnifiedConfigFacade';
8
+ export { runV3Migration, retryV3Migration, type V3MigrationOptions } from './V3MigrationService';
9
+ export { type ConfigDomain, type ReadyUnifiedPicGoConfigFacade, type UnifiedConfigSnapshot, type UnifiedConfigMigrationState, type UnifiedPicGoConfigFacadeOptions, type UnifiedConfigPaths, type PasteTakeoverSnapshot, type SiyuanConfigLike, type MigrationDomainState, type MigrationDomainStatus, type MigrationGlobalStatus, type ConfigFlushFailure, ALL_CONFIG_DOMAINS, OWNER_FILE_MAP, UNIFIED_CONFIG_MIGRATION_VERSION, INITIAL_MIGRATION_STATE, MASK_VALUE, SENSITIVE_FIELD_PATTERNS, MAIN_CONFIG_LOGICAL_KEY, EXTERNAL_CONFIG_LOGICAL_KEY, SIYUAN_CONNECTION_LOGICAL_KEY, KERNEL_MAIN_CONFIG_PATH, KERNEL_EXTERNAL_CONFIG_PATH, KERNEL_SIYUAN_CONNECTION_PATH, PICGO_MAIN_DEFAULTS, EXTERNAL_PICGO_DEFAULTS, SIYUAN_CONNECTION_DEFAULTS, DOMAIN_DEFAULTS, ConfigNotReadyError, ConfigFlushError, ConfigReadError, } from './UnifiedConfigTypes';
10
+ export { maskSnapshot, maskSensitiveFields, maskIfSensitive, isSensitiveField } from './MaskUtils';
11
+ export { isPicgoMainGeneratedDefault, isExternalPicgoGeneratedDefault, isSiyuanConnectionGeneratedDefault, classifyDomainDefaults, type DefaultClassification, } from './DefaultRecognition';
@@ -1,5 +1,4 @@
1
- import { IImgInfo, IPicGo } from '../types';
2
- import { default as ExternalPicgoConfigDb } from '../db/externalPicGo';
1
+ import { IExternalPicgoConfig, IImgInfo, IPicGo } from '../types';
3
2
 
4
3
  /**
5
4
  *外部的PicGO 上传 Api
@@ -12,13 +11,14 @@ declare class ExternalPicgo {
12
11
  private logger;
13
12
  private requestUrl;
14
13
  private readonly endpointUrl;
15
- db: ExternalPicgoConfigDb;
16
- constructor(ctx: IPicGo, isDev?: boolean);
14
+ private readonly configProvider?;
15
+ constructor(_ctx: IPicGo, isDev?: boolean, configProvider?: () => IExternalPicgoConfig);
17
16
  /**
18
17
  * 上传图片到PicGO
19
18
  *
20
19
  * @param input 路径数组,可为空,为空上传剪贴板
21
20
  */
22
21
  upload(input?: any[]): Promise<IImgInfo[] | Error>;
22
+ private getRouteConfig;
23
23
  }
24
24
  export { ExternalPicgo };
@@ -0,0 +1,50 @@
1
+ import { IExternalPicgoConfig, IImgInfo, IPicGo } from '../types';
2
+
3
+ /**
4
+ * 远程 PicList 上传 API
5
+ *
6
+ * 对接远程 PicList 容器的图片上传接口。
7
+ * 与本地 ExternalPicgo 不同,此上传器通过 multipart/form-data 直接携带图片二进制数据。
8
+ *
9
+ * 接口规范:
10
+ * - URL: POST {apiUrl}?key={apiKey}
11
+ * - Content-Type: multipart/form-data
12
+ * - Body: file 字段,包含图片文件
13
+ * - 响应: { success: true, result: "https://..." }
14
+ *
15
+ * @author terwer
16
+ */
17
+ declare class PicListUploader {
18
+ private readonly logger;
19
+ private readonly configProvider?;
20
+ constructor(_ctx: IPicGo, isDev?: boolean, configProvider?: () => IExternalPicgoConfig);
21
+ /**
22
+ * 上传图片到远程 PicList 服务
23
+ *
24
+ * @param input 文件路径、URL、Blob 或 File 数组。为空则上传剪贴板(不支持,会抛错)
25
+ * @returns 上传结果数组
26
+ */
27
+ upload(input?: any[]): Promise<IImgInfo[] | Error>;
28
+ /**
29
+ * 检查当前是否配置了 PicList(有远程 URL 和 API Key)
30
+ */
31
+ isPicListConfigured(): boolean;
32
+ private getRouteConfig;
33
+ /**
34
+ * 将输入项解析为 Blob 和文件名
35
+ */
36
+ private resolveFileData;
37
+ /**
38
+ * Node.js 环境:从文件系统读取图片
39
+ */
40
+ private resolveNodeFilePath;
41
+ /**
42
+ * 浏览器环境:通过 URL 获取图片数据
43
+ */
44
+ private resolveBrowserUrlOrPath;
45
+ /**
46
+ * 构建带 API Key 的请求 URL
47
+ */
48
+ private buildRequestUrl;
49
+ }
50
+ export { PicListUploader };
@@ -0,0 +1 @@
1
+ export {};