@interactive-inc/docs-client 1.0.15 → 1.0.17

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/build/index.d.ts CHANGED
@@ -219,10 +219,6 @@ declare class DocFileMdContentValue<T extends DocCustomSchema> {
219
219
  * Generate from Markdown text
220
220
  */
221
221
  static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
222
- /**
223
- * Generate complete Markdown text
224
- */
225
- toMarkdownText(): string;
226
222
  /**
227
223
  * Generate complete text combining FrontMatter and body
228
224
  */
@@ -1331,10 +1327,6 @@ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
1331
1327
  * Generate from Markdown text
1332
1328
  */
1333
1329
  static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
1334
- /**
1335
- * Generate complete Markdown text
1336
- */
1337
- toMarkdownText(): string;
1338
1330
  /**
1339
1331
  * Update content
1340
1332
  */
@@ -1668,11 +1660,11 @@ declare class DocMarkdownSystem {
1668
1660
  */
1669
1661
  extractDescription(text: string): string | null;
1670
1662
  /**
1671
- * Update title in body
1663
+ * Update title in body (returns body only, without FrontMatter)
1672
1664
  */
1673
1665
  updateTitle(text: string, newTitle: string): string;
1674
1666
  /**
1675
- * Update description in body
1667
+ * Update description in body (returns body only, without FrontMatter)
1676
1668
  */
1677
1669
  updateDescription(text: string, newDescription: string, defaultTitle: string): string;
1678
1670
  /**
package/build/index.js CHANGED
@@ -398,40 +398,30 @@ ${separator}`, separator.length);
398
398
  return null;
399
399
  }
400
400
  /**
401
- * Update title in body
401
+ * Update title in body (returns body only, without FrontMatter)
402
402
  */
403
403
  updateTitle(text, newTitle) {
404
- const body = this.extractBody(text);
405
- const lines = body.split("\n");
404
+ const lines = text.split("\n");
406
405
  const titleIndex = lines.findIndex((line) => line.match(/^#\s+/));
407
406
  if (titleIndex !== -1) {
408
407
  lines[titleIndex] = `# ${newTitle}`;
409
408
  } else {
410
409
  lines.unshift(`# ${newTitle}`, "");
411
410
  }
412
- const updatedBody = lines.join("\n");
413
- const frontMatter = this.extractFrontMatter(text);
414
- const separator = this.detectFrontMatterSeparator(text);
415
- return frontMatter ? `${separator}
416
- ${frontMatter}
417
- ${separator}
418
-
419
- ${updatedBody}` : updatedBody;
411
+ return lines.join("\n");
420
412
  }
421
413
  /**
422
- * Update description in body
414
+ * Update description in body (returns body only, without FrontMatter)
423
415
  */
424
416
  updateDescription(text, newDescription, defaultTitle) {
425
- const body = this.extractBody(text);
426
- const lines = body.split("\n");
417
+ const lines = text.split("\n");
427
418
  const titleIndex = lines.findIndex((line) => line.match(/^#\s+/));
428
- let updatedBody;
429
419
  if (titleIndex === -1) {
430
- updatedBody = `# ${defaultTitle}
420
+ return `# ${defaultTitle}
431
421
 
432
422
  ${newDescription}
433
423
 
434
- ${body}`.trim();
424
+ ${text}`.trim();
435
425
  } else {
436
426
  const descIndex = this.skipEmptyLines(lines, titleIndex + 1);
437
427
  if (descIndex < lines.length && lines[descIndex] && !lines[descIndex].startsWith("#")) {
@@ -439,15 +429,8 @@ ${body}`.trim();
439
429
  } else {
440
430
  lines.splice(titleIndex + 1, 0, "", newDescription);
441
431
  }
442
- updatedBody = lines.join("\n");
432
+ return lines.join("\n");
443
433
  }
444
- const frontMatter = this.extractFrontMatter(text);
445
- const separator = this.detectFrontMatterSeparator(text);
446
- return frontMatter ? `${separator}
447
- ${frontMatter}
448
- ${separator}
449
-
450
- ${updatedBody}` : updatedBody;
451
434
  }
452
435
  /**
453
436
  * Skip empty lines
@@ -1524,12 +1507,6 @@ var DocFileMdContentValue = class _DocFileMdContentValue {
1524
1507
  customSchema
1525
1508
  );
1526
1509
  }
1527
- /**
1528
- * Generate complete Markdown text
1529
- */
1530
- toMarkdownText() {
1531
- return DocMarkdownSystem.from(this.title, this.description, this.body);
1532
- }
1533
1510
  /**
1534
1511
  * Generate complete text combining FrontMatter and body
1535
1512
  */
@@ -1881,7 +1858,9 @@ var DocFileRelationReference = class {
1881
1858
  if (file instanceof Error) {
1882
1859
  return file;
1883
1860
  }
1884
- if (file === null) continue;
1861
+ if (file === null) {
1862
+ continue;
1863
+ }
1885
1864
  files.push(file);
1886
1865
  }
1887
1866
  return files;
@@ -1893,6 +1872,9 @@ var DocFileRelationReference = class {
1893
1872
  if (filePath.includes("index.md")) {
1894
1873
  return null;
1895
1874
  }
1875
+ if (!filePath.endsWith(".md")) {
1876
+ return null;
1877
+ }
1896
1878
  const content = await this.fileSystem.readFile(filePath);
1897
1879
  if (content instanceof Error) {
1898
1880
  return content;
@@ -3072,17 +3054,16 @@ var DocFileIndexContentValue = class _DocFileIndexContentValue {
3072
3054
  * Update description
3073
3055
  */
3074
3056
  withDescription(description, defaultTitle) {
3075
- const fullText = this.toText();
3076
3057
  const engine = new DocMarkdownSystem();
3077
- const updatedText = engine.updateDescription(
3078
- fullText,
3058
+ const updatedBody = engine.updateDescription(
3059
+ this.body,
3079
3060
  description,
3080
3061
  defaultTitle || this.title
3081
3062
  );
3082
3063
  return new _DocFileIndexContentValue(
3083
3064
  {
3084
3065
  ...this.value,
3085
- body: engine.extractBody(updatedText),
3066
+ body: updatedBody,
3086
3067
  description
3087
3068
  },
3088
3069
  this.customSchema,
@@ -3111,12 +3092,6 @@ var DocFileIndexContentValue = class _DocFileIndexContentValue {
3111
3092
  config
3112
3093
  );
3113
3094
  }
3114
- /**
3115
- * Generate complete Markdown text
3116
- */
3117
- toMarkdownText() {
3118
- return DocMarkdownSystem.from(this.title, this.description, this.body);
3119
- }
3120
3095
  /**
3121
3096
  * Update content
3122
3097
  */
@@ -3178,11 +3153,13 @@ schema: {}
3178
3153
  schema: this.meta().schema().toJson()
3179
3154
  };
3180
3155
  const yamlStr = stringify3(yamlData).trim();
3181
- return `---
3156
+ const text = `---
3182
3157
  ${yamlStr}
3183
3158
  ---
3184
3159
 
3185
- ${this.toMarkdownText()}`;
3160
+ ${this.body.trim()}`;
3161
+ return `${text.trim()}
3162
+ `;
3186
3163
  }
3187
3164
  /**
3188
3165
  * Output in JSON format
@@ -3426,7 +3403,7 @@ var DocFileIndexReference = class _DocFileIndexReference {
3426
3403
  return [];
3427
3404
  }
3428
3405
  const refs = [];
3429
- const fieldKeys = Object.keys(schema);
3406
+ const fieldKeys = Object.keys(schema.value);
3430
3407
  for (const key of fieldKeys) {
3431
3408
  const fieldValue = schema.value[key];
3432
3409
  if (fieldValue === void 0) continue;
@@ -3434,8 +3411,9 @@ var DocFileIndexReference = class _DocFileIndexReference {
3434
3411
  continue;
3435
3412
  }
3436
3413
  const field = schema.field(key);
3414
+ const path = field.path;
3437
3415
  const fileRef = new DocFileRelationReference({
3438
- filePath: field.path,
3416
+ filePath: path,
3439
3417
  fileSystem: this.fileSystem,
3440
3418
  pathSystem: this.pathSystem
3441
3419
  });
@@ -3451,8 +3429,12 @@ var DocFileIndexReference = class _DocFileIndexReference {
3451
3429
  const files = [];
3452
3430
  for (const relation of relations) {
3453
3431
  const entity = await relation.read();
3454
- if (entity === null) continue;
3455
- if (entity instanceof Error) continue;
3432
+ if (entity === null) {
3433
+ continue;
3434
+ }
3435
+ if (entity instanceof Error) {
3436
+ continue;
3437
+ }
3456
3438
  files.push(entity);
3457
3439
  }
3458
3440
  return files;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interactive-inc/docs-client",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsgo --noEmit",