@teambit/semantics.entities.semantic-schema 0.0.70 → 0.0.71

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 (195) hide show
  1. package/api-schema.ts +49 -1
  2. package/dist/api-schema.d.ts +7 -44
  3. package/dist/api-schema.js +36 -1
  4. package/dist/api-schema.js.map +1 -1
  5. package/dist/{preview-1719137078208.js → preview-1726715976656.js} +1 -1
  6. package/dist/schema-node.d.ts +12 -2
  7. package/dist/schema-node.js.map +1 -1
  8. package/dist/schemas/array-literal-expression.d.ts +3 -0
  9. package/dist/schemas/array-literal-expression.js +4 -0
  10. package/dist/schemas/array-literal-expression.js.map +1 -1
  11. package/dist/schemas/class.d.ts +6 -1
  12. package/dist/schemas/class.js +41 -4
  13. package/dist/schemas/class.js.map +1 -1
  14. package/dist/schemas/conditional-type.d.ts +3 -0
  15. package/dist/schemas/conditional-type.js +7 -0
  16. package/dist/schemas/conditional-type.js.map +1 -1
  17. package/dist/schemas/decorator.d.ts +3 -0
  18. package/dist/schemas/decorator.js +10 -1
  19. package/dist/schemas/decorator.js.map +1 -1
  20. package/dist/schemas/docs/doc.d.ts +1 -0
  21. package/dist/schemas/docs/doc.js +15 -0
  22. package/dist/schemas/docs/doc.js.map +1 -1
  23. package/dist/schemas/docs/property-like-tag.d.ts +3 -0
  24. package/dist/schemas/docs/property-like-tag.js +5 -0
  25. package/dist/schemas/docs/property-like-tag.js.map +1 -1
  26. package/dist/schemas/docs/return-tag.d.ts +3 -0
  27. package/dist/schemas/docs/return-tag.js +5 -0
  28. package/dist/schemas/docs/return-tag.js.map +1 -1
  29. package/dist/schemas/docs/tag.d.ts +1 -0
  30. package/dist/schemas/docs/tag.js +3 -0
  31. package/dist/schemas/docs/tag.js.map +1 -1
  32. package/dist/schemas/enum-member.d.ts +3 -0
  33. package/dist/schemas/enum-member.js +13 -0
  34. package/dist/schemas/enum-member.js.map +1 -1
  35. package/dist/schemas/enum.d.ts +4 -1
  36. package/dist/schemas/enum.js +20 -3
  37. package/dist/schemas/enum.js.map +1 -1
  38. package/dist/schemas/export.d.ts +7 -1
  39. package/dist/schemas/export.js +31 -4
  40. package/dist/schemas/export.js.map +1 -1
  41. package/dist/schemas/expression-with-arguments.d.ts +3 -0
  42. package/dist/schemas/expression-with-arguments.js +8 -0
  43. package/dist/schemas/expression-with-arguments.js.map +1 -1
  44. package/dist/schemas/function-like.d.ts +6 -1
  45. package/dist/schemas/function-like.js +35 -2
  46. package/dist/schemas/function-like.js.map +1 -1
  47. package/dist/schemas/get-accessor.d.ts +6 -1
  48. package/dist/schemas/get-accessor.js +11 -2
  49. package/dist/schemas/get-accessor.js.map +1 -1
  50. package/dist/schemas/ignored.d.ts +1 -0
  51. package/dist/schemas/ignored.js +3 -0
  52. package/dist/schemas/ignored.js.map +1 -1
  53. package/dist/schemas/index-signature.d.ts +3 -0
  54. package/dist/schemas/index-signature.js +5 -0
  55. package/dist/schemas/index-signature.js.map +1 -1
  56. package/dist/schemas/indexed-access-type.d.ts +3 -0
  57. package/dist/schemas/indexed-access-type.js +5 -0
  58. package/dist/schemas/indexed-access-type.js.map +1 -1
  59. package/dist/schemas/inference-type.d.ts +1 -0
  60. package/dist/schemas/inference-type.js +11 -0
  61. package/dist/schemas/inference-type.js.map +1 -1
  62. package/dist/schemas/interface.d.ts +6 -1
  63. package/dist/schemas/interface.js +31 -3
  64. package/dist/schemas/interface.js.map +1 -1
  65. package/dist/schemas/keyword-type.d.ts +1 -0
  66. package/dist/schemas/keyword-type.js +3 -0
  67. package/dist/schemas/keyword-type.js.map +1 -1
  68. package/dist/schemas/literal-type.d.ts +1 -0
  69. package/dist/schemas/literal-type.js +3 -0
  70. package/dist/schemas/literal-type.js.map +1 -1
  71. package/dist/schemas/literal-value.d.ts +1 -0
  72. package/dist/schemas/literal-value.js +3 -0
  73. package/dist/schemas/literal-value.js.map +1 -1
  74. package/dist/schemas/module.d.ts +10 -27
  75. package/dist/schemas/module.js +15 -3
  76. package/dist/schemas/module.js.map +1 -1
  77. package/dist/schemas/named-tuple.d.ts +6 -1
  78. package/dist/schemas/named-tuple.js +5 -2
  79. package/dist/schemas/named-tuple.js.map +1 -1
  80. package/dist/schemas/object-literal-expression.d.ts +6 -1
  81. package/dist/schemas/object-literal-expression.js +9 -2
  82. package/dist/schemas/object-literal-expression.js.map +1 -1
  83. package/dist/schemas/parameter.d.ts +3 -0
  84. package/dist/schemas/parameter.js +31 -0
  85. package/dist/schemas/parameter.js.map +1 -1
  86. package/dist/schemas/parenthesized-type.d.ts +6 -1
  87. package/dist/schemas/parenthesized-type.js +5 -2
  88. package/dist/schemas/parenthesized-type.js.map +1 -1
  89. package/dist/schemas/property-assignment.d.ts +6 -1
  90. package/dist/schemas/property-assignment.js +11 -2
  91. package/dist/schemas/property-assignment.js.map +1 -1
  92. package/dist/schemas/set-accessor.d.ts +3 -0
  93. package/dist/schemas/set-accessor.js +4 -0
  94. package/dist/schemas/set-accessor.js.map +1 -1
  95. package/dist/schemas/template-literal-type-span.d.ts +6 -1
  96. package/dist/schemas/template-literal-type-span.js +5 -2
  97. package/dist/schemas/template-literal-type-span.js.map +1 -1
  98. package/dist/schemas/template-literal-type.d.ts +6 -1
  99. package/dist/schemas/template-literal-type.js +6 -2
  100. package/dist/schemas/template-literal-type.js.map +1 -1
  101. package/dist/schemas/this-type.d.ts +1 -0
  102. package/dist/schemas/this-type.js +3 -0
  103. package/dist/schemas/this-type.js.map +1 -1
  104. package/dist/schemas/tuple-type.d.ts +6 -1
  105. package/dist/schemas/tuple-type.js +5 -2
  106. package/dist/schemas/tuple-type.js.map +1 -1
  107. package/dist/schemas/type-array.d.ts +6 -1
  108. package/dist/schemas/type-array.js +5 -2
  109. package/dist/schemas/type-array.js.map +1 -1
  110. package/dist/schemas/type-intersection.d.ts +6 -1
  111. package/dist/schemas/type-intersection.js +5 -2
  112. package/dist/schemas/type-intersection.js.map +1 -1
  113. package/dist/schemas/type-literal.d.ts +3 -0
  114. package/dist/schemas/type-literal.js +14 -0
  115. package/dist/schemas/type-literal.js.map +1 -1
  116. package/dist/schemas/type-operator.d.ts +6 -1
  117. package/dist/schemas/type-operator.js +5 -2
  118. package/dist/schemas/type-operator.js.map +1 -1
  119. package/dist/schemas/type-predicate.d.ts +6 -1
  120. package/dist/schemas/type-predicate.js +12 -2
  121. package/dist/schemas/type-predicate.js.map +1 -1
  122. package/dist/schemas/type-query.d.ts +6 -1
  123. package/dist/schemas/type-query.js +5 -2
  124. package/dist/schemas/type-query.js.map +1 -1
  125. package/dist/schemas/type-ref.d.ts +6 -1
  126. package/dist/schemas/type-ref.js +19 -6
  127. package/dist/schemas/type-ref.js.map +1 -1
  128. package/dist/schemas/type-union.d.ts +6 -1
  129. package/dist/schemas/type-union.js +11 -2
  130. package/dist/schemas/type-union.js.map +1 -1
  131. package/dist/schemas/type.d.ts +6 -1
  132. package/dist/schemas/type.js +12 -2
  133. package/dist/schemas/type.js.map +1 -1
  134. package/dist/schemas/unimplemented-schema.d.ts +1 -0
  135. package/dist/schemas/unimplemented-schema.js +3 -0
  136. package/dist/schemas/unimplemented-schema.js.map +1 -1
  137. package/dist/schemas/unknown-schema.d.ts +1 -0
  138. package/dist/schemas/unknown-schema.js +3 -0
  139. package/dist/schemas/unknown-schema.js.map +1 -1
  140. package/dist/schemas/unresolved-schema.d.ts +1 -0
  141. package/dist/schemas/unresolved-schema.js +3 -0
  142. package/dist/schemas/unresolved-schema.js.map +1 -1
  143. package/dist/schemas/variable-like.d.ts +6 -1
  144. package/dist/schemas/variable-like.js +16 -2
  145. package/dist/schemas/variable-like.js.map +1 -1
  146. package/package.json +2 -2
  147. package/schema-node.ts +4 -2
  148. package/schemas/array-literal-expression.ts +5 -0
  149. package/schemas/class.ts +52 -4
  150. package/schemas/conditional-type.ts +9 -0
  151. package/schemas/decorator.ts +14 -1
  152. package/schemas/docs/doc.ts +20 -0
  153. package/schemas/docs/property-like-tag.ts +6 -0
  154. package/schemas/docs/return-tag.ts +6 -0
  155. package/schemas/docs/tag.ts +4 -0
  156. package/schemas/enum-member.ts +16 -0
  157. package/schemas/enum.ts +27 -3
  158. package/schemas/export.ts +42 -4
  159. package/schemas/expression-with-arguments.ts +11 -0
  160. package/schemas/function-like.ts +37 -4
  161. package/schemas/get-accessor.ts +15 -2
  162. package/schemas/ignored.ts +4 -0
  163. package/schemas/index-signature.ts +7 -0
  164. package/schemas/indexed-access-type.ts +7 -0
  165. package/schemas/inference-type.ts +16 -0
  166. package/schemas/interface.ts +41 -3
  167. package/schemas/keyword-type.ts +4 -0
  168. package/schemas/literal-type.ts +4 -0
  169. package/schemas/literal-value.ts +4 -0
  170. package/schemas/module.ts +25 -5
  171. package/schemas/named-tuple.ts +6 -2
  172. package/schemas/object-literal-expression.ts +11 -2
  173. package/schemas/parameter.ts +40 -0
  174. package/schemas/parenthesized-type.ts +6 -2
  175. package/schemas/property-assignment.ts +16 -2
  176. package/schemas/set-accessor.ts +5 -0
  177. package/schemas/template-literal-type-span.ts +6 -2
  178. package/schemas/template-literal-type.ts +7 -2
  179. package/schemas/this-type.ts +4 -0
  180. package/schemas/tuple-type.ts +6 -2
  181. package/schemas/type-array.ts +6 -2
  182. package/schemas/type-intersection.ts +6 -2
  183. package/schemas/type-literal.ts +22 -0
  184. package/schemas/type-operator.ts +6 -2
  185. package/schemas/type-predicate.ts +15 -2
  186. package/schemas/type-query.ts +6 -2
  187. package/schemas/type-ref.ts +23 -6
  188. package/schemas/type-union.ts +13 -2
  189. package/schemas/type.ts +16 -2
  190. package/schemas/unimplemented-schema.ts +4 -0
  191. package/schemas/unknown-schema.ts +4 -0
  192. package/schemas/unresolved-schema.ts +4 -0
  193. package/schemas/variable-like.ts +20 -2
  194. package/dist/tsconfig.json +0 -37
  195. package/tsconfig.json +0 -37
@@ -13,8 +13,12 @@ export class TypeIntersectionSchema extends SchemaNode {
13
13
  return this.types;
14
14
  }
15
15
 
16
- toString() {
17
- return `${this.types.map((type) => type.toString()).join(' & ')}`;
16
+ toString(options?: { color?: boolean }) {
17
+ return `${this.types.map((type) => type.toString(options)).join(' & ')}`;
18
+ }
19
+
20
+ toFullSignature(options?: { showDocs?: boolean }): string {
21
+ return this.types.map((type) => type.toFullSignature(options)).join(' & ');
18
22
  }
19
23
 
20
24
  toObject() {
@@ -20,6 +20,28 @@ export class TypeLiteralSchema extends SchemaNode {
20
20
  return `{ ${this.members.map((type) => type.toString()).join('; ')} }`;
21
21
  }
22
22
 
23
+ toFullSignature(options?: { showDocs?: boolean }): string {
24
+ const indent = (level: number) => ' '.repeat(level);
25
+ const level = 0;
26
+ let signature = '';
27
+
28
+ signature += '{\n';
29
+
30
+ this.members.forEach((member) => {
31
+ const memberSignature = member.toFullSignature(options);
32
+
33
+ const memberLines = memberSignature.split('\n');
34
+
35
+ const indentedLines = memberLines.map((line) => indent(level + 1) + line);
36
+
37
+ signature += indentedLines.join('\n') + '\n';
38
+ });
39
+
40
+ signature += indent(level) + '}';
41
+
42
+ return signature;
43
+ }
44
+
23
45
  toObject() {
24
46
  return {
25
47
  ...super.toObject(),
@@ -12,8 +12,12 @@ export class TypeOperatorSchema extends SchemaNode {
12
12
  return [this.type];
13
13
  }
14
14
 
15
- toString() {
16
- return `${this.name} ${this.type.toString()}`;
15
+ toString(options?: { color?: boolean }) {
16
+ return `${this.name} ${this.type.toString(options)}`;
17
+ }
18
+
19
+ toFullSignature(options?: { showDocs?: boolean }): string {
20
+ return `${this.name} ${this.type.toFullSignature(options)}`;
17
21
  }
18
22
 
19
23
  toObject() {
@@ -26,12 +26,25 @@ export class TypePredicateSchema extends SchemaNode {
26
26
  this.type = type;
27
27
  }
28
28
 
29
- toString() {
29
+ toString(options?: { color?: boolean }) {
30
30
  const assertsKeyword = this.hasAssertsModifier ? 'asserts ' : '';
31
- const typeStr = this.type ? ` is ${this.type.toString()}` : '';
31
+ const typeStr = this.type ? ` is ${this.type.toString(options)}` : '';
32
32
  return assertsKeyword + this.name + typeStr;
33
33
  }
34
34
 
35
+ toFullSignature(options?: { showDocs?: boolean }): string {
36
+ const assertsKeyword = this.hasAssertsModifier ? 'asserts ' : '';
37
+ const typeSignature = this.type ? ` is ${this.type.toFullSignature(options)}` : '';
38
+ let signature = `${assertsKeyword}${this.name}${typeSignature}`;
39
+
40
+ if (options?.showDocs && this.doc) {
41
+ const docString = this.doc.toFullSignature();
42
+ signature = `${docString}\n${signature}`;
43
+ }
44
+
45
+ return signature;
46
+ }
47
+
35
48
  toObject() {
36
49
  return {
37
50
  ...super.toObject(),
@@ -20,8 +20,12 @@ export class TypeQuerySchema extends SchemaNode {
20
20
  return this.signature;
21
21
  }
22
22
 
23
- toString() {
24
- return `typeof ${this.type.toString()}`;
23
+ toString(options?: { color?: boolean }) {
24
+ return `typeof ${this.type.toString(options)}`;
25
+ }
26
+
27
+ toFullSignature(options?: { showDocs?: boolean }): string {
28
+ return `typeof ${this.type.toFullSignature(options)}`;
25
29
  }
26
30
 
27
31
  toObject() {
@@ -52,27 +52,44 @@ export class TypeRefSchema extends SchemaNode {
52
52
  return this;
53
53
  }
54
54
 
55
- toString() {
56
- const name = this.nameToString();
55
+ toString(options?: { color?: boolean }) {
56
+ const name = this.nameToString(options);
57
57
  if (!this.typeArgs) {
58
58
  return name;
59
59
  }
60
- const args = this.typeArgs.map((arg) => arg.toString()).join(', ');
60
+ const args = this.typeArgs.map((arg) => arg.toString(options)).join(', ');
61
61
  return `${name}<${args}>`;
62
62
  }
63
63
 
64
- private nameToString() {
64
+ private nameToString(options?: { color?: boolean }) {
65
+ const dim = options?.color ? chalk.dim : (str: string) => str;
65
66
  if (this.componentId) {
66
- const compStr = chalk.dim(`(component: ${this.componentId.toStringWithoutVersion()})`);
67
+ const compStr = dim(`(component: ${this.componentId.toStringWithoutVersion()})`);
67
68
  return `${compStr} ${this.name}`;
68
69
  }
69
70
  if (this.packageName) {
70
- const pkgStr = chalk.dim(`(package: ${this.packageName})`);
71
+ const pkgStr = dim(`(package: ${this.packageName})`);
71
72
  return `${pkgStr} ${this.name}`;
72
73
  }
73
74
  return this.name;
74
75
  }
75
76
 
77
+ toFullSignature(options?: { showDocs?: boolean }): string {
78
+ let signature = this.name;
79
+
80
+ if (this.typeArgs && this.typeArgs.length > 0) {
81
+ const argsSignatures = this.typeArgs.map((arg) => arg.toFullSignature(options)).join(', ');
82
+ signature += `<${argsSignatures}>`;
83
+ }
84
+
85
+ if (options?.showDocs && this.doc) {
86
+ const docString = this.doc.toFullSignature();
87
+ signature = `${docString}\n${signature}`;
88
+ }
89
+
90
+ return signature;
91
+ }
92
+
76
93
  /**
77
94
  * whether this type was already exported in this component
78
95
  */
@@ -7,8 +7,19 @@ export class TypeUnionSchema extends SchemaNode {
7
7
  super();
8
8
  this.types = types;
9
9
  }
10
- toString() {
11
- return `${this.types.map((type) => type.toString()).join(' | ')}`;
10
+ toString(options?: { color?: boolean }) {
11
+ return `${this.types.map((type) => type.toString(options)).join(' | ')}`;
12
+ }
13
+ toFullSignature(options?: { showDocs?: boolean }): string {
14
+ const typeSignatures = this.types.map((type) => type.toFullSignature(options));
15
+ let signature = typeSignatures.join(' | ');
16
+
17
+ if (options?.showDocs && this.doc) {
18
+ const docString = this.doc.toFullSignature();
19
+ signature = `${docString}\n${signature}`;
20
+ }
21
+
22
+ return signature;
12
23
  }
13
24
  getNodes() {
14
25
  return this.types;
package/schemas/type.ts CHANGED
@@ -19,8 +19,22 @@ export class TypeSchema extends SchemaNode {
19
19
  this.doc = doc;
20
20
  }
21
21
 
22
- toString() {
23
- return `${chalk.bold(this.name)}: ${this.type.toString()}`;
22
+ toString(options?: { color?: boolean }) {
23
+ const bold = options?.color ? chalk.bold : (str: string) => str;
24
+ return `${bold(this.name)}: ${this.type.toString(options)}`;
25
+ }
26
+
27
+ toFullSignature(options?: { showDocs?: boolean }): string {
28
+ const typeSignature = this.type.toFullSignature(options);
29
+
30
+ let signature = `${this.name}: ${typeSignature}`;
31
+
32
+ if (options?.showDocs && this.doc) {
33
+ const docString = this.doc.toFullSignature();
34
+ signature = `${docString}\n${signature}`;
35
+ }
36
+
37
+ return signature;
24
38
  }
25
39
 
26
40
  getNodes() {
@@ -9,6 +9,10 @@ export class UnImplementedSchema extends SchemaNode {
9
9
  return `<<unimplemented schema ${this.name} of type ${this.type}>>`;
10
10
  }
11
11
 
12
+ toFullSignature(): string {
13
+ return `<<unimplemented schema ${this.name} of type ${this.type}>>`;
14
+ }
15
+
12
16
  toObject() {
13
17
  return {
14
18
  ...super.toObject(),
@@ -14,6 +14,10 @@ export class UnknownSchema extends SchemaNode {
14
14
  return `<<unknown schema ${this.name}>>`;
15
15
  }
16
16
 
17
+ toFullSignature(): string {
18
+ return this.toString();
19
+ }
20
+
17
21
  toObject() {
18
22
  return {
19
23
  ...super.toObject(),
@@ -13,6 +13,10 @@ export class UnresolvedSchema extends SchemaNode {
13
13
  return this.name;
14
14
  }
15
15
 
16
+ toFullSignature(): string {
17
+ return this.toString();
18
+ }
19
+
16
20
  toObject() {
17
21
  return super.toObject();
18
22
  }
@@ -28,8 +28,26 @@ export class VariableLikeSchema extends SchemaNode {
28
28
  return [this.type];
29
29
  }
30
30
 
31
- toString() {
32
- return `${chalk.bold(this.name)}${this.isOptional ? '?' : ''}: ${this.type.toString()}`;
31
+ toString(options?: { color?: boolean }) {
32
+ const bold = options?.color ? chalk.bold : (str: string) => str;
33
+ return `${bold(this.name)}${this.isOptional ? '?' : ''}: ${this.type.toString(options)}`;
34
+ }
35
+
36
+ toFullSignature(options?: { showDocs?: boolean }): string {
37
+ const namePart = `${this.name}${this.isOptional ? '?' : ''}`;
38
+ const typeSignature = this.type.toFullSignature(options);
39
+ let signature = `${namePart}: ${typeSignature}`;
40
+
41
+ if (this.defaultValue !== undefined) {
42
+ signature += ` = ${this.defaultValue}`;
43
+ }
44
+
45
+ if (options?.showDocs && this.doc) {
46
+ const docString = this.doc.toFullSignature();
47
+ signature = `${docString}\n${signature}`;
48
+ }
49
+
50
+ return signature;
33
51
  }
34
52
 
35
53
  toObject() {
@@ -1,37 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable"
8
- ],
9
- "target": "es2015",
10
- "module": "CommonJS",
11
- "jsx": "react",
12
- "allowJs": true,
13
- "composite": true,
14
- "declaration": true,
15
- "sourceMap": true,
16
- "skipLibCheck": true,
17
- "experimentalDecorators": true,
18
- "outDir": "dist",
19
- "moduleResolution": "node",
20
- "esModuleInterop": true,
21
- "rootDir": ".",
22
- "resolveJsonModule": true
23
- },
24
- "exclude": [
25
- "artifacts",
26
- "public",
27
- "dist",
28
- "node_modules",
29
- "package.json",
30
- "**/*.cjs"
31
- ],
32
- "include": [
33
- "**/*",
34
- "**/*.json"
35
- ],
36
- "references": []
37
- }
package/tsconfig.json DELETED
@@ -1,37 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable"
8
- ],
9
- "target": "es2015",
10
- "module": "CommonJS",
11
- "jsx": "react",
12
- "allowJs": true,
13
- "composite": true,
14
- "declaration": true,
15
- "sourceMap": true,
16
- "skipLibCheck": true,
17
- "experimentalDecorators": true,
18
- "outDir": "dist",
19
- "moduleResolution": "node",
20
- "esModuleInterop": true,
21
- "rootDir": ".",
22
- "resolveJsonModule": true
23
- },
24
- "exclude": [
25
- "artifacts",
26
- "public",
27
- "dist",
28
- "node_modules",
29
- "package.json",
30
- "**/*.cjs"
31
- ],
32
- "include": [
33
- "**/*",
34
- "**/*.json"
35
- ],
36
- "references": []
37
- }