@teambit/semantics.entities.semantic-schema 0.0.7 → 0.0.10
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 +64 -0
- package/dist/api-schema.d.ts +24 -0
- package/dist/api-schema.js +44 -0
- package/dist/api-schema.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/schema-node.d.ts +11 -5
- package/dist/schemas/class.d.ts +15 -0
- package/dist/schemas/class.js +26 -0
- package/dist/schemas/class.js.map +1 -1
- package/dist/schemas/constructor.d.ts +19 -0
- package/dist/schemas/constructor.js +24 -0
- package/dist/schemas/constructor.js.map +1 -0
- package/dist/schemas/export.d.ts +7 -3
- package/dist/schemas/export.js +8 -2
- package/dist/schemas/export.js.map +1 -1
- package/dist/schemas/function-like.d.ts +26 -0
- package/dist/schemas/function-like.js +41 -0
- package/dist/schemas/function-like.js.map +1 -0
- package/dist/schemas/get-accessor.d.ts +17 -0
- package/dist/schemas/get-accessor.js +30 -0
- package/dist/schemas/get-accessor.js.map +1 -0
- package/dist/schemas/index-signature.d.ts +19 -0
- package/dist/schemas/index-signature.js +26 -0
- package/dist/schemas/index-signature.js.map +1 -0
- package/dist/schemas/index.d.ts +20 -1
- package/dist/schemas/index.js +41 -3
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/inference-type.d.ts +13 -0
- package/dist/schemas/inference-type.js +22 -0
- package/dist/schemas/inference-type.js.map +1 -0
- package/dist/schemas/interface.d.ts +14 -0
- package/dist/schemas/interface.js +26 -0
- package/dist/schemas/interface.js.map +1 -0
- package/dist/schemas/keyword-type.d.ts +13 -0
- package/dist/schemas/keyword-type.js +22 -0
- package/dist/schemas/keyword-type.js.map +1 -0
- package/dist/schemas/literal-type.d.ts +13 -0
- package/dist/schemas/literal-type.js +22 -0
- package/dist/schemas/literal-type.js.map +1 -0
- package/dist/schemas/module.d.ts +14 -10
- package/dist/schemas/module.js +33 -5
- package/dist/schemas/module.js.map +1 -1
- package/dist/schemas/parameter.d.ts +18 -0
- package/dist/schemas/parameter.js +25 -0
- package/dist/schemas/parameter.js.map +1 -0
- package/dist/schemas/set-accessor.d.ts +16 -0
- package/dist/schemas/set-accessor.js +30 -0
- package/dist/schemas/set-accessor.js.map +1 -0
- package/dist/schemas/tuple-type.d.ts +12 -0
- package/dist/schemas/tuple-type.js +19 -0
- package/dist/schemas/tuple-type.js.map +1 -0
- package/dist/schemas/type-array.d.ts +12 -0
- package/dist/schemas/type-array.js +19 -0
- package/dist/schemas/type-array.js.map +1 -0
- package/dist/schemas/type-intersection.d.ts +12 -0
- package/dist/schemas/type-intersection.js +19 -0
- package/dist/schemas/type-intersection.js.map +1 -0
- package/dist/schemas/type-literal.d.ts +15 -0
- package/dist/schemas/type-literal.js +22 -0
- package/dist/schemas/type-literal.js.map +1 -0
- package/dist/schemas/type-operator.d.ts +14 -0
- package/dist/schemas/type-operator.js +21 -0
- package/dist/schemas/type-operator.js.map +1 -0
- package/dist/schemas/type-query.d.ts +16 -0
- package/dist/schemas/type-query.js +27 -0
- package/dist/schemas/type-query.js.map +1 -0
- package/dist/schemas/type-ref.d.ts +12 -3
- package/dist/schemas/type-ref.js +29 -3
- package/dist/schemas/type-ref.js.map +1 -1
- package/dist/schemas/type-union.d.ts +12 -0
- package/dist/schemas/type-union.js +19 -0
- package/dist/schemas/type-union.js.map +1 -0
- package/dist/schemas/type.d.ts +16 -0
- package/dist/schemas/type.js +26 -0
- package/dist/schemas/type.js.map +1 -1
- package/dist/schemas/variable.d.ts +17 -0
- package/dist/schemas/variable.js +30 -0
- package/dist/schemas/variable.js.map +1 -0
- package/index.ts +29 -3
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.10.tgz +0 -0
- package/package.json +3 -2
- package/{preview-1650468178717.js → preview-1652757984397.js} +1 -1
- package/schema-node.ts +7 -5
- package/schemas/class.ts +19 -0
- package/schemas/constructor.ts +19 -0
- package/schemas/export.ts +9 -2
- package/schemas/function-like.ts +43 -0
- package/schemas/get-accessor.ts +22 -0
- package/schemas/index-signature.ts +21 -0
- package/schemas/index.ts +20 -1
- package/schemas/inference-type.ts +19 -0
- package/schemas/interface.ts +17 -0
- package/schemas/keyword-type.ts +19 -0
- package/schemas/literal-type.ts +19 -0
- package/schemas/module.ts +36 -7
- package/schemas/parameter.ts +23 -0
- package/schemas/set-accessor.ts +23 -0
- package/schemas/tuple-type.ts +14 -0
- package/schemas/type-array.ts +14 -0
- package/schemas/type-intersection.ts +14 -0
- package/schemas/type-literal.ts +17 -0
- package/schemas/type-operator.ts +15 -0
- package/schemas/type-query.ts +23 -0
- package/schemas/type-ref.ts +29 -6
- package/schemas/type-union.ts +14 -0
- package/schemas/type.ts +17 -0
- package/schemas/variable.ts +22 -0
- package/dist/schemas/function.d.ts +0 -16
- package/dist/schemas/function.js +0 -16
- package/dist/schemas/function.js.map +0 -1
- package/dist/semantic-schema.d.ts +0 -12
- package/dist/semantic-schema.js +0 -17
- package/dist/semantic-schema.js.map +0 -1
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.7.tgz +0 -0
- package/schemas/function.ts +0 -23
- package/semantic-schema.ts +0 -20
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SchemaNode } from '../schema-node';
|
|
2
|
+
|
|
3
|
+
export class TypeArraySchema implements SchemaNode {
|
|
4
|
+
constructor(private type: SchemaNode) {}
|
|
5
|
+
toObject() {
|
|
6
|
+
return {
|
|
7
|
+
constructorName: this.constructor.name,
|
|
8
|
+
type: this.type.toObject(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.type.toString()}[]`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SchemaNode } from '../schema-node';
|
|
2
|
+
|
|
3
|
+
export class TypeIntersectionSchema implements SchemaNode {
|
|
4
|
+
constructor(private types: SchemaNode[]) {}
|
|
5
|
+
toObject() {
|
|
6
|
+
return {
|
|
7
|
+
constructorName: this.constructor.name,
|
|
8
|
+
types: this.types.map((type) => type.toObject()),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.types.map((type) => type.toString()).join(' & ')}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SchemaNode } from '../schema-node';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* e.g. `{ a: string; b: number }`
|
|
5
|
+
*/
|
|
6
|
+
export class TypeLiteralSchema implements SchemaNode {
|
|
7
|
+
constructor(private members: SchemaNode[]) {}
|
|
8
|
+
toObject() {
|
|
9
|
+
return {
|
|
10
|
+
constructorName: this.constructor.name,
|
|
11
|
+
types: this.members.map((type) => type.toObject()),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `{ ${this.members.map((type) => type.toString()).join('; ')} }`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SchemaNode } from '../schema-node';
|
|
2
|
+
|
|
3
|
+
export class TypeOperatorSchema implements SchemaNode {
|
|
4
|
+
constructor(private operatorName: string, private type: SchemaNode) {}
|
|
5
|
+
toObject() {
|
|
6
|
+
return {
|
|
7
|
+
constructorName: this.constructor.name,
|
|
8
|
+
operatorName: this.operatorName,
|
|
9
|
+
type: this.type.toObject(),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return `${this.operatorName} ${this.type.toString()}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SchemaNode } from '../schema-node';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* e.g. `typeof Foo`
|
|
5
|
+
*/
|
|
6
|
+
export class TypeQuerySchema implements SchemaNode {
|
|
7
|
+
constructor(private type: SchemaNode, private signature: string) {}
|
|
8
|
+
getSignature() {
|
|
9
|
+
return this.signature;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
toObject() {
|
|
13
|
+
return {
|
|
14
|
+
constructorName: this.constructor.name,
|
|
15
|
+
type: this.type,
|
|
16
|
+
signature: this.signature,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toString() {
|
|
21
|
+
return `typeof ${this.type.toString()}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/schemas/type-ref.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ComponentID } from '@teambit/component';
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import { SchemaNode } from '../schema-node';
|
|
3
4
|
|
|
4
5
|
export type PlainTypeRefSchema = {
|
|
5
6
|
name: string;
|
|
6
7
|
componentId?: string;
|
|
7
8
|
packageName?: string;
|
|
8
|
-
node?: SchemaNode;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export class TypeRefSchema implements SchemaNode {
|
|
@@ -23,17 +23,40 @@ export class TypeRefSchema implements SchemaNode {
|
|
|
23
23
|
/**
|
|
24
24
|
* target package name. existing if type is defined in different package.
|
|
25
25
|
*/
|
|
26
|
-
readonly packageName?: string
|
|
27
|
-
|
|
28
|
-
readonly node?: SchemaNode
|
|
26
|
+
readonly packageName?: string
|
|
29
27
|
) {}
|
|
30
28
|
|
|
29
|
+
toObject() {
|
|
30
|
+
return {
|
|
31
|
+
constructorName: this.constructor.name,
|
|
32
|
+
name: this.name,
|
|
33
|
+
componentId: this.componentId,
|
|
34
|
+
packageName: this.packageName,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toString() {
|
|
39
|
+
if (this.componentId) {
|
|
40
|
+
return `${this.componentId}/${this.name}`;
|
|
41
|
+
}
|
|
42
|
+
if (this.packageName) {
|
|
43
|
+
return `${chalk.dim(this.packageName)}/${this.name}`;
|
|
44
|
+
}
|
|
45
|
+
return this.name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* whether this type was already exported in this component
|
|
50
|
+
*/
|
|
51
|
+
isFromThisComponent() {
|
|
52
|
+
return !this.componentId && !this.packageName;
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
static from(plainSchema: PlainTypeRefSchema) {
|
|
32
56
|
return new TypeRefSchema(
|
|
33
57
|
plainSchema.name,
|
|
34
58
|
plainSchema.componentId ? ComponentID.fromString(plainSchema.componentId) : undefined,
|
|
35
|
-
plainSchema.packageName
|
|
36
|
-
plainSchema.node
|
|
59
|
+
plainSchema.packageName
|
|
37
60
|
);
|
|
38
61
|
}
|
|
39
62
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SchemaNode } from '../schema-node';
|
|
2
|
+
|
|
3
|
+
export class TypeUnionSchema implements SchemaNode {
|
|
4
|
+
constructor(private types: SchemaNode[]) {}
|
|
5
|
+
toObject() {
|
|
6
|
+
return {
|
|
7
|
+
constructorName: this.constructor.name,
|
|
8
|
+
types: this.types.map((type) => type.toObject()),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.types.map((type) => type.toString()).join(' | ')}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/schemas/type.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { SchemaNode } from '../schema-node';
|
|
3
|
+
|
|
4
|
+
export class TypeSchema implements SchemaNode {
|
|
5
|
+
constructor(private name: string, private type: SchemaNode, private signature: string) {}
|
|
6
|
+
toObject() {
|
|
7
|
+
return {
|
|
8
|
+
constructorName: this.constructor.name,
|
|
9
|
+
name: this.name,
|
|
10
|
+
type: this.type.toObject(),
|
|
11
|
+
signature: this.signature,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `${chalk.bold(this.name)}: ${this.type.toString()}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { SchemaNode } from '../schema-node';
|
|
3
|
+
|
|
4
|
+
export class VariableSchema implements SchemaNode {
|
|
5
|
+
constructor(readonly name: string, private signature: string, private type: SchemaNode) {}
|
|
6
|
+
getSignature() {
|
|
7
|
+
return this.signature;
|
|
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
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toString() {
|
|
20
|
+
return `${chalk.bold(this.name)}: ${this.type.toString()}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SchemaNode } from '../schema-node';
|
|
2
|
-
import { TypeRefSchema } from './type-ref';
|
|
3
|
-
export declare type Argument = {
|
|
4
|
-
name: string;
|
|
5
|
-
defaultValue?: any;
|
|
6
|
-
description: any;
|
|
7
|
-
type: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class FunctionSchema implements SchemaNode {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly args: Argument[];
|
|
12
|
-
readonly returnType: TypeRefSchema;
|
|
13
|
-
constructor(name: string, args: Argument[], returnType: TypeRefSchema);
|
|
14
|
-
serialize(): void;
|
|
15
|
-
toJsonSchema(): void;
|
|
16
|
-
}
|
package/dist/schemas/function.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FunctionSchema = void 0;
|
|
4
|
-
class FunctionSchema {
|
|
5
|
-
constructor(name,
|
|
6
|
-
// readonly doc: any,
|
|
7
|
-
args, returnType) {
|
|
8
|
-
this.name = name;
|
|
9
|
-
this.args = args;
|
|
10
|
-
this.returnType = returnType;
|
|
11
|
-
}
|
|
12
|
-
serialize() { }
|
|
13
|
-
toJsonSchema() { }
|
|
14
|
-
}
|
|
15
|
-
exports.FunctionSchema = FunctionSchema;
|
|
16
|
-
//# sourceMappingURL=function.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../schemas/function.ts"],"names":[],"mappings":";;;AAUA,MAAa,cAAc;IACzB,YACW,IAAY;IACrB,qBAAqB;IACZ,IAAgB,EAEhB,UAAyB;QAJzB,SAAI,GAAJ,IAAI,CAAQ;QAEZ,SAAI,GAAJ,IAAI,CAAY;QAEhB,eAAU,GAAV,UAAU,CAAe;IACjC,CAAC;IAEJ,SAAS,KAAI,CAAC;IAEd,YAAY,KAAI,CAAC;CAClB;AAZD,wCAYC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Export } from './schemas';
|
|
2
|
-
import { SchemaNode } from './schema-node';
|
|
3
|
-
export declare type PlainSemanticSchema = {
|
|
4
|
-
exports?: Export[];
|
|
5
|
-
};
|
|
6
|
-
export declare class SemanticSchema implements SchemaNode {
|
|
7
|
-
readonly exports: Export[];
|
|
8
|
-
constructor(exports?: Export[]);
|
|
9
|
-
toString(): string;
|
|
10
|
-
static fromSchema(): void;
|
|
11
|
-
static from(plainSchema: PlainSemanticSchema): SemanticSchema;
|
|
12
|
-
}
|
package/dist/semantic-schema.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SemanticSchema = void 0;
|
|
4
|
-
class SemanticSchema {
|
|
5
|
-
constructor(exports = []) {
|
|
6
|
-
this.exports = exports;
|
|
7
|
-
}
|
|
8
|
-
toString() {
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
static fromSchema() { }
|
|
12
|
-
static from(plainSchema) {
|
|
13
|
-
return new SemanticSchema(plainSchema.exports);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.SemanticSchema = SemanticSchema;
|
|
17
|
-
//# sourceMappingURL=semantic-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-schema.js","sourceRoot":"","sources":["../semantic-schema.ts"],"names":[],"mappings":";;;AAOA,MAAa,cAAc;IACzB,YAAqB,UAAoB,EAAE;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAE/C,QAAQ;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,CAAC,UAAU,KAAI,CAAC;IAEtB,MAAM,CAAC,IAAI,CAAC,WAAgC;QAC1C,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAZD,wCAYC"}
|
|
Binary file
|
package/schemas/function.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SchemaNode } from '../schema-node';
|
|
2
|
-
import { TypeRefSchema } from './type-ref';
|
|
3
|
-
|
|
4
|
-
export type Argument = {
|
|
5
|
-
name: string;
|
|
6
|
-
defaultValue?: any;
|
|
7
|
-
description: any;
|
|
8
|
-
type: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export class FunctionSchema implements SchemaNode {
|
|
12
|
-
constructor(
|
|
13
|
-
readonly name: string,
|
|
14
|
-
// readonly doc: any,
|
|
15
|
-
readonly args: Argument[],
|
|
16
|
-
|
|
17
|
-
readonly returnType: TypeRefSchema
|
|
18
|
-
) {}
|
|
19
|
-
|
|
20
|
-
serialize() {}
|
|
21
|
-
|
|
22
|
-
toJsonSchema() {}
|
|
23
|
-
}
|
package/semantic-schema.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Export } from './schemas';
|
|
2
|
-
import { SchemaNode } from './schema-node';
|
|
3
|
-
|
|
4
|
-
export type PlainSemanticSchema = {
|
|
5
|
-
exports?: Export[];
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export class SemanticSchema implements SchemaNode {
|
|
9
|
-
constructor(readonly exports: Export[] = []) {}
|
|
10
|
-
|
|
11
|
-
toString() {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static fromSchema() {}
|
|
16
|
-
|
|
17
|
-
static from(plainSchema: PlainSemanticSchema) {
|
|
18
|
-
return new SemanticSchema(plainSchema.exports);
|
|
19
|
-
}
|
|
20
|
-
}
|