@teambit/semantics.entities.semantic-schema 0.0.13 → 0.0.16

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 (137) hide show
  1. package/api-schema.ts +13 -3
  2. package/class-transformers/comp-id-transformer.ts +22 -0
  3. package/class-transformers/index.ts +2 -0
  4. package/{schema-obj-to-class.ts → class-transformers/schema-obj-to-class.ts} +12 -3
  5. package/dist/api-schema.d.ts +3 -1
  6. package/dist/api-schema.js +13 -5
  7. package/dist/api-schema.js.map +1 -1
  8. package/dist/class-transformers/comp-id-transformer.d.ts +6 -0
  9. package/dist/class-transformers/comp-id-transformer.js +20 -0
  10. package/dist/class-transformers/comp-id-transformer.js.map +1 -0
  11. package/dist/class-transformers/index.d.ts +2 -0
  12. package/dist/class-transformers/index.js +9 -0
  13. package/dist/class-transformers/index.js.map +1 -0
  14. package/dist/{schema-obj-to-class.d.ts → class-transformers/schema-obj-to-class.d.ts} +3 -3
  15. package/dist/{schema-obj-to-class.js → class-transformers/schema-obj-to-class.js} +5 -2
  16. package/dist/class-transformers/schema-obj-to-class.js.map +1 -0
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.js +14 -28
  19. package/dist/index.js.map +1 -1
  20. package/dist/schema-node.d.ts +2 -0
  21. package/dist/schema-node.js.map +1 -1
  22. package/dist/schemas/class.d.ts +3 -1
  23. package/dist/schemas/class.js +7 -3
  24. package/dist/schemas/class.js.map +1 -1
  25. package/dist/schemas/constructor.js +2 -2
  26. package/dist/schemas/constructor.js.map +1 -1
  27. package/dist/schemas/docs/doc.d.ts +11 -0
  28. package/dist/schemas/docs/doc.js +37 -0
  29. package/dist/schemas/docs/doc.js.map +1 -0
  30. package/dist/schemas/docs/index.d.ts +3 -0
  31. package/dist/schemas/docs/index.js +10 -0
  32. package/dist/schemas/docs/index.js.map +1 -0
  33. package/dist/schemas/docs/return-tag.d.ts +13 -0
  34. package/dist/schemas/docs/return-tag.js +22 -0
  35. package/dist/schemas/docs/return-tag.js.map +1 -0
  36. package/dist/schemas/docs/tag.d.ts +33 -0
  37. package/dist/schemas/docs/tag.js +44 -0
  38. package/dist/schemas/docs/tag.js.map +1 -0
  39. package/dist/schemas/function-like.d.ts +5 -2
  40. package/dist/schemas/function-like.js +17 -7
  41. package/dist/schemas/function-like.js.map +1 -1
  42. package/dist/schemas/get-accessor.js +2 -2
  43. package/dist/schemas/get-accessor.js.map +1 -1
  44. package/dist/schemas/index-signature.js +3 -3
  45. package/dist/schemas/index-signature.js.map +1 -1
  46. package/dist/schemas/index.d.ts +4 -0
  47. package/dist/schemas/index.js +18 -1
  48. package/dist/schemas/index.js.map +1 -1
  49. package/dist/schemas/indexed-access-type.js +3 -3
  50. package/dist/schemas/indexed-access-type.js.map +1 -1
  51. package/dist/schemas/interface.js +2 -2
  52. package/dist/schemas/interface.js.map +1 -1
  53. package/dist/schemas/keyword-type.d.ts +1 -1
  54. package/dist/schemas/keyword-type.js.map +1 -1
  55. package/dist/schemas/module.js +2 -2
  56. package/dist/schemas/module.js.map +1 -1
  57. package/dist/schemas/parameter.js +2 -2
  58. package/dist/schemas/parameter.js.map +1 -1
  59. package/dist/schemas/parenthesized-type.js +2 -2
  60. package/dist/schemas/parenthesized-type.js.map +1 -1
  61. package/dist/schemas/set-accessor.js +2 -2
  62. package/dist/schemas/set-accessor.js.map +1 -1
  63. package/dist/schemas/template-literal-type-span.d.ts +8 -0
  64. package/dist/schemas/template-literal-type-span.js +28 -0
  65. package/dist/schemas/template-literal-type-span.js.map +1 -0
  66. package/dist/schemas/template-literal-type.d.ts +9 -0
  67. package/dist/schemas/template-literal-type.js +29 -0
  68. package/dist/schemas/template-literal-type.js.map +1 -0
  69. package/dist/schemas/this-type.d.ts +9 -0
  70. package/dist/schemas/this-type.js +18 -0
  71. package/dist/schemas/this-type.js.map +1 -0
  72. package/dist/schemas/tuple-type.js +2 -2
  73. package/dist/schemas/tuple-type.js.map +1 -1
  74. package/dist/schemas/type-array.js +2 -2
  75. package/dist/schemas/type-array.js.map +1 -1
  76. package/dist/schemas/type-intersection.js +2 -2
  77. package/dist/schemas/type-intersection.js.map +1 -1
  78. package/dist/schemas/type-literal.js +2 -2
  79. package/dist/schemas/type-literal.js.map +1 -1
  80. package/dist/schemas/type-operator.js +2 -2
  81. package/dist/schemas/type-operator.js.map +1 -1
  82. package/dist/schemas/type-predicate.js +2 -2
  83. package/dist/schemas/type-predicate.js.map +1 -1
  84. package/dist/schemas/type-query.js +2 -2
  85. package/dist/schemas/type-query.js.map +1 -1
  86. package/dist/schemas/type-ref.d.ts +1 -4
  87. package/dist/schemas/type-ref.js +7 -3
  88. package/dist/schemas/type-ref.js.map +1 -1
  89. package/dist/schemas/type-union.js +2 -2
  90. package/dist/schemas/type-union.js.map +1 -1
  91. package/dist/schemas/type.js +2 -2
  92. package/dist/schemas/type.js.map +1 -1
  93. package/dist/schemas/variable.d.ts +1 -1
  94. package/dist/schemas/variable.js +3 -3
  95. package/dist/schemas/variable.js.map +1 -1
  96. package/index.ts +2 -30
  97. package/package-tar/teambit-semantics.entities.semantic-schema-0.0.16.tgz +0 -0
  98. package/package.json +4 -5
  99. package/{preview-1653449228788.js → preview-1653708349111.js} +1 -1
  100. package/schema-node.ts +2 -0
  101. package/schemas/class.ts +8 -2
  102. package/schemas/constructor.ts +1 -1
  103. package/schemas/docs/doc.ts +27 -0
  104. package/schemas/docs/index.ts +3 -0
  105. package/schemas/docs/return-tag.ts +21 -0
  106. package/schemas/docs/tag.ts +38 -0
  107. package/schemas/function-like.ts +17 -6
  108. package/schemas/get-accessor.ts +1 -1
  109. package/schemas/index-signature.ts +1 -1
  110. package/schemas/index.ts +4 -0
  111. package/schemas/indexed-access-type.ts +1 -1
  112. package/schemas/interface.ts +1 -1
  113. package/schemas/keyword-type.ts +1 -1
  114. package/schemas/module.ts +1 -1
  115. package/schemas/parameter.ts +1 -1
  116. package/schemas/parenthesized-type.ts +1 -1
  117. package/schemas/set-accessor.ts +1 -1
  118. package/schemas/template-literal-type-span.ts +16 -0
  119. package/schemas/template-literal-type.ts +18 -0
  120. package/schemas/this-type.ts +14 -0
  121. package/schemas/tuple-type.ts +1 -1
  122. package/schemas/type-array.ts +1 -1
  123. package/schemas/type-intersection.ts +1 -1
  124. package/schemas/type-literal.ts +1 -1
  125. package/schemas/type-operator.ts +1 -1
  126. package/schemas/type-predicate.ts +1 -1
  127. package/schemas/type-query.ts +1 -1
  128. package/schemas/type-ref.ts +7 -10
  129. package/schemas/type-union.ts +1 -1
  130. package/schemas/type.ts +1 -1
  131. package/schemas/variable.ts +2 -2
  132. package/dist/json-schema.d.ts +0 -1
  133. package/dist/json-schema.js +0 -3
  134. package/dist/json-schema.js.map +0 -1
  135. package/dist/schema-obj-to-class.js.map +0 -1
  136. package/json-schema.ts +0 -1
  137. package/package-tar/teambit-semantics.entities.semantic-schema-0.0.13.tgz +0 -0
@@ -0,0 +1,16 @@
1
+ import { Transform } from 'class-transformer';
2
+ import { Location, SchemaNode } from '../schema-node';
3
+ import { schemaObjToInstance } from '../class-transformers';
4
+
5
+ export class TemplateLiteralTypeSpanSchema extends SchemaNode {
6
+ @Transform(schemaObjToInstance)
7
+ type: SchemaNode;
8
+ constructor(readonly location: Location, readonly literal: string, type: SchemaNode) {
9
+ super();
10
+ this.type = type;
11
+ }
12
+
13
+ toString() {
14
+ return `${this.type.toString()} ${this.literal}`;
15
+ }
16
+ }
@@ -0,0 +1,18 @@
1
+ import { Transform } from 'class-transformer';
2
+ import { Location, SchemaNode } from '../schema-node';
3
+ import { schemaObjArrayToInstances } from '../class-transformers';
4
+ import { TemplateLiteralTypeSpanSchema } from './template-literal-type-span';
5
+
6
+ export class TemplateLiteralTypeSchema extends SchemaNode {
7
+ @Transform(schemaObjArrayToInstances)
8
+ readonly templateSpans: TemplateLiteralTypeSpanSchema[];
9
+ constructor(readonly location: Location, readonly head: string, templateSpans: TemplateLiteralTypeSpanSchema[]) {
10
+ super();
11
+ this.templateSpans = templateSpans;
12
+ }
13
+
14
+ toString() {
15
+ const spans = this.templateSpans.map((span) => span.toString()).join('');
16
+ return `${this.head}${spans}`;
17
+ }
18
+ }
@@ -0,0 +1,14 @@
1
+ import { Location, SchemaNode } from '../schema-node';
2
+
3
+ /**
4
+ * e.g. `class A { createA(): this {} }`
5
+ */
6
+ export class ThisTypeSchema extends SchemaNode {
7
+ constructor(readonly location: Location) {
8
+ super();
9
+ }
10
+
11
+ toString() {
12
+ return 'this';
13
+ }
14
+ }
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjArrayToInstances } from '../schema-obj-to-class';
3
+ import { schemaObjArrayToInstances } from '../class-transformers';
4
4
 
5
5
  export class TupleTypeSchema extends SchemaNode {
6
6
  @Transform(schemaObjArrayToInstances)
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjToInstance } from '../schema-obj-to-class';
3
+ import { schemaObjToInstance } from '../class-transformers';
4
4
 
5
5
  export class TypeArraySchema extends SchemaNode {
6
6
  @Transform(schemaObjToInstance)
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjArrayToInstances } from '../schema-obj-to-class';
3
+ import { schemaObjArrayToInstances } from '../class-transformers';
4
4
 
5
5
  export class TypeIntersectionSchema extends SchemaNode {
6
6
  @Transform(schemaObjArrayToInstances)
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjArrayToInstances } from '../schema-obj-to-class';
3
+ import { schemaObjArrayToInstances } from '../class-transformers';
4
4
 
5
5
  /**
6
6
  * e.g. `{ a: string; b: number }`
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjToInstance } from '../schema-obj-to-class';
3
+ import { schemaObjToInstance } from '../class-transformers';
4
4
 
5
5
  export class TypeOperatorSchema extends SchemaNode {
6
6
  @Transform(schemaObjToInstance)
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjToInstance } from '../schema-obj-to-class';
3
+ import { schemaObjToInstance } from '../class-transformers';
4
4
 
5
5
  /**
6
6
  * e.g. `function f(str: any): str is string {}`
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjToInstance } from '../schema-obj-to-class';
3
+ import { schemaObjToInstance } from '../class-transformers';
4
4
 
5
5
  /**
6
6
  * e.g. `typeof Foo`
@@ -2,7 +2,8 @@ import { Transform } from 'class-transformer';
2
2
  import { ComponentID } from '@teambit/component';
3
3
  import chalk from 'chalk';
4
4
  import { Location, SchemaNode } from '../schema-node';
5
- import { schemaObjArrayToInstances } from '../schema-obj-to-class';
5
+ import { schemaObjArrayToInstances } from '../class-transformers';
6
+ import { componentIdTransformer } from '../class-transformers/comp-id-transformer';
6
7
 
7
8
  export type PlainTypeRefSchema = {
8
9
  name: string;
@@ -23,6 +24,9 @@ export class TypeRefSchema extends SchemaNode {
23
24
  */
24
25
  typeArgs?: SchemaNode[];
25
26
 
27
+ @Transform(componentIdTransformer)
28
+ readonly componentId?: ComponentID;
29
+
26
30
  constructor(
27
31
  readonly location: Location,
28
32
  /**
@@ -33,7 +37,7 @@ export class TypeRefSchema extends SchemaNode {
33
37
  /**
34
38
  * target component id. existing if the type is defined in another component.
35
39
  */
36
- readonly componentId?: ComponentID,
40
+ componentId?: ComponentID,
37
41
 
38
42
  /**
39
43
  * target package name. existing if type is defined in different package.
@@ -41,6 +45,7 @@ export class TypeRefSchema extends SchemaNode {
41
45
  readonly packageName?: string
42
46
  ) {
43
47
  super();
48
+ this.componentId = componentId;
44
49
  }
45
50
 
46
51
  toString() {
@@ -70,12 +75,4 @@ export class TypeRefSchema extends SchemaNode {
70
75
  isFromThisComponent() {
71
76
  return !this.componentId && !this.packageName;
72
77
  }
73
-
74
- // static from(plainSchema: PlainTypeRefSchema) {
75
- // return new TypeRefSchema(
76
- // plainSchema.name,
77
- // plainSchema.componentId ? ComponentID.fromString(plainSchema.componentId) : undefined,
78
- // plainSchema.packageName
79
- // );
80
- // }
81
78
  }
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import { Location, SchemaNode } from '../schema-node';
3
- import { schemaObjArrayToInstances } from '../schema-obj-to-class';
3
+ import { schemaObjArrayToInstances } from '../class-transformers';
4
4
 
5
5
  export class TypeUnionSchema extends SchemaNode {
6
6
  @Transform(schemaObjArrayToInstances)
package/schemas/type.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import chalk from 'chalk';
3
3
  import { Location, SchemaNode } from '../schema-node';
4
- import { schemaObjToInstance } from '../schema-obj-to-class';
4
+ import { schemaObjToInstance } from '../class-transformers';
5
5
 
6
6
  export class TypeSchema extends SchemaNode {
7
7
  @Transform(schemaObjToInstance)
@@ -1,10 +1,10 @@
1
1
  import { Transform } from 'class-transformer';
2
2
  import chalk from 'chalk';
3
3
  import { Location, SchemaNode } from '../schema-node';
4
- import { schemaObjToInstance } from '../schema-obj-to-class';
4
+ import { schemaObjToInstance } from '../class-transformers';
5
5
 
6
6
  /**
7
- * can be also a property.
7
+ * can be also a property or property-signature
8
8
  */
9
9
  export class VariableSchema extends SchemaNode {
10
10
  @Transform(schemaObjToInstance)
@@ -1 +0,0 @@
1
- export { JSONSchema7 as JSONSchema, JSONSchema7Object as JSONSchemaObject } from 'json-schema';
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=json-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../json-schema.ts"],"names":[],"mappings":""}
@@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