@sdk-it/readme 0.28.0 → 0.29.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/dist/index.js CHANGED
@@ -10,8 +10,9 @@ function toTOC(spec) {
10
10
  tocLines.push("");
11
11
  }
12
12
  for (const item of category.items) {
13
- if (item.id === "generated-introduction") continue;
14
- contents.push(item.content || "");
13
+ if (item.id !== "generated-introduction") {
14
+ contents.push(item.content || "");
15
+ }
15
16
  if (item.items && item.items.length > 0) {
16
17
  tocLines.push(`- **${item.title}**`);
17
18
  for (const subItem of item.items) {
@@ -37,13 +38,6 @@ function toReadme(spec) {
37
38
  if (generatedIntro && generatedIntro.content) {
38
39
  markdown.push(generatedIntro.content);
39
40
  }
40
- markdown.push("---");
41
- markdown.push("## Table of Contents");
42
- markdown.push(...toc.tocLines);
43
- markdown.push("---");
44
- markdown.push(
45
- "This document provides an overview of the API endpoints available in this service. Each endpoint includes a brief description, example usage, and details about request and response formats."
46
- );
47
41
  markdown.push(toc.contents.join("\n\n"));
48
42
  return markdown.join("\n\n");
49
43
  }
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/lib/readme.ts"],
4
- "sourcesContent": ["import { type OurOpenAPIObject, toSidebar } from '@sdk-it/spec';\n\nfunction toTOC(spec: OurOpenAPIObject) {\n const tocLines: string[] = [];\n const sidebar = toSidebar(spec);\n const contents: string[] = [];\n\n for (const category of sidebar) {\n if (category.category) {\n tocLines.push(`### ${category.category}`);\n tocLines.push('');\n }\n\n for (const item of category.items) {\n if (item.id === 'generated-introduction') continue;\n\n contents.push(item.content || '');\n if (item.items && item.items.length > 0) {\n // This is a tag/group with operations\n tocLines.push(`- **${item.title}**`);\n\n // Add each operation in this tag\n for (const subItem of item.items) {\n // Create anchor that matches the markdown header format\n const anchor = `#${subItem.title\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/\\s+/g, '-')}`;\n tocLines.push(` - [${subItem.title}](${anchor})`);\n }\n } else {\n // This might be a standalone item\n tocLines.push(`- **${item.title}**`);\n }\n }\n tocLines.push('');\n }\n\n if (spec.components?.schemas) {\n tocLines.push('- [Schemas](#schemas)');\n tocLines.push('');\n }\n\n return { tocLines, contents };\n}\n\nexport function toReadme(spec: OurOpenAPIObject) {\n const toc = toTOC(spec);\n const markdown: string[] = [];\n\n const generatedIntro = spec['x-docs']\n .flatMap((it) => it.items)\n .find((doc) => doc.id === 'generated-introduction');\n\n if (generatedIntro && generatedIntro.content) {\n markdown.push(generatedIntro.content);\n }\n\n markdown.push('---');\n markdown.push('## Table of Contents');\n markdown.push(...toc.tocLines);\n markdown.push('---');\n\n markdown.push(\n 'This document provides an overview of the API endpoints available in this service. Each endpoint includes a brief description, example usage, and details about request and response formats.',\n );\n\n markdown.push(toc.contents.join('\\n\\n'));\n\n return markdown.join('\\n\\n');\n}\n"],
5
- "mappings": ";AAAA,SAAgC,iBAAiB;AAEjD,SAAS,MAAM,MAAwB;AACrC,QAAM,WAAqB,CAAC;AAC5B,QAAM,UAAU,UAAU,IAAI;AAC9B,QAAM,WAAqB,CAAC;AAE5B,aAAW,YAAY,SAAS;AAC9B,QAAI,SAAS,UAAU;AACrB,eAAS,KAAK,OAAO,SAAS,QAAQ,EAAE;AACxC,eAAS,KAAK,EAAE;AAAA,IAClB;AAEA,eAAW,QAAQ,SAAS,OAAO;AACjC,UAAI,KAAK,OAAO,yBAA0B;AAE1C,eAAS,KAAK,KAAK,WAAW,EAAE;AAChC,UAAI,KAAK,SAAS,KAAK,MAAM,SAAS,GAAG;AAEvC,iBAAS,KAAK,OAAO,KAAK,KAAK,IAAI;AAGnC,mBAAW,WAAW,KAAK,OAAO;AAEhC,gBAAM,SAAS,IAAI,QAAQ,MACxB,YAAY,EACZ,QAAQ,aAAa,EAAE,EACvB,QAAQ,QAAQ,GAAG,CAAC;AACvB,mBAAS,KAAK,QAAQ,QAAQ,KAAK,KAAK,MAAM,GAAG;AAAA,QACnD;AAAA,MACF,OAAO;AAEL,iBAAS,KAAK,OAAO,KAAK,KAAK,IAAI;AAAA,MACrC;AAAA,IACF;AACA,aAAS,KAAK,EAAE;AAAA,EAClB;AAEA,MAAI,KAAK,YAAY,SAAS;AAC5B,aAAS,KAAK,uBAAuB;AACrC,aAAS,KAAK,EAAE;AAAA,EAClB;AAEA,SAAO,EAAE,UAAU,SAAS;AAC9B;AAEO,SAAS,SAAS,MAAwB;AAC/C,QAAM,MAAM,MAAM,IAAI;AACtB,QAAM,WAAqB,CAAC;AAE5B,QAAM,iBAAiB,KAAK,QAAQ,EACjC,QAAQ,CAAC,OAAO,GAAG,KAAK,EACxB,KAAK,CAAC,QAAQ,IAAI,OAAO,wBAAwB;AAEpD,MAAI,kBAAkB,eAAe,SAAS;AAC5C,aAAS,KAAK,eAAe,OAAO;AAAA,EACtC;AAEA,WAAS,KAAK,KAAK;AACnB,WAAS,KAAK,sBAAsB;AACpC,WAAS,KAAK,GAAG,IAAI,QAAQ;AAC7B,WAAS,KAAK,KAAK;AAEnB,WAAS;AAAA,IACP;AAAA,EACF;AAEA,WAAS,KAAK,IAAI,SAAS,KAAK,MAAM,CAAC;AAEvC,SAAO,SAAS,KAAK,MAAM;AAC7B;",
4
+ "sourcesContent": ["import { type OurOpenAPIObject, toSidebar } from '@sdk-it/spec';\n\nfunction toTOC(spec: OurOpenAPIObject) {\n const tocLines: string[] = [];\n const sidebar = toSidebar(spec);\n const contents: string[] = [];\n\n for (const category of sidebar) {\n if (category.category) {\n tocLines.push(`### ${category.category}`);\n tocLines.push('');\n }\n\n for (const item of category.items) {\n if (item.id !== 'generated-introduction') {\n contents.push(item.content || '');\n }\n\n if (item.items && item.items.length > 0) {\n // This is a tag/group with operations\n tocLines.push(`- **${item.title}**`);\n\n // Add each operation in this tag\n for (const subItem of item.items) {\n // Create anchor that matches the markdown header format\n const anchor = `#${subItem.title\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/\\s+/g, '-')}`;\n tocLines.push(` - [${subItem.title}](${anchor})`);\n }\n } else {\n // This might be a standalone item\n tocLines.push(`- **${item.title}**`);\n }\n }\n tocLines.push('');\n }\n\n if (spec.components?.schemas) {\n tocLines.push('- [Schemas](#schemas)');\n tocLines.push('');\n }\n\n return { tocLines, contents };\n}\n\nexport function toReadme(spec: OurOpenAPIObject) {\n const toc = toTOC(spec);\n const markdown: string[] = [];\n\n const generatedIntro = spec['x-docs']\n .flatMap((it) => it.items)\n .find((doc) => doc.id === 'generated-introduction');\n\n if (generatedIntro && generatedIntro.content) {\n markdown.push(generatedIntro.content);\n }\n\n // markdown.push('---');\n // markdown.push('## Table of Contents');\n // markdown.push(...toc.tocLines);\n // markdown.push('---');\n\n markdown.push(toc.contents.join('\\n\\n'));\n\n return markdown.join('\\n\\n');\n}\n"],
5
+ "mappings": ";AAAA,SAAgC,iBAAiB;AAEjD,SAAS,MAAM,MAAwB;AACrC,QAAM,WAAqB,CAAC;AAC5B,QAAM,UAAU,UAAU,IAAI;AAC9B,QAAM,WAAqB,CAAC;AAE5B,aAAW,YAAY,SAAS;AAC9B,QAAI,SAAS,UAAU;AACrB,eAAS,KAAK,OAAO,SAAS,QAAQ,EAAE;AACxC,eAAS,KAAK,EAAE;AAAA,IAClB;AAEA,eAAW,QAAQ,SAAS,OAAO;AACjC,UAAI,KAAK,OAAO,0BAA0B;AACxC,iBAAS,KAAK,KAAK,WAAW,EAAE;AAAA,MAClC;AAEA,UAAI,KAAK,SAAS,KAAK,MAAM,SAAS,GAAG;AAEvC,iBAAS,KAAK,OAAO,KAAK,KAAK,IAAI;AAGnC,mBAAW,WAAW,KAAK,OAAO;AAEhC,gBAAM,SAAS,IAAI,QAAQ,MACxB,YAAY,EACZ,QAAQ,aAAa,EAAE,EACvB,QAAQ,QAAQ,GAAG,CAAC;AACvB,mBAAS,KAAK,QAAQ,QAAQ,KAAK,KAAK,MAAM,GAAG;AAAA,QACnD;AAAA,MACF,OAAO;AAEL,iBAAS,KAAK,OAAO,KAAK,KAAK,IAAI;AAAA,MACrC;AAAA,IACF;AACA,aAAS,KAAK,EAAE;AAAA,EAClB;AAEA,MAAI,KAAK,YAAY,SAAS;AAC5B,aAAS,KAAK,uBAAuB;AACrC,aAAS,KAAK,EAAE;AAAA,EAClB;AAEA,SAAO,EAAE,UAAU,SAAS;AAC9B;AAEO,SAAS,SAAS,MAAwB;AAC/C,QAAM,MAAM,MAAM,IAAI;AACtB,QAAM,WAAqB,CAAC;AAE5B,QAAM,iBAAiB,KAAK,QAAQ,EACjC,QAAQ,CAAC,OAAO,GAAG,KAAK,EACxB,KAAK,CAAC,QAAQ,IAAI,OAAO,wBAAwB;AAEpD,MAAI,kBAAkB,eAAe,SAAS;AAC5C,aAAS,KAAK,eAAe,OAAO;AAAA,EACtC;AAOA,WAAS,KAAK,IAAI,SAAS,KAAK,MAAM,CAAC;AAEvC,SAAO,SAAS,KAAK,MAAM;AAC7B;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/lib/readme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,cAAc,CAAC;AA8ChE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,UAwB9C"}
1
+ {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/lib/readme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,cAAc,CAAC;AA+ChE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,UAoB9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-it/readme",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -21,7 +21,8 @@
21
21
  "!**/*.tsbuildinfo"
22
22
  ],
23
23
  "dependencies": {
24
- "@sdk-it/core": "0.28.0",
25
- "@sdk-it/spec": "0.28.0"
24
+ "@sdk-it/core": "0.29.0",
25
+ "@sdk-it/spec": "0.29.0",
26
+ "openapi3-ts": "4.4.0"
26
27
  }
27
28
  }