@yankeguo/dsh-devlead-protocol 0.4.2-rc.3 → 0.4.2-rc.5
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/README.md +18 -9
- package/lib/client.js +142 -2
- package/lib/index.js +142 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# @yankeguo/dsh-devlead-protocol
|
|
2
2
|
|
|
3
3
|
Pure shared protocol for the DevLead plugin suite: durable record payloads, Session projection
|
|
4
|
-
types, the strict project-board wire
|
|
5
|
-
Host and the browser bundle use. It is the only package both halves share: the
|
|
6
|
-
path segments (`DEVLEAD_BOARD_DIR_SEGMENTS`, `DEVLEAD_BOARD_FILE_NAME`) and the
|
|
4
|
+
types, the strict project-board and project-notes wire schemas (both v1), formatting helpers, and the
|
|
5
|
+
constants both the Host and the browser bundle use. It is the only package both halves share: the
|
|
6
|
+
board's default path segments (`DEVLEAD_BOARD_DIR_SEGMENTS`, `DEVLEAD_BOARD_FILE_NAME`) and the
|
|
7
7
|
`DEVLEAD_BOARD_READ_MAX_BYTES` tool-read cap live here, so the Host (which derives
|
|
8
8
|
`<lead header.cwd>/.dsh/devlead/board.json`) and the browser (which derives the same default path
|
|
9
|
-
from the Session summary `cwd` when the page-load global is absent) cannot drift.
|
|
9
|
+
from the Session summary `cwd` when the page-load global is absent) cannot drift. Notes constants
|
|
10
|
+
identify `dirname(boardPath)/notes/index.json`, cap the index at 128 KiB and each Markdown body at
|
|
11
|
+
256 KiB, and limit each project to 100 notes.
|
|
10
12
|
|
|
11
13
|
This package has **no runtime dependency** on any DSH package. Its single DSH import is a
|
|
12
14
|
type-only projection-map augmentation; it is erased at build time. The one third-party runtime
|
|
13
|
-
dependency is `zod`, which builds the board
|
|
14
|
-
|
|
15
|
+
dependency is `zod`, which builds the board and notes-index schemas shared by the Host validators and
|
|
16
|
+
browser decoders: both published entries bundle it, so an installed profile does not need to resolve `zod`
|
|
15
17
|
for the Host half, while DSH's browser build imports the frozen module table's `zod` platform
|
|
16
18
|
singleton (the same module `client-ui` already relied on). Installing this package alone does not
|
|
17
19
|
enable DevLead — install the bundle (below) to get the host service, tools, command, and UI.
|
|
@@ -31,7 +33,7 @@ Only install this package directly when you are composing the suite yourself.
|
|
|
31
33
|
| Export | Contents |
|
|
32
34
|
| --- | --- |
|
|
33
35
|
| `@yankeguo/dsh-devlead-protocol` | Host entry; re-exports the client-safe surface |
|
|
34
|
-
| `@yankeguo/dsh-devlead-protocol/client` | Browser-safe constants, types, pure formatting helpers, the shared board schema
|
|
36
|
+
| `@yankeguo/dsh-devlead-protocol/client` | Browser-safe constants, types, pure formatting helpers, the shared board and notes-index schema factories/parsers, and the default board path segments / read cap |
|
|
35
37
|
| `@yankeguo/dsh-devlead-protocol/package.json` | Package manifest |
|
|
36
38
|
|
|
37
39
|
The public contract includes the `devLead` / `devLeadMode` / `devLeadWatch` projection keys and
|
|
@@ -49,7 +51,14 @@ the schema version, byte/count/length limits, the default path segment constants
|
|
|
49
51
|
`createDevLeadBoardSchema(isAbsolutePath)` — one strict decoder both the Host (with its own
|
|
50
52
|
`node:path.isAbsolute`) and the browser (with the Host-published `pathPlatform`) consume, including
|
|
51
53
|
duplicate project/workspace-path/blocker/task rules, UTC-only timestamps, and strict unknown-field
|
|
52
|
-
rejection.
|
|
54
|
+
rejection. The notes contract adds `DevLeadNotesIndex` / `DevLeadNotesProject` /
|
|
55
|
+
`DevLeadNoteMetadata`, `createDevLeadNotesIndexSchema()` and `parseDevLeadNotesIndex()`, plus
|
|
56
|
+
`DEVLEAD_NOTES_*` path and limit constants. Its strict schema-v1 index is
|
|
57
|
+
`{ schemaVersion:1, revision, updatedAt, projects:[{ id, directory, notes[] }] }`; metadata rows are
|
|
58
|
+
`{ id, title, summary, updatedAt, bytes, path }`. Unknown fields, duplicate project ids/directories,
|
|
59
|
+
duplicate note ids/paths, unsafe absolute/traversal paths, and any path other than the exact
|
|
60
|
+
`<project.directory>/<note.id>.md` are rejected. Note bodies never appear in the index.
|
|
61
|
+
`client-ui` imports these constants and decoders from this package instead of depending on the Host
|
|
53
62
|
core package.
|
|
54
63
|
|
|
55
64
|
## Related docs
|
|
@@ -61,4 +70,4 @@ core package.
|
|
|
61
70
|
## 中文
|
|
62
71
|
|
|
63
72
|
`@yankeguo/dsh-devlead-protocol` 是 DevLead 套件的纯协议包:host 与浏览器共用的类型、常量、
|
|
64
|
-
projection 键(`devLead` / `devLeadMode` / `devLeadWatch`)、`plugin:devlead/*` 持久记录类型(mode / watch / notification / report / reset
|
|
73
|
+
projection 键(`devLead` / `devLeadMode` / `devLeadWatch`)、`plugin:devlead/*` 持久记录类型(mode / watch / notification / report / reset)、项目看板与项目 notes 的严格 wire schema v1,以及格式化函数和请求/结果形状。看板导出 `createDevLeadBoardSchema(isAbsolutePath)`、limits、持久类型、重复 id/path 与 UTC 时间规则、RFC 6901 issue 映射;包内另导出看板默认路径段常量(`DEVLEAD_BOARD_DIR_SEGMENTS` = `.dsh`/`devlead`、`DEVLEAD_BOARD_FILE_NAME` = `board.json`)与 `devlead_board_read` 的 64 KiB 上限 `DEVLEAD_BOARD_READ_MAX_BYTES`,Host 与浏览器各自用自己的路径实现派生同一默认路径,不会各写一份。notes 导出 `DevLeadNotesIndex` / `DevLeadNotesProject` / `DevLeadNoteMetadata`、`createDevLeadNotesIndexSchema()` / `parseDevLeadNotesIndex()` 与 `DEVLEAD_NOTES_*` 常量:index 固定为 `{schemaVersion:1,revision,updatedAt,projects:[{id,directory,notes[]}]}`,metadata 固定为 `{id,title,summary,updatedAt,bytes,path}`;正文不进入 index,路径必须精确等于 `<directory>/<note-id>.md`。未知字段、重复 project id/directory/note id/path、绝对路径和 path traversal 一律拒绝;index ≤128 KiB、单 note ≤256 KiB、每项目 ≤100 条。它没有运行时 DSH 依赖;`zod` 是唯一的第三方运行期依赖,会被打包进两个发布入口,浏览器侧使用 DSH 冻结 module table 的 `zod` platform singleton。`@yankeguo/dsh-client-ui-devlead` 只依赖本包(不依赖 `@yankeguo/dsh-devlead`)。通常随 bundle 安装。完整中文文档见[根 README.zh.md](https://github.com/yankeguo/dsh-devlead/blob/main/README.zh.md)与[设计说明](https://github.com/yankeguo/dsh-devlead/blob/main/docs/DESIGN.md)。
|
package/lib/client.js
CHANGED
|
@@ -14694,7 +14694,7 @@ var taskSchema = external_exports.object({
|
|
|
14694
14694
|
updatedAt: timestampSchema
|
|
14695
14695
|
}).strict();
|
|
14696
14696
|
function createDevLeadBoardSchema(isAbsolutePath) {
|
|
14697
|
-
const
|
|
14697
|
+
const projectSchema2 = external_exports.object({
|
|
14698
14698
|
id: idSchema,
|
|
14699
14699
|
workspace: external_exports.object({
|
|
14700
14700
|
path: external_exports.string().min(1).max(DEVLEAD_BOARD_PATH_MAX).refine(isAbsolutePath, {
|
|
@@ -14716,7 +14716,7 @@ function createDevLeadBoardSchema(isAbsolutePath) {
|
|
|
14716
14716
|
revision: external_exports.number().int().nonnegative().safe(),
|
|
14717
14717
|
updatedAt: timestampSchema,
|
|
14718
14718
|
updatedBy: external_exports.object({ sessionId: idSchema, title: titleSchema }).strict(),
|
|
14719
|
-
projects: external_exports.array(
|
|
14719
|
+
projects: external_exports.array(projectSchema2).max(DEVLEAD_BOARD_MAX_PROJECTS)
|
|
14720
14720
|
}).strict().superRefine((board, context) => {
|
|
14721
14721
|
const projectIds = /* @__PURE__ */ new Set();
|
|
14722
14722
|
const workspacePaths = /* @__PURE__ */ new Set();
|
|
@@ -14754,6 +14754,130 @@ function createDevLeadBoardSchema(isAbsolutePath) {
|
|
|
14754
14754
|
});
|
|
14755
14755
|
return boardSchema;
|
|
14756
14756
|
}
|
|
14757
|
+
|
|
14758
|
+
// packages/protocol/src/notes.ts
|
|
14759
|
+
var DEVLEAD_NOTES_SCHEMA_VERSION = 1;
|
|
14760
|
+
var DEVLEAD_NOTES_DIR_NAME = "notes";
|
|
14761
|
+
var DEVLEAD_NOTES_INDEX_FILE_NAME = "index.json";
|
|
14762
|
+
var DEVLEAD_NOTES_INDEX_MAX_BYTES = 128 * 1024;
|
|
14763
|
+
var DEVLEAD_NOTES_NOTE_MAX_BYTES = 256 * 1024;
|
|
14764
|
+
var DEVLEAD_NOTES_READ_MAX_BYTES = DEVLEAD_BOARD_READ_MAX_BYTES;
|
|
14765
|
+
var DEVLEAD_NOTES_MAX_PROJECTS = 50;
|
|
14766
|
+
var DEVLEAD_NOTES_MAX_PER_PROJECT = 100;
|
|
14767
|
+
var DEVLEAD_NOTES_ID_MAX = 128;
|
|
14768
|
+
var DEVLEAD_NOTES_DIRECTORY_MAX = 128;
|
|
14769
|
+
var DEVLEAD_NOTES_TITLE_MAX = 200;
|
|
14770
|
+
var DEVLEAD_NOTES_SUMMARY_MAX = 500;
|
|
14771
|
+
var DEVLEAD_NOTES_PATH_MAX = 512;
|
|
14772
|
+
var DEVLEAD_NOTES_TIMESTAMP_MAX = 64;
|
|
14773
|
+
var timestampSchema2 = external_exports.string().max(DEVLEAD_NOTES_TIMESTAMP_MAX).pipe(external_exports.iso.datetime());
|
|
14774
|
+
var projectIdSchema = external_exports.string().min(1).max(DEVLEAD_NOTES_ID_MAX);
|
|
14775
|
+
var titleSchema2 = external_exports.string().min(1).max(DEVLEAD_NOTES_TITLE_MAX);
|
|
14776
|
+
var summarySchema = external_exports.string().max(DEVLEAD_NOTES_SUMMARY_MAX);
|
|
14777
|
+
var WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
14778
|
+
"CON",
|
|
14779
|
+
"PRN",
|
|
14780
|
+
"AUX",
|
|
14781
|
+
"NUL",
|
|
14782
|
+
...Array.from({ length: 9 }, (_, index) => `COM${index + 1}`),
|
|
14783
|
+
...Array.from({ length: 9 }, (_, index) => `LPT${index + 1}`)
|
|
14784
|
+
]);
|
|
14785
|
+
function isWindowsReservedName(value) {
|
|
14786
|
+
const normalized = value.replace(/[. ]+$/gu, "");
|
|
14787
|
+
const basename = normalized.split(".", 1)[0]?.replace(/ +$/gu, "").toUpperCase() ?? "";
|
|
14788
|
+
return WINDOWS_RESERVED_NAMES.has(basename);
|
|
14789
|
+
}
|
|
14790
|
+
var noteIdSchema = projectIdSchema.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u, {
|
|
14791
|
+
message: "note id must start with an alphanumeric and contain only alphanumerics, dot, underscore, or dash"
|
|
14792
|
+
}).refine((value) => !isWindowsReservedName(value), {
|
|
14793
|
+
message: "note id must not be a Windows reserved device name"
|
|
14794
|
+
});
|
|
14795
|
+
var directorySchema = external_exports.string().min(1).max(DEVLEAD_NOTES_DIRECTORY_MAX).regex(/^[a-z0-9][a-z0-9._-]*$/u, {
|
|
14796
|
+
message: "directory must be a sanitized lowercase POSIX segment"
|
|
14797
|
+
}).refine((value) => value !== "." && value !== "..", {
|
|
14798
|
+
message: "directory must not be a traversal segment"
|
|
14799
|
+
}).refine((value) => !isWindowsReservedName(value), {
|
|
14800
|
+
message: "directory must not be a Windows reserved device name"
|
|
14801
|
+
});
|
|
14802
|
+
var relativePathSchema = external_exports.string().min(1).max(DEVLEAD_NOTES_PATH_MAX).refine((value) => !value.includes("\\"), { message: "note path must use POSIX separators" }).refine((value) => !value.startsWith("/"), { message: "note path must be relative to the notes root" }).refine((value) => value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".."), {
|
|
14803
|
+
message: "note path must not contain empty or traversal segments"
|
|
14804
|
+
});
|
|
14805
|
+
var noteSchema = external_exports.object({
|
|
14806
|
+
id: noteIdSchema,
|
|
14807
|
+
title: titleSchema2,
|
|
14808
|
+
summary: summarySchema,
|
|
14809
|
+
updatedAt: timestampSchema2,
|
|
14810
|
+
bytes: external_exports.number().int().nonnegative().max(DEVLEAD_NOTES_NOTE_MAX_BYTES),
|
|
14811
|
+
path: relativePathSchema
|
|
14812
|
+
}).strict();
|
|
14813
|
+
var projectSchema = external_exports.object({
|
|
14814
|
+
id: projectIdSchema,
|
|
14815
|
+
directory: directorySchema,
|
|
14816
|
+
notes: external_exports.array(noteSchema).max(DEVLEAD_NOTES_MAX_PER_PROJECT)
|
|
14817
|
+
}).strict();
|
|
14818
|
+
var indexSchema = external_exports.object({
|
|
14819
|
+
schemaVersion: external_exports.literal(DEVLEAD_NOTES_SCHEMA_VERSION),
|
|
14820
|
+
revision: external_exports.number().int().nonnegative().safe(),
|
|
14821
|
+
updatedAt: timestampSchema2,
|
|
14822
|
+
projects: external_exports.array(projectSchema).max(DEVLEAD_NOTES_MAX_PROJECTS)
|
|
14823
|
+
}).strict().superRefine((index, context) => {
|
|
14824
|
+
const projectIds = /* @__PURE__ */ new Set();
|
|
14825
|
+
const directories = /* @__PURE__ */ new Set();
|
|
14826
|
+
const paths = /* @__PURE__ */ new Set();
|
|
14827
|
+
index.projects.forEach((project, projectIndex) => {
|
|
14828
|
+
if (projectIds.has(project.id)) {
|
|
14829
|
+
context.addIssue({
|
|
14830
|
+
code: "custom",
|
|
14831
|
+
path: ["projects", projectIndex, "id"],
|
|
14832
|
+
message: `duplicate project id "${project.id}"`
|
|
14833
|
+
});
|
|
14834
|
+
}
|
|
14835
|
+
projectIds.add(project.id);
|
|
14836
|
+
if (directories.has(project.directory)) {
|
|
14837
|
+
context.addIssue({
|
|
14838
|
+
code: "custom",
|
|
14839
|
+
path: ["projects", projectIndex, "directory"],
|
|
14840
|
+
message: `duplicate project directory "${project.directory}"`
|
|
14841
|
+
});
|
|
14842
|
+
}
|
|
14843
|
+
directories.add(project.directory);
|
|
14844
|
+
const noteIds = /* @__PURE__ */ new Set();
|
|
14845
|
+
project.notes.forEach((note, noteIndex) => {
|
|
14846
|
+
const portableId = note.id.toLowerCase();
|
|
14847
|
+
if (noteIds.has(portableId)) {
|
|
14848
|
+
context.addIssue({
|
|
14849
|
+
code: "custom",
|
|
14850
|
+
path: ["projects", projectIndex, "notes", noteIndex, "id"],
|
|
14851
|
+
message: `duplicate note id "${note.id}" ignoring case`
|
|
14852
|
+
});
|
|
14853
|
+
}
|
|
14854
|
+
noteIds.add(portableId);
|
|
14855
|
+
const expectedPath = `${project.directory}/${note.id}.md`;
|
|
14856
|
+
if (note.path !== expectedPath) {
|
|
14857
|
+
context.addIssue({
|
|
14858
|
+
code: "custom",
|
|
14859
|
+
path: ["projects", projectIndex, "notes", noteIndex, "path"],
|
|
14860
|
+
message: `note path must be "${expectedPath}"`
|
|
14861
|
+
});
|
|
14862
|
+
}
|
|
14863
|
+
const portablePath = note.path.toLowerCase();
|
|
14864
|
+
if (paths.has(portablePath)) {
|
|
14865
|
+
context.addIssue({
|
|
14866
|
+
code: "custom",
|
|
14867
|
+
path: ["projects", projectIndex, "notes", noteIndex, "path"],
|
|
14868
|
+
message: `duplicate note path "${note.path}" ignoring case`
|
|
14869
|
+
});
|
|
14870
|
+
}
|
|
14871
|
+
paths.add(portablePath);
|
|
14872
|
+
});
|
|
14873
|
+
});
|
|
14874
|
+
});
|
|
14875
|
+
function createDevLeadNotesIndexSchema() {
|
|
14876
|
+
return indexSchema;
|
|
14877
|
+
}
|
|
14878
|
+
function parseDevLeadNotesIndex(value) {
|
|
14879
|
+
return createDevLeadNotesIndexSchema().parse(value);
|
|
14880
|
+
}
|
|
14757
14881
|
export {
|
|
14758
14882
|
DEVLEAD_ANSWER_RETENTION,
|
|
14759
14883
|
DEVLEAD_BOARD_DIR_SEGMENTS,
|
|
@@ -14778,6 +14902,20 @@ export {
|
|
|
14778
14902
|
DEVLEAD_MESSAGE_KIND,
|
|
14779
14903
|
DEVLEAD_MODE_PROJECTION_KEY,
|
|
14780
14904
|
DEVLEAD_MODE_RECORD_TYPE,
|
|
14905
|
+
DEVLEAD_NOTES_DIRECTORY_MAX,
|
|
14906
|
+
DEVLEAD_NOTES_DIR_NAME,
|
|
14907
|
+
DEVLEAD_NOTES_ID_MAX,
|
|
14908
|
+
DEVLEAD_NOTES_INDEX_FILE_NAME,
|
|
14909
|
+
DEVLEAD_NOTES_INDEX_MAX_BYTES,
|
|
14910
|
+
DEVLEAD_NOTES_MAX_PER_PROJECT,
|
|
14911
|
+
DEVLEAD_NOTES_MAX_PROJECTS,
|
|
14912
|
+
DEVLEAD_NOTES_NOTE_MAX_BYTES,
|
|
14913
|
+
DEVLEAD_NOTES_PATH_MAX,
|
|
14914
|
+
DEVLEAD_NOTES_READ_MAX_BYTES,
|
|
14915
|
+
DEVLEAD_NOTES_SCHEMA_VERSION,
|
|
14916
|
+
DEVLEAD_NOTES_SUMMARY_MAX,
|
|
14917
|
+
DEVLEAD_NOTES_TIMESTAMP_MAX,
|
|
14918
|
+
DEVLEAD_NOTES_TITLE_MAX,
|
|
14781
14919
|
DEVLEAD_NOTIFICATION_RECORD_TYPE,
|
|
14782
14920
|
DEVLEAD_OPEN_QUESTION_PIN_MAX,
|
|
14783
14921
|
DEVLEAD_PROJECTION_KEY,
|
|
@@ -14800,6 +14938,7 @@ export {
|
|
|
14800
14938
|
DEVLEAD_WATCH_PROJECTION_KEY,
|
|
14801
14939
|
DEVLEAD_WATCH_RECORD_TYPE,
|
|
14802
14940
|
createDevLeadBoardSchema,
|
|
14941
|
+
createDevLeadNotesIndexSchema,
|
|
14803
14942
|
devLeadBoardIssuePointer,
|
|
14804
14943
|
devLeadBoardIssueViews,
|
|
14805
14944
|
devLeadReportId,
|
|
@@ -14810,6 +14949,7 @@ export {
|
|
|
14810
14949
|
notificationDigest,
|
|
14811
14950
|
notificationId,
|
|
14812
14951
|
notificationLine,
|
|
14952
|
+
parseDevLeadNotesIndex,
|
|
14813
14953
|
reportDigest,
|
|
14814
14954
|
reportLine,
|
|
14815
14955
|
sessionRefLabel,
|
package/lib/index.js
CHANGED
|
@@ -14694,7 +14694,7 @@ var taskSchema = external_exports.object({
|
|
|
14694
14694
|
updatedAt: timestampSchema
|
|
14695
14695
|
}).strict();
|
|
14696
14696
|
function createDevLeadBoardSchema(isAbsolutePath) {
|
|
14697
|
-
const
|
|
14697
|
+
const projectSchema2 = external_exports.object({
|
|
14698
14698
|
id: idSchema,
|
|
14699
14699
|
workspace: external_exports.object({
|
|
14700
14700
|
path: external_exports.string().min(1).max(DEVLEAD_BOARD_PATH_MAX).refine(isAbsolutePath, {
|
|
@@ -14716,7 +14716,7 @@ function createDevLeadBoardSchema(isAbsolutePath) {
|
|
|
14716
14716
|
revision: external_exports.number().int().nonnegative().safe(),
|
|
14717
14717
|
updatedAt: timestampSchema,
|
|
14718
14718
|
updatedBy: external_exports.object({ sessionId: idSchema, title: titleSchema }).strict(),
|
|
14719
|
-
projects: external_exports.array(
|
|
14719
|
+
projects: external_exports.array(projectSchema2).max(DEVLEAD_BOARD_MAX_PROJECTS)
|
|
14720
14720
|
}).strict().superRefine((board, context) => {
|
|
14721
14721
|
const projectIds = /* @__PURE__ */ new Set();
|
|
14722
14722
|
const workspacePaths = /* @__PURE__ */ new Set();
|
|
@@ -14754,6 +14754,130 @@ function createDevLeadBoardSchema(isAbsolutePath) {
|
|
|
14754
14754
|
});
|
|
14755
14755
|
return boardSchema;
|
|
14756
14756
|
}
|
|
14757
|
+
|
|
14758
|
+
// packages/protocol/src/notes.ts
|
|
14759
|
+
var DEVLEAD_NOTES_SCHEMA_VERSION = 1;
|
|
14760
|
+
var DEVLEAD_NOTES_DIR_NAME = "notes";
|
|
14761
|
+
var DEVLEAD_NOTES_INDEX_FILE_NAME = "index.json";
|
|
14762
|
+
var DEVLEAD_NOTES_INDEX_MAX_BYTES = 128 * 1024;
|
|
14763
|
+
var DEVLEAD_NOTES_NOTE_MAX_BYTES = 256 * 1024;
|
|
14764
|
+
var DEVLEAD_NOTES_READ_MAX_BYTES = DEVLEAD_BOARD_READ_MAX_BYTES;
|
|
14765
|
+
var DEVLEAD_NOTES_MAX_PROJECTS = 50;
|
|
14766
|
+
var DEVLEAD_NOTES_MAX_PER_PROJECT = 100;
|
|
14767
|
+
var DEVLEAD_NOTES_ID_MAX = 128;
|
|
14768
|
+
var DEVLEAD_NOTES_DIRECTORY_MAX = 128;
|
|
14769
|
+
var DEVLEAD_NOTES_TITLE_MAX = 200;
|
|
14770
|
+
var DEVLEAD_NOTES_SUMMARY_MAX = 500;
|
|
14771
|
+
var DEVLEAD_NOTES_PATH_MAX = 512;
|
|
14772
|
+
var DEVLEAD_NOTES_TIMESTAMP_MAX = 64;
|
|
14773
|
+
var timestampSchema2 = external_exports.string().max(DEVLEAD_NOTES_TIMESTAMP_MAX).pipe(external_exports.iso.datetime());
|
|
14774
|
+
var projectIdSchema = external_exports.string().min(1).max(DEVLEAD_NOTES_ID_MAX);
|
|
14775
|
+
var titleSchema2 = external_exports.string().min(1).max(DEVLEAD_NOTES_TITLE_MAX);
|
|
14776
|
+
var summarySchema = external_exports.string().max(DEVLEAD_NOTES_SUMMARY_MAX);
|
|
14777
|
+
var WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
14778
|
+
"CON",
|
|
14779
|
+
"PRN",
|
|
14780
|
+
"AUX",
|
|
14781
|
+
"NUL",
|
|
14782
|
+
...Array.from({ length: 9 }, (_, index) => `COM${index + 1}`),
|
|
14783
|
+
...Array.from({ length: 9 }, (_, index) => `LPT${index + 1}`)
|
|
14784
|
+
]);
|
|
14785
|
+
function isWindowsReservedName(value) {
|
|
14786
|
+
const normalized = value.replace(/[. ]+$/gu, "");
|
|
14787
|
+
const basename = normalized.split(".", 1)[0]?.replace(/ +$/gu, "").toUpperCase() ?? "";
|
|
14788
|
+
return WINDOWS_RESERVED_NAMES.has(basename);
|
|
14789
|
+
}
|
|
14790
|
+
var noteIdSchema = projectIdSchema.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u, {
|
|
14791
|
+
message: "note id must start with an alphanumeric and contain only alphanumerics, dot, underscore, or dash"
|
|
14792
|
+
}).refine((value) => !isWindowsReservedName(value), {
|
|
14793
|
+
message: "note id must not be a Windows reserved device name"
|
|
14794
|
+
});
|
|
14795
|
+
var directorySchema = external_exports.string().min(1).max(DEVLEAD_NOTES_DIRECTORY_MAX).regex(/^[a-z0-9][a-z0-9._-]*$/u, {
|
|
14796
|
+
message: "directory must be a sanitized lowercase POSIX segment"
|
|
14797
|
+
}).refine((value) => value !== "." && value !== "..", {
|
|
14798
|
+
message: "directory must not be a traversal segment"
|
|
14799
|
+
}).refine((value) => !isWindowsReservedName(value), {
|
|
14800
|
+
message: "directory must not be a Windows reserved device name"
|
|
14801
|
+
});
|
|
14802
|
+
var relativePathSchema = external_exports.string().min(1).max(DEVLEAD_NOTES_PATH_MAX).refine((value) => !value.includes("\\"), { message: "note path must use POSIX separators" }).refine((value) => !value.startsWith("/"), { message: "note path must be relative to the notes root" }).refine((value) => value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".."), {
|
|
14803
|
+
message: "note path must not contain empty or traversal segments"
|
|
14804
|
+
});
|
|
14805
|
+
var noteSchema = external_exports.object({
|
|
14806
|
+
id: noteIdSchema,
|
|
14807
|
+
title: titleSchema2,
|
|
14808
|
+
summary: summarySchema,
|
|
14809
|
+
updatedAt: timestampSchema2,
|
|
14810
|
+
bytes: external_exports.number().int().nonnegative().max(DEVLEAD_NOTES_NOTE_MAX_BYTES),
|
|
14811
|
+
path: relativePathSchema
|
|
14812
|
+
}).strict();
|
|
14813
|
+
var projectSchema = external_exports.object({
|
|
14814
|
+
id: projectIdSchema,
|
|
14815
|
+
directory: directorySchema,
|
|
14816
|
+
notes: external_exports.array(noteSchema).max(DEVLEAD_NOTES_MAX_PER_PROJECT)
|
|
14817
|
+
}).strict();
|
|
14818
|
+
var indexSchema = external_exports.object({
|
|
14819
|
+
schemaVersion: external_exports.literal(DEVLEAD_NOTES_SCHEMA_VERSION),
|
|
14820
|
+
revision: external_exports.number().int().nonnegative().safe(),
|
|
14821
|
+
updatedAt: timestampSchema2,
|
|
14822
|
+
projects: external_exports.array(projectSchema).max(DEVLEAD_NOTES_MAX_PROJECTS)
|
|
14823
|
+
}).strict().superRefine((index, context) => {
|
|
14824
|
+
const projectIds = /* @__PURE__ */ new Set();
|
|
14825
|
+
const directories = /* @__PURE__ */ new Set();
|
|
14826
|
+
const paths = /* @__PURE__ */ new Set();
|
|
14827
|
+
index.projects.forEach((project, projectIndex) => {
|
|
14828
|
+
if (projectIds.has(project.id)) {
|
|
14829
|
+
context.addIssue({
|
|
14830
|
+
code: "custom",
|
|
14831
|
+
path: ["projects", projectIndex, "id"],
|
|
14832
|
+
message: `duplicate project id "${project.id}"`
|
|
14833
|
+
});
|
|
14834
|
+
}
|
|
14835
|
+
projectIds.add(project.id);
|
|
14836
|
+
if (directories.has(project.directory)) {
|
|
14837
|
+
context.addIssue({
|
|
14838
|
+
code: "custom",
|
|
14839
|
+
path: ["projects", projectIndex, "directory"],
|
|
14840
|
+
message: `duplicate project directory "${project.directory}"`
|
|
14841
|
+
});
|
|
14842
|
+
}
|
|
14843
|
+
directories.add(project.directory);
|
|
14844
|
+
const noteIds = /* @__PURE__ */ new Set();
|
|
14845
|
+
project.notes.forEach((note, noteIndex) => {
|
|
14846
|
+
const portableId = note.id.toLowerCase();
|
|
14847
|
+
if (noteIds.has(portableId)) {
|
|
14848
|
+
context.addIssue({
|
|
14849
|
+
code: "custom",
|
|
14850
|
+
path: ["projects", projectIndex, "notes", noteIndex, "id"],
|
|
14851
|
+
message: `duplicate note id "${note.id}" ignoring case`
|
|
14852
|
+
});
|
|
14853
|
+
}
|
|
14854
|
+
noteIds.add(portableId);
|
|
14855
|
+
const expectedPath = `${project.directory}/${note.id}.md`;
|
|
14856
|
+
if (note.path !== expectedPath) {
|
|
14857
|
+
context.addIssue({
|
|
14858
|
+
code: "custom",
|
|
14859
|
+
path: ["projects", projectIndex, "notes", noteIndex, "path"],
|
|
14860
|
+
message: `note path must be "${expectedPath}"`
|
|
14861
|
+
});
|
|
14862
|
+
}
|
|
14863
|
+
const portablePath = note.path.toLowerCase();
|
|
14864
|
+
if (paths.has(portablePath)) {
|
|
14865
|
+
context.addIssue({
|
|
14866
|
+
code: "custom",
|
|
14867
|
+
path: ["projects", projectIndex, "notes", noteIndex, "path"],
|
|
14868
|
+
message: `duplicate note path "${note.path}" ignoring case`
|
|
14869
|
+
});
|
|
14870
|
+
}
|
|
14871
|
+
paths.add(portablePath);
|
|
14872
|
+
});
|
|
14873
|
+
});
|
|
14874
|
+
});
|
|
14875
|
+
function createDevLeadNotesIndexSchema() {
|
|
14876
|
+
return indexSchema;
|
|
14877
|
+
}
|
|
14878
|
+
function parseDevLeadNotesIndex(value) {
|
|
14879
|
+
return createDevLeadNotesIndexSchema().parse(value);
|
|
14880
|
+
}
|
|
14757
14881
|
export {
|
|
14758
14882
|
DEVLEAD_ANSWER_RETENTION,
|
|
14759
14883
|
DEVLEAD_BOARD_DIR_SEGMENTS,
|
|
@@ -14778,6 +14902,20 @@ export {
|
|
|
14778
14902
|
DEVLEAD_MESSAGE_KIND,
|
|
14779
14903
|
DEVLEAD_MODE_PROJECTION_KEY,
|
|
14780
14904
|
DEVLEAD_MODE_RECORD_TYPE,
|
|
14905
|
+
DEVLEAD_NOTES_DIRECTORY_MAX,
|
|
14906
|
+
DEVLEAD_NOTES_DIR_NAME,
|
|
14907
|
+
DEVLEAD_NOTES_ID_MAX,
|
|
14908
|
+
DEVLEAD_NOTES_INDEX_FILE_NAME,
|
|
14909
|
+
DEVLEAD_NOTES_INDEX_MAX_BYTES,
|
|
14910
|
+
DEVLEAD_NOTES_MAX_PER_PROJECT,
|
|
14911
|
+
DEVLEAD_NOTES_MAX_PROJECTS,
|
|
14912
|
+
DEVLEAD_NOTES_NOTE_MAX_BYTES,
|
|
14913
|
+
DEVLEAD_NOTES_PATH_MAX,
|
|
14914
|
+
DEVLEAD_NOTES_READ_MAX_BYTES,
|
|
14915
|
+
DEVLEAD_NOTES_SCHEMA_VERSION,
|
|
14916
|
+
DEVLEAD_NOTES_SUMMARY_MAX,
|
|
14917
|
+
DEVLEAD_NOTES_TIMESTAMP_MAX,
|
|
14918
|
+
DEVLEAD_NOTES_TITLE_MAX,
|
|
14781
14919
|
DEVLEAD_NOTIFICATION_RECORD_TYPE,
|
|
14782
14920
|
DEVLEAD_OPEN_QUESTION_PIN_MAX,
|
|
14783
14921
|
DEVLEAD_PROJECTION_KEY,
|
|
@@ -14800,6 +14938,7 @@ export {
|
|
|
14800
14938
|
DEVLEAD_WATCH_PROJECTION_KEY,
|
|
14801
14939
|
DEVLEAD_WATCH_RECORD_TYPE,
|
|
14802
14940
|
createDevLeadBoardSchema,
|
|
14941
|
+
createDevLeadNotesIndexSchema,
|
|
14803
14942
|
devLeadBoardIssuePointer,
|
|
14804
14943
|
devLeadBoardIssueViews,
|
|
14805
14944
|
devLeadReportId,
|
|
@@ -14810,6 +14949,7 @@ export {
|
|
|
14810
14949
|
notificationDigest,
|
|
14811
14950
|
notificationId,
|
|
14812
14951
|
notificationLine,
|
|
14952
|
+
parseDevLeadNotesIndex,
|
|
14813
14953
|
reportDigest,
|
|
14814
14954
|
reportLine,
|
|
14815
14955
|
sessionRefLabel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-devlead-protocol",
|
|
3
|
-
"version": "0.4.2-rc.
|
|
3
|
+
"version": "0.4.2-rc.5",
|
|
4
4
|
"description": "Pure shared protocol of the devlead plugin suite: durable mode, watched-session and notification types, the project-board wire schema shared by Host and browser, plus the pure fold and formatting rules both sides use.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|