@teambit/semantics.entities.semantic-schema 0.0.10 → 0.0.13
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/api-schema.ts +18 -22
- package/dist/api-schema.d.ts +6 -19
- package/dist/api-schema.js +22 -12
- package/dist/api-schema.js.map +1 -1
- package/dist/{schemas/export.d.ts → export.d.ts} +5 -10
- package/dist/{schemas/export.js → export.js} +4 -5
- package/dist/export.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/schema-node.d.ts +9 -8
- package/dist/schema-node.js +16 -0
- package/dist/schema-node.js.map +1 -1
- package/dist/schema-obj-to-class.d.ts +10 -0
- package/dist/schema-obj-to-class.js +56 -0
- package/dist/schema-obj-to-class.js.map +1 -0
- package/dist/schemas/class.d.ts +2 -9
- package/dist/schemas/class.js +15 -9
- package/dist/schemas/class.js.map +1 -1
- package/dist/schemas/constructor.d.ts +4 -15
- package/dist/schemas/constructor.js +16 -8
- package/dist/schemas/constructor.js.map +1 -1
- package/dist/schemas/enum.d.ts +8 -0
- package/dist/schemas/enum.js +21 -0
- package/dist/schemas/enum.js.map +1 -1
- package/dist/schemas/function-like.d.ts +10 -18
- package/dist/schemas/function-like.js +30 -20
- package/dist/schemas/function-like.js.map +1 -1
- package/dist/schemas/get-accessor.d.ts +7 -14
- package/dist/schemas/get-accessor.js +17 -11
- package/dist/schemas/get-accessor.js.map +1 -1
- package/dist/schemas/index-signature.d.ts +6 -12
- package/dist/schemas/index-signature.js +19 -9
- package/dist/schemas/index-signature.js.map +1 -1
- package/dist/schemas/index.d.ts +4 -1
- package/dist/schemas/index.js +9 -3
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/indexed-access-type.d.ts +8 -0
- package/dist/schemas/indexed-access-type.js +31 -0
- package/dist/schemas/indexed-access-type.js.map +1 -0
- package/dist/schemas/inference-type.d.ts +6 -8
- package/dist/schemas/inference-type.js +9 -8
- package/dist/schemas/inference-type.js.map +1 -1
- package/dist/schemas/interface.d.ts +6 -12
- package/dist/schemas/interface.js +16 -9
- package/dist/schemas/interface.js.map +1 -1
- package/dist/schemas/keyword-type.d.ts +4 -7
- package/dist/schemas/keyword-type.js +5 -8
- package/dist/schemas/keyword-type.js.map +1 -1
- package/dist/schemas/literal-type.d.ts +5 -4
- package/dist/schemas/literal-type.js +5 -2
- package/dist/schemas/literal-type.js.map +1 -1
- package/dist/schemas/module.d.ts +5 -8
- package/dist/schemas/module.js +16 -6
- package/dist/schemas/module.js.map +1 -1
- package/dist/schemas/parameter.d.ts +5 -13
- package/dist/schemas/parameter.js +17 -12
- package/dist/schemas/parameter.js.map +1 -1
- package/dist/schemas/parenthesized-type.d.ts +11 -0
- package/dist/schemas/parenthesized-type.js +31 -0
- package/dist/schemas/parenthesized-type.js.map +1 -0
- package/dist/schemas/set-accessor.d.ts +7 -12
- package/dist/schemas/set-accessor.js +17 -11
- package/dist/schemas/set-accessor.js.map +1 -1
- package/dist/schemas/tuple-type.d.ts +5 -10
- package/dist/schemas/tuple-type.js +16 -8
- package/dist/schemas/tuple-type.js.map +1 -1
- package/dist/schemas/type-array.d.ts +5 -10
- package/dist/schemas/type-array.js +16 -8
- package/dist/schemas/type-array.js.map +1 -1
- package/dist/schemas/type-intersection.d.ts +5 -10
- package/dist/schemas/type-intersection.js +16 -8
- package/dist/schemas/type-intersection.js.map +1 -1
- package/dist/schemas/type-literal.d.ts +5 -10
- package/dist/schemas/type-literal.js +16 -8
- package/dist/schemas/type-literal.js.map +1 -1
- package/dist/schemas/type-operator.d.ts +6 -12
- package/dist/schemas/type-operator.js +16 -9
- package/dist/schemas/type-operator.js.map +1 -1
- package/dist/schemas/type-predicate.d.ts +22 -0
- package/dist/schemas/type-predicate.js +44 -0
- package/dist/schemas/type-predicate.js.map +1 -0
- package/dist/schemas/type-query.d.ts +6 -10
- package/dist/schemas/type-query.js +17 -10
- package/dist/schemas/type-query.js.map +1 -1
- package/dist/schemas/type-ref.d.ts +15 -10
- package/dist/schemas/type-ref.js +34 -16
- package/dist/schemas/type-ref.js.map +1 -1
- package/dist/schemas/type-union.d.ts +5 -10
- package/dist/schemas/type-union.js +16 -8
- package/dist/schemas/type-union.js.map +1 -1
- package/dist/schemas/type.d.ts +7 -14
- package/dist/schemas/type.js +17 -11
- package/dist/schemas/type.js.map +1 -1
- package/dist/schemas/variable.d.ts +9 -14
- package/dist/schemas/variable.js +19 -13
- package/dist/schemas/variable.js.map +1 -1
- package/{schemas/export.ts → export.ts} +5 -8
- package/index.ts +5 -2
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.13.tgz +0 -0
- package/package.json +6 -3
- package/{preview-1652757984397.js → preview-1653449228788.js} +1 -1
- package/schema-node.ts +13 -6
- package/schema-obj-to-class.ts +36 -0
- package/schemas/class.ts +8 -9
- package/schemas/constructor.ts +10 -10
- package/schemas/enum.ts +13 -0
- package/schemas/function-like.ts +36 -23
- package/schemas/get-accessor.ts +10 -12
- package/schemas/index-signature.ts +13 -9
- package/schemas/index.ts +4 -1
- package/schemas/indexed-access-type.ts +18 -0
- package/schemas/inference-type.ts +7 -9
- package/schemas/interface.ts +10 -9
- package/schemas/keyword-type.ts +4 -9
- package/schemas/literal-type.ts +5 -3
- package/schemas/module.ts +9 -7
- package/schemas/parameter.ts +12 -13
- package/schemas/parenthesized-type.ts +20 -0
- package/schemas/set-accessor.ts +10 -12
- package/schemas/tuple-type.ts +10 -8
- package/schemas/type-array.ts +10 -8
- package/schemas/type-intersection.ts +10 -8
- package/schemas/type-literal.ts +10 -8
- package/schemas/type-operator.ts +10 -9
- package/schemas/type-predicate.ts +36 -0
- package/schemas/type-query.ts +10 -11
- package/schemas/type-ref.ts +39 -20
- package/schemas/type-union.ts +9 -8
- package/schemas/type.ts +10 -10
- package/schemas/variable.ts +12 -14
- package/tsconfig.json +1 -0
- package/dist/schemas/export.js.map +0 -1
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.10.tgz +0 -0
package/schemas/type-ref.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
1
2
|
import { ComponentID } from '@teambit/component';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
|
-
import { SchemaNode } from '../schema-node';
|
|
4
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
5
|
+
import { schemaObjArrayToInstances } from '../schema-obj-to-class';
|
|
4
6
|
|
|
5
7
|
export type PlainTypeRefSchema = {
|
|
6
8
|
name: string;
|
|
@@ -8,8 +10,21 @@ export type PlainTypeRefSchema = {
|
|
|
8
10
|
packageName?: string;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* can be one of the following:
|
|
15
|
+
* 1. a reference to another "export" in the same component
|
|
16
|
+
* 2. a reference to another component.
|
|
17
|
+
* 3. a reference to a package.
|
|
18
|
+
*/
|
|
19
|
+
export class TypeRefSchema extends SchemaNode {
|
|
20
|
+
@Transform(schemaObjArrayToInstances)
|
|
21
|
+
/**
|
|
22
|
+
* optional type arguments, e.g. type Foo = Bar<X, Y>. The X and Y are type arguments.
|
|
23
|
+
*/
|
|
24
|
+
typeArgs?: SchemaNode[];
|
|
25
|
+
|
|
12
26
|
constructor(
|
|
27
|
+
readonly location: Location,
|
|
13
28
|
/**
|
|
14
29
|
* name of the reference to type.
|
|
15
30
|
*/
|
|
@@ -24,23 +39,27 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
24
39
|
* target package name. existing if type is defined in different package.
|
|
25
40
|
*/
|
|
26
41
|
readonly packageName?: string
|
|
27
|
-
) {
|
|
28
|
-
|
|
29
|
-
toObject() {
|
|
30
|
-
return {
|
|
31
|
-
constructorName: this.constructor.name,
|
|
32
|
-
name: this.name,
|
|
33
|
-
componentId: this.componentId,
|
|
34
|
-
packageName: this.packageName,
|
|
35
|
-
};
|
|
42
|
+
) {
|
|
43
|
+
super();
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
toString() {
|
|
47
|
+
const name = this.nameToString();
|
|
48
|
+
if (!this.typeArgs) {
|
|
49
|
+
return name;
|
|
50
|
+
}
|
|
51
|
+
const args = this.typeArgs.map((arg) => arg.toString()).join(', ');
|
|
52
|
+
return `${name}<${args}>`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private nameToString() {
|
|
39
56
|
if (this.componentId) {
|
|
40
|
-
|
|
57
|
+
const compStr = chalk.dim(`(component: ${this.componentId.toStringWithoutVersion()})`);
|
|
58
|
+
return `${compStr} ${this.name}`;
|
|
41
59
|
}
|
|
42
60
|
if (this.packageName) {
|
|
43
|
-
|
|
61
|
+
const pkgStr = chalk.dim(`(package: ${this.packageName})`);
|
|
62
|
+
return `${pkgStr} ${this.name}`;
|
|
44
63
|
}
|
|
45
64
|
return this.name;
|
|
46
65
|
}
|
|
@@ -52,11 +71,11 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
52
71
|
return !this.componentId && !this.packageName;
|
|
53
72
|
}
|
|
54
73
|
|
|
55
|
-
static from(plainSchema: PlainTypeRefSchema) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
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
|
+
// }
|
|
62
81
|
}
|
package/schemas/type-union.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
2
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
3
|
+
import { schemaObjArrayToInstances } from '../schema-obj-to-class';
|
|
2
4
|
|
|
3
|
-
export class TypeUnionSchema
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
5
|
+
export class TypeUnionSchema extends SchemaNode {
|
|
6
|
+
@Transform(schemaObjArrayToInstances)
|
|
7
|
+
readonly types: SchemaNode[];
|
|
8
|
+
constructor(readonly location: Location, types: SchemaNode[]) {
|
|
9
|
+
super();
|
|
10
|
+
this.types = types;
|
|
10
11
|
}
|
|
11
12
|
toString() {
|
|
12
13
|
return `${this.types.map((type) => type.toString()).join(' | ')}`;
|
package/schemas/type.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
1
2
|
import chalk from 'chalk';
|
|
2
|
-
import { SchemaNode } from '../schema-node';
|
|
3
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
4
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
3
5
|
|
|
4
|
-
export class TypeSchema
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type: this.type.toObject(),
|
|
11
|
-
signature: this.signature,
|
|
12
|
-
};
|
|
6
|
+
export class TypeSchema extends SchemaNode {
|
|
7
|
+
@Transform(schemaObjToInstance)
|
|
8
|
+
readonly type: SchemaNode;
|
|
9
|
+
constructor(readonly location: Location, readonly name: string, type: SchemaNode, readonly signature: string) {
|
|
10
|
+
super();
|
|
11
|
+
this.type = type;
|
|
13
12
|
}
|
|
13
|
+
|
|
14
14
|
toString() {
|
|
15
15
|
return `${chalk.bold(this.name)}: ${this.type.toString()}`;
|
|
16
16
|
}
|
package/schemas/variable.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
1
2
|
import chalk from 'chalk';
|
|
2
|
-
import { SchemaNode } from '../schema-node';
|
|
3
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
4
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
name: this.name,
|
|
14
|
-
signature: this.signature,
|
|
15
|
-
type: this.type.toObject(),
|
|
16
|
-
};
|
|
6
|
+
/**
|
|
7
|
+
* can be also a property.
|
|
8
|
+
*/
|
|
9
|
+
export class VariableSchema extends SchemaNode {
|
|
10
|
+
@Transform(schemaObjToInstance)
|
|
11
|
+
type: SchemaNode;
|
|
12
|
+
constructor(readonly location: Location, readonly name: string, readonly signature: string, type: SchemaNode) {
|
|
13
|
+
super();
|
|
14
|
+
this.type = type;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
toString() {
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../schemas/export.ts"],"names":[],"mappings":";;;AAKA,MAAa,MAAM;IACjB;IACE;;OAEG;IACM,UAAkB;IAE3B;;OAEG;IACM,KAAoB;IAE7B;;;;;;OAMG;IACM,gBAAmC;QAdnC,eAAU,GAAV,UAAU,CAAQ;QAKlB,UAAK,GAAL,KAAK,CAAe;QASpB,qBAAgB,GAAhB,gBAAgB,CAAmB;IAC3C,CAAC;IAEJ,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF;AA5BD,wBA4BC"}
|
|
Binary file
|