@teambit/semantics.entities.semantic-schema 0.0.53 → 0.0.56
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 +23 -10
- package/class-transformers/comp-id-transformer.ts +21 -21
- package/class-transformers/index.ts +2 -2
- package/class-transformers/schema-obj-to-class.ts +51 -45
- package/dist/api-schema.d.ts +17 -3
- package/dist/api-schema.js +9 -22
- package/dist/api-schema.js.map +1 -1
- package/dist/class-transformers/comp-id-transformer.d.ts +0 -6
- package/dist/class-transformers/comp-id-transformer.js +21 -19
- package/dist/class-transformers/comp-id-transformer.js.map +1 -1
- package/dist/class-transformers/index.d.ts +0 -2
- package/dist/class-transformers/index.js +2 -8
- package/dist/class-transformers/index.js.map +1 -1
- package/dist/class-transformers/schema-obj-to-class.d.ts +0 -10
- package/dist/class-transformers/schema-obj-to-class.js +49 -66
- package/dist/class-transformers/schema-obj-to-class.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/{preview-1678246516830.js → preview-1695124733440.js} +1 -1
- package/dist/schema-node-constructor.d.ts +7 -0
- package/dist/schema-node-constructor.js +3 -0
- package/dist/schema-node-constructor.js.map +1 -0
- package/dist/schema-node.d.ts +20 -4
- package/dist/schema-node.js +36 -2
- package/dist/schema-node.js.map +1 -1
- package/dist/schema-registry.d.ts +9 -0
- package/dist/schema-registry.js +31 -0
- package/dist/schema-registry.js.map +1 -0
- package/dist/schemas/class.d.ts +39 -3
- package/dist/schemas/class.js +22 -14
- package/dist/schemas/class.js.map +1 -1
- package/dist/schemas/conditional-type.d.ts +11 -3
- package/dist/schemas/conditional-type.js +15 -20
- package/dist/schemas/conditional-type.js.map +1 -1
- package/dist/schemas/constructor.d.ts +3 -2
- package/dist/schemas/constructor.js +14 -2
- package/dist/schemas/constructor.js.map +1 -1
- package/dist/schemas/docs/doc.d.ts +20 -3
- package/dist/schemas/docs/doc.js +17 -11
- package/dist/schemas/docs/doc.js.map +1 -1
- package/dist/schemas/docs/property-like-tag.d.ts +13 -3
- package/dist/schemas/docs/property-like-tag.js +12 -11
- package/dist/schemas/docs/property-like-tag.js.map +1 -1
- package/dist/schemas/docs/return-tag.d.ts +13 -3
- package/dist/schemas/docs/return-tag.js +11 -11
- package/dist/schemas/docs/return-tag.js.map +1 -1
- package/dist/schemas/docs/tag.d.ts +12 -3
- package/dist/schemas/docs/tag.js +16 -0
- package/dist/schemas/docs/tag.js.map +1 -1
- package/dist/schemas/enum-member.d.ts +25 -3
- package/dist/schemas/enum-member.js +13 -11
- package/dist/schemas/enum-member.js.map +1 -1
- package/dist/schemas/enum.d.ts +26 -3
- package/dist/schemas/enum.js +17 -14
- package/dist/schemas/enum.js.map +1 -1
- package/dist/schemas/expression-with-arguments.d.ts +10 -3
- package/dist/schemas/expression-with-arguments.js +11 -14
- package/dist/schemas/expression-with-arguments.js.map +1 -1
- package/dist/schemas/function-like.d.ts +40 -4
- package/dist/schemas/function-like.js +28 -18
- package/dist/schemas/function-like.js.map +1 -1
- package/dist/schemas/get-accessor.d.ts +10 -3
- package/dist/schemas/get-accessor.js +14 -11
- package/dist/schemas/get-accessor.js.map +1 -1
- package/dist/schemas/index-signature.d.ts +17 -3
- package/dist/schemas/index-signature.js +11 -14
- package/dist/schemas/index-signature.js.map +1 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/indexed-access-type.d.ts +9 -3
- package/dist/schemas/indexed-access-type.js +13 -14
- package/dist/schemas/indexed-access-type.js.map +1 -1
- package/dist/schemas/inference-type.d.ts +9 -3
- package/dist/schemas/inference-type.js +12 -1
- package/dist/schemas/inference-type.js.map +1 -1
- package/dist/schemas/interface.d.ts +33 -3
- package/dist/schemas/interface.js +21 -14
- package/dist/schemas/interface.js.map +1 -1
- package/dist/schemas/keyword-type.d.ts +7 -3
- package/dist/schemas/keyword-type.js +8 -0
- package/dist/schemas/keyword-type.js.map +1 -1
- package/dist/schemas/literal-type.d.ts +4 -4
- package/dist/schemas/literal-type.js +6 -4
- package/dist/schemas/literal-type.js.map +1 -1
- package/dist/schemas/module.d.ts +9 -7
- package/dist/schemas/module.js +15 -20
- package/dist/schemas/module.js.map +1 -1
- package/dist/schemas/named-tuple.d.ts +9 -3
- package/dist/schemas/named-tuple.js +13 -0
- package/dist/schemas/named-tuple.js.map +1 -1
- package/dist/schemas/parameter.d.ts +16 -5
- package/dist/schemas/parameter.js +20 -16
- package/dist/schemas/parameter.js.map +1 -1
- package/dist/schemas/parenthesized-type.d.ts +8 -3
- package/dist/schemas/parenthesized-type.js +12 -11
- package/dist/schemas/parenthesized-type.js.map +1 -1
- package/dist/schemas/set-accessor.d.ts +17 -3
- package/dist/schemas/set-accessor.js +11 -11
- package/dist/schemas/set-accessor.js.map +1 -1
- package/dist/schemas/template-literal-type-span.d.ts +9 -3
- package/dist/schemas/template-literal-type-span.js +13 -11
- package/dist/schemas/template-literal-type-span.js.map +1 -1
- package/dist/schemas/template-literal-type.d.ts +11 -3
- package/dist/schemas/template-literal-type.js +10 -11
- package/dist/schemas/template-literal-type.js.map +1 -1
- package/dist/schemas/this-type.d.ts +4 -3
- package/dist/schemas/this-type.js +4 -0
- package/dist/schemas/this-type.js.map +1 -1
- package/dist/schemas/tuple-type.d.ts +7 -3
- package/dist/schemas/tuple-type.js +9 -11
- package/dist/schemas/tuple-type.js.map +1 -1
- package/dist/schemas/type-array.d.ts +8 -3
- package/dist/schemas/type-array.js +12 -11
- package/dist/schemas/type-array.js.map +1 -1
- package/dist/schemas/type-intersection.d.ts +8 -3
- package/dist/schemas/type-intersection.js +12 -11
- package/dist/schemas/type-intersection.js.map +1 -1
- package/dist/schemas/type-literal.d.ts +8 -3
- package/dist/schemas/type-literal.js +12 -11
- package/dist/schemas/type-literal.js.map +1 -1
- package/dist/schemas/type-operator.d.ts +9 -3
- package/dist/schemas/type-operator.js +13 -11
- package/dist/schemas/type-operator.js.map +1 -1
- package/dist/schemas/type-predicate.d.ts +9 -3
- package/dist/schemas/type-predicate.js +12 -11
- package/dist/schemas/type-predicate.js.map +1 -1
- package/dist/schemas/type-query.d.ts +9 -3
- package/dist/schemas/type-query.js +13 -11
- package/dist/schemas/type-query.js.map +1 -1
- package/dist/schemas/type-ref.d.ts +28 -4
- package/dist/schemas/type-ref.js +43 -16
- package/dist/schemas/type-ref.js.map +1 -1
- package/dist/schemas/type-union.d.ts +8 -3
- package/dist/schemas/type-union.js +12 -11
- package/dist/schemas/type-union.js.map +1 -1
- package/dist/schemas/type.d.ts +10 -3
- package/dist/schemas/type.js +16 -14
- package/dist/schemas/type.js.map +1 -1
- package/dist/schemas/unimplemented-schema.d.ts +7 -3
- package/dist/schemas/unimplemented-schema.js +9 -0
- package/dist/schemas/unimplemented-schema.js.map +1 -1
- package/dist/schemas/unknown-schema.d.ts +7 -3
- package/dist/schemas/unknown-schema.js +9 -0
- package/dist/schemas/unknown-schema.js.map +1 -1
- package/dist/schemas/unresolved-schema.d.ts +5 -3
- package/dist/schemas/unresolved-schema.js +8 -0
- package/dist/schemas/unresolved-schema.js.map +1 -1
- package/dist/schemas/variable-like.d.ts +29 -3
- package/dist/schemas/variable-like.js +21 -15
- package/dist/schemas/variable-like.js.map +1 -1
- package/dist/unknown-schema-factory.d.ts +4 -0
- package/dist/unknown-schema-factory.js +13 -0
- package/dist/unknown-schema-factory.js.map +1 -0
- package/index.ts +10 -2
- package/package.json +3 -4
- package/schema-node-constructor.ts +8 -0
- package/schema-node.ts +62 -6
- package/schema-registry.ts +33 -0
- package/schemas/class.ts +32 -7
- package/schemas/conditional-type.ts +27 -11
- package/schemas/constructor.ts +14 -4
- package/schemas/docs/doc.ts +22 -5
- package/schemas/docs/property-like-tag.ts +19 -5
- package/schemas/docs/return-tag.ts +18 -5
- package/schemas/docs/tag.ts +20 -2
- package/schemas/enum-member.ts +21 -5
- package/schemas/enum.ts +26 -6
- package/schemas/expression-with-arguments.ts +26 -7
- package/schemas/function-like.ts +51 -10
- package/schemas/get-accessor.ts +24 -5
- package/schemas/index-signature.ts +19 -6
- package/schemas/index.ts +1 -1
- package/schemas/indexed-access-type.ts +24 -6
- package/schemas/inference-type.ts +23 -2
- package/schemas/interface.ts +30 -7
- package/schemas/keyword-type.ts +15 -2
- package/schemas/literal-type.ts +9 -3
- package/schemas/module.ts +24 -14
- package/schemas/named-tuple.ts +22 -2
- package/schemas/parameter.ts +43 -11
- package/schemas/parenthesized-type.ts +20 -5
- package/schemas/set-accessor.ts +26 -5
- package/schemas/template-literal-type-span.ts +23 -5
- package/schemas/template-literal-type.ts +22 -5
- package/schemas/this-type.ts +7 -2
- package/schemas/tuple-type.ts +17 -5
- package/schemas/type-array.ts +21 -5
- package/schemas/type-intersection.ts +21 -5
- package/schemas/type-literal.ts +21 -5
- package/schemas/type-operator.ts +22 -5
- package/schemas/type-predicate.ts +20 -5
- package/schemas/type-query.ts +24 -5
- package/schemas/type-ref.ts +51 -10
- package/schemas/type-union.ts +17 -5
- package/schemas/type.ts +25 -7
- package/schemas/unimplemented-schema.ts +16 -2
- package/schemas/unknown-schema.ts +16 -2
- package/schemas/unresolved-schema.ts +12 -2
- package/schemas/variable-like.ts +33 -8
- package/unknown-schema-factory.ts +10 -0
- package/package-tar/teambit-semantics.entities.semantic-schema-0.0.53.tgz +0 -0
|
@@ -1,15 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../schema-node';
|
|
2
2
|
import { DocSchema } from './docs';
|
|
3
3
|
/**
|
|
4
4
|
* can be also a property or property-signature
|
|
5
5
|
*/
|
|
6
6
|
export declare class VariableLikeSchema extends SchemaNode {
|
|
7
|
-
readonly location:
|
|
7
|
+
readonly location: SchemaLocation;
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly signature: string;
|
|
10
10
|
readonly isOptional: boolean;
|
|
11
|
+
readonly defaultValue?: string;
|
|
11
12
|
type: SchemaNode;
|
|
12
13
|
readonly doc?: DocSchema;
|
|
13
|
-
constructor(location:
|
|
14
|
+
constructor(location: SchemaLocation, name: string, signature: string, type: SchemaNode, isOptional: boolean, doc?: DocSchema, defaultValue?: string);
|
|
15
|
+
getNodes(): SchemaNode[];
|
|
14
16
|
toString(): string;
|
|
17
|
+
toObject(): {
|
|
18
|
+
name: string;
|
|
19
|
+
signature: string;
|
|
20
|
+
type: Record<string, any>;
|
|
21
|
+
isOptional: boolean;
|
|
22
|
+
doc: {
|
|
23
|
+
__schema: string;
|
|
24
|
+
name: string;
|
|
25
|
+
location: SchemaLocation;
|
|
26
|
+
signature: string;
|
|
27
|
+
raw: string;
|
|
28
|
+
comment: string;
|
|
29
|
+
tags: {
|
|
30
|
+
__schema: string;
|
|
31
|
+
location: SchemaLocation;
|
|
32
|
+
name: string;
|
|
33
|
+
signature: string;
|
|
34
|
+
tagName: string;
|
|
35
|
+
comment: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
defaultValue: string;
|
|
39
|
+
};
|
|
40
|
+
static fromObject(obj: Record<string, any>): VariableLikeSchema;
|
|
15
41
|
}
|
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
|
11
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
6
|
exports.VariableLikeSchema = void 0;
|
|
13
|
-
const class_transformer_1 = require("class-transformer");
|
|
14
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
15
8
|
const schema_node_1 = require("../schema-node");
|
|
16
|
-
const
|
|
9
|
+
const docs_1 = require("./docs");
|
|
10
|
+
const schema_registry_1 = require("../schema-registry");
|
|
17
11
|
/**
|
|
18
12
|
* can be also a property or property-signature
|
|
19
13
|
*/
|
|
20
14
|
class VariableLikeSchema extends schema_node_1.SchemaNode {
|
|
21
|
-
constructor(location, name, signature, type, isOptional, doc) {
|
|
15
|
+
constructor(location, name, signature, type, isOptional, doc, defaultValue) {
|
|
22
16
|
super();
|
|
23
17
|
this.location = location;
|
|
24
18
|
this.name = name;
|
|
25
19
|
this.signature = signature;
|
|
26
20
|
this.isOptional = isOptional;
|
|
21
|
+
this.defaultValue = defaultValue;
|
|
27
22
|
this.type = type;
|
|
28
23
|
this.doc = doc;
|
|
29
24
|
}
|
|
25
|
+
getNodes() {
|
|
26
|
+
return [this.type];
|
|
27
|
+
}
|
|
30
28
|
toString() {
|
|
31
29
|
return `${chalk_1.default.bold(this.name)}${this.isOptional ? '?' : ''}: ${this.type.toString()}`;
|
|
32
30
|
}
|
|
31
|
+
toObject() {
|
|
32
|
+
var _a;
|
|
33
|
+
return Object.assign(Object.assign({}, super.toObject()), { name: this.name, signature: this.signature, type: this.type.toObject(), isOptional: this.isOptional, doc: (_a = this.doc) === null || _a === void 0 ? void 0 : _a.toObject(), defaultValue: this.defaultValue });
|
|
34
|
+
}
|
|
35
|
+
static fromObject(obj) {
|
|
36
|
+
const location = obj.location;
|
|
37
|
+
const name = obj.name;
|
|
38
|
+
const signature = obj.signature;
|
|
39
|
+
const type = schema_registry_1.SchemaRegistry.fromObject(obj.type);
|
|
40
|
+
const isOptional = obj.isOptional;
|
|
41
|
+
const doc = obj.doc ? docs_1.DocSchema.fromObject(obj.doc) : undefined;
|
|
42
|
+
const defaultValue = obj.defaultValue;
|
|
43
|
+
return new VariableLikeSchema(location, name, signature, type, isOptional, doc, defaultValue);
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, class_transformer_1.Transform)(class_transformers_1.schemaObjToInstance)
|
|
36
|
-
], VariableLikeSchema.prototype, "type", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, class_transformer_1.Transform)(class_transformers_1.schemaObjToInstance)
|
|
39
|
-
], VariableLikeSchema.prototype, "doc", void 0);
|
|
40
46
|
exports.VariableLikeSchema = VariableLikeSchema;
|
|
41
47
|
//# sourceMappingURL=variable-like.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-like.js","sourceRoot":"","sources":["../../schemas/variable-like.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"variable-like.js","sourceRoot":"","sources":["../../schemas/variable-like.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gDAA4D;AAC5D,iCAAmC;AACnC,wDAAoD;AAEpD;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wBAAU;IAIhD,YACW,QAAwB,EACxB,IAAY,EACZ,SAAiB,EAC1B,IAAgB,EACP,UAAmB,EAC5B,GAAe,EACN,YAAqB;QAE9B,KAAK,EAAE,CAAC;QARC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAQ;QAEjB,eAAU,GAAV,UAAU,CAAS;QAEnB,iBAAY,GAAZ,YAAY,CAAS;QAG9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC1F,CAAC;IAED,QAAQ;;QACN,uCACK,KAAK,CAAC,QAAQ,EAAE,KACnB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,GAAG,EAAE,MAAA,IAAI,CAAC,GAAG,0CAAE,QAAQ,EAAE,EACzB,YAAY,EAAE,IAAI,CAAC,YAAY,IAC/B;IACJ,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAwB;QACxC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAChC,MAAM,IAAI,GAAG,gCAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;QAClC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,gBAAS,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAChE,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;QACtC,OAAO,IAAI,kBAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAChG,CAAC;CACF;AAhDD,gDAgDC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownSchemaFactory = void 0;
|
|
4
|
+
class UnknownSchemaFactory {
|
|
5
|
+
static create(location, name, schemaObj) {
|
|
6
|
+
// dynamic require() to import UnknownSchema at runtime when it's needed, which breaks the circular dependency.
|
|
7
|
+
// eslint-disable-next-line global-require
|
|
8
|
+
const { UnknownSchema } = require('./schemas/unknown-schema');
|
|
9
|
+
return new UnknownSchema(location, name, schemaObj);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.UnknownSchemaFactory = UnknownSchemaFactory;
|
|
13
|
+
//# sourceMappingURL=unknown-schema-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-schema-factory.js","sourceRoot":"","sources":["../unknown-schema-factory.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAoB;IAC/B,MAAM,CAAC,MAAM,CAAC,QAAwB,EAAE,IAAY,EAAE,SAA8B;QAClF,+GAA+G;QAC/G,0CAA0C;QAC1C,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;QAC9D,OAAO,IAAI,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;CACF;AAPD,oDAOC"}
|
package/index.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import * as Schemas from './schemas';
|
|
2
|
+
|
|
3
|
+
export { SchemaNode, ISchemaNode } from './schema-node';
|
|
1
4
|
export { APISchema } from './api-schema';
|
|
2
5
|
export { Export, StaticProperties } from './export';
|
|
3
|
-
export type {
|
|
4
|
-
export * from './schemas';
|
|
6
|
+
export type { SchemaLocation as Location } from './schema-node';
|
|
5
7
|
export { TagName } from './schemas/docs/tag';
|
|
8
|
+
export { SchemaRegistry } from './schema-registry';
|
|
9
|
+
export { SchemaNodeConstructor } from './schema-node-constructor';
|
|
10
|
+
export { Modifier } from './schemas/function-like';
|
|
11
|
+
export { Schemas };
|
|
12
|
+
|
|
13
|
+
export * from './schemas';
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/semantics.entities.semantic-schema",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"homepage": "https://bit.
|
|
3
|
+
"version": "0.0.56",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/semantics/entities/semantic-schema",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.semantics",
|
|
8
8
|
"name": "entities/semantic-schema",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.56"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
13
|
-
"class-transformer": "0.5.1",
|
|
14
13
|
"lodash": "4.17.21",
|
|
15
14
|
"@teambit/component-id": "0.0.427"
|
|
16
15
|
},
|
package/schema-node.ts
CHANGED
|
@@ -1,26 +1,82 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pickBy } from 'lodash';
|
|
2
2
|
import { DocSchema } from './schemas';
|
|
3
3
|
|
|
4
|
+
export interface ISchemaNode {
|
|
5
|
+
__schema: string;
|
|
6
|
+
location: SchemaLocation;
|
|
7
|
+
doc?: DocSchema;
|
|
8
|
+
signature?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
toObject(): Record<string, any>;
|
|
11
|
+
toString(): string;
|
|
12
|
+
getNodes(): SchemaNode[];
|
|
13
|
+
findNode(predicate: (node: SchemaNode) => boolean, visitedNodes?: Set<SchemaNode>): SchemaNode | undefined;
|
|
14
|
+
getAllNodesRecursively(visitedNodes?: Set<SchemaNode>): SchemaNode[];
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
/**
|
|
5
18
|
* a convenient abstract class for all schema to extend.
|
|
6
19
|
* the reason for having it as an abstract class and not an interface, for now, is mostly for the `__schema` prop.
|
|
7
20
|
* this way it won't need to be implemented in each one of the subclasses.
|
|
8
21
|
*/
|
|
9
|
-
export abstract class SchemaNode {
|
|
22
|
+
export abstract class SchemaNode implements ISchemaNode {
|
|
10
23
|
readonly __schema = this.constructor.name;
|
|
11
|
-
abstract readonly location:
|
|
24
|
+
abstract readonly location: SchemaLocation;
|
|
12
25
|
readonly doc?: DocSchema;
|
|
13
26
|
readonly signature?: string;
|
|
14
27
|
readonly name?: string;
|
|
15
28
|
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
+
static fromObject(obj: Record<string, any>): SchemaNode {
|
|
31
|
+
throw new Error(`Method 'fromObject' not implemented in subclass.`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
toObject(): Record<string, any> {
|
|
35
|
+
return pickBy(
|
|
36
|
+
{
|
|
37
|
+
__schema: this.__schema,
|
|
38
|
+
location: this.location,
|
|
39
|
+
doc: this.doc ? this.doc.toObject() : undefined,
|
|
40
|
+
signature: this.signature,
|
|
41
|
+
name: this.name,
|
|
42
|
+
},
|
|
43
|
+
(v) => v !== undefined
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
16
47
|
abstract toString(): string;
|
|
17
48
|
|
|
18
|
-
|
|
19
|
-
return
|
|
49
|
+
getNodes(): SchemaNode[] {
|
|
50
|
+
return [this];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getAllNodesRecursively(visitedNodes = new Set<SchemaNode>()): SchemaNode[] {
|
|
54
|
+
if (visitedNodes.has(this)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
visitedNodes.add(this);
|
|
59
|
+
|
|
60
|
+
const nodes = this.getNodes();
|
|
61
|
+
return [this, ...nodes.flatMap((node) => node.getAllNodesRecursively(visitedNodes))];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
findNode(predicate: (node: SchemaNode) => boolean, visitedNodes = new Set<SchemaNode>()): SchemaNode | undefined {
|
|
65
|
+
if (predicate(this)) return this;
|
|
66
|
+
if (visitedNodes.has(this)) return undefined;
|
|
67
|
+
|
|
68
|
+
visitedNodes.add(this);
|
|
69
|
+
|
|
70
|
+
for (const child of this.getNodes()) {
|
|
71
|
+
const foundNode = child.findNode(predicate, visitedNodes);
|
|
72
|
+
if (foundNode) return foundNode;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return undefined;
|
|
20
76
|
}
|
|
21
77
|
}
|
|
22
78
|
|
|
23
|
-
export type
|
|
79
|
+
export type SchemaLocation = {
|
|
24
80
|
/**
|
|
25
81
|
* file-path relative to the component root-dir. normalized to Linux.
|
|
26
82
|
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SchemaNodeConstructor } from './schema-node-constructor';
|
|
2
|
+
import { UnknownSchemaFactory } from './unknown-schema-factory';
|
|
3
|
+
|
|
4
|
+
export class SchemaRegistry {
|
|
5
|
+
private static instance = new SchemaRegistry();
|
|
6
|
+
private _schemas: Record<string, SchemaNodeConstructor>;
|
|
7
|
+
|
|
8
|
+
private constructor() {
|
|
9
|
+
this._schemas = {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static register(schema: SchemaNodeConstructor) {
|
|
13
|
+
if (this.instance._schemas[schema.name]) return;
|
|
14
|
+
this.instance._schemas[schema.name] = schema;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static schemas() {
|
|
18
|
+
return this.instance._schemas;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static fromObject(obj: Record<string, any>) {
|
|
22
|
+
if (!obj.__schema) {
|
|
23
|
+
throw new Error(`fatal: "__schema" is missing, make sure the transformer is set on SchemaNode type`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const SchemaClass = this.instance._schemas[obj.__schema];
|
|
27
|
+
if (!SchemaClass) {
|
|
28
|
+
// for backward and forward compatibility, to not break the users, it's better to return an unknown schema than throwing.
|
|
29
|
+
return UnknownSchemaFactory.create(obj.location || { path: '', line: 0, character: 0 }, obj.__schema, obj);
|
|
30
|
+
}
|
|
31
|
+
return SchemaClass.fromObject(obj);
|
|
32
|
+
}
|
|
33
|
+
}
|
package/schemas/class.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { Transform } from 'class-transformer';
|
|
2
1
|
import chalk from 'chalk';
|
|
3
|
-
import {
|
|
4
|
-
import { schemaObjArrayToInstances, schemaObjToInstance } from '../class-transformers';
|
|
2
|
+
import { SchemaLocation, SchemaNode } from '../schema-node';
|
|
5
3
|
import { DocSchema } from './docs';
|
|
6
4
|
import { ExpressionWithTypeArgumentsSchema } from './expression-with-arguments';
|
|
5
|
+
import { SchemaRegistry } from '../schema-registry';
|
|
7
6
|
|
|
8
7
|
export class ClassSchema extends SchemaNode {
|
|
9
|
-
@Transform(schemaObjArrayToInstances)
|
|
10
8
|
readonly members: SchemaNode[];
|
|
11
|
-
|
|
12
|
-
@Transform(schemaObjToInstance)
|
|
13
9
|
readonly doc?: DocSchema;
|
|
14
10
|
|
|
15
11
|
constructor(
|
|
16
12
|
readonly name: string,
|
|
17
13
|
members: SchemaNode[],
|
|
18
|
-
readonly location:
|
|
14
|
+
readonly location: SchemaLocation,
|
|
19
15
|
readonly signature: string,
|
|
20
16
|
doc?: DocSchema,
|
|
21
17
|
readonly typeParams?: string[],
|
|
@@ -27,8 +23,37 @@ export class ClassSchema extends SchemaNode {
|
|
|
27
23
|
this.doc = doc;
|
|
28
24
|
}
|
|
29
25
|
|
|
26
|
+
getNodes() {
|
|
27
|
+
return this.members;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
30
|
toString() {
|
|
31
31
|
const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
|
|
32
32
|
return `${chalk.bold.underline(this.name)}\n${membersStr}`;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
toObject() {
|
|
36
|
+
return {
|
|
37
|
+
...super.toObject(),
|
|
38
|
+
name: this.name,
|
|
39
|
+
members: this.members.map((member) => member.toObject()),
|
|
40
|
+
doc: this.doc?.toObject(),
|
|
41
|
+
signature: this.signature,
|
|
42
|
+
typeParams: this.typeParams,
|
|
43
|
+
extendsNodes: this.extendsNodes?.map((node) => node.toObject()),
|
|
44
|
+
implementNodes: this.implementNodes?.map((node) => node.toObject()),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static fromObject(obj: Record<string, any>): ClassSchema {
|
|
49
|
+
const name = obj.name;
|
|
50
|
+
const members = obj.members.map((member: any) => SchemaRegistry.fromObject(member));
|
|
51
|
+
const location = obj.location;
|
|
52
|
+
const signature = obj.signature;
|
|
53
|
+
const doc = obj.doc ? DocSchema.fromObject(obj.doc) : undefined;
|
|
54
|
+
const typeParams = obj.typeParams;
|
|
55
|
+
const extendsNodes = obj.extendsNodes?.map((node: any) => ExpressionWithTypeArgumentsSchema.fromObject(node));
|
|
56
|
+
const implementNodes = obj.implementNodes?.map((node: any) => ExpressionWithTypeArgumentsSchema.fromObject(node));
|
|
57
|
+
return new ClassSchema(name, members, location, signature, doc, typeParams, extendsNodes, implementNodes);
|
|
58
|
+
}
|
|
34
59
|
}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { schemaObjToInstance } from '../class-transformers';
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../schema-node';
|
|
2
|
+
import { SchemaRegistry } from '../schema-registry';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* e.g. `T extends U ? Y : N`
|
|
7
6
|
*
|
|
8
7
|
*/
|
|
9
8
|
export class ConditionalTypeSchema extends SchemaNode {
|
|
10
|
-
@Transform(schemaObjToInstance)
|
|
11
9
|
readonly checkType: SchemaNode;
|
|
12
|
-
|
|
13
|
-
@Transform(schemaObjToInstance)
|
|
14
10
|
readonly extendsType: SchemaNode;
|
|
15
|
-
|
|
16
|
-
@Transform(schemaObjToInstance)
|
|
17
11
|
readonly trueType: SchemaNode;
|
|
18
|
-
|
|
19
|
-
@Transform(schemaObjToInstance)
|
|
20
12
|
readonly falseType: SchemaNode;
|
|
13
|
+
|
|
21
14
|
constructor(
|
|
22
|
-
readonly location:
|
|
15
|
+
readonly location: SchemaLocation,
|
|
23
16
|
checkType: SchemaNode,
|
|
24
17
|
extendsType: SchemaNode,
|
|
25
18
|
trueType: SchemaNode,
|
|
@@ -32,7 +25,30 @@ export class ConditionalTypeSchema extends SchemaNode {
|
|
|
32
25
|
this.falseType = falseType;
|
|
33
26
|
}
|
|
34
27
|
|
|
28
|
+
getNodes() {
|
|
29
|
+
return [this.checkType, this.extendsType, this.trueType, this.falseType];
|
|
30
|
+
}
|
|
31
|
+
|
|
35
32
|
toString() {
|
|
36
33
|
return `${this.checkType.toString()} extends ${this.extendsType.toString()} ? ${this.trueType.toString()} : ${this.falseType.toString()}`;
|
|
37
34
|
}
|
|
35
|
+
|
|
36
|
+
toObject() {
|
|
37
|
+
return {
|
|
38
|
+
...super.toObject(),
|
|
39
|
+
checkType: this.checkType.toObject(),
|
|
40
|
+
extendsType: this.extendsType.toObject(),
|
|
41
|
+
trueType: this.trueType.toObject(),
|
|
42
|
+
falseType: this.falseType.toObject(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromObject(obj: Record<string, any>): ConditionalTypeSchema {
|
|
47
|
+
const location = obj.location;
|
|
48
|
+
const checkType = SchemaRegistry.fromObject(obj.checkType);
|
|
49
|
+
const extendsType = SchemaRegistry.fromObject(obj.extendsType);
|
|
50
|
+
const trueType = SchemaRegistry.fromObject(obj.trueType);
|
|
51
|
+
const falseType = SchemaRegistry.fromObject(obj.falseType);
|
|
52
|
+
return new ConditionalTypeSchema(location, checkType, extendsType, trueType, falseType);
|
|
53
|
+
}
|
|
38
54
|
}
|
package/schemas/constructor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SchemaLocation } from '../schema-node';
|
|
2
2
|
import { ParameterSchema } from './parameter';
|
|
3
3
|
import { FunctionLikeSchema, Modifier } from './function-like';
|
|
4
4
|
import { DocSchema } from './docs';
|
|
@@ -6,13 +6,23 @@ import { ThisTypeSchema } from './this-type';
|
|
|
6
6
|
|
|
7
7
|
export class ConstructorSchema extends FunctionLikeSchema {
|
|
8
8
|
constructor(
|
|
9
|
-
location:
|
|
9
|
+
location: SchemaLocation,
|
|
10
10
|
params: ParameterSchema[],
|
|
11
|
-
|
|
11
|
+
returnType: ThisTypeSchema,
|
|
12
12
|
signature: string,
|
|
13
13
|
modifiers: Modifier[] = [],
|
|
14
14
|
doc?: DocSchema
|
|
15
15
|
) {
|
|
16
|
-
super(location, 'constructor', params,
|
|
16
|
+
super(location, 'constructor', params, returnType, signature, modifiers, doc, undefined);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static fromObject(obj: Record<string, any>): ConstructorSchema {
|
|
20
|
+
const location = obj.location;
|
|
21
|
+
const params = obj.params.map((param: any) => ParameterSchema.fromObject(param));
|
|
22
|
+
const returns = ThisTypeSchema.fromObject(obj.returnType);
|
|
23
|
+
const signature = obj.signature;
|
|
24
|
+
const modifiers = obj.modifiers;
|
|
25
|
+
const doc = obj.doc ? DocSchema.fromObject(obj.doc) : undefined;
|
|
26
|
+
return new ConstructorSchema(location, params, returns, signature, modifiers, doc);
|
|
17
27
|
}
|
|
18
28
|
}
|
package/schemas/docs/doc.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Location, SchemaNode } from '../../schema-node';
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../../schema-node';
|
|
2
|
+
import { SchemaRegistry } from '../../schema-registry';
|
|
4
3
|
import { TagName, TagSchema } from './tag';
|
|
5
4
|
|
|
6
5
|
export class DocSchema extends SchemaNode {
|
|
7
|
-
@Transform(schemaObjArrayToInstances)
|
|
8
6
|
readonly tags?: TagSchema[];
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
constructor(readonly location: SchemaLocation, readonly raw: string, readonly comment?: string, tags?: TagSchema[]) {
|
|
10
9
|
super();
|
|
11
10
|
this.tags = tags;
|
|
12
11
|
}
|
|
@@ -24,4 +23,22 @@ export class DocSchema extends SchemaNode {
|
|
|
24
23
|
findTag(tagName: TagName) {
|
|
25
24
|
return this.tags?.find((tag) => tag.tagName === tagName);
|
|
26
25
|
}
|
|
26
|
+
|
|
27
|
+
toObject() {
|
|
28
|
+
return {
|
|
29
|
+
__schema: this.__schema,
|
|
30
|
+
name: this.name,
|
|
31
|
+
location: this.location,
|
|
32
|
+
signature: this.signature,
|
|
33
|
+
raw: this.raw,
|
|
34
|
+
comment: this.comment,
|
|
35
|
+
tags: this.tags ? this.tags.map((tag) => tag.toObject()) : undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static fromObject(obj: Record<string, any>): DocSchema {
|
|
40
|
+
const location = obj.location;
|
|
41
|
+
const tags = obj.tags ? obj.tags.map((tag: any) => SchemaRegistry.fromObject(tag)) : undefined;
|
|
42
|
+
return new DocSchema(location, obj.raw, obj.comment, tags);
|
|
43
|
+
}
|
|
27
44
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../../schema-node';
|
|
2
|
+
import { SchemaRegistry } from '../../schema-registry';
|
|
3
3
|
import { TagName, TagSchema } from './tag';
|
|
4
|
-
import { schemaObjToInstance } from '../../class-transformers';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* e.g. `@param myParam {string} some comment`
|
|
8
7
|
*/
|
|
9
8
|
export class PropertyLikeTagSchema extends TagSchema {
|
|
10
|
-
@Transform(schemaObjToInstance)
|
|
11
9
|
readonly type?: SchemaNode;
|
|
12
|
-
constructor(readonly location:
|
|
10
|
+
constructor(readonly location: SchemaLocation, readonly name: string, readonly comment?: string, type?: SchemaNode) {
|
|
13
11
|
super(location, TagName.parameter, comment);
|
|
14
12
|
this.type = type;
|
|
15
13
|
}
|
|
@@ -19,4 +17,20 @@ export class PropertyLikeTagSchema extends TagSchema {
|
|
|
19
17
|
const type = this.type ? ` {${this.type.toString()}} ` : '';
|
|
20
18
|
return `@${this.tagName} ${this.name}${type} ${comment}`;
|
|
21
19
|
}
|
|
20
|
+
|
|
21
|
+
toObject() {
|
|
22
|
+
return {
|
|
23
|
+
...super.toObject(),
|
|
24
|
+
name: this.name,
|
|
25
|
+
type: this.type?.toObject(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static fromObject(obj: Record<string, any>): PropertyLikeTagSchema {
|
|
30
|
+
const location = obj.location;
|
|
31
|
+
const name = obj.name;
|
|
32
|
+
const comment = obj.comment;
|
|
33
|
+
const type = obj.type ? SchemaRegistry.fromObject(obj.type) : undefined;
|
|
34
|
+
return new PropertyLikeTagSchema(location, name, comment, type);
|
|
35
|
+
}
|
|
22
36
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../../schema-node';
|
|
2
|
+
import { SchemaRegistry } from '../../schema-registry';
|
|
3
3
|
import { TagName, TagSchema } from './tag';
|
|
4
|
-
import { schemaObjToInstance } from '../../class-transformers';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* e.g. `@return {string} some comment`
|
|
8
7
|
*/
|
|
9
8
|
export class ReturnTagSchema extends TagSchema {
|
|
10
|
-
@Transform(schemaObjToInstance)
|
|
11
9
|
readonly type?: SchemaNode;
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
constructor(readonly location: SchemaLocation, readonly comment?: string, type?: SchemaNode) {
|
|
13
12
|
super(location, TagName.return, comment);
|
|
14
13
|
this.type = type;
|
|
15
14
|
}
|
|
@@ -18,4 +17,18 @@ export class ReturnTagSchema extends TagSchema {
|
|
|
18
17
|
const comment = this.comment ? ` ${this.comment}` : '';
|
|
19
18
|
return `@${this.tagName}${comment}`;
|
|
20
19
|
}
|
|
20
|
+
|
|
21
|
+
toObject() {
|
|
22
|
+
return {
|
|
23
|
+
...super.toObject(),
|
|
24
|
+
type: this.type?.toObject(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static fromObject(obj: Record<string, any>): ReturnTagSchema {
|
|
29
|
+
const location = obj.location;
|
|
30
|
+
const comment = obj.comment;
|
|
31
|
+
const type = obj.type ? SchemaRegistry.fromObject(obj.type) : undefined;
|
|
32
|
+
return new ReturnTagSchema(location, comment, type);
|
|
33
|
+
}
|
|
21
34
|
}
|
package/schemas/docs/tag.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../../schema-node';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* e.g. `@deprecated please use something else`
|
|
5
5
|
*/
|
|
6
6
|
export class TagSchema extends SchemaNode {
|
|
7
|
-
constructor(readonly location:
|
|
7
|
+
constructor(readonly location: SchemaLocation, readonly tagName: TagName | string, readonly comment?: string) {
|
|
8
8
|
super();
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -12,6 +12,24 @@ export class TagSchema extends SchemaNode {
|
|
|
12
12
|
const comment = this.comment ? ` ${this.comment}` : '';
|
|
13
13
|
return `@${this.tagName}${comment}`;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
static fromObject(obj: Record<string, any>): TagSchema {
|
|
17
|
+
const location = obj.location;
|
|
18
|
+
const tagName = obj.tagName;
|
|
19
|
+
const comment = obj.comment;
|
|
20
|
+
return new TagSchema(location, tagName, comment);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
toObject() {
|
|
24
|
+
return {
|
|
25
|
+
__schema: this.__schema,
|
|
26
|
+
location: this.location,
|
|
27
|
+
name: this.name,
|
|
28
|
+
signature: this.signature,
|
|
29
|
+
tagName: this.tagName,
|
|
30
|
+
comment: this.comment,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
export enum TagName {
|
package/schemas/enum-member.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { schemaObjToInstance } from '../class-transformers';
|
|
3
|
-
import { Location, SchemaNode } from '../schema-node';
|
|
1
|
+
import { SchemaLocation, SchemaNode } from '../schema-node';
|
|
4
2
|
import { DocSchema } from './docs';
|
|
5
3
|
|
|
6
4
|
export class EnumMemberSchema extends SchemaNode {
|
|
7
|
-
@Transform(schemaObjToInstance)
|
|
8
5
|
readonly doc?: DocSchema;
|
|
9
6
|
|
|
10
7
|
constructor(
|
|
11
|
-
readonly location:
|
|
8
|
+
readonly location: SchemaLocation,
|
|
12
9
|
readonly name: string,
|
|
13
10
|
readonly signature: string,
|
|
14
11
|
readonly value?: string,
|
|
@@ -22,4 +19,23 @@ export class EnumMemberSchema extends SchemaNode {
|
|
|
22
19
|
if (!this.value) return this.name;
|
|
23
20
|
return `${this.name}=${this.value}`;
|
|
24
21
|
}
|
|
22
|
+
|
|
23
|
+
toObject() {
|
|
24
|
+
return {
|
|
25
|
+
...super.toObject(),
|
|
26
|
+
name: this.name,
|
|
27
|
+
signature: this.signature,
|
|
28
|
+
value: this.value,
|
|
29
|
+
doc: this.doc?.toObject(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static fromObject(obj: Record<string, any>): EnumMemberSchema {
|
|
34
|
+
const location = obj.location;
|
|
35
|
+
const name = obj.name;
|
|
36
|
+
const signature = obj.signature;
|
|
37
|
+
const value = obj.value;
|
|
38
|
+
const doc = obj.doc ? DocSchema.fromObject(obj.doc) : undefined;
|
|
39
|
+
return new EnumMemberSchema(location, name, signature, value, doc);
|
|
40
|
+
}
|
|
25
41
|
}
|