@teambit/semantics.entities.semantic-schema 0.0.7 → 0.0.8

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.
Files changed (82) hide show
  1. package/api-schema.ts +56 -0
  2. package/dist/api-schema.d.ts +24 -0
  3. package/dist/api-schema.js +44 -0
  4. package/dist/api-schema.js.map +1 -0
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +14 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/schema-node.d.ts +5 -5
  9. package/dist/schemas/class.d.ts +14 -0
  10. package/dist/schemas/class.js +25 -0
  11. package/dist/schemas/class.js.map +1 -1
  12. package/dist/schemas/constructor.d.ts +11 -0
  13. package/dist/schemas/constructor.js +24 -0
  14. package/dist/schemas/constructor.js.map +1 -0
  15. package/dist/schemas/export.d.ts +7 -3
  16. package/dist/schemas/export.js +8 -2
  17. package/dist/schemas/export.js.map +1 -1
  18. package/dist/schemas/function.d.ts +20 -5
  19. package/dist/schemas/function.js +23 -2
  20. package/dist/schemas/function.js.map +1 -1
  21. package/dist/schemas/get-accessor.d.ts +21 -0
  22. package/dist/schemas/get-accessor.js +30 -0
  23. package/dist/schemas/get-accessor.js.map +1 -0
  24. package/dist/schemas/index-signature.d.ts +23 -0
  25. package/dist/schemas/index-signature.js +26 -0
  26. package/dist/schemas/index-signature.js.map +1 -0
  27. package/dist/schemas/index.d.ts +12 -1
  28. package/dist/schemas/index.js +23 -1
  29. package/dist/schemas/index.js.map +1 -1
  30. package/dist/schemas/interface.d.ts +14 -0
  31. package/dist/schemas/interface.js +26 -0
  32. package/dist/schemas/interface.js.map +1 -0
  33. package/dist/schemas/module.d.ts +14 -10
  34. package/dist/schemas/module.js +33 -5
  35. package/dist/schemas/module.js.map +1 -1
  36. package/dist/schemas/set-accessor.d.ts +16 -0
  37. package/dist/schemas/set-accessor.js +30 -0
  38. package/dist/schemas/set-accessor.js.map +1 -0
  39. package/dist/schemas/type-intersection.d.ts +12 -0
  40. package/dist/schemas/type-intersection.js +19 -0
  41. package/dist/schemas/type-intersection.js.map +1 -0
  42. package/dist/schemas/type-literal.d.ts +15 -0
  43. package/dist/schemas/type-literal.js +22 -0
  44. package/dist/schemas/type-literal.js.map +1 -0
  45. package/dist/schemas/type-ref.d.ts +7 -0
  46. package/dist/schemas/type-ref.js +21 -0
  47. package/dist/schemas/type-ref.js.map +1 -1
  48. package/dist/schemas/type-union.d.ts +12 -0
  49. package/dist/schemas/type-union.js +19 -0
  50. package/dist/schemas/type-union.js.map +1 -0
  51. package/dist/schemas/type.d.ts +16 -0
  52. package/dist/schemas/type.js +26 -0
  53. package/dist/schemas/type.js.map +1 -1
  54. package/dist/schemas/variable.d.ts +21 -0
  55. package/dist/schemas/variable.js +30 -0
  56. package/dist/schemas/variable.js.map +1 -0
  57. package/index.ts +20 -2
  58. package/package-tar/teambit-semantics.entities.semantic-schema-0.0.8.tgz +0 -0
  59. package/package.json +3 -2
  60. package/{preview-1650468178717.js → preview-1652239597845.js} +1 -1
  61. package/schema-node.ts +4 -5
  62. package/schemas/class.ts +19 -0
  63. package/schemas/constructor.ts +19 -0
  64. package/schemas/export.ts +9 -2
  65. package/schemas/function.ts +26 -5
  66. package/schemas/get-accessor.ts +23 -0
  67. package/schemas/index-signature.ts +22 -0
  68. package/schemas/index.ts +12 -1
  69. package/schemas/interface.ts +17 -0
  70. package/schemas/module.ts +36 -7
  71. package/schemas/set-accessor.ts +23 -0
  72. package/schemas/type-intersection.ts +14 -0
  73. package/schemas/type-literal.ts +17 -0
  74. package/schemas/type-ref.ts +20 -0
  75. package/schemas/type-union.ts +14 -0
  76. package/schemas/type.ts +17 -0
  77. package/schemas/variable.ts +23 -0
  78. package/dist/semantic-schema.d.ts +0 -12
  79. package/dist/semantic-schema.js +0 -17
  80. package/dist/semantic-schema.js.map +0 -1
  81. package/package-tar/teambit-semantics.entities.semantic-schema-0.0.7.tgz +0 -0
  82. package/semantic-schema.ts +0 -20
package/api-schema.ts ADDED
@@ -0,0 +1,56 @@
1
+ import chalk from 'chalk';
2
+ import { ClassSchema, Export, FunctionSchema, InterfaceSchema, Module, TypeSchema, VariableSchema } from './schemas';
3
+ import { SchemaNode } from './schema-node';
4
+
5
+ export type PlainSemanticSchema = {
6
+ exports?: Export[];
7
+ };
8
+
9
+ export class APISchema implements SchemaNode {
10
+ constructor(readonly module: Module) {}
11
+
12
+ toString() {
13
+ return JSON.stringify(
14
+ this.module.exports.map((exp) => exp.toObject()),
15
+ undefined,
16
+ 2
17
+ );
18
+ }
19
+
20
+ toObject() {
21
+ return {
22
+ constructorName: this.constructor.name,
23
+ module: this.module.toObject(),
24
+ filename: '',
25
+ };
26
+ }
27
+
28
+ toStringPerType() {
29
+ const getSection = (ClassObj, sectionName: string) => {
30
+ const objects = this.module.exports.filter((exp) => exp instanceof ClassObj);
31
+ if (!objects.length) {
32
+ return '';
33
+ }
34
+ return `${chalk.green.bold(sectionName)}\n${objects.map((c) => c.toString()).join('\n')}\n\n`;
35
+ };
36
+
37
+ return (
38
+ getSection(Module, 'Namespaces') +
39
+ getSection(ClassSchema, 'Classes') +
40
+ getSection(InterfaceSchema, 'Interfaces') +
41
+ getSection(FunctionSchema, 'Functions') +
42
+ getSection(VariableSchema, 'Variables') +
43
+ getSection(TypeSchema, 'Types')
44
+ );
45
+ }
46
+
47
+ listSignatures() {
48
+ return this.module.exports.map((exp) => exp.getSignature?.());
49
+ }
50
+
51
+ static fromSchema() {}
52
+
53
+ // static from(plainSchema: PlainSemanticSchema) {
54
+ // return new APISchema(plainSchema.exports);
55
+ // }
56
+ }
@@ -0,0 +1,24 @@
1
+ import { Export, Module } from './schemas';
2
+ import { SchemaNode } from './schema-node';
3
+ export declare type PlainSemanticSchema = {
4
+ exports?: Export[];
5
+ };
6
+ export declare class APISchema implements SchemaNode {
7
+ readonly module: Module;
8
+ constructor(module: Module);
9
+ toString(): string;
10
+ toObject(): {
11
+ constructorName: string;
12
+ module: {
13
+ constructorName: string;
14
+ namespace: string;
15
+ exports: (Record<string, any> & {
16
+ constructorName: string;
17
+ })[];
18
+ };
19
+ filename: string;
20
+ };
21
+ toStringPerType(): string;
22
+ listSignatures(): string[];
23
+ static fromSchema(): void;
24
+ }
@@ -0,0 +1,44 @@
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.APISchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const schemas_1 = require("./schemas");
9
+ class APISchema {
10
+ constructor(module) {
11
+ this.module = module;
12
+ }
13
+ toString() {
14
+ return JSON.stringify(this.module.exports.map((exp) => exp.toObject()), undefined, 2);
15
+ }
16
+ toObject() {
17
+ return {
18
+ constructorName: this.constructor.name,
19
+ module: this.module.toObject(),
20
+ filename: '',
21
+ };
22
+ }
23
+ toStringPerType() {
24
+ const getSection = (ClassObj, sectionName) => {
25
+ const objects = this.module.exports.filter((exp) => exp instanceof ClassObj);
26
+ if (!objects.length) {
27
+ return '';
28
+ }
29
+ return `${chalk_1.default.green.bold(sectionName)}\n${objects.map((c) => c.toString()).join('\n')}\n\n`;
30
+ };
31
+ return (getSection(schemas_1.Module, 'Namespaces') +
32
+ getSection(schemas_1.ClassSchema, 'Classes') +
33
+ getSection(schemas_1.InterfaceSchema, 'Interfaces') +
34
+ getSection(schemas_1.FunctionSchema, 'Functions') +
35
+ getSection(schemas_1.VariableSchema, 'Variables') +
36
+ getSection(schemas_1.TypeSchema, 'Types'));
37
+ }
38
+ listSignatures() {
39
+ return this.module.exports.map((exp) => { var _a; return (_a = exp.getSignature) === null || _a === void 0 ? void 0 : _a.call(exp); });
40
+ }
41
+ static fromSchema() { }
42
+ }
43
+ exports.APISchema = APISchema;
44
+ //# sourceMappingURL=api-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-schema.js","sourceRoot":"","sources":["../api-schema.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,uCAAqH;AAOrH,MAAa,SAAS;IACpB,YAAqB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAEvC,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CACnB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAChD,SAAS,EACT,CAAC,CACF,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC9B,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,eAAe;QACb,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,WAAmB,EAAE,EAAE;YACnD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,YAAY,QAAQ,CAAC,CAAC;YAC7E,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;gBACnB,OAAO,EAAE,CAAC;aACX;YACD,OAAO,GAAG,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAChG,CAAC,CAAC;QAEF,OAAO,CACL,UAAU,CAAC,gBAAM,EAAE,YAAY,CAAC;YAChC,UAAU,CAAC,qBAAW,EAAE,SAAS,CAAC;YAClC,UAAU,CAAC,yBAAe,EAAE,YAAY,CAAC;YACzC,UAAU,CAAC,wBAAc,EAAE,WAAW,CAAC;YACvC,UAAU,CAAC,wBAAc,EAAE,WAAW,CAAC;YACvC,UAAU,CAAC,oBAAU,EAAE,OAAO,CAAC,CAChC,CAAC;IACJ,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAC,OAAA,MAAA,GAAG,CAAC,YAAY,+CAAhB,GAAG,CAAiB,CAAA,EAAA,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,UAAU,KAAI,CAAC;CAKvB;AA/CD,8BA+CC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { SemanticSchema } from './semantic-schema';
1
+ export { APISchema } from './api-schema';
2
2
  export type { SchemaNode } from './schema-node';
3
- export { Export, Module, StaticProperties, FunctionSchema, TypeRefSchema } from './schemas';
3
+ export { Export, Module, StaticProperties, FunctionSchema, Parameter, TypeRefSchema, VariableSchema, ClassSchema, ConstructorSchema, TypeSchema, TypeIntersectionSchema, TypeUnionSchema, TypeLiteralSchema, IndexSignatureSchema, InterfaceSchema, GetAccessorSchema, SetAccessorSchema, } from './schemas';
4
4
  export type { JSONSchema, JSONSchemaObject } from './json-schema';
package/dist/index.js CHANGED
@@ -1,11 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeRefSchema = exports.FunctionSchema = exports.Module = exports.Export = exports.SemanticSchema = void 0;
4
- var semantic_schema_1 = require("./semantic-schema");
5
- Object.defineProperty(exports, "SemanticSchema", { enumerable: true, get: function () { return semantic_schema_1.SemanticSchema; } });
3
+ exports.SetAccessorSchema = exports.GetAccessorSchema = exports.InterfaceSchema = exports.IndexSignatureSchema = exports.TypeLiteralSchema = exports.TypeUnionSchema = exports.TypeIntersectionSchema = exports.TypeSchema = exports.ConstructorSchema = exports.ClassSchema = exports.VariableSchema = exports.TypeRefSchema = exports.FunctionSchema = exports.Module = exports.Export = exports.APISchema = void 0;
4
+ var api_schema_1 = require("./api-schema");
5
+ Object.defineProperty(exports, "APISchema", { enumerable: true, get: function () { return api_schema_1.APISchema; } });
6
6
  var schemas_1 = require("./schemas");
7
7
  Object.defineProperty(exports, "Export", { enumerable: true, get: function () { return schemas_1.Export; } });
8
8
  Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return schemas_1.Module; } });
9
9
  Object.defineProperty(exports, "FunctionSchema", { enumerable: true, get: function () { return schemas_1.FunctionSchema; } });
10
10
  Object.defineProperty(exports, "TypeRefSchema", { enumerable: true, get: function () { return schemas_1.TypeRefSchema; } });
11
+ Object.defineProperty(exports, "VariableSchema", { enumerable: true, get: function () { return schemas_1.VariableSchema; } });
12
+ Object.defineProperty(exports, "ClassSchema", { enumerable: true, get: function () { return schemas_1.ClassSchema; } });
13
+ Object.defineProperty(exports, "ConstructorSchema", { enumerable: true, get: function () { return schemas_1.ConstructorSchema; } });
14
+ Object.defineProperty(exports, "TypeSchema", { enumerable: true, get: function () { return schemas_1.TypeSchema; } });
15
+ Object.defineProperty(exports, "TypeIntersectionSchema", { enumerable: true, get: function () { return schemas_1.TypeIntersectionSchema; } });
16
+ Object.defineProperty(exports, "TypeUnionSchema", { enumerable: true, get: function () { return schemas_1.TypeUnionSchema; } });
17
+ Object.defineProperty(exports, "TypeLiteralSchema", { enumerable: true, get: function () { return schemas_1.TypeLiteralSchema; } });
18
+ Object.defineProperty(exports, "IndexSignatureSchema", { enumerable: true, get: function () { return schemas_1.IndexSignatureSchema; } });
19
+ Object.defineProperty(exports, "InterfaceSchema", { enumerable: true, get: function () { return schemas_1.InterfaceSchema; } });
20
+ Object.defineProperty(exports, "GetAccessorSchema", { enumerable: true, get: function () { return schemas_1.GetAccessorSchema; } });
21
+ Object.defineProperty(exports, "SetAccessorSchema", { enumerable: true, get: function () { return schemas_1.SetAccessorSchema; } });
11
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAEvB,qCAA4F;AAAnF,iGAAA,MAAM,OAAA;AAAE,iGAAA,MAAM,OAAA;AAAoB,yGAAA,cAAc,OAAA;AAAE,wGAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAElB,qCAkBmB;AAjBjB,iGAAA,MAAM,OAAA;AACN,iGAAA,MAAM,OAAA;AAEN,yGAAA,cAAc,OAAA;AAEd,wGAAA,aAAa,OAAA;AACb,yGAAA,cAAc,OAAA;AACd,sGAAA,WAAW,OAAA;AACX,4GAAA,iBAAiB,OAAA;AACjB,qGAAA,UAAU,OAAA;AACV,iHAAA,sBAAsB,OAAA;AACtB,0GAAA,eAAe,OAAA;AACf,4GAAA,iBAAiB,OAAA;AACjB,+GAAA,oBAAoB,OAAA;AACpB,0GAAA,eAAe,OAAA;AACf,4GAAA,iBAAiB,OAAA;AACjB,4GAAA,iBAAiB,OAAA"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * an interface for implmenting a new schema node.
2
+ * an interface for implementing a new schema node.
3
3
  */
4
4
  export interface SchemaNode {
5
+ getSignature?(): string;
5
6
  toString(): string;
6
- /**
7
- * TODO: this should be made mandatory. this is the main serialization method.
8
- */
9
- toObject?(): string;
7
+ toObject(): Record<string, any> & {
8
+ constructorName: string;
9
+ };
10
10
  }
@@ -0,0 +1,14 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ export declare class ClassSchema implements SchemaNode {
3
+ readonly className: string;
4
+ readonly members: SchemaNode[];
5
+ constructor(className: string, members: SchemaNode[]);
6
+ toObject(): {
7
+ constructorName: string;
8
+ name: string;
9
+ members: (Record<string, any> & {
10
+ constructorName: string;
11
+ })[];
12
+ };
13
+ toString(): string;
14
+ }
@@ -1 +1,26 @@
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.ClassSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class ClassSchema {
9
+ constructor(className, members) {
10
+ this.className = className;
11
+ this.members = members;
12
+ }
13
+ toObject() {
14
+ return {
15
+ constructorName: this.constructor.name,
16
+ name: this.className,
17
+ members: this.members.map((member) => member.toObject()),
18
+ };
19
+ }
20
+ toString() {
21
+ const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
22
+ return `${chalk_1.default.bold.underline(this.className)}\n${membersStr}`;
23
+ }
24
+ }
25
+ exports.ClassSchema = ClassSchema;
1
26
  //# sourceMappingURL=class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"class.js","sourceRoot":"","sources":["../../schemas/class.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../schemas/class.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,MAAa,WAAW;IACtB,YAAqB,SAAiB,EAAW,OAAqB;QAAjD,cAAS,GAAT,SAAS,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAE1E,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;SACzD,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3E,OAAO,GAAG,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,UAAU,EAAE,CAAC;IAClE,CAAC;CACF;AAfD,kCAeC"}
@@ -0,0 +1,11 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ import { Parameter } from './function';
3
+ export declare class ConstructorSchema implements SchemaNode {
4
+ readonly args: Parameter[];
5
+ constructor(args: Parameter[]);
6
+ toString(): string;
7
+ toObject(): {
8
+ constructorName: string;
9
+ args: Parameter[];
10
+ };
11
+ }
@@ -0,0 +1,24 @@
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.ConstructorSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class ConstructorSchema {
9
+ constructor(args) {
10
+ this.args = args;
11
+ }
12
+ toString() {
13
+ const argsStr = this.args.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
14
+ return `${chalk_1.default.bold('constructor')}(${argsStr})`;
15
+ }
16
+ toObject() {
17
+ return {
18
+ constructorName: this.constructor.name,
19
+ args: this.args,
20
+ };
21
+ }
22
+ }
23
+ exports.ConstructorSchema = ConstructorSchema;
24
+ //# sourceMappingURL=constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructor.js","sourceRoot":"","sources":["../../schemas/constructor.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,MAAa,iBAAiB;IAC5B,YAAqB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAE1C,QAAQ;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,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;QACzF,OAAO,GAAG,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,OAAO,GAAG,CAAC;IACpD,CAAC;IAED,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF;AAdD,8CAcC"}
@@ -1,7 +1,7 @@
1
1
  import { SchemaNode } from '../schema-node';
2
2
  declare type Primitive = string | number | boolean | null | undefined;
3
3
  export declare type StaticProperties = Map<string, Primitive>;
4
- export declare class Export {
4
+ export declare class Export implements SchemaNode {
5
5
  /**
6
6
  * named export identifier of the module export.
7
7
  */
@@ -9,7 +9,7 @@ export declare class Export {
9
9
  /**
10
10
  * API node.
11
11
  */
12
- readonly node?: SchemaNode;
12
+ readonly nodes?: SchemaNode[];
13
13
  /**
14
14
  * static properties attached to this export
15
15
  * @example
@@ -26,7 +26,7 @@ export declare class Export {
26
26
  /**
27
27
  * API node.
28
28
  */
29
- node?: SchemaNode,
29
+ nodes?: SchemaNode[],
30
30
  /**
31
31
  * static properties attached to this export
32
32
  * @example
@@ -35,5 +35,9 @@ export declare class Export {
35
35
  * hello.count = 3; // <-- static property
36
36
  */
37
37
  staticProperties?: StaticProperties);
38
+ toObject(): {
39
+ constructorName: string;
40
+ identifier: string;
41
+ };
38
42
  }
39
43
  export {};
@@ -10,7 +10,7 @@ class Export {
10
10
  /**
11
11
  * API node.
12
12
  */
13
- node,
13
+ nodes,
14
14
  /**
15
15
  * static properties attached to this export
16
16
  * @example
@@ -20,9 +20,15 @@ class Export {
20
20
  */
21
21
  staticProperties) {
22
22
  this.identifier = identifier;
23
- this.node = node;
23
+ this.nodes = nodes;
24
24
  this.staticProperties = staticProperties;
25
25
  }
26
+ toObject() {
27
+ return {
28
+ constructorName: this.constructor.name,
29
+ identifier: this.identifier,
30
+ };
31
+ }
26
32
  }
27
33
  exports.Export = Export;
28
34
  //# sourceMappingURL=export.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"export.js","sourceRoot":"","sources":["../../schemas/export.ts"],"names":[],"mappings":";;;AAKA,MAAa,MAAM;IACjB;IACE;;OAEG;IACM,UAAkB;IAE3B;;OAEG;IACM,IAAiB;IAE1B;;;;;;OAMG;IACM,gBAAmC;QAdnC,eAAU,GAAV,UAAU,CAAQ;QAKlB,SAAI,GAAJ,IAAI,CAAa;QASjB,qBAAgB,GAAhB,gBAAgB,CAAmB;IAC3C,CAAC;CACL;AArBD,wBAqBC"}
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,16 +1,31 @@
1
1
  import { SchemaNode } from '../schema-node';
2
2
  import { TypeRefSchema } from './type-ref';
3
- export declare type Argument = {
3
+ export declare type Parameter = {
4
4
  name: string;
5
+ type: TypeRefSchema;
5
6
  defaultValue?: any;
6
- description: any;
7
- type: string;
7
+ description?: string;
8
8
  };
9
9
  export declare class FunctionSchema implements SchemaNode {
10
10
  readonly name: string;
11
- readonly args: Argument[];
11
+ readonly params: Parameter[];
12
12
  readonly returnType: TypeRefSchema;
13
- constructor(name: string, args: Argument[], returnType: TypeRefSchema);
13
+ private signature;
14
+ constructor(name: string, params: Parameter[], returnType: TypeRefSchema, signature: string);
14
15
  serialize(): void;
15
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;
16
31
  }
@@ -1,16 +1,37 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.FunctionSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
4
8
  class FunctionSchema {
5
9
  constructor(name,
6
10
  // readonly doc: any,
7
- args, returnType) {
11
+ params, returnType, signature) {
8
12
  this.name = name;
9
- this.args = args;
13
+ this.params = params;
10
14
  this.returnType = returnType;
15
+ this.signature = signature;
11
16
  }
12
17
  serialize() { }
13
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
+ }
14
35
  }
15
36
  exports.FunctionSchema = FunctionSchema;
16
37
  //# sourceMappingURL=function.js.map
@@ -1 +1 @@
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
+ {"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"}
@@ -0,0 +1,21 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ import { TypeRefSchema } from './type-ref';
3
+ export declare class GetAccessorSchema implements SchemaNode {
4
+ private name;
5
+ private type;
6
+ private signature;
7
+ constructor(name: string, type: TypeRefSchema, signature: string);
8
+ getSignature(): string;
9
+ toObject(): {
10
+ constructorName: string;
11
+ name: string;
12
+ type: {
13
+ constructorName: string;
14
+ name: string;
15
+ componentId: import("@teambit/component").ComponentID;
16
+ packageName: string;
17
+ };
18
+ signature: string;
19
+ };
20
+ toString(): string;
21
+ }
@@ -0,0 +1,30 @@
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.GetAccessorSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class GetAccessorSchema {
9
+ constructor(name, type, signature) {
10
+ this.name = name;
11
+ this.type = type;
12
+ this.signature = signature;
13
+ }
14
+ getSignature() {
15
+ return this.signature;
16
+ }
17
+ toObject() {
18
+ return {
19
+ constructorName: this.constructor.name,
20
+ name: this.name,
21
+ type: this.type.toObject(),
22
+ signature: this.signature,
23
+ };
24
+ }
25
+ toString() {
26
+ return `get ${chalk_1.default.bold(this.name)}(): ${this.type.toString()}`;
27
+ }
28
+ }
29
+ exports.GetAccessorSchema = GetAccessorSchema;
30
+ //# sourceMappingURL=get-accessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-accessor.js","sourceRoot":"","sources":["../../schemas/get-accessor.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,MAAa,iBAAiB;IAC5B,YAAoB,IAAY,EAAU,IAAmB,EAAU,SAAiB;QAApE,SAAI,GAAJ,IAAI,CAAQ;QAAU,SAAI,GAAJ,IAAI,CAAe;QAAU,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAC5F,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,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC1B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,OAAO,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IACnE,CAAC;CACF;AAlBD,8CAkBC"}
@@ -0,0 +1,23 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ import { Parameter } from './function';
3
+ import { TypeRefSchema } from './type-ref';
4
+ /**
5
+ * e.g. `{ [key: string]: boolean };`
6
+ * the "[key: string]" is the "parameter", and the "boolean" is the "type".
7
+ */
8
+ export declare class IndexSignatureSchema implements SchemaNode {
9
+ private parameters;
10
+ private type;
11
+ constructor(parameters: Parameter[], type: TypeRefSchema);
12
+ toObject(): {
13
+ constructorName: string;
14
+ parameters: Parameter[];
15
+ type: {
16
+ constructorName: string;
17
+ name: string;
18
+ componentId: import("@teambit/component").ComponentID;
19
+ packageName: string;
20
+ };
21
+ };
22
+ toString(): string;
23
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndexSignatureSchema = void 0;
4
+ /**
5
+ * e.g. `{ [key: string]: boolean };`
6
+ * the "[key: string]" is the "parameter", and the "boolean" is the "type".
7
+ */
8
+ class IndexSignatureSchema {
9
+ constructor(parameters, type) {
10
+ this.parameters = parameters;
11
+ this.type = type;
12
+ }
13
+ toObject() {
14
+ return {
15
+ constructorName: this.constructor.name,
16
+ parameters: this.parameters,
17
+ type: this.type.toObject(),
18
+ };
19
+ }
20
+ toString() {
21
+ const parameters = this.parameters.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
22
+ return `[${parameters}]: ${this.type.toString()}`;
23
+ }
24
+ }
25
+ exports.IndexSignatureSchema = IndexSignatureSchema;
26
+ //# sourceMappingURL=index-signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-signature.js","sourceRoot":"","sources":["../../schemas/index-signature.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,MAAa,oBAAoB;IAC/B,YAAoB,UAAuB,EAAU,IAAmB;QAApD,eAAU,GAAV,UAAU,CAAa;QAAU,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAC5E,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;SAC3B,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,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;QAClG,OAAO,IAAI,UAAU,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpD,CAAC;CACF;AAbD,oDAaC"}
@@ -1,4 +1,15 @@
1
1
  export { Module } from './module';
2
2
  export { Export, StaticProperties } from './export';
3
- export { FunctionSchema } from './function';
3
+ export { FunctionSchema, Parameter } from './function';
4
4
  export { TypeRefSchema } from './type-ref';
5
+ export { VariableSchema } from './variable';
6
+ export { ClassSchema } from './class';
7
+ export { ConstructorSchema } from './constructor';
8
+ export { TypeSchema } from './type';
9
+ export { TypeIntersectionSchema } from './type-intersection';
10
+ export { TypeUnionSchema } from './type-union';
11
+ export { TypeLiteralSchema } from './type-literal';
12
+ export { IndexSignatureSchema } from './index-signature';
13
+ export { InterfaceSchema } from './interface';
14
+ export { GetAccessorSchema } from './get-accessor';
15
+ export { SetAccessorSchema } from './set-accessor';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeRefSchema = exports.FunctionSchema = exports.Export = exports.Module = void 0;
3
+ exports.SetAccessorSchema = exports.GetAccessorSchema = exports.InterfaceSchema = exports.IndexSignatureSchema = exports.TypeLiteralSchema = exports.TypeUnionSchema = exports.TypeIntersectionSchema = exports.TypeSchema = exports.ConstructorSchema = exports.ClassSchema = exports.VariableSchema = exports.TypeRefSchema = exports.FunctionSchema = exports.Export = exports.Module = void 0;
4
4
  var module_1 = require("./module");
5
5
  Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return module_1.Module; } });
6
6
  var export_1 = require("./export");
@@ -9,4 +9,26 @@ var function_1 = require("./function");
9
9
  Object.defineProperty(exports, "FunctionSchema", { enumerable: true, get: function () { return function_1.FunctionSchema; } });
10
10
  var type_ref_1 = require("./type-ref");
11
11
  Object.defineProperty(exports, "TypeRefSchema", { enumerable: true, get: function () { return type_ref_1.TypeRefSchema; } });
12
+ var variable_1 = require("./variable");
13
+ Object.defineProperty(exports, "VariableSchema", { enumerable: true, get: function () { return variable_1.VariableSchema; } });
14
+ var class_1 = require("./class");
15
+ Object.defineProperty(exports, "ClassSchema", { enumerable: true, get: function () { return class_1.ClassSchema; } });
16
+ var constructor_1 = require("./constructor");
17
+ Object.defineProperty(exports, "ConstructorSchema", { enumerable: true, get: function () { return constructor_1.ConstructorSchema; } });
18
+ var type_1 = require("./type");
19
+ Object.defineProperty(exports, "TypeSchema", { enumerable: true, get: function () { return type_1.TypeSchema; } });
20
+ var type_intersection_1 = require("./type-intersection");
21
+ Object.defineProperty(exports, "TypeIntersectionSchema", { enumerable: true, get: function () { return type_intersection_1.TypeIntersectionSchema; } });
22
+ var type_union_1 = require("./type-union");
23
+ Object.defineProperty(exports, "TypeUnionSchema", { enumerable: true, get: function () { return type_union_1.TypeUnionSchema; } });
24
+ var type_literal_1 = require("./type-literal");
25
+ Object.defineProperty(exports, "TypeLiteralSchema", { enumerable: true, get: function () { return type_literal_1.TypeLiteralSchema; } });
26
+ var index_signature_1 = require("./index-signature");
27
+ Object.defineProperty(exports, "IndexSignatureSchema", { enumerable: true, get: function () { return index_signature_1.IndexSignatureSchema; } });
28
+ var interface_1 = require("./interface");
29
+ Object.defineProperty(exports, "InterfaceSchema", { enumerable: true, get: function () { return interface_1.InterfaceSchema; } });
30
+ var get_accessor_1 = require("./get-accessor");
31
+ Object.defineProperty(exports, "GetAccessorSchema", { enumerable: true, get: function () { return get_accessor_1.GetAccessorSchema; } });
32
+ var set_accessor_1 = require("./set-accessor");
33
+ Object.defineProperty(exports, "SetAccessorSchema", { enumerable: true, get: function () { return set_accessor_1.SetAccessorSchema; } });
12
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../schemas/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mCAAoD;AAA3C,gGAAA,MAAM,OAAA;AACf,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uCAA2C;AAAlC,yGAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../schemas/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mCAAoD;AAA3C,gGAAA,MAAM,OAAA;AACf,uCAAuD;AAA9C,0GAAA,cAAc,OAAA;AACvB,uCAA2C;AAAlC,yGAAA,aAAa,OAAA;AACtB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,+BAAoC;AAA3B,kGAAA,UAAU,OAAA;AACnB,yDAA6D;AAApD,2HAAA,sBAAsB,OAAA;AAC/B,2CAA+C;AAAtC,6GAAA,eAAe,OAAA;AACxB,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA;AAC1B,qDAAyD;AAAhD,uHAAA,oBAAoB,OAAA;AAC7B,yCAA8C;AAArC,4GAAA,eAAe,OAAA;AACxB,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA;AAC1B,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ export declare class InterfaceSchema implements SchemaNode {
3
+ private name;
4
+ private members;
5
+ constructor(name: string, members: SchemaNode[]);
6
+ toObject(): {
7
+ constructorName: string;
8
+ name: string;
9
+ types: (Record<string, any> & {
10
+ constructorName: string;
11
+ })[];
12
+ };
13
+ toString(): string;
14
+ }