@dogsbay/commands 0.2.0-beta.101

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 (86) hide show
  1. package/README.md +137 -0
  2. package/dist/commands/content.d.ts +78 -0
  3. package/dist/commands/content.d.ts.map +1 -0
  4. package/dist/commands/content.js +634 -0
  5. package/dist/commands/content.js.map +1 -0
  6. package/dist/commands/examples.d.ts +49 -0
  7. package/dist/commands/examples.d.ts.map +1 -0
  8. package/dist/commands/examples.js +173 -0
  9. package/dist/commands/examples.js.map +1 -0
  10. package/dist/commands/keys.d.ts +14 -0
  11. package/dist/commands/keys.d.ts.map +1 -0
  12. package/dist/commands/keys.js +87 -0
  13. package/dist/commands/keys.js.map +1 -0
  14. package/dist/commands/link-retarget.d.ts +18 -0
  15. package/dist/commands/link-retarget.d.ts.map +1 -0
  16. package/dist/commands/link-retarget.js +104 -0
  17. package/dist/commands/link-retarget.js.map +1 -0
  18. package/dist/commands/refactor-files.d.ts +27 -0
  19. package/dist/commands/refactor-files.d.ts.map +1 -0
  20. package/dist/commands/refactor-files.js +264 -0
  21. package/dist/commands/refactor-files.js.map +1 -0
  22. package/dist/commands/refactor-keys.d.ts +21 -0
  23. package/dist/commands/refactor-keys.d.ts.map +1 -0
  24. package/dist/commands/refactor-keys.js +224 -0
  25. package/dist/commands/refactor-keys.js.map +1 -0
  26. package/dist/commands/refactor-structure.d.ts +19 -0
  27. package/dist/commands/refactor-structure.d.ts.map +1 -0
  28. package/dist/commands/refactor-structure.js +314 -0
  29. package/dist/commands/refactor-structure.js.map +1 -0
  30. package/dist/commands/reindex.d.ts +10 -0
  31. package/dist/commands/reindex.d.ts.map +1 -0
  32. package/dist/commands/reindex.js +23 -0
  33. package/dist/commands/reindex.js.map +1 -0
  34. package/dist/commands/topicmap-edit.d.ts +65 -0
  35. package/dist/commands/topicmap-edit.d.ts.map +1 -0
  36. package/dist/commands/topicmap-edit.js +194 -0
  37. package/dist/commands/topicmap-edit.js.map +1 -0
  38. package/dist/commands/topicmap.d.ts +13 -0
  39. package/dist/commands/topicmap.d.ts.map +1 -0
  40. package/dist/commands/topicmap.js +69 -0
  41. package/dist/commands/topicmap.js.map +1 -0
  42. package/dist/commands/validate.d.ts +13 -0
  43. package/dist/commands/validate.d.ts.map +1 -0
  44. package/dist/commands/validate.js +753 -0
  45. package/dist/commands/validate.js.map +1 -0
  46. package/dist/commands/where-used.d.ts +16 -0
  47. package/dist/commands/where-used.d.ts.map +1 -0
  48. package/dist/commands/where-used.js +83 -0
  49. package/dist/commands/where-used.js.map +1 -0
  50. package/dist/edits.d.ts +54 -0
  51. package/dist/edits.d.ts.map +1 -0
  52. package/dist/edits.js +158 -0
  53. package/dist/edits.js.map +1 -0
  54. package/dist/engine.d.ts +103 -0
  55. package/dist/engine.d.ts.map +1 -0
  56. package/dist/engine.js +115 -0
  57. package/dist/engine.js.map +1 -0
  58. package/dist/flags.d.ts +31 -0
  59. package/dist/flags.d.ts.map +1 -0
  60. package/dist/flags.js +73 -0
  61. package/dist/flags.js.map +1 -0
  62. package/dist/frontmatter-schema.d.ts +97 -0
  63. package/dist/frontmatter-schema.d.ts.map +1 -0
  64. package/dist/frontmatter-schema.js +240 -0
  65. package/dist/frontmatter-schema.js.map +1 -0
  66. package/dist/index.d.ts +35 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +70 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/indexes.d.ts +175 -0
  71. package/dist/indexes.d.ts.map +1 -0
  72. package/dist/indexes.js +536 -0
  73. package/dist/indexes.js.map +1 -0
  74. package/dist/json-schema.d.ts +10 -0
  75. package/dist/json-schema.d.ts.map +1 -0
  76. package/dist/json-schema.js +50 -0
  77. package/dist/json-schema.js.map +1 -0
  78. package/dist/storage.d.ts +68 -0
  79. package/dist/storage.d.ts.map +1 -0
  80. package/dist/storage.js +193 -0
  81. package/dist/storage.js.map +1 -0
  82. package/dist/workspace.d.ts +30 -0
  83. package/dist/workspace.d.ts.map +1 -0
  84. package/dist/workspace.js +63 -0
  85. package/dist/workspace.js.map +1 -0
  86. package/package.json +47 -0
@@ -0,0 +1,175 @@
1
+ import { type TopicMapError } from "@dogsbay/format-topicmap";
2
+ import type { Storage } from "./storage.js";
3
+ export interface DocHeading {
4
+ level: number;
5
+ text: string;
6
+ /** Explicit `{#id}` anchor, when authored. */
7
+ id?: string;
8
+ /** The anchor the SITE renders for this heading (renderer-parity slug), when it is a top-level heading. */
9
+ slug?: string;
10
+ }
11
+ export type RefKind = "link" | "image" | "include" | "topicmap" | "key";
12
+ export interface DocLink {
13
+ /** The href exactly as authored. */
14
+ href: string;
15
+ /** Workspace-relative target path — undefined for external/unresolvable hrefs. */
16
+ target?: string;
17
+ /** `#fragment` portion, when present. */
18
+ fragment?: string;
19
+ /** The relative target resolves ABOVE the workspace root (`../` remains after joining). */
20
+ escapes?: boolean;
21
+ /** Site-absolute (`/guides/x`): resolved by validate against the content roots (no `target`). */
22
+ siteAbsolute?: boolean;
23
+ /** For site-absolute links: the path part, query stripped and percent-decoded, no leading/trailing `/`. */
24
+ sitePath?: string;
25
+ /** 1-based line of the first un-attributed occurrence of the href in the (code-masked) source. */
26
+ line?: number;
27
+ kind: "link" | "image";
28
+ }
29
+ export interface DocInclude {
30
+ /** Path exactly as written in the `{% include %}` directive. */
31
+ raw: string;
32
+ /** Workspace-relative resolved target. */
33
+ target: string;
34
+ /** 1-based line of the directive. */
35
+ line?: number;
36
+ }
37
+ export interface DocIndexEntry {
38
+ path: string;
39
+ frontmatter: Record<string, unknown>;
40
+ title?: string;
41
+ headings: DocHeading[];
42
+ /** Every id a `#fragment` link can land on: explicit heading ids, `<a id>` anchors, heading slugs. */
43
+ anchors: string[];
44
+ links: DocLink[];
45
+ includes: DocInclude[];
46
+ /** Key names referenced via `key:` hrefs. */
47
+ keyUses: string[];
48
+ /**
49
+ * "none" — no `---` opener; "block" — a terminated block, whatever it
50
+ * parsed to; "unterminated" — an opener with no closer, which makes the
51
+ * parser swallow the WHOLE page (empty tree, no headings, no links).
52
+ * `frontmatter` alone cannot tell these apart, and two of the three drop
53
+ * content silently.
54
+ */
55
+ frontmatterBlock: "none" | "block" | "unterminated";
56
+ /**
57
+ * 1-based line of each top-level frontmatter key, and whether the block has
58
+ * any content at all. Derived on the SAME pass that reads the file: validate
59
+ * used to re-read every page's source for these, which was a second full
60
+ * read of the corpus (+231% on a 653-doc corpus) and defeated the
61
+ * incremental index — one changed file, every file re-read.
62
+ */
63
+ frontmatterKeyLines: Map<string, number>;
64
+ /** True when the block holds only blank lines/comments (a stub, not a broken block). */
65
+ frontmatterEmpty: boolean;
66
+ /** Set when the file could not be parsed; the entry is otherwise empty. */
67
+ parseError?: string;
68
+ /**
69
+ * Hash of the source bytes this entry was built from — the same hash
70
+ * `topic-read` returns and the content verbs accept as `expect`, so a fix
71
+ * derived from this entry can be gated on the file NOT having changed since.
72
+ */
73
+ hash: string;
74
+ }
75
+ export interface TopicMapRef {
76
+ href: string;
77
+ /**
78
+ * Workspace-relative target — undefined for external hrefs AND for
79
+ * "/"-rooted hrefs, which the topicmap loader convention resolves
80
+ * against the ROOT map's directory (only known when walking from a
81
+ * root; see `rootRelative`).
82
+ */
83
+ target?: string;
84
+ /** True for "/"-rooted hrefs (root-map-dir-relative, per the loader convention). */
85
+ rootRelative?: boolean;
86
+ /** True for `format: topicmap` includes. */
87
+ isMap: boolean;
88
+ navtitle?: string;
89
+ }
90
+ export interface TopicMapIndexEntry {
91
+ path: string;
92
+ title?: string;
93
+ refs: TopicMapRef[];
94
+ errors: TopicMapError[];
95
+ }
96
+ export interface KeyDefinition {
97
+ name: string;
98
+ /** keys.yaml file that defines it. */
99
+ file: string;
100
+ def: Record<string, unknown>;
101
+ }
102
+ export interface KeyFileError {
103
+ file: string;
104
+ message: string;
105
+ }
106
+ export interface InboundRef {
107
+ /** Referencing file (doc or topic map). */
108
+ from: string;
109
+ kind: RefKind;
110
+ /** The href/path exactly as authored in the referencing file. */
111
+ raw: string;
112
+ /** Fragment the reference targets, when present. */
113
+ fragment?: string;
114
+ }
115
+ export interface WorkspaceIndex {
116
+ /** Every file in the workspace (posix-relative) — assets included; what a site-absolute link may land on. */
117
+ files: Set<string>;
118
+ docs: Map<string, DocIndexEntry>;
119
+ maps: Map<string, TopicMapIndexEntry>;
120
+ /** All definitions per key name, in file order — first is the winner. */
121
+ keys: Map<string, KeyDefinition[]>;
122
+ keyFileErrors: KeyFileError[];
123
+ /** Inverted reference graph: target file → inbound references. */
124
+ inbound: Map<string, InboundRef[]>;
125
+ /** Key name → files that use it (via key: hrefs). */
126
+ keyUses: Map<string, string[]>;
127
+ stats: {
128
+ files: number;
129
+ docs: number;
130
+ maps: number;
131
+ keyFiles: number;
132
+ keys: number;
133
+ links: number;
134
+ includes: number;
135
+ };
136
+ }
137
+ /**
138
+ * Blank out code-region CONTENT so the raw-source include scan never
139
+ * counts template EXAMPLES as real includes. The fence/span grammar is
140
+ * @dogsbay/format-dogsbay-md's transformCodeRegions — the same walker
141
+ * the build preprocessor uses, so "what counts as code" cannot drift
142
+ * between validate and the build. (The include grammar itself comes
143
+ * from @dogsbay/minja for the same reason.)
144
+ *
145
+ * A `{minja}`-marked fence is NOT blanked, for the same no-drift reason:
146
+ * the build preprocessor PROCESSES marked fences (its masker skips them),
147
+ * so a directive inside one is real and must be visible to validation.
148
+ */
149
+ export declare const blankCodeRegions: (source: string) => string;
150
+ /**
151
+ * Anchors OTHER renderers would give a heading text — GitHub-slugger
152
+ * (lowercase, punctuation removed except `-`/space, spaces → `-`, no
153
+ * collapse) and Python-Markdown/mkdocs (non-word chars removed, runs of
154
+ * `-`/space → one `-`). Dogsbay's own rule (the site build's) is what
155
+ * `anchors` holds; these let validate tell "the anchor exists under another
156
+ * tool's rule" (a migration-era mismatch) from "no such heading" (a dead
157
+ * link in any tool).
158
+ */
159
+ /** For each alias (GitHub/mkdocs slug) the DOGSBAY anchor of the same heading — what a mismatched link should be retargeted to. */
160
+ export declare function anchorAliasTargets(headings: DocHeading[], dogsbayAnchors: string[]): Map<string, string>;
161
+ export declare function anchorAliases(headings: DocHeading[]): Set<string>;
162
+ export interface BuildIndexOptions {
163
+ /**
164
+ * Incremental: keep every entry of `previous` whose path is NOT in
165
+ * `changed`, re-read only the changed paths (a gone path is dropped), and
166
+ * recompute the inverted graphs — the per-file indexing is the cost, the
167
+ * graphs are milliseconds. Keys files are always re-read (they are few and
168
+ * their table is global).
169
+ */
170
+ previous?: WorkspaceIndex;
171
+ changed?: string[];
172
+ }
173
+ /** Build every index in one pass over the workspace (or patch a previous one — see BuildIndexOptions). */
174
+ export declare function buildWorkspaceIndex(storage: Storage, options?: BuildIndexOptions): Promise<WorkspaceIndex>;
175
+ //# sourceMappingURL=indexes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.d.ts","sourceRoot":"","sources":["../src/indexes.ts"],"names":[],"mappings":"AAcA,OAAO,EAQL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,CAAC;AAExE,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iGAAiG;IACjG,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2GAA2G;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