@askdb/enrich 0.2.0-beta.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.
- package/LICENSE +201 -0
- package/NOTICE +10 -0
- package/README.md +7 -0
- package/dist/draft.d.ts +41 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +131 -0
- package/dist/draft.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/suggest.d.ts +19 -0
- package/dist/suggest.d.ts.map +1 -0
- package/dist/suggest.js +54 -0
- package/dist/suggest.js.map +1 -0
- package/dist/workspace.d.ts +61 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +262 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, the acceptance of support, warranty, indemnity, or
|
|
168
|
+
other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Yahya Gilany
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
AskDB
|
|
2
|
+
Copyright 2026 Yahya Gilany
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Yahya Gilany and contributors.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @askdb/enrich
|
|
2
|
+
|
|
3
|
+
Shared Schema v2 enrichment workspace helpers used by AskDB authoring surfaces.
|
|
4
|
+
|
|
5
|
+
This package owns the non-UI enrichment model: loading and saving Schema v2
|
|
6
|
+
workspaces, building editable table drafts, preserving markdown sections, and
|
|
7
|
+
building AI suggestion targets and context.
|
package/dist/draft.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ParsedTableMarkdown, V2Column, V2Table, V2TableFrontmatter } from "@askdb/core";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory editable representation of a single table's describable layer.
|
|
4
|
+
* Built from the parsed markdown when present; defaulted when not.
|
|
5
|
+
*/
|
|
6
|
+
export type ColumnDraft = {
|
|
7
|
+
description?: string;
|
|
8
|
+
aliases?: string[];
|
|
9
|
+
enum?: string[];
|
|
10
|
+
sensitive?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type TableDraft = {
|
|
13
|
+
description: string;
|
|
14
|
+
aliases?: string[];
|
|
15
|
+
primaryEntity?: string;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
/** Override (only set when user explicitly toggles). */
|
|
18
|
+
sensitive?: boolean;
|
|
19
|
+
/** Verbatim content under `## Common query language`. */
|
|
20
|
+
commonQueryLanguage?: string;
|
|
21
|
+
/** Verbatim content under `## Example questions`. */
|
|
22
|
+
exampleQuestions?: string;
|
|
23
|
+
/** Per-column drafts keyed by column id. */
|
|
24
|
+
columns: Record<string, ColumnDraft>;
|
|
25
|
+
};
|
|
26
|
+
export declare function buildTableDraft(physical: V2Table, parsed: ParsedTableMarkdown | undefined): TableDraft;
|
|
27
|
+
/**
|
|
28
|
+
* Build the V2TableFrontmatter to write to disk from a draft + physical.
|
|
29
|
+
* Empty optional fields are omitted entirely (cleaner round-trip).
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildFrontmatter(physical: V2Table, schemaId: string, draft: TableDraft): V2TableFrontmatter;
|
|
32
|
+
/** Parse a comma-separated string into a trimmed list (empty entries dropped). */
|
|
33
|
+
export declare function parseListInput(input: string): string[];
|
|
34
|
+
export declare function formatList(list: string[] | undefined): string;
|
|
35
|
+
/** Sensitive column names (per physical layer) referenced in a description. */
|
|
36
|
+
export declare function findSensitiveColumnReferences(description: string, physical: V2Table): string[];
|
|
37
|
+
/** Are any per-column describable fields populated? */
|
|
38
|
+
export declare function hasAnyColumnDescribable(draft: TableDraft): boolean;
|
|
39
|
+
/** Is the column type a candidate for an enum field? (text-y types). */
|
|
40
|
+
export declare function isEnumCandidate(col: V2Column): boolean;
|
|
41
|
+
//# sourceMappingURL=draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,QAAQ,EAER,OAAO,EACP,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACtC,CAAC;AAEF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,mBAAmB,GAAG,SAAS,GACtC,UAAU,CAuBZ;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,UAAU,GAChB,kBAAkB,CA0BpB;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAE7D;AAED,+EAA+E;AAC/E,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,GAChB,MAAM,EAAE,CASV;AA+BD,uDAAuD;AACvD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAQlE;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAStD"}
|
package/dist/draft.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export function buildTableDraft(physical, parsed) {
|
|
2
|
+
const fm = parsed?.frontmatter;
|
|
3
|
+
const columns = {};
|
|
4
|
+
for (const col of physical.columns) {
|
|
5
|
+
const fmCol = fm?.columns?.find((c) => c.id === col.id);
|
|
6
|
+
const draft = {};
|
|
7
|
+
if (fmCol?.description !== undefined)
|
|
8
|
+
draft.description = fmCol.description;
|
|
9
|
+
if (fmCol?.aliases !== undefined)
|
|
10
|
+
draft.aliases = [...fmCol.aliases];
|
|
11
|
+
if (fmCol?.enum !== undefined)
|
|
12
|
+
draft.enum = [...fmCol.enum];
|
|
13
|
+
if (fmCol?.sensitive !== undefined)
|
|
14
|
+
draft.sensitive = fmCol.sensitive;
|
|
15
|
+
columns[col.id] = draft;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
description: parsed ? extractFirstParagraph(parsed.body) ?? "" : "",
|
|
19
|
+
aliases: fm?.aliases ? [...fm.aliases] : undefined,
|
|
20
|
+
primaryEntity: fm?.primaryEntity,
|
|
21
|
+
tags: fm?.tags ? [...fm.tags] : undefined,
|
|
22
|
+
sensitive: fm?.sensitive,
|
|
23
|
+
commonQueryLanguage: parsed?.sections["Common query language"],
|
|
24
|
+
exampleQuestions: parsed?.sections["Example questions"],
|
|
25
|
+
columns,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the V2TableFrontmatter to write to disk from a draft + physical.
|
|
30
|
+
* Empty optional fields are omitted entirely (cleaner round-trip).
|
|
31
|
+
*/
|
|
32
|
+
export function buildFrontmatter(physical, schemaId, draft) {
|
|
33
|
+
const columns = physical.columns.map((col) => {
|
|
34
|
+
const c = draft.columns[col.id] ?? {};
|
|
35
|
+
const out = { id: col.id };
|
|
36
|
+
if (nonEmptyStrings(c.aliases))
|
|
37
|
+
out.aliases = c.aliases;
|
|
38
|
+
if (nonEmptyStrings(c.enum))
|
|
39
|
+
out.enum = c.enum;
|
|
40
|
+
if (c.description !== undefined && c.description !== "") {
|
|
41
|
+
out.description = c.description;
|
|
42
|
+
}
|
|
43
|
+
if (c.sensitive !== undefined)
|
|
44
|
+
out.sensitive = c.sensitive;
|
|
45
|
+
return out;
|
|
46
|
+
});
|
|
47
|
+
const fm = {
|
|
48
|
+
id: physical.id,
|
|
49
|
+
name: physical.name,
|
|
50
|
+
schemaId,
|
|
51
|
+
};
|
|
52
|
+
if (draft.primaryEntity)
|
|
53
|
+
fm.primaryEntity = draft.primaryEntity;
|
|
54
|
+
if (nonEmptyStrings(draft.aliases))
|
|
55
|
+
fm.aliases = draft.aliases;
|
|
56
|
+
if (nonEmptyStrings(draft.tags))
|
|
57
|
+
fm.tags = draft.tags;
|
|
58
|
+
if (draft.sensitive !== undefined)
|
|
59
|
+
fm.sensitive = draft.sensitive;
|
|
60
|
+
// Only emit columns array when at least one column has describable content,
|
|
61
|
+
// so "untouched" tables stay minimal.
|
|
62
|
+
if (columns.some((c) => Object.keys(c).length > 1))
|
|
63
|
+
fm.columns = columns;
|
|
64
|
+
return fm;
|
|
65
|
+
}
|
|
66
|
+
/** Parse a comma-separated string into a trimmed list (empty entries dropped). */
|
|
67
|
+
export function parseListInput(input) {
|
|
68
|
+
return input
|
|
69
|
+
.split(",")
|
|
70
|
+
.map((s) => s.trim())
|
|
71
|
+
.filter((s) => s.length > 0);
|
|
72
|
+
}
|
|
73
|
+
export function formatList(list) {
|
|
74
|
+
return list ? list.join(", ") : "";
|
|
75
|
+
}
|
|
76
|
+
/** Sensitive column names (per physical layer) referenced in a description. */
|
|
77
|
+
export function findSensitiveColumnReferences(description, physical) {
|
|
78
|
+
const lower = description.toLowerCase();
|
|
79
|
+
return physical.columns
|
|
80
|
+
.filter((c) => c.sensitive)
|
|
81
|
+
.map((c) => c.name)
|
|
82
|
+
.filter((name) => {
|
|
83
|
+
const re = new RegExp(`\\b${escapeRegex(name)}\\b`, "i");
|
|
84
|
+
return re.test(lower);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function escapeRegex(s) {
|
|
88
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
89
|
+
}
|
|
90
|
+
function nonEmptyStrings(list) {
|
|
91
|
+
return Array.isArray(list) && list.length > 0;
|
|
92
|
+
}
|
|
93
|
+
function extractFirstParagraph(body) {
|
|
94
|
+
const lines = body.split("\n");
|
|
95
|
+
const out = [];
|
|
96
|
+
let inParagraph = false;
|
|
97
|
+
let seenHeading = false;
|
|
98
|
+
for (const line of lines) {
|
|
99
|
+
if (line.startsWith("#")) {
|
|
100
|
+
if (seenHeading)
|
|
101
|
+
break;
|
|
102
|
+
seenHeading = true;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (line.trim() === "") {
|
|
106
|
+
if (inParagraph)
|
|
107
|
+
break;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
inParagraph = true;
|
|
111
|
+
out.push(line.trim());
|
|
112
|
+
}
|
|
113
|
+
return out.length > 0 ? out.join(" ") : undefined;
|
|
114
|
+
}
|
|
115
|
+
/** Are any per-column describable fields populated? */
|
|
116
|
+
export function hasAnyColumnDescribable(draft) {
|
|
117
|
+
return Object.values(draft.columns).some((c) => (c.description !== undefined && c.description !== "") ||
|
|
118
|
+
(c.aliases && c.aliases.length > 0) ||
|
|
119
|
+
(c.enum && c.enum.length > 0) ||
|
|
120
|
+
c.sensitive !== undefined);
|
|
121
|
+
}
|
|
122
|
+
/** Is the column type a candidate for an enum field? (text-y types). */
|
|
123
|
+
export function isEnumCandidate(col) {
|
|
124
|
+
const t = col.type.toLowerCase();
|
|
125
|
+
return (t === "text" ||
|
|
126
|
+
t.startsWith("varchar") ||
|
|
127
|
+
t.startsWith("char") ||
|
|
128
|
+
t === "citext" ||
|
|
129
|
+
t.endsWith("[]") === false && t.includes("enum"));
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=draft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft.js","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAkCA,MAAM,UAAU,eAAe,CAC7B,QAAiB,EACjB,MAAuC;IAEvC,MAAM,EAAE,GAAG,MAAM,EAAE,WAAW,CAAC;IAC/B,MAAM,OAAO,GAAgC,EAAE,CAAC;IAChD,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QACxD,MAAM,KAAK,GAAgB,EAAE,CAAC;QAC9B,IAAI,KAAK,EAAE,WAAW,KAAK,SAAS;YAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAC5E,IAAI,KAAK,EAAE,OAAO,KAAK,SAAS;YAAE,KAAK,CAAC,OAAO,GAAG,CAA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wEAAwE;AACxE,MAAM,UAAU,eAAe,CAAC,GAAa;IAC3C,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,CACL,CAAC,KAAK,MAAM;QACZ,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QACvB,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;QACpB,CAAC,KAAK,QAAQ;QACd,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CACjD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { buildFrontmatter, buildTableDraft, findSensitiveColumnReferences, formatList, hasAnyColumnDescribable, isEnumCandidate, parseListInput, } from "./draft.js";
|
|
2
|
+
export type { ColumnDraft, TableDraft } from "./draft.js";
|
|
3
|
+
export { buildSuggestionContext, buildSuggestionTarget, } from "./suggest.js";
|
|
4
|
+
export type { ColumnSuggestField, SuggestEnrichment, SuggestEnrichmentForTui, SuggestSource, TableSuggestField, } from "./suggest.js";
|
|
5
|
+
export { buildDefaultTableBody, bundleSchemaDirectory, loadWorkspace, pruneOrphanedColumns, replaceH2Section, replaceTableDescription, saveConcepts, saveTable, validateConceptLinks, } from "./workspace.js";
|
|
6
|
+
export type { BundledSchemaV2, Workspace, WorkspaceTable } from "./workspace.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,UAAU,EACV,uBAAuB,EACvB,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,SAAS,EACT,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildFrontmatter, buildTableDraft, findSensitiveColumnReferences, formatList, hasAnyColumnDescribable, isEnumCandidate, parseListInput, } from "./draft.js";
|
|
2
|
+
export { buildSuggestionContext, buildSuggestionTarget, } from "./suggest.js";
|
|
3
|
+
export { buildDefaultTableBody, bundleSchemaDirectory, loadWorkspace, pruneOrphanedColumns, replaceH2Section, replaceTableDescription, saveConcepts, saveTable, validateConceptLinks, } from "./workspace.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,UAAU,EACV,uBAAuB,EACvB,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAQtB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,SAAS,EACT,oBAAoB,GACrB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EnrichmentCandidate, EnrichmentContext, EnrichmentTarget } from "@askdb/core";
|
|
2
|
+
import type { Workspace } from "./workspace.js";
|
|
3
|
+
export type SuggestEnrichment = (target: EnrichmentTarget, context: EnrichmentContext) => Promise<EnrichmentCandidate[]>;
|
|
4
|
+
export type SuggestEnrichmentForTui = SuggestEnrichment;
|
|
5
|
+
export type TableSuggestField = "description" | "aliases" | "primaryEntity" | "commonQueryLanguage";
|
|
6
|
+
export type ColumnSuggestField = "description" | "aliases";
|
|
7
|
+
export type SuggestSource = {
|
|
8
|
+
scope: "table";
|
|
9
|
+
tableId: string;
|
|
10
|
+
field: TableSuggestField;
|
|
11
|
+
} | {
|
|
12
|
+
scope: "column";
|
|
13
|
+
tableId: string;
|
|
14
|
+
columnId: string;
|
|
15
|
+
field: ColumnSuggestField;
|
|
16
|
+
};
|
|
17
|
+
export declare function buildSuggestionTarget(workspace: Workspace, source: SuggestSource): EnrichmentTarget;
|
|
18
|
+
export declare function buildSuggestionContext(workspace: Workspace, tableId: string): EnrichmentContext;
|
|
19
|
+
//# sourceMappingURL=suggest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../src/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,iBAAiB,KACvB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;AAEpC,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAExD,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,SAAS,GACT,eAAe,GACf,qBAAqB,CAAC;AAC1B,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,SAAS,CAAC;AAE3D,MAAM,MAAM,aAAa,GACrB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,GAC7D;IACE,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAEN,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,aAAa,GACpB,gBAAgB,CAqBlB;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,GACd,iBAAiB,CA2BnB"}
|
package/dist/suggest.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function buildSuggestionTarget(workspace, source) {
|
|
2
|
+
const table = findTable(workspace, source.tableId);
|
|
3
|
+
if (source.scope === "table") {
|
|
4
|
+
switch (source.field) {
|
|
5
|
+
case "description":
|
|
6
|
+
return { kind: "table-description", table };
|
|
7
|
+
case "aliases":
|
|
8
|
+
return { kind: "table-aliases", table };
|
|
9
|
+
case "primaryEntity":
|
|
10
|
+
return { kind: "table-primary-entity", table };
|
|
11
|
+
case "commonQueryLanguage":
|
|
12
|
+
return { kind: "common-query-language", table };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
switch (source.field) {
|
|
16
|
+
case "description":
|
|
17
|
+
return { kind: "column-description", table, columnId: source.columnId };
|
|
18
|
+
case "aliases":
|
|
19
|
+
return { kind: "column-aliases", table, columnId: source.columnId };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function buildSuggestionContext(workspace, tableId) {
|
|
23
|
+
const table = findTable(workspace, tableId);
|
|
24
|
+
const relatedIds = new Set();
|
|
25
|
+
const columnToTable = new Map();
|
|
26
|
+
for (const wt of workspace.tables) {
|
|
27
|
+
for (const column of wt.physical.columns) {
|
|
28
|
+
columnToTable.set(column.id, wt.physical.id);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const rel of table.relationships ?? []) {
|
|
32
|
+
const fromTable = columnToTable.get(rel.from);
|
|
33
|
+
const toTable = columnToTable.get(rel.to);
|
|
34
|
+
if (fromTable && fromTable !== table.id)
|
|
35
|
+
relatedIds.add(fromTable);
|
|
36
|
+
if (toTable && toTable !== table.id)
|
|
37
|
+
relatedIds.add(toTable);
|
|
38
|
+
}
|
|
39
|
+
const neighbors = [...relatedIds]
|
|
40
|
+
.map((id) => workspace.tables.find((wt) => wt.physical.id === id)?.physical)
|
|
41
|
+
.filter((t) => Boolean(t))
|
|
42
|
+
.slice(0, 4);
|
|
43
|
+
return {
|
|
44
|
+
schemaId: workspace.physical.schemaId,
|
|
45
|
+
...(neighbors.length > 0 ? { neighbors } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function findTable(workspace, tableId) {
|
|
49
|
+
const table = workspace.tables.find((wt) => wt.physical.id === tableId)?.physical;
|
|
50
|
+
if (!table)
|
|
51
|
+
throw new Error(`No such table: ${tableId}`);
|
|
52
|
+
return table;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=suggest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest.js","sourceRoot":"","sources":["../src/suggest.ts"],"names":[],"mappings":"AA+BA,MAAM,UAAU,qBAAqB,CACnC,SAAoB,EACpB,MAAqB;IAErB,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QAC7B,QAAQ,MAAM,CAAC,KAAK,EAAE,CAAC;YACrB,KAAK,aAAa;gBAChB,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;YAC9C,KAAK,SAAS;gBACZ,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,KA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} from "@askdb/core";
|
|
2
|
+
/**
|
|
3
|
+
* One table in the workspace. Pairs the physical layer entry with the (optional)
|
|
4
|
+
* describable-layer markdown file so save knows where to write.
|
|
5
|
+
*/
|
|
6
|
+
export type WorkspaceTable = {
|
|
7
|
+
/** Physical layer entry from `schema.json`. */
|
|
8
|
+
physical: V2Table;
|
|
9
|
+
/** Path to `tables/<filename>.md` (relative to `tables/`). May not exist on disk yet. */
|
|
10
|
+
filename: string;
|
|
11
|
+
/** Parsed markdown if the file exists; `undefined` for tables without a `.md` yet. */
|
|
12
|
+
parsed: ParsedTableMarkdown | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type Workspace = {
|
|
15
|
+
schemaDir: string;
|
|
16
|
+
physical: V2SchemaJson;
|
|
17
|
+
tables: WorkspaceTable[];
|
|
18
|
+
concepts: ParsedConceptsMarkdown | undefined;
|
|
19
|
+
warnings: SchemaV2Warning[];
|
|
20
|
+
};
|
|
21
|
+
export type BundledSchemaV2 = {
|
|
22
|
+
bundled: true;
|
|
23
|
+
physical: V2SchemaJson;
|
|
24
|
+
tables: Record<string, string>;
|
|
25
|
+
concepts?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Load a Schema v2 workspace from disk, preserving file-path information for
|
|
29
|
+
* round-trippable save.
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadWorkspace(schemaDir: string): Workspace;
|
|
32
|
+
/**
|
|
33
|
+
* Save a table's frontmatter + body back to disk via the Phase 5 writer.
|
|
34
|
+
* If the `.md` file does not exist, it is created with a minimal body skeleton.
|
|
35
|
+
*/
|
|
36
|
+
export declare function saveTable(workspace: Workspace, tableId: string, frontmatter: V2TableFrontmatter, body: string): void;
|
|
37
|
+
/** Save concepts.md back to disk via the Phase 5 writer. */
|
|
38
|
+
export declare function saveConcepts(workspace: Workspace, frontmatter: V2ConceptsFrontmatter, body?: string): void;
|
|
39
|
+
export declare function validateConceptLinks(workspace: Workspace, concepts: V2Concept[]): string[];
|
|
40
|
+
export declare function pruneOrphanedColumns(workspace: Workspace): number;
|
|
41
|
+
export declare function bundleSchemaDirectory(schemaDir: string): BundledSchemaV2;
|
|
42
|
+
/**
|
|
43
|
+
* Build a default body skeleton for a brand-new table .md file:
|
|
44
|
+
* `# Table: <name>` heading + the description as the first paragraph.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildDefaultTableBody(name: string, description: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Replace the description (first paragraph after the H1) in a table markdown body,
|
|
49
|
+
* preserving the H1 line and all subsequent H2 sections verbatim.
|
|
50
|
+
*
|
|
51
|
+
* The result has exactly one blank line between H1 and the description, and exactly
|
|
52
|
+
* one blank line between the description and whatever follows.
|
|
53
|
+
*/
|
|
54
|
+
export declare function replaceTableDescription(body: string, newDescription: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Replace or append a recognized H2 section body without touching the rest of
|
|
57
|
+
* the markdown body. The section content is normalized to one blank line after
|
|
58
|
+
* the heading and a trailing newline before the next section.
|
|
59
|
+
*/
|
|
60
|
+
export declare function replaceH2Section(body: string, heading: string, content: string): string;
|
|
61
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB,yFAAyF;IACzF,QAAQ,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,MAAM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wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAiBvF"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parseConceptsMarkdown, parseTableMarkdown, loadSchema, writeConceptsMarkdown, writeTableMarkdown, v2SchemaJsonSchema, } from "@askdb/core";
|
|
4
|
+
/**
|
|
5
|
+
* Load a Schema v2 workspace from disk, preserving file-path information for
|
|
6
|
+
* round-trippable save.
|
|
7
|
+
*/
|
|
8
|
+
export function loadWorkspace(schemaDir) {
|
|
9
|
+
const schemaJsonPath = join(schemaDir, "schema.json");
|
|
10
|
+
if (!existsSync(schemaJsonPath)) {
|
|
11
|
+
throw new Error(`No schema.json found in ${schemaDir}`);
|
|
12
|
+
}
|
|
13
|
+
const physical = parsePhysical(readFileSync(schemaJsonPath, "utf8"), schemaJsonPath);
|
|
14
|
+
const tableDir = join(schemaDir, "tables");
|
|
15
|
+
const parsedByFile = new Map();
|
|
16
|
+
if (existsSync(tableDir)) {
|
|
17
|
+
for (const entry of readdirSync(tableDir)) {
|
|
18
|
+
if (!entry.endsWith(".md"))
|
|
19
|
+
continue;
|
|
20
|
+
const content = readFileSync(join(tableDir, entry), "utf8");
|
|
21
|
+
parsedByFile.set(entry, parseTableMarkdown(content, join(tableDir, entry)));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Pair physical tables with their .md (if any). New physical tables get a
|
|
25
|
+
// default filename derived from the table name.
|
|
26
|
+
const tables = physical.tables.map((physTable) => {
|
|
27
|
+
const matched = [...parsedByFile.entries()].find(([, p]) => p.frontmatter.id === physTable.id);
|
|
28
|
+
if (matched) {
|
|
29
|
+
return { physical: physTable, filename: matched[0], parsed: matched[1] };
|
|
30
|
+
}
|
|
31
|
+
return { physical: physTable, filename: `${physTable.name}.md`, parsed: undefined };
|
|
32
|
+
});
|
|
33
|
+
let concepts;
|
|
34
|
+
const conceptsPath = join(schemaDir, "concepts.md");
|
|
35
|
+
if (existsSync(conceptsPath)) {
|
|
36
|
+
concepts = parseConceptsMarkdown(readFileSync(conceptsPath, "utf8"), conceptsPath);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
schemaDir,
|
|
40
|
+
physical,
|
|
41
|
+
tables,
|
|
42
|
+
concepts,
|
|
43
|
+
warnings: [...loadSchema(schemaDir).warnings, ...computeMissingDescribableWarnings(tables)],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Save a table's frontmatter + body back to disk via the Phase 5 writer.
|
|
48
|
+
* If the `.md` file does not exist, it is created with a minimal body skeleton.
|
|
49
|
+
*/
|
|
50
|
+
export function saveTable(workspace, tableId, frontmatter, body) {
|
|
51
|
+
const wt = workspace.tables.find((t) => t.physical.id === tableId);
|
|
52
|
+
if (!wt)
|
|
53
|
+
throw new Error(`No such table: ${tableId}`);
|
|
54
|
+
const tablesDir = join(workspace.schemaDir, "tables");
|
|
55
|
+
mkdirSync(tablesDir, { recursive: true });
|
|
56
|
+
const filePath = join(tablesDir, wt.filename);
|
|
57
|
+
const md = writeTableMarkdown(frontmatter, body);
|
|
58
|
+
writeFileSync(filePath, md, "utf8");
|
|
59
|
+
// Update in-memory parse so subsequent edits see the saved state.
|
|
60
|
+
const reparsed = parseTableMarkdown(md, filePath);
|
|
61
|
+
wt.parsed = reparsed;
|
|
62
|
+
}
|
|
63
|
+
/** Save concepts.md back to disk via the Phase 5 writer. */
|
|
64
|
+
export function saveConcepts(workspace, frontmatter, body = workspace.concepts?.body ?? "# Concepts\n\nCross-table vocabulary.\n") {
|
|
65
|
+
const invalid = validateConceptLinks(workspace, frontmatter.concepts);
|
|
66
|
+
if (invalid.length > 0) {
|
|
67
|
+
throw new Error(`Invalid concept link(s): ${invalid.join(", ")}`);
|
|
68
|
+
}
|
|
69
|
+
const filePath = join(workspace.schemaDir, "concepts.md");
|
|
70
|
+
const md = writeConceptsMarkdown(frontmatter, body);
|
|
71
|
+
writeFileSync(filePath, md, "utf8");
|
|
72
|
+
workspace.concepts = parseConceptsMarkdown(md, filePath);
|
|
73
|
+
}
|
|
74
|
+
export function validateConceptLinks(workspace, concepts) {
|
|
75
|
+
const known = new Set();
|
|
76
|
+
for (const table of workspace.physical.tables) {
|
|
77
|
+
known.add(table.id);
|
|
78
|
+
for (const column of table.columns)
|
|
79
|
+
known.add(column.id);
|
|
80
|
+
}
|
|
81
|
+
return concepts.flatMap((concept) => concept.links ?? []).filter((link) => !known.has(link));
|
|
82
|
+
}
|
|
83
|
+
export function pruneOrphanedColumns(workspace) {
|
|
84
|
+
const physicalColumnIds = new Set(workspace.physical.tables.flatMap((table) => table.columns.map((column) => column.id)));
|
|
85
|
+
let pruned = 0;
|
|
86
|
+
for (const table of workspace.tables) {
|
|
87
|
+
const parsed = table.parsed;
|
|
88
|
+
if (!parsed?.frontmatter.columns)
|
|
89
|
+
continue;
|
|
90
|
+
const nextColumns = parsed.frontmatter.columns.filter((column) => {
|
|
91
|
+
const keep = physicalColumnIds.has(column.id);
|
|
92
|
+
if (!keep)
|
|
93
|
+
pruned += 1;
|
|
94
|
+
return keep;
|
|
95
|
+
});
|
|
96
|
+
if (nextColumns.length === parsed.frontmatter.columns.length)
|
|
97
|
+
continue;
|
|
98
|
+
const nextFrontmatter = {
|
|
99
|
+
...parsed.frontmatter,
|
|
100
|
+
columns: nextColumns.length > 0 ? nextColumns : undefined,
|
|
101
|
+
};
|
|
102
|
+
saveTable(workspace, table.physical.id, nextFrontmatter, parsed.body);
|
|
103
|
+
}
|
|
104
|
+
workspace.warnings = [
|
|
105
|
+
...loadSchema(workspace.schemaDir).warnings,
|
|
106
|
+
...computeMissingDescribableWarnings(workspace.tables),
|
|
107
|
+
];
|
|
108
|
+
return pruned;
|
|
109
|
+
}
|
|
110
|
+
function computeMissingDescribableWarnings(tables) {
|
|
111
|
+
const warnings = [];
|
|
112
|
+
for (const table of tables) {
|
|
113
|
+
if (!table.parsed) {
|
|
114
|
+
warnings.push({ kind: "missing_table_md", tableId: table.physical.id });
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const described = new Set((table.parsed.frontmatter.columns ?? []).map((column) => column.id));
|
|
118
|
+
for (const column of table.physical.columns) {
|
|
119
|
+
if (!described.has(column.id)) {
|
|
120
|
+
warnings.push({
|
|
121
|
+
kind: "missing_column_md",
|
|
122
|
+
tableId: table.physical.id,
|
|
123
|
+
columnId: column.id,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return warnings;
|
|
129
|
+
}
|
|
130
|
+
function parsePhysical(raw, filePath) {
|
|
131
|
+
let parsed;
|
|
132
|
+
try {
|
|
133
|
+
parsed = JSON.parse(raw);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
throw new Error(`Failed to parse JSON at ${filePath}`);
|
|
137
|
+
}
|
|
138
|
+
const result = v2SchemaJsonSchema.safeParse(parsed);
|
|
139
|
+
if (!result.success) {
|
|
140
|
+
throw new Error(`Invalid schema.json at ${filePath}: ${result.error.message}`);
|
|
141
|
+
}
|
|
142
|
+
return result.data;
|
|
143
|
+
}
|
|
144
|
+
export function bundleSchemaDirectory(schemaDir) {
|
|
145
|
+
const schemaJsonPath = join(schemaDir, "schema.json");
|
|
146
|
+
if (!existsSync(schemaJsonPath)) {
|
|
147
|
+
throw new Error(`No schema.json found in ${schemaDir}`);
|
|
148
|
+
}
|
|
149
|
+
const physical = parsePhysical(readFileSync(schemaJsonPath, "utf8"), schemaJsonPath);
|
|
150
|
+
const tables = {};
|
|
151
|
+
const tableDir = join(schemaDir, "tables");
|
|
152
|
+
if (existsSync(tableDir)) {
|
|
153
|
+
for (const entry of readdirSync(tableDir).sort()) {
|
|
154
|
+
if (!entry.endsWith(".md"))
|
|
155
|
+
continue;
|
|
156
|
+
tables[entry] = readFileSync(join(tableDir, entry), "utf8");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const conceptsPath = join(schemaDir, "concepts.md");
|
|
160
|
+
const concepts = existsSync(conceptsPath)
|
|
161
|
+
? readFileSync(conceptsPath, "utf8")
|
|
162
|
+
: undefined;
|
|
163
|
+
return {
|
|
164
|
+
bundled: true,
|
|
165
|
+
physical,
|
|
166
|
+
tables,
|
|
167
|
+
...(concepts !== undefined ? { concepts } : {}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Build a default body skeleton for a brand-new table .md file:
|
|
172
|
+
* `# Table: <name>` heading + the description as the first paragraph.
|
|
173
|
+
*/
|
|
174
|
+
export function buildDefaultTableBody(name, description) {
|
|
175
|
+
const desc = description.trim();
|
|
176
|
+
const head = `# Table: ${name}\n`;
|
|
177
|
+
if (!desc)
|
|
178
|
+
return `${head}\n`;
|
|
179
|
+
return `${head}\n${desc}\n`;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Replace the description (first paragraph after the H1) in a table markdown body,
|
|
183
|
+
* preserving the H1 line and all subsequent H2 sections verbatim.
|
|
184
|
+
*
|
|
185
|
+
* The result has exactly one blank line between H1 and the description, and exactly
|
|
186
|
+
* one blank line between the description and whatever follows.
|
|
187
|
+
*/
|
|
188
|
+
export function replaceTableDescription(body, newDescription) {
|
|
189
|
+
const trimmed = newDescription.trim();
|
|
190
|
+
const lines = body.split("\n");
|
|
191
|
+
const h1Idx = lines.findIndex((l) => l.startsWith("# "));
|
|
192
|
+
// Where description content starts: the first non-blank line after H1
|
|
193
|
+
// (or the first non-blank line in the body if there is no H1).
|
|
194
|
+
let descStart = h1Idx >= 0 ? h1Idx + 1 : 0;
|
|
195
|
+
while (descStart < lines.length && lines[descStart].trim() === "") {
|
|
196
|
+
descStart += 1;
|
|
197
|
+
}
|
|
198
|
+
// Where description content ends: the first blank line or H1/H2 we hit.
|
|
199
|
+
let descEnd = descStart;
|
|
200
|
+
while (descEnd < lines.length &&
|
|
201
|
+
lines[descEnd].trim() !== "" &&
|
|
202
|
+
!lines[descEnd].startsWith("# ") &&
|
|
203
|
+
!lines[descEnd].startsWith("## ")) {
|
|
204
|
+
descEnd += 1;
|
|
205
|
+
}
|
|
206
|
+
const before = h1Idx >= 0 ? lines.slice(0, h1Idx + 1) : [];
|
|
207
|
+
// Drop trailing blanks at the end of `before` so we control spacing exactly.
|
|
208
|
+
while (before.length > 0 && before[before.length - 1].trim() === "") {
|
|
209
|
+
before.pop();
|
|
210
|
+
}
|
|
211
|
+
const after = lines.slice(descEnd);
|
|
212
|
+
// Drop leading blanks from `after` so we control spacing exactly.
|
|
213
|
+
while (after.length > 0 && after[0].trim() === "") {
|
|
214
|
+
after.shift();
|
|
215
|
+
}
|
|
216
|
+
const segments = [];
|
|
217
|
+
if (before.length > 0) {
|
|
218
|
+
segments.push(...before);
|
|
219
|
+
if (trimmed || after.length > 0)
|
|
220
|
+
segments.push("");
|
|
221
|
+
}
|
|
222
|
+
if (trimmed) {
|
|
223
|
+
segments.push(trimmed);
|
|
224
|
+
if (after.length > 0)
|
|
225
|
+
segments.push("");
|
|
226
|
+
}
|
|
227
|
+
segments.push(...after);
|
|
228
|
+
// Preserve a trailing newline if the original had one.
|
|
229
|
+
const trailingNewline = body.endsWith("\n");
|
|
230
|
+
const out = segments.join("\n");
|
|
231
|
+
return trailingNewline && !out.endsWith("\n") ? `${out}\n` : out;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Replace or append a recognized H2 section body without touching the rest of
|
|
235
|
+
* the markdown body. The section content is normalized to one blank line after
|
|
236
|
+
* the heading and a trailing newline before the next section.
|
|
237
|
+
*/
|
|
238
|
+
export function replaceH2Section(body, heading, content) {
|
|
239
|
+
const normalized = normalizeSection(heading, content);
|
|
240
|
+
const pattern = new RegExp(`^## ${escapeRegex(heading)}\\s*$`, "im");
|
|
241
|
+
const match = pattern.exec(body);
|
|
242
|
+
if (!match) {
|
|
243
|
+
const base = body.endsWith("\n") ? body : `${body}\n`;
|
|
244
|
+
return `${base}\n${normalized}`;
|
|
245
|
+
}
|
|
246
|
+
const start = match.index;
|
|
247
|
+
const afterHeading = start + match[0].length;
|
|
248
|
+
const rest = body.slice(afterHeading);
|
|
249
|
+
const nextMatch = /^## .+$/m.exec(rest);
|
|
250
|
+
const end = nextMatch ? afterHeading + nextMatch.index : body.length;
|
|
251
|
+
const before = body.slice(0, start).replace(/\s*$/, "\n\n");
|
|
252
|
+
const after = body.slice(end).replace(/^\s*/, "");
|
|
253
|
+
return after ? `${before}${normalized}\n${after}` : `${before}${normalized}`;
|
|
254
|
+
}
|
|
255
|
+
function normalizeSection(heading, content) {
|
|
256
|
+
const trimmed = content.trim();
|
|
257
|
+
return trimmed ? `## ${heading}\n\n${trimmed}\n` : `## ${heading}\n`;
|
|
258
|
+
}
|
|
259
|
+
function escapeRegex(s) {
|
|
260
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,GASnB,MAAM,aAAa,CAAC;AA8BrB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACtD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,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,KAAK,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IACrE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,UAAU,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,UAAU,EAAE,CAAC;AAC/E,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAe,EAAE,OAAe;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO,IAAI,CAAC;AACvE,CAAC;AAED,SAAS,WAAW,CAAC,CAAS;IAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@askdb/enrich",
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
|
+
"description": "AskDB enrichment workspace helpers for Schema v2 authoring surfaces.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"askdb",
|
|
7
|
+
"schema",
|
|
8
|
+
"schema-v2",
|
|
9
|
+
"enrichment"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/Ygilany/AskDB#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Ygilany/AskDB/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Ygilany/AskDB.git",
|
|
18
|
+
"directory": "packages/enrich"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"author": "Yahya Gilany",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"NOTICE"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@askdb/core": "0.5.0-beta.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.7.3",
|
|
45
|
+
"vitest": "^3.0.9"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -p tsconfig.build.json",
|
|
49
|
+
"lint": "tsc -p tsconfig.build.json --noEmit",
|
|
50
|
+
"test": "vitest run --config ../../vitest.config.ts"
|
|
51
|
+
}
|
|
52
|
+
}
|