@shrkcrft/knowledge 0.1.0-alpha.19 → 0.1.0-alpha.20

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.
@@ -7,5 +7,17 @@ export interface FormatEntryOptions {
7
7
  maxContentChars?: number;
8
8
  }
9
9
  export declare function formatEntryCompact(entry: IKnowledgeEntry): string;
10
+ /**
11
+ * Project an entry to a plain JSON-serialisable object by reading each declared
12
+ * `IKnowledgeEntry` field by DIRECT property access.
13
+ *
14
+ * Spreading (`{ ...entry }`) copies only own-enumerable properties, so a
15
+ * pack-contributed entry whose fields are getters / non-enumerable /
16
+ * prototype-backed would serialise to `{ id, source }` only — the JSON looked
17
+ * "empty" while the text form (which reads fields directly) was complete.
18
+ * Direct access matches the text path and is robust to the entry's property
19
+ * descriptors. Undefined optionals drop out of `JSON.stringify` naturally.
20
+ */
21
+ export declare function projectKnowledgeEntryForJson(entry: IKnowledgeEntry): Record<string, unknown>;
10
22
  export declare function formatEntryFull(entry: IKnowledgeEntry, options?: FormatEntryOptions): string;
11
23
  //# sourceMappingURL=knowledge-formatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"knowledge-formatter.d.ts","sourceRoot":"","sources":["../../src/format/knowledge-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAKjE;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CA4CR"}
1
+ {"version":3,"file":"knowledge-formatter.d.ts","sourceRoot":"","sources":["../../src/format/knowledge-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAKjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmB5F;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CA4CR"}
@@ -5,6 +5,37 @@ export function formatEntryCompact(entry) {
5
5
  const appliesWhen = entry.appliesWhen.length ? ` appliesWhen=[${entry.appliesWhen.join(', ')}]` : '';
6
6
  return `${entry.id} (${entry.type}, ${entry.priority}) — ${entry.title}${tags}${scope}${appliesWhen}`;
7
7
  }
8
+ /**
9
+ * Project an entry to a plain JSON-serialisable object by reading each declared
10
+ * `IKnowledgeEntry` field by DIRECT property access.
11
+ *
12
+ * Spreading (`{ ...entry }`) copies only own-enumerable properties, so a
13
+ * pack-contributed entry whose fields are getters / non-enumerable /
14
+ * prototype-backed would serialise to `{ id, source }` only — the JSON looked
15
+ * "empty" while the text form (which reads fields directly) was complete.
16
+ * Direct access matches the text path and is robust to the entry's property
17
+ * descriptors. Undefined optionals drop out of `JSON.stringify` naturally.
18
+ */
19
+ export function projectKnowledgeEntryForJson(entry) {
20
+ return {
21
+ id: entry.id,
22
+ title: entry.title,
23
+ type: entry.type,
24
+ priority: entry.priority,
25
+ scope: entry.scope,
26
+ tags: entry.tags,
27
+ appliesWhen: entry.appliesWhen,
28
+ content: entry.content,
29
+ summary: entry.summary,
30
+ examples: entry.examples,
31
+ related: entry.related,
32
+ source: entry.source,
33
+ metadata: entry.metadata,
34
+ actionHints: entry.actionHints,
35
+ references: entry.references,
36
+ anchors: entry.anchors,
37
+ };
38
+ }
8
39
  export function formatEntryFull(entry, options = {}) {
9
40
  const { includeExamples = true, includeContent = true, maxContentChars } = options;
10
41
  const lines = [];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@shrkcrft/knowledge",
3
- "version": "0.1.0-alpha.19",
3
+ "version": "0.1.0-alpha.20",
4
4
  "description": "SharkCraft structured knowledge model: typed entries, index, search, loaders (TS + markdown), validation.",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",
7
7
  "type": "module",
8
8
  "main": "./dist/index.js",
9
- "types": "./dist/index.d.d.ts",
9
+ "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "typecheck": "tsc --noEmit -p tsconfig.json"
45
45
  },
46
46
  "dependencies": {
47
- "@shrkcrft/core": "^0.1.0-alpha.19"
47
+ "@shrkcrft/core": "^0.1.0-alpha.20"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"