@teambit/semantics.entities.semantic-schema 0.0.8 → 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 +17 -22
- package/dist/api-schema.d.ts +6 -19
- package/dist/api-schema.js +21 -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 +3 -2
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/schema-node.d.ts +14 -7
- 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 +4 -10
- package/dist/schemas/class.js +16 -9
- package/dist/schemas/class.js.map +1 -1
- package/dist/schemas/constructor.d.ts +6 -9
- package/dist/schemas/constructor.js +19 -11
- package/dist/schemas/constructor.js.map +1 -1
- package/dist/schemas/function-like.d.ts +14 -0
- package/dist/schemas/function-like.js +45 -0
- package/dist/schemas/function-like.js.map +1 -0
- package/dist/schemas/get-accessor.d.ts +7 -18
- package/dist/schemas/get-accessor.js +17 -11
- package/dist/schemas/get-accessor.js.map +1 -1
- package/dist/schemas/index-signature.d.ts +7 -17
- package/dist/schemas/index-signature.js +22 -12
- package/dist/schemas/index-signature.js.map +1 -1
- package/dist/schemas/index.d.ts +9 -2
- package/dist/schemas/index.js +19 -5
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/inference-type.d.ts +10 -0
- package/dist/schemas/inference-type.js +19 -0
- package/dist/schemas/inference-type.js.map +1 -0
- 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 +10 -0
- package/dist/schemas/keyword-type.js +19 -0
- package/dist/schemas/keyword-type.js.map +1 -0
- package/dist/schemas/literal-type.d.ts +14 -0
- package/dist/schemas/literal-type.js +25 -0
- package/dist/schemas/literal-type.js.map +1 -0
- 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 +10 -0
- package/dist/schemas/parameter.js +30 -0
- package/dist/schemas/parameter.js.map +1 -0
- package/dist/schemas/set-accessor.d.ts +8 -13
- package/dist/schemas/set-accessor.js +18 -12
- package/dist/schemas/set-accessor.js.map +1 -1
- package/dist/schemas/tuple-type.d.ts +7 -0
- package/dist/schemas/tuple-type.js +27 -0
- package/dist/schemas/tuple-type.js.map +1 -0
- package/dist/schemas/type-array.d.ts +7 -0
- package/dist/schemas/type-array.js +27 -0
- package/dist/schemas/type-array.js.map +1 -0
- 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 +8 -0
- package/dist/schemas/type-operator.js +28 -0
- package/dist/schemas/type-operator.js.map +1 -0
- package/dist/schemas/type-query.d.ts +12 -0
- package/dist/schemas/type-query.js +34 -0
- package/dist/schemas/type-query.js.map +1 -0
- package/dist/schemas/type-ref.d.ts +9 -13
- package/dist/schemas/type-ref.js +11 -15
- 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 -18
- 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 +12 -5
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.11.tgz +0 -0
- package/package.json +7 -4
- package/{preview-1652239597845.js → preview-1652930732694.js} +1 -1
- package/schema-node.ts +15 -5
- package/schema-obj-to-class.ts +36 -0
- package/schemas/class.ts +9 -10
- package/schemas/constructor.ts +13 -13
- package/schemas/function-like.ts +40 -0
- package/schemas/get-accessor.ts +10 -13
- package/schemas/index-signature.ts +16 -13
- package/schemas/index.ts +9 -2
- package/schemas/inference-type.ts +14 -0
- package/schemas/interface.ts +10 -9
- package/schemas/keyword-type.ts +14 -0
- package/schemas/literal-type.ts +21 -0
- package/schemas/module.ts +9 -7
- package/schemas/parameter.ts +22 -0
- package/schemas/set-accessor.ts +12 -14
- package/schemas/tuple-type.ts +16 -0
- package/schemas/type-array.ts +16 -0
- package/schemas/type-intersection.ts +10 -8
- package/schemas/type-literal.ts +10 -8
- package/schemas/type-operator.ts +16 -0
- package/schemas/type-query.ts +22 -0
- package/schemas/type-ref.ts +19 -22
- package/schemas/type-union.ts +9 -8
- package/schemas/type.ts +10 -10
- package/schemas/variable.ts +9 -15
- package/tsconfig.json +1 -0
- package/dist/schemas/export.js.map +0 -1
- package/dist/schemas/function.d.ts +0 -31
- package/dist/schemas/function.js +0 -37
- package/dist/schemas/function.js.map +0 -1
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.8.tgz +0 -0
- package/schemas/function.ts +0 -44
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
2
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
3
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
4
|
+
|
|
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
|
+
}
|
|
12
|
+
|
|
13
|
+
toString() {
|
|
14
|
+
return `${this.operatorName} ${this.type.toString()}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
2
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
3
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* e.g. `typeof Foo`
|
|
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
|
+
}
|
|
15
|
+
getSignature() {
|
|
16
|
+
return this.signature;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toString() {
|
|
20
|
+
return `typeof ${this.type.toString()}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/schemas/type-ref.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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;
|
|
7
7
|
componentId?: string;
|
|
8
8
|
packageName?: string;
|
|
9
|
-
node?: SchemaNode;
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
export class TypeRefSchema
|
|
11
|
+
export class TypeRefSchema extends SchemaNode {
|
|
13
12
|
constructor(
|
|
13
|
+
readonly location: Location,
|
|
14
14
|
/**
|
|
15
15
|
* name of the reference to type.
|
|
16
16
|
*/
|
|
@@ -24,18 +24,9 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
24
24
|
/**
|
|
25
25
|
* target package name. existing if type is defined in different package.
|
|
26
26
|
*/
|
|
27
|
-
readonly packageName?: string
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
) {}
|
|
31
|
-
|
|
32
|
-
toObject() {
|
|
33
|
-
return {
|
|
34
|
-
constructorName: this.constructor.name,
|
|
35
|
-
name: this.name,
|
|
36
|
-
componentId: this.componentId,
|
|
37
|
-
packageName: this.packageName,
|
|
38
|
-
};
|
|
27
|
+
readonly packageName?: string
|
|
28
|
+
) {
|
|
29
|
+
super();
|
|
39
30
|
}
|
|
40
31
|
|
|
41
32
|
toString() {
|
|
@@ -48,12 +39,18 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
48
39
|
return this.name;
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
plainSchema.node
|
|
57
|
-
);
|
|
42
|
+
/**
|
|
43
|
+
* whether this type was already exported in this component
|
|
44
|
+
*/
|
|
45
|
+
isFromThisComponent() {
|
|
46
|
+
return !this.componentId && !this.packageName;
|
|
58
47
|
}
|
|
48
|
+
|
|
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
|
+
// }
|
|
59
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,20 +1,14 @@
|
|
|
1
|
+
import { Transform } from 'class-transformer';
|
|
1
2
|
import chalk from 'chalk';
|
|
2
|
-
import { SchemaNode } from '../schema-node';
|
|
3
|
-
import {
|
|
3
|
+
import { Location, SchemaNode } from '../schema-node';
|
|
4
|
+
import { schemaObjToInstance } from '../schema-obj-to-class';
|
|
4
5
|
|
|
5
|
-
export class VariableSchema
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
toObject() {
|
|
12
|
-
return {
|
|
13
|
-
constructorName: this.constructor.name,
|
|
14
|
-
name: this.name,
|
|
15
|
-
signature: this.signature,
|
|
16
|
-
type: this.type.toObject(),
|
|
17
|
-
};
|
|
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;
|
|
18
12
|
}
|
|
19
13
|
|
|
20
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"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SchemaNode } from '../schema-node';
|
|
2
|
-
import { TypeRefSchema } from './type-ref';
|
|
3
|
-
export declare type Parameter = {
|
|
4
|
-
name: string;
|
|
5
|
-
type: TypeRefSchema;
|
|
6
|
-
defaultValue?: any;
|
|
7
|
-
description?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class FunctionSchema implements SchemaNode {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly params: Parameter[];
|
|
12
|
-
readonly returnType: TypeRefSchema;
|
|
13
|
-
private signature;
|
|
14
|
-
constructor(name: string, params: Parameter[], returnType: TypeRefSchema, signature: string);
|
|
15
|
-
serialize(): void;
|
|
16
|
-
toJsonSchema(): void;
|
|
17
|
-
getSignature(): string;
|
|
18
|
-
toObject(): {
|
|
19
|
-
constructorName: string;
|
|
20
|
-
name: string;
|
|
21
|
-
params: Parameter[];
|
|
22
|
-
returnType: {
|
|
23
|
-
constructorName: string;
|
|
24
|
-
name: string;
|
|
25
|
-
componentId: import("@teambit/component").ComponentID;
|
|
26
|
-
packageName: string;
|
|
27
|
-
};
|
|
28
|
-
signature: string;
|
|
29
|
-
};
|
|
30
|
-
toString(): string;
|
|
31
|
-
}
|
package/dist/schemas/function.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FunctionSchema = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
class FunctionSchema {
|
|
9
|
-
constructor(name,
|
|
10
|
-
// readonly doc: any,
|
|
11
|
-
params, returnType, signature) {
|
|
12
|
-
this.name = name;
|
|
13
|
-
this.params = params;
|
|
14
|
-
this.returnType = returnType;
|
|
15
|
-
this.signature = signature;
|
|
16
|
-
}
|
|
17
|
-
serialize() { }
|
|
18
|
-
toJsonSchema() { }
|
|
19
|
-
getSignature() {
|
|
20
|
-
return this.signature;
|
|
21
|
-
}
|
|
22
|
-
toObject() {
|
|
23
|
-
return {
|
|
24
|
-
constructorName: this.constructor.name,
|
|
25
|
-
name: this.name,
|
|
26
|
-
params: this.params,
|
|
27
|
-
returnType: this.returnType.toObject(),
|
|
28
|
-
signature: this.signature,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
toString() {
|
|
32
|
-
const paramsStr = this.params.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
|
|
33
|
-
return `${chalk_1.default.bold(this.name)}(${paramsStr}): ${this.returnType.toString()}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.FunctionSchema = FunctionSchema;
|
|
37
|
-
//# sourceMappingURL=function.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../schemas/function.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAW1B,MAAa,cAAc;IACzB,YACW,IAAY;IACrB,qBAAqB;IACZ,MAAmB,EAEnB,UAAyB,EAC1B,SAAiB;QALhB,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAa;QAEnB,eAAU,GAAV,UAAU,CAAe;QAC1B,cAAS,GAAT,SAAS,CAAQ;IACxB,CAAC;IAEJ,SAAS,KAAI,CAAC;IAEd,YAAY,KAAI,CAAC;IAEjB,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtC,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7F,OAAO,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;IACjF,CAAC;CACF;AAhCD,wCAgCC"}
|
|
Binary file
|
package/schemas/function.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { SchemaNode } from '../schema-node';
|
|
3
|
-
import { TypeRefSchema } from './type-ref';
|
|
4
|
-
|
|
5
|
-
export type Parameter = {
|
|
6
|
-
name: string;
|
|
7
|
-
type: TypeRefSchema;
|
|
8
|
-
defaultValue?: any;
|
|
9
|
-
description?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export class FunctionSchema implements SchemaNode {
|
|
13
|
-
constructor(
|
|
14
|
-
readonly name: string,
|
|
15
|
-
// readonly doc: any,
|
|
16
|
-
readonly params: Parameter[],
|
|
17
|
-
|
|
18
|
-
readonly returnType: TypeRefSchema,
|
|
19
|
-
private signature: string
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
serialize() {}
|
|
23
|
-
|
|
24
|
-
toJsonSchema() {}
|
|
25
|
-
|
|
26
|
-
getSignature() {
|
|
27
|
-
return this.signature;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
toObject() {
|
|
31
|
-
return {
|
|
32
|
-
constructorName: this.constructor.name,
|
|
33
|
-
name: this.name,
|
|
34
|
-
params: this.params,
|
|
35
|
-
returnType: this.returnType.toObject(),
|
|
36
|
-
signature: this.signature,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
toString() {
|
|
41
|
-
const paramsStr = this.params.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
|
|
42
|
-
return `${chalk.bold(this.name)}(${paramsStr}): ${this.returnType.toString()}`;
|
|
43
|
-
}
|
|
44
|
-
}
|