@he0119/dsh-settings-sync 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.en.md +122 -0
- package/README.md +76 -2
- package/cordis.patch.yml +3 -0
- package/icon.svg +7 -0
- package/lib/client.js +1175 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +1346 -0
- package/lib/types/credential-sync.d.ts +55 -0
- package/lib/types/error.d.ts +2 -0
- package/lib/types/index.d.ts +37 -0
- package/lib/types/local-only.d.ts +30 -0
- package/lib/types/patch-view.d.ts +43 -0
- package/lib/types/snapshot.d.ts +23 -0
- package/lib/types/sync-scope.d.ts +15 -0
- package/lib/types/sync.d.ts +73 -0
- package/lib/types/web.d.ts +25 -0
- package/lib/types/webdav.d.ts +38 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +94 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CredentialsDocument } from "@deepseek-ai/dsh-credentials-local";
|
|
2
|
+
import { SnapshotCredentials } from "./snapshot.js";
|
|
3
|
+
export declare const MAX_CREDENTIAL_SELECTION = 128;
|
|
4
|
+
/** 本机凭据文件里参与合并的两段。 */
|
|
5
|
+
export type CredentialEntries = Pick<CredentialsDocument, 'refs' | 'records'>;
|
|
6
|
+
/** 一次凭据搬运的输入。远端那一侧就是整份同步快照里的凭据,不再有单独的加密文件。 */
|
|
7
|
+
export interface CredentialSyncOptions {
|
|
8
|
+
/** 上传或下载。 */
|
|
9
|
+
direction: 'push' | 'pull';
|
|
10
|
+
/** 本机凭据文件路径。 */
|
|
11
|
+
filename: string;
|
|
12
|
+
/** 远端快照里的凭据。 */
|
|
13
|
+
saved: SnapshotCredentials;
|
|
14
|
+
/** 本轮要搬的条目名字,由同步范围决定。 */
|
|
15
|
+
selection: readonly string[];
|
|
16
|
+
/** 摘要里怎么写条目;统一同步时会串上配置同步的写法。 */
|
|
17
|
+
describe?: (counts: {
|
|
18
|
+
added: number;
|
|
19
|
+
replaced: number;
|
|
20
|
+
}) => string;
|
|
21
|
+
/** 和配置同步共用的上一轮运行开关,保证一次手动同步只跑一条。 */
|
|
22
|
+
running?: {
|
|
23
|
+
current: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** true 时只算计划、不写本机文件;预览阶段用。 */
|
|
26
|
+
dryRun?: boolean;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
/** 凭据搬运的结果:计数、更新后的远端凭据,以及要写回本机的文件内容。 */
|
|
30
|
+
export interface CredentialOutcome {
|
|
31
|
+
summary: string;
|
|
32
|
+
edited: boolean;
|
|
33
|
+
/** 合并之后远端快照里的凭据;上传方向才变化。 */
|
|
34
|
+
saved: SnapshotCredentials;
|
|
35
|
+
/** 合并之后本机凭据文件的内容;下载方向才变化。 */
|
|
36
|
+
file?: string;
|
|
37
|
+
}
|
|
38
|
+
/** 把条目转成同步范围里用的名字:`ref:名字` / `record:记录标识`,并排好序。 */
|
|
39
|
+
export declare function credentialNames(entries: CredentialEntries): string[];
|
|
40
|
+
/** 读出某个方向的来源端凭据:上传看本机文件,下载看远端快照里的那一份。 */
|
|
41
|
+
export declare function readCredentialSource(options: {
|
|
42
|
+
direction: 'push' | 'pull';
|
|
43
|
+
filename: string;
|
|
44
|
+
saved: SnapshotCredentials;
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
entries: CredentialEntries;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* 跑一次凭据搬运:从本机凭据文件或远端快照里挑出选中的条目,合进另一边。
|
|
51
|
+
* 远端那一侧只是内存里的凭据,写进加密快照由调用方统一做,这里不碰网络。
|
|
52
|
+
*/
|
|
53
|
+
export declare function createCredentialSync(shared?: {
|
|
54
|
+
current: boolean;
|
|
55
|
+
}): (options: CredentialSyncOptions) => Promise<CredentialOutcome>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import Schema from "@deepseek-ai/schemastery";
|
|
3
|
+
export declare const inject: string[];
|
|
4
|
+
export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
5
|
+
sync: Schema<Schemastery.ObjectS<NoInfer<{
|
|
6
|
+
url: Schema<string, string, "volatile-defined">;
|
|
7
|
+
auto: Schema<boolean, boolean, "volatile-defined">;
|
|
8
|
+
username: Schema<string, string, "volatile-defined">;
|
|
9
|
+
passwordRef: Schema<string, string, "volatile-defined">;
|
|
10
|
+
keyEnv: Schema<string, string, "volatile-defined">;
|
|
11
|
+
localOnly: Schema<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
|
|
12
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
13
|
+
url: Schema<string, string, "volatile-defined">;
|
|
14
|
+
auto: Schema<boolean, boolean, "volatile-defined">;
|
|
15
|
+
username: Schema<string, string, "volatile-defined">;
|
|
16
|
+
passwordRef: Schema<string, string, "volatile-defined">;
|
|
17
|
+
keyEnv: Schema<string, string, "volatile-defined">;
|
|
18
|
+
localOnly: Schema<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
|
|
19
|
+
}>>, "defined">;
|
|
20
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
21
|
+
sync: Schema<Schemastery.ObjectS<NoInfer<{
|
|
22
|
+
url: Schema<string, string, "volatile-defined">;
|
|
23
|
+
auto: Schema<boolean, boolean, "volatile-defined">;
|
|
24
|
+
username: Schema<string, string, "volatile-defined">;
|
|
25
|
+
passwordRef: Schema<string, string, "volatile-defined">;
|
|
26
|
+
keyEnv: Schema<string, string, "volatile-defined">;
|
|
27
|
+
localOnly: Schema<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
|
|
28
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
29
|
+
url: Schema<string, string, "volatile-defined">;
|
|
30
|
+
auto: Schema<boolean, boolean, "volatile-defined">;
|
|
31
|
+
username: Schema<string, string, "volatile-defined">;
|
|
32
|
+
passwordRef: Schema<string, string, "volatile-defined">;
|
|
33
|
+
keyEnv: Schema<string, string, "volatile-defined">;
|
|
34
|
+
localOnly: Schema<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
|
|
35
|
+
}>>, "defined">;
|
|
36
|
+
}>>, "plain">;
|
|
37
|
+
export declare function apply(ctx: Context, config: ReturnType<typeof Config>): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「仅本机」规则:默认所有条目都同步,规则负责把某些条目或键留在本机。
|
|
3
|
+
* 写法是 `条目ID` 或 `条目ID:键.路径`;以 `+` 开头表示在已排除的分组里把这一项放回同步。
|
|
4
|
+
*/
|
|
5
|
+
export interface LocalOnlyRule {
|
|
6
|
+
readonly raw: string;
|
|
7
|
+
readonly segments: readonly string[];
|
|
8
|
+
readonly include: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface LocalOnlyState {
|
|
11
|
+
/** 写法不合法、被忽略的规则。 */
|
|
12
|
+
readonly invalid: readonly string[];
|
|
13
|
+
/** 这个节点是否不参与同步。 */
|
|
14
|
+
isLocalOnly(id: string): boolean;
|
|
15
|
+
/** 决定这个节点状态的最具体规则。 */
|
|
16
|
+
reasonFor(id: string): string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** 把 `条目ID:键.路径` 拆成段;没有冒号时只有条目本身。 */
|
|
19
|
+
export declare function idSegments(id: string): string[];
|
|
20
|
+
/** 段列表拼回节点 ID。 */
|
|
21
|
+
export declare function nodeId(segments: readonly string[]): string;
|
|
22
|
+
export declare function isPrefix(prefix: readonly string[], target: readonly string[]): boolean;
|
|
23
|
+
export declare function parseRule(raw: string): LocalOnlyRule | undefined;
|
|
24
|
+
export declare function localOnlyState(rules: readonly string[]): LocalOnlyState;
|
|
25
|
+
/** 勾选/取消勾选一个节点,返回新的规则列表。`synced` 为 true 表示这一项参与同步。 */
|
|
26
|
+
export declare function toggleLocalOnly(rules: readonly string[], id: string, synced: boolean): string[];
|
|
27
|
+
/** 规则列表是否合法(供页面在保存前提示)。 */
|
|
28
|
+
export declare function invalidRules(rules: readonly string[]): string[];
|
|
29
|
+
/** 找出在本机配置里找不到对应节点的规则;写法不合法的也算在里面,让页面能提示并移除。 */
|
|
30
|
+
export declare function staleRules(rules: readonly string[], leaves: readonly (readonly string[])[]): string[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置补丁里的一段值:YAML 解析后的普通数据。
|
|
3
|
+
* 数组整体当作一个叶子({@link flattenConfig} 不展开下标)。
|
|
4
|
+
*/
|
|
5
|
+
export type PatchValue = null | boolean | number | string | PatchValue[] | {
|
|
6
|
+
[key: string]: PatchValue;
|
|
7
|
+
};
|
|
8
|
+
/** 一个条目的 `config:` 段。 */
|
|
9
|
+
export type PatchConfig = Record<string, PatchValue>;
|
|
10
|
+
export declare function isPlainObject(value: unknown): value is Record<string, PatchValue>;
|
|
11
|
+
export declare function cloneValue(value: PatchValue): PatchValue;
|
|
12
|
+
/** 子树里是否含有 `!!js` 表达式。表达式可能引用本机路径或环境变量,默认不跨机器搬运。 */
|
|
13
|
+
export declare function hasExpression(value: PatchValue): boolean;
|
|
14
|
+
/** 丢掉子树里含 `!!js` 表达式的键。 */
|
|
15
|
+
export declare function stripExpressions(config: PatchConfig): PatchConfig;
|
|
16
|
+
/** 按路径移除子树(就地修改传入的副本)。 */
|
|
17
|
+
export declare function stripPaths(config: PatchConfig, paths: readonly (readonly string[])[]): PatchConfig;
|
|
18
|
+
/** 路径段列表拼成内部键。 */
|
|
19
|
+
export declare function pathKey(path: readonly string[]): string;
|
|
20
|
+
export declare function splitKey(key: string): string[];
|
|
21
|
+
/** 把一段配置展开成「叶子路径 → 值」。数组、标量都是叶子;空对象不产生叶子。 */
|
|
22
|
+
export declare function flattenConfig(config: PatchValue, prefix?: string[], out?: Map<string, PatchValue>): Map<string, PatchValue>;
|
|
23
|
+
export declare function deepEqual(left: PatchValue | undefined, right: PatchValue | undefined): boolean;
|
|
24
|
+
export declare function getPath(config: PatchConfig, path: readonly string[]): PatchValue | undefined;
|
|
25
|
+
/** 深合并:对象逐键合并,其它值(含数组)由后者整体替换。 */
|
|
26
|
+
export declare function mergeConfig(base: PatchValue | undefined, overlay: PatchValue): PatchValue;
|
|
27
|
+
/** 写回一个叶子路径(`value` 为 undefined 时删除该键)。 */
|
|
28
|
+
export declare function setPath(config: PatchConfig, path: readonly string[], value: PatchValue | undefined): PatchConfig;
|
|
29
|
+
export interface ConfigChangeDetail {
|
|
30
|
+
path: string[];
|
|
31
|
+
before: PatchValue | undefined;
|
|
32
|
+
after: PatchValue | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** 逐叶子比较两段配置;返回需要写入的路径。 */
|
|
35
|
+
export declare function diffConfig(current: PatchConfig, target: PatchConfig): ConfigChangeDetail[];
|
|
36
|
+
/** 预览里的值描述:文本与数组不打印内容,避免把配置正文带出预览界面。 */
|
|
37
|
+
export declare function displayValue(value: PatchValue | undefined): string;
|
|
38
|
+
/** 校验一段配置能不能进快照:必须是普通对象,且不能带表达式。 */
|
|
39
|
+
export declare function assertSyncable(config: PatchConfig): void;
|
|
40
|
+
/** 按路径裁剪配置树:`keep` 返回 false 的节点连同子树一起丢掉。 */
|
|
41
|
+
export declare function stripWhere(config: PatchConfig, keep: (path: string[]) => boolean): PatchConfig;
|
|
42
|
+
/** 同步范围里显示的一行值:折成单行、截断;对象用 JSON,数组取 id 或直接列元素。 */
|
|
43
|
+
export declare function previewValue(value: PatchValue | undefined, limit?: number): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PatchConfig } from "./patch-view.js";
|
|
2
|
+
/** 加密快照的大小上限。配置和凭据同在一份快照里,所以凭据也受这个上限约束。 */
|
|
3
|
+
export declare const MAX_SNAPSHOT_BYTES: number;
|
|
4
|
+
export type SnapshotKey = Buffer<ArrayBuffer>;
|
|
5
|
+
/** 一份快照里的凭据:和本机凭据文件同一套结构,只是存在远端。 */
|
|
6
|
+
export interface SnapshotCredentials {
|
|
7
|
+
refs: Record<string, string>;
|
|
8
|
+
records: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/** 上传时交给 encodeSnapshot 的内容:配置条目和凭据。 */
|
|
11
|
+
export interface SnapshotContents {
|
|
12
|
+
entries: ReadonlyMap<string, PatchConfig>;
|
|
13
|
+
credentials: SnapshotCredentials;
|
|
14
|
+
}
|
|
15
|
+
export declare function encryptionKey(secret: string | undefined): SnapshotKey;
|
|
16
|
+
export declare function emptyCredentials(): SnapshotCredentials;
|
|
17
|
+
export declare function encodeSnapshot(contents: SnapshotContents, key: SnapshotKey): Buffer<ArrayBuffer>;
|
|
18
|
+
/** 解出快照里的配置条目和凭据。 */
|
|
19
|
+
export declare function decodeSnapshot(bytes: Buffer, key: SnapshotKey): {
|
|
20
|
+
entries: Map<string, PatchConfig>;
|
|
21
|
+
credentials: SnapshotCredentials;
|
|
22
|
+
};
|
|
23
|
+
export type { PatchConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LocalOnlyState } from "./local-only.js";
|
|
2
|
+
/**
|
|
3
|
+
* 凭据在同步范围里的前缀。凭据那一行写成 `credentials:凭据名`(就是网页上显示的节点 ID),
|
|
4
|
+
* 配置那一行是 `条目ID:键.路径`,两者用同一套「仅本机」规则决定要不要同步。
|
|
5
|
+
*/
|
|
6
|
+
export declare const CREDENTIAL_ENTRY = "credentials";
|
|
7
|
+
/** 内部名字里去掉身份标签:`ref:名字` 与 `record:记录标识` 都还原成名字,预览和合并按名字对应。 */
|
|
8
|
+
export declare function stripCredentialTag(name: string): string;
|
|
9
|
+
/** 一个凭据名字在不在同步范围里。规则按网页上显示的节点 ID 写,所以这里也用同一种写法去查。 */
|
|
10
|
+
export declare function credentialInScope(state: LocalOnlyState, name: string): boolean;
|
|
11
|
+
/** 凭据文档里的条目 → 在同步范围里的名字,排好序。搬不搬只看范围,不另设名单。 */
|
|
12
|
+
export declare function scopeCredentialNames(entries: {
|
|
13
|
+
refs: ReadonlyMap<string, unknown>;
|
|
14
|
+
records: ReadonlyMap<string, unknown>;
|
|
15
|
+
}, state: LocalOnlyState): string[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { PatchConfig } from "./patch-view.js";
|
|
2
|
+
import { SnapshotCredentials, SnapshotKey } from "./snapshot.js";
|
|
3
|
+
import { SnapshotTransport } from "./webdav.js";
|
|
4
|
+
/** 本机补丁文件的读写入口:读回每条目当前 config,按条目写回合并后的 config。 */
|
|
5
|
+
export interface PatchAccess {
|
|
6
|
+
read(): Map<string, PatchConfig>;
|
|
7
|
+
write(id: string, config: PatchConfig): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface ManualSyncInput {
|
|
10
|
+
direction: 'push' | 'pull';
|
|
11
|
+
confirmation?: string;
|
|
12
|
+
scope?: 'settings' | 'credentials';
|
|
13
|
+
selection?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export type SyncInput = ManualSyncInput | {
|
|
16
|
+
direction: 'auto';
|
|
17
|
+
confirmation?: string;
|
|
18
|
+
};
|
|
19
|
+
export type SyncChannel = 'web' | 'auto';
|
|
20
|
+
export interface ManualSyncResult {
|
|
21
|
+
summary: string;
|
|
22
|
+
changed: string[];
|
|
23
|
+
applied: string[];
|
|
24
|
+
confirmation?: string;
|
|
25
|
+
credentialCounts?: {
|
|
26
|
+
added: number;
|
|
27
|
+
replaced: number;
|
|
28
|
+
};
|
|
29
|
+
/** 需要用户先决定同步范围的凭据名字,只在自动同步里出现。 */
|
|
30
|
+
credentialsPending?: string[];
|
|
31
|
+
}
|
|
32
|
+
type AutoSyncResult = {
|
|
33
|
+
summary: string;
|
|
34
|
+
credentialsPending?: string[];
|
|
35
|
+
};
|
|
36
|
+
type Filter = (config: PatchConfig, id: string) => PatchConfig;
|
|
37
|
+
export interface SyncOptions {
|
|
38
|
+
url: string;
|
|
39
|
+
username?: string;
|
|
40
|
+
transport: SnapshotTransport;
|
|
41
|
+
key: SnapshotKey;
|
|
42
|
+
access: PatchAccess;
|
|
43
|
+
/** 仅本机规则,原样参与确认值,实际过滤由 filter 完成。 */
|
|
44
|
+
localOnly?: readonly string[];
|
|
45
|
+
/** 去掉仅本机条目、秘密字段与 !!js 表达式。 */
|
|
46
|
+
filter?: Filter;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
channel?: SyncChannel;
|
|
49
|
+
checkActive?: () => void;
|
|
50
|
+
/** 凭据那一半:给了就一起进预览和确认,凭据和配置写进同一份加密快照;自动同步不传。 */
|
|
51
|
+
credentials?: (input: {
|
|
52
|
+
direction: 'push' | 'pull';
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
dryRun: boolean;
|
|
55
|
+
}) => Promise<CredentialPlan | null>;
|
|
56
|
+
/** 自动同步只用来提示还有凭据没处理,不出内容。 */
|
|
57
|
+
pendingCredentials?: () => Promise<string[]>;
|
|
58
|
+
}
|
|
59
|
+
/** 凭据那一半交回来的东西:要不要动、动完之后的快照凭据,以及给人看的一句话。 */
|
|
60
|
+
export interface CredentialPlan {
|
|
61
|
+
summary: string;
|
|
62
|
+
/** 这次要不要真的动凭据。 */
|
|
63
|
+
edited: boolean;
|
|
64
|
+
/** 远端快照里的凭据。 */
|
|
65
|
+
saved: SnapshotCredentials;
|
|
66
|
+
}
|
|
67
|
+
export declare function createSync(access: PatchAccess, shared?: {
|
|
68
|
+
current: boolean;
|
|
69
|
+
}): {
|
|
70
|
+
(options: SyncOptions & ManualSyncInput): Promise<ManualSyncResult>;
|
|
71
|
+
(options: SyncOptions & SyncInput): Promise<ManualSyncResult | AutoSyncResult>;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { ManualSyncInput, ManualSyncResult } from "./sync.js";
|
|
3
|
+
export interface SyncRoute {
|
|
4
|
+
kind: 'exact';
|
|
5
|
+
path: string;
|
|
6
|
+
auth: 'required';
|
|
7
|
+
handler(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export type RunWebSync = (input: ManualSyncInput, signal: AbortSignal, channel: 'web') => Promise<ManualSyncResult>;
|
|
10
|
+
type ListCredentials = (direction: ManualSyncInput['direction'], signal: AbortSignal) => Promise<{
|
|
11
|
+
entries: string[];
|
|
12
|
+
}>;
|
|
13
|
+
type ListSettings = () => Promise<{
|
|
14
|
+
entries: string[];
|
|
15
|
+
values?: Record<string, string>;
|
|
16
|
+
stale?: string[];
|
|
17
|
+
}> | {
|
|
18
|
+
entries: string[];
|
|
19
|
+
values?: Record<string, string>;
|
|
20
|
+
stale?: string[];
|
|
21
|
+
};
|
|
22
|
+
export declare function registerSyncRoute(webServer: {
|
|
23
|
+
register(route: SyncRoute): () => void;
|
|
24
|
+
}, runSync: RunWebSync, autoStatus?: () => string, listCredentials?: ListCredentials, listSettings?: ListSettings): () => void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface RemoteSnapshot {
|
|
2
|
+
bytes: Buffer;
|
|
3
|
+
etag: string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface SnapshotTransport {
|
|
6
|
+
read(): Promise<RemoteSnapshot | null>;
|
|
7
|
+
write(bytes: Buffer<ArrayBuffer>, previous: RemoteSnapshot | null): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
interface WebDavRequest extends RequestInit {
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
interface WebDavOptions {
|
|
13
|
+
username?: string;
|
|
14
|
+
password?: string;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
fetcher?: (url: string | URL, options: WebDavRequest) => Promise<Response>;
|
|
17
|
+
/** 插件自己那一层目录(以 / 结尾)。第一次写快照遇到 409 时按它逐层建出来。 */
|
|
18
|
+
directory?: URL;
|
|
19
|
+
}
|
|
20
|
+
export declare function requireFileVersion(previous: Pick<RemoteSnapshot, 'etag'> | null): asserts previous is {
|
|
21
|
+
etag: string;
|
|
22
|
+
} | null;
|
|
23
|
+
/** 远端快照固定放在这一层目录里,用户填的地址当作它的上级。 */
|
|
24
|
+
export declare const SYNC_DIRECTORY = "dsh-settings-sync";
|
|
25
|
+
/** 快照文件名。 */
|
|
26
|
+
export declare const SNAPSHOT_FILE = "dsh-settings.bin";
|
|
27
|
+
/** 插件自己那一层目录的地址;上传前不存在就建出来。 */
|
|
28
|
+
export declare function syncDirectoryUrl(value: string): import("url").URL;
|
|
29
|
+
/** 快照文件的地址。 */
|
|
30
|
+
export declare function snapshotUrl(value: string): import("url").URL;
|
|
31
|
+
export declare function webdav(url: string | URL, { username, password, signal, fetcher, directory }: WebDavOptions): {
|
|
32
|
+
read(): Promise<{
|
|
33
|
+
bytes: Buffer<ArrayBuffer>;
|
|
34
|
+
etag: string | null;
|
|
35
|
+
} | null>;
|
|
36
|
+
write(bytes: Buffer<ArrayBuffer>, previous: Pick<RemoteSnapshot, "etag"> | null): Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@he0119/dsh-settings-sync",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "通过 WebDAV 在设备之间同步选定的 DeepSeek Harness 设置和凭据。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"dsh",
|
|
10
|
+
"dsh-plugin",
|
|
11
|
+
"deepseek-harness",
|
|
12
|
+
"settings",
|
|
13
|
+
"sync",
|
|
14
|
+
"webdav"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/he0119/dsh-settings-sync.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/he0119/dsh-settings-sync",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/he0119/dsh-settings-sync/issues"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./lib/types/index.d.ts",
|
|
30
|
+
"default": "./lib/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./client": "./lib/client.js",
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
35
|
+
"./locale/*.json": "./locale/*.json",
|
|
36
|
+
"./icon": "./icon.svg"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"lib",
|
|
40
|
+
"cordis.patch.yml",
|
|
41
|
+
"locale/*.json",
|
|
42
|
+
"icon.svg",
|
|
43
|
+
"README.md",
|
|
44
|
+
"README.en.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": "^24.22.3 || >=26.13.1",
|
|
49
|
+
"dsh": "^0.2.3-alpha.3"
|
|
50
|
+
},
|
|
51
|
+
"dsh": {
|
|
52
|
+
"bundle": {
|
|
53
|
+
"patch": "./cordis.patch.yml"
|
|
54
|
+
},
|
|
55
|
+
"client": {
|
|
56
|
+
"platform": "web",
|
|
57
|
+
"immediately": true,
|
|
58
|
+
"inject": [
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-primitives"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@deepseek-ai/cordis": "~4.2.0-alpha.2",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.3",
|
|
67
|
+
"@deepseek-ai/dsh-config-editor": "0.2.3-alpha.3",
|
|
68
|
+
"@deepseek-ai/dsh-credentials": "0.2.3-alpha.3",
|
|
69
|
+
"@deepseek-ai/dsh-credentials-local": "0.2.3-alpha.3",
|
|
70
|
+
"@deepseek-ai/schemastery": "~3.20.0-alpha.2"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@deepseek-ai/cordis": "~4.2.0-alpha.2",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.3",
|
|
75
|
+
"@deepseek-ai/dsh-config-editor": "0.2.3-alpha.3",
|
|
76
|
+
"@deepseek-ai/dsh-credentials": "0.2.3-alpha.3",
|
|
77
|
+
"@deepseek-ai/dsh-credentials-local": "0.2.3-alpha.3",
|
|
78
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.3-alpha.3",
|
|
79
|
+
"@deepseek-ai/dsh-settings": "0.2.3-alpha.3",
|
|
80
|
+
"@deepseek-ai/schemastery": "~3.20.0-alpha.2",
|
|
81
|
+
"@types/node": "^24.0.0",
|
|
82
|
+
"@types/react": "^19.2.0",
|
|
83
|
+
"tsdown": "^0.23.0",
|
|
84
|
+
"typescript": "^5.9.3"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@deepseek-ai/dsh-atomic-write": "0.2.3-alpha.3",
|
|
88
|
+
"yaml": "^2.9.0"
|
|
89
|
+
},
|
|
90
|
+
"scripts": {
|
|
91
|
+
"build": "tsdown --concurrency 1",
|
|
92
|
+
"typecheck": "tsc -p tsconfig.test.json && tsc -p tsconfig.client.json",
|
|
93
|
+
"test": "node --test test/*.test.ts",
|
|
94
|
+
"check:package": "node scripts/check-package.mjs",
|
|
95
|
+
"check": "pnpm typecheck && pnpm build && pnpm test && pnpm check:package"
|
|
96
|
+
}
|
|
6
97
|
}
|