@teambit/semantics.entities.semantic-schema 0.0.10 → 0.0.11
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 +16 -29
- package/dist/api-schema.d.ts +6 -19
- package/dist/api-schema.js +20 -11
- 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 +2 -1
- 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/function-like.d.ts +5 -17
- package/dist/schemas/function-like.js +22 -18
- 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 +0 -1
- package/dist/schemas/index.js +1 -3
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/inference-type.d.ts +5 -8
- package/dist/schemas/inference-type.js +5 -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/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-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 +4 -10
- package/dist/schemas/type-ref.js +5 -14
- 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 +6 -14
- package/dist/schemas/variable.js +16 -13
- package/dist/schemas/variable.js.map +1 -1
- package/{schemas/export.ts → export.ts} +5 -8
- package/index.ts +1 -2
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.11.tgz +0 -0
- package/package.json +6 -3
- package/{preview-1652757984397.js → preview-1652930732694.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/function-like.ts +17 -20
- package/schemas/get-accessor.ts +10 -12
- package/schemas/index-signature.ts +13 -9
- package/schemas/index.ts +0 -1
- package/schemas/inference-type.ts +4 -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/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-query.ts +10 -11
- package/schemas/type-ref.ts +12 -18
- package/schemas/type-union.ts +9 -8
- package/schemas/type.ts +10 -10
- package/schemas/variable.ts +9 -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
|
@@ -1,13 +1,15 @@
|
|
|
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 TypeIntersectionSchema
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
5
|
+
export class TypeIntersectionSchema extends SchemaNode {
|
|
6
|
+
@Transform(schemaObjArrayToInstances)
|
|
7
|
+
readonly types: SchemaNode[];
|
|
8
|
+
constructor(readonly location: Location, types: SchemaNode[]) {
|
|
9
|
+
super();
|
|
10
|
+
this.types = types;
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
toString() {
|
|
12
14
|
return `${this.types.map((type) => type.toString()).join(' & ')}`;
|
|
13
15
|
}
|
package/schemas/type-literal.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
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
5
|
/**
|
|
4
6
|
* e.g. `{ a: string; b: number }`
|
|
5
7
|
*/
|
|
6
|
-
export class TypeLiteralSchema
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
8
|
+
export class TypeLiteralSchema extends SchemaNode {
|
|
9
|
+
@Transform(schemaObjArrayToInstances)
|
|
10
|
+
readonly members: SchemaNode[];
|
|
11
|
+
constructor(readonly location: Location, members: SchemaNode[]) {
|
|
12
|
+
super();
|
|
13
|
+
this.members = members;
|
|
13
14
|
}
|
|
15
|
+
|
|
14
16
|
toString() {
|
|
15
17
|
return `{ ${this.members.map((type) => type.toString()).join('; ')} }`;
|
|
16
18
|
}
|
package/schemas/type-operator.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
2
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
3
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
2
4
|
|
|
3
|
-
export class TypeOperatorSchema
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type: this.type.toObject(),
|
|
10
|
-
};
|
|
5
|
+
export class TypeOperatorSchema extends SchemaNode {
|
|
6
|
+
@Transform(schemaObjToInstance)
|
|
7
|
+
type: SchemaNode;
|
|
8
|
+
constructor(readonly location: Location, readonly operatorName: string, type: SchemaNode) {
|
|
9
|
+
super();
|
|
10
|
+
this.type = type;
|
|
11
11
|
}
|
|
12
|
+
|
|
12
13
|
toString() {
|
|
13
14
|
return `${this.operatorName} ${this.type.toString()}`;
|
|
14
15
|
}
|
package/schemas/type-query.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
2
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
3
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* e.g. `typeof Foo`
|
|
5
7
|
*/
|
|
6
|
-
export class TypeQuerySchema
|
|
7
|
-
|
|
8
|
+
export class TypeQuerySchema extends SchemaNode {
|
|
9
|
+
@Transform(schemaObjToInstance)
|
|
10
|
+
readonly type: SchemaNode;
|
|
11
|
+
constructor(readonly location: Location, type: SchemaNode, readonly signature: string) {
|
|
12
|
+
super();
|
|
13
|
+
this.type = type;
|
|
14
|
+
}
|
|
8
15
|
getSignature() {
|
|
9
16
|
return this.signature;
|
|
10
17
|
}
|
|
11
18
|
|
|
12
|
-
toObject() {
|
|
13
|
-
return {
|
|
14
|
-
constructorName: this.constructor.name,
|
|
15
|
-
type: this.type,
|
|
16
|
-
signature: this.signature,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
19
|
toString() {
|
|
21
20
|
return `typeof ${this.type.toString()}`;
|
|
22
21
|
}
|
package/schemas/type-ref.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentID } from '@teambit/component';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { SchemaNode } from '../schema-node';
|
|
3
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
4
4
|
|
|
5
5
|
export type PlainTypeRefSchema = {
|
|
6
6
|
name: string;
|
|
@@ -8,8 +8,9 @@ export type PlainTypeRefSchema = {
|
|
|
8
8
|
packageName?: string;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export class TypeRefSchema
|
|
11
|
+
export class TypeRefSchema extends SchemaNode {
|
|
12
12
|
constructor(
|
|
13
|
+
readonly location: Location,
|
|
13
14
|
/**
|
|
14
15
|
* name of the reference to type.
|
|
15
16
|
*/
|
|
@@ -24,15 +25,8 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
24
25
|
* target package name. existing if type is defined in different package.
|
|
25
26
|
*/
|
|
26
27
|
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
|
-
};
|
|
28
|
+
) {
|
|
29
|
+
super();
|
|
36
30
|
}
|
|
37
31
|
|
|
38
32
|
toString() {
|
|
@@ -52,11 +46,11 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
52
46
|
return !this.componentId && !this.packageName;
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
static from(plainSchema: PlainTypeRefSchema) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
49
|
+
// static from(plainSchema: PlainTypeRefSchema) {
|
|
50
|
+
// return new TypeRefSchema(
|
|
51
|
+
// plainSchema.name,
|
|
52
|
+
// plainSchema.componentId ? ComponentID.fromString(plainSchema.componentId) : undefined,
|
|
53
|
+
// plainSchema.packageName
|
|
54
|
+
// );
|
|
55
|
+
// }
|
|
62
56
|
}
|
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,14 @@
|
|
|
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 VariableSchema
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
toObject() {
|
|
11
|
-
return {
|
|
12
|
-
constructorName: this.constructor.name,
|
|
13
|
-
name: this.name,
|
|
14
|
-
signature: this.signature,
|
|
15
|
-
type: this.type.toObject(),
|
|
16
|
-
};
|
|
6
|
+
export class VariableSchema extends SchemaNode {
|
|
7
|
+
@Transform(schemaObjToInstance)
|
|
8
|
+
type: SchemaNode;
|
|
9
|
+
constructor(readonly location: Location, readonly name: string, readonly signature: string, type: SchemaNode) {
|
|
10
|
+
super();
|
|
11
|
+
this.type = type;
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
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
|