@xyd-js/sources 0.0.1-xyd.0 → 0.1.1-build.161

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 (110) hide show
  1. package/CHANGELOG.md +1342 -0
  2. package/ISSUES.md +10 -0
  3. package/LICENSE +21 -0
  4. package/TODO.md +5 -2
  5. package/__fixtures__/-1.typescript/package.json +5 -0
  6. package/__fixtures__/-1.typescript/src/index.ts +0 -0
  7. package/__fixtures__/-1.typescript/src/settings.ts +592 -0
  8. package/__fixtures__/-1.typescript/tsconfig.json +8 -0
  9. package/__fixtures__/-2.react.basic/1.flat-interface.output.json +114 -0
  10. package/__fixtures__/-2.react.basic/2.file-connect-interface.output.json +60 -0
  11. package/__fixtures__/-2.react.basic/2a.file-connect-interface-advanced.output.json +92 -0
  12. package/__fixtures__/-2.react.basic/3.props-as-variants.output.json +166 -0
  13. package/__fixtures__/-2.react.basic/4.outside-interface.output.json +60 -0
  14. package/__fixtures__/-2.react.basic/5.inline-props.output.json +60 -0
  15. package/__fixtures__/-2.react.basic/5.outside-inline-props.output.json +60 -0
  16. package/__fixtures__/-2.react.basic/5a.inline-props+outside.output.json +60 -0
  17. package/__fixtures__/-2.react.basic/5b.inline-props+interfaces.output.json +92 -0
  18. package/__fixtures__/-2.react.basic/package.json +4 -0
  19. package/__fixtures__/-2.react.basic/src/1.flat-interface.tsx +41 -0
  20. package/__fixtures__/-2.react.basic/src/2.file-connect-interface.tsx +28 -0
  21. package/__fixtures__/-2.react.basic/src/2a.file-connect-interace+advanced.tsx +54 -0
  22. package/__fixtures__/-2.react.basic/src/3.props-as-variants.tsx +67 -0
  23. package/__fixtures__/-2.react.basic/src/4.outside-interface.tsx +13 -0
  24. package/__fixtures__/-2.react.basic/src/4.outside-interface2.ts +15 -0
  25. package/__fixtures__/-2.react.basic/src/5.inline-props.tsx +19 -0
  26. package/__fixtures__/-2.react.basic/src/5a.inline-props+outside.tsx +19 -0
  27. package/__fixtures__/-2.react.basic/src/5b.inline-props+interfaces.tsx +62 -0
  28. package/__fixtures__/-2.react.basic/src/index.ts +0 -0
  29. package/__fixtures__/-2.react.basic/tsconfig.json +8 -0
  30. package/__tests__/sourcesToUniform.test.ts +167 -0
  31. package/__tests__/testResolvePropertySymbol.ts +838 -0
  32. package/__tests__/types.ts +12 -0
  33. package/__tests__/utils.ts +108 -0
  34. package/dist/index.cjs +0 -645
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +1 -82
  37. package/dist/index.d.ts +1 -82
  38. package/dist/index.js +0 -611
  39. package/dist/index.js.map +1 -1
  40. package/dist/react.cjs +237 -0
  41. package/dist/react.cjs.map +1 -0
  42. package/dist/react.d.cts +6 -0
  43. package/dist/react.d.ts +6 -0
  44. package/dist/react.js +212 -0
  45. package/dist/react.js.map +1 -0
  46. package/dist/ts.cjs +1794 -0
  47. package/dist/ts.cjs.map +1 -0
  48. package/dist/ts.d.cts +14 -0
  49. package/dist/ts.d.ts +14 -0
  50. package/dist/ts.js +1760 -0
  51. package/dist/ts.js.map +1 -0
  52. package/package.json +23 -4
  53. package/packages/react/index.ts +1 -0
  54. package/packages/react/uniformToReactUniform.ts +275 -0
  55. package/{src → packages/ts}/SignatureText.ts +26 -7
  56. package/packages/ts/TypeDocTransformer.ts +1519 -0
  57. package/packages/ts/__fixtures__/packages2/package-a/package.json +4 -0
  58. package/packages/ts/__fixtures__/packages2/package-a/src/index.ts +496 -0
  59. package/packages/ts/__fixtures__/packages2/package-a/tsconfig.json +6 -0
  60. package/packages/ts/__fixtures__/packages3/package-a/package.json +4 -0
  61. package/packages/ts/__fixtures__/packages3/package-a/src/index.ts +488 -0
  62. package/packages/ts/__fixtures__/packages3/package-a/tsconfig.json +6 -0
  63. package/packages/ts/__fixtures__/packages3/project.json +171 -0
  64. package/packages/ts/__fixtures__/react/react-a/package.json +5 -0
  65. package/packages/ts/__fixtures__/react/react-a/src/TestAbc.tsx +90 -0
  66. package/packages/ts/__fixtures__/react/react-a/src/TestBasic.tsx +27 -0
  67. package/packages/ts/__fixtures__/react/react-a/src/TestNamedParameters.tsx +27 -0
  68. package/packages/ts/__fixtures__/react/react-a/src/TestNamedParameters2.tsx +26 -0
  69. package/packages/ts/__fixtures__/react/react-a/src/TestUnion.tsx +32 -0
  70. package/packages/ts/__fixtures__/react/react-a/src/index.ts +1 -0
  71. package/packages/ts/__fixtures__/react/react-a/tsconfig.json +8 -0
  72. package/packages/ts/__fixtures__/references-output-project.json +344 -0
  73. package/packages/ts/__fixtures__/references-output-react.json +68 -0
  74. package/packages/ts/__fixtures__/references-output.json +129 -0
  75. package/packages/ts/__tests__/sourcesToUniform.test.ts +106 -0
  76. package/packages/ts/context.ts +0 -0
  77. package/packages/ts/converterts/ts-class.ts +0 -0
  78. package/packages/ts/converterts/ts-enum.ts +0 -0
  79. package/packages/ts/converterts/ts-function.ts +0 -0
  80. package/packages/ts/converterts/ts-interface.ts +0 -0
  81. package/packages/ts/converterts/ts-type.ts +0 -0
  82. package/packages/ts/index.ts +129 -0
  83. package/packages/ts/ts-core.ts +0 -0
  84. package/packages/ts/uniformToMiniUniform.ts +486 -0
  85. package/src/index.ts +0 -45
  86. package/tsconfig.json +9 -1
  87. package/tsup.config.ts +4 -4
  88. package/vitest.config.ts +34 -0
  89. package/dist/example.cjs +0 -642
  90. package/dist/example.cjs.map +0 -1
  91. package/dist/example.d.cts +0 -2
  92. package/dist/example.d.ts +0 -2
  93. package/dist/example.js +0 -618
  94. package/dist/example.js.map +0 -1
  95. package/docs/README.md +0 -20
  96. package/docs/classes/ExampleClass.md +0 -35
  97. package/docs/functions/gqlSchemaToReferences.md +0 -27
  98. package/docs/functions/helloWorld.md +0 -17
  99. package/docs/functions/helloWorldV2.md +0 -33
  100. package/docs/functions/helloWorldV3.md +0 -35
  101. package/docs.json +0 -551
  102. package/references_todo.json +0 -220
  103. package/src/TypeDocTransformer.ts +0 -572
  104. /package/{example → packages/ts/__fixtures__/packages}/package-a/package.json +0 -0
  105. /package/{example → packages/ts/__fixtures__/packages}/package-a/src/index.ts +0 -0
  106. /package/{example → packages/ts/__fixtures__/packages}/package-a/tsconfig.json +0 -0
  107. /package/{example → packages/ts/__fixtures__/packages}/package-b/package.json +0 -0
  108. /package/{example → packages/ts/__fixtures__/packages}/package-b/src/billing.ts +0 -0
  109. /package/{example → packages/ts/__fixtures__/packages}/package-b/src/index.ts +0 -0
  110. /package/{example → packages/ts/__fixtures__/packages}/package-b/tsconfig.json +0 -0
@@ -0,0 +1,12 @@
1
+ export interface Test {
2
+ id: string
3
+ file: string;
4
+ description: string;
5
+ react?: boolean;
6
+ miniUniformRoot?: string;
7
+ entryPoints?: string[];
8
+ forceSave?: boolean;
9
+ saveUniform?: boolean;
10
+ saveTypedoc?: boolean;
11
+ multiOutput?: boolean;
12
+ }
@@ -0,0 +1,108 @@
1
+ import * as path from "node:path";
2
+ import * as fs from "node:fs";
3
+
4
+ import {expect} from "vitest";
5
+
6
+ import type {Test} from "./types";
7
+ import {sourcesToUniformV2, uniformToMiniUniform} from "../packages/ts";
8
+ import {Reference, TypeDocReferenceContext} from "@xyd-js/uniform";
9
+ import {uniformToReactUniform} from "../packages/react";
10
+
11
+ // Helper function to run a test with a specific fixture
12
+ export async function testSourcesToUniform(test: Test) {
13
+ const {
14
+ id: fixtureName,
15
+ file: fixtureFile,
16
+ } = test;
17
+ const fixtureRoot = fullFixturePath(fixtureFile);
18
+
19
+ const resp = await sourcesToUniformV2(fixtureRoot,
20
+ test.entryPoints || [],
21
+ );
22
+ if (!resp || !resp.references || !resp.projectJson) {
23
+ throw new Error("Failed to generate documentation.")
24
+ }
25
+
26
+ if (resp.projectJson && test.saveTypedoc) {
27
+ const typedocOutputPath = fullFixturePath(path.join(fixtureFile, `${fixtureName}.output.typedoc.json`));
28
+ fs.writeFileSync(typedocOutputPath, JSON.stringify(resp.projectJson, null, 2));
29
+ }
30
+
31
+ let result: Reference[]
32
+ {
33
+ const references = resp.references as Reference<TypeDocReferenceContext>[]
34
+ const referencesCopy = JSON.parse(JSON.stringify(references));
35
+ if (test.react) {
36
+ const reactUniform = uniformToReactUniform(references, resp.projectJson)
37
+ result = reactUniform;
38
+ } else if (test.miniUniformRoot) {
39
+ const miniUniform = uniformToMiniUniform(test.miniUniformRoot, references)
40
+ result = miniUniform;
41
+ } else {
42
+ result = resp.references;
43
+ }
44
+
45
+ if (test.saveUniform) {
46
+ saveResultAsOutput(fixtureFile, fixtureName, referencesCopy, test.multiOutput || false, true);
47
+ }
48
+ }
49
+
50
+ if (test.forceSave) {
51
+ saveResultAsOutput(fixtureFile, fixtureName, result, test.multiOutput || false);
52
+ }
53
+
54
+ const expectedOutput = readFixtureOutput(fixtureFile, fixtureName, test.multiOutput || false);
55
+
56
+ try {
57
+ expect(result).toEqual(expectedOutput);
58
+ } catch (error) {
59
+ if (result?.length > 100) {
60
+ throw new Error(`FAILED: The diff result is too long (${result.length} items) to show.`);
61
+ }
62
+ throw error;
63
+ }
64
+ }
65
+
66
+ // Helper function to read fixture output
67
+ function readFixtureOutput(
68
+ fixtureBasePath: string,
69
+ fixtureName: string,
70
+ multiOutput: boolean,
71
+ ) {
72
+ const name = outputName(fixtureName, multiOutput, false);
73
+ const fixturePath = fullFixturePath(path.join(fixtureBasePath, name));
74
+
75
+ return JSON.parse(fs.readFileSync(fixturePath, "utf8"));
76
+ }
77
+
78
+ function fullFixturePath(name: string) {
79
+ return path.join(__dirname, "../__fixtures__", name);
80
+ }
81
+
82
+ function saveResultAsOutput(fixtureBasePath: string, fixtureName: string, result: any, multiOutput: boolean, uniform?: boolean) {
83
+ const name = outputName(fixtureName, multiOutput, uniform);
84
+ const fixturePath = fullFixturePath(path.join(fixtureBasePath, name));
85
+
86
+ fs.writeFileSync(fixturePath, JSON.stringify(result, null, 2));
87
+ }
88
+
89
+ function outputName(
90
+ fixtureName: string,
91
+ multiOutput: boolean,
92
+ uniform?: boolean,
93
+ ) {
94
+ let name = "";
95
+ if (multiOutput) {
96
+ name = `${fixtureName}.output.json`;
97
+ if (uniform) {
98
+ name = `${fixtureName}.output.uniform.json`;
99
+ }
100
+ } else {
101
+ name = name || "output.json";
102
+ if (uniform) {
103
+ name = "output.uniform.json";
104
+ }
105
+ }
106
+
107
+ return name;
108
+ }