@teambit/semantics.entities.semantic-schema 0.0.5 → 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 (83) 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 +5 -4
  60. package/preview-1652239597845.js +1 -0
  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/tsconfig.json +1 -1
  79. package/dist/semantic-schema.d.ts +0 -12
  80. package/dist/semantic-schema.js +0 -17
  81. package/dist/semantic-schema.js.map +0 -1
  82. package/package-tar/teambit-semantics.entities.semantic-schema-0.0.5.tgz +0 -0
  83. package/semantic-schema.ts +0 -20
@@ -0,0 +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.InterfaceSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class InterfaceSchema {
9
+ constructor(name, members) {
10
+ this.name = name;
11
+ this.members = members;
12
+ }
13
+ toObject() {
14
+ return {
15
+ constructorName: this.constructor.name,
16
+ name: this.name,
17
+ types: this.members.map((type) => type.toObject()),
18
+ };
19
+ }
20
+ toString() {
21
+ const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
22
+ return `${chalk_1.default.bold.underline(this.name)}\n${membersStr}`;
23
+ }
24
+ }
25
+ exports.InterfaceSchema = InterfaceSchema;
26
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../schemas/interface.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,MAAa,eAAe;IAC1B,YAAoB,IAAY,EAAU,OAAqB;QAA3C,SAAI,GAAJ,IAAI,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IACnE,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC;IACD,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,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;IAC7D,CAAC;CACF;AAbD,0CAaC"}
@@ -1,13 +1,17 @@
1
- import { Export } from './export';
2
1
  import { SchemaNode } from '../schema-node';
2
+ import { Export } from '../schemas';
3
3
  export declare class Module implements SchemaNode {
4
- /**
5
- * all module exports.
6
- */
7
- readonly exports: Export[];
8
- constructor(
9
- /**
10
- * all module exports.
11
- */
12
- exports: Export[]);
4
+ exports: SchemaNode[];
5
+ namespace?: string;
6
+ constructor(exports: SchemaNode[]);
7
+ getExportSchemas(): Export[];
8
+ toObject(): {
9
+ constructorName: string;
10
+ namespace: string;
11
+ exports: (Record<string, any> & {
12
+ constructorName: string;
13
+ })[];
14
+ };
15
+ flatExportsRecursively(): void;
16
+ toString(): string;
13
17
  }
@@ -1,14 +1,42 @@
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.Module = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const schemas_1 = require("../schemas");
4
9
  class Module {
5
- constructor(
6
- /**
7
- * all module exports.
8
- */
9
- exports) {
10
+ constructor(exports) {
10
11
  this.exports = exports;
11
12
  }
13
+ getExportSchemas() {
14
+ return this.exports.filter((e) => e instanceof schemas_1.Export);
15
+ }
16
+ toObject() {
17
+ return {
18
+ constructorName: this.constructor.name,
19
+ namespace: this.namespace,
20
+ exports: this.exports.map((exp) => exp.toObject()),
21
+ };
22
+ }
23
+ flatExportsRecursively() {
24
+ this.exports = this.exports.reduce((acc, exp) => {
25
+ if (exp instanceof Module) {
26
+ exp.flatExportsRecursively();
27
+ if (exp.namespace)
28
+ return [...acc, exp];
29
+ return [...acc, ...exp.exports];
30
+ }
31
+ return [...acc, exp];
32
+ }, []);
33
+ }
34
+ toString() {
35
+ if (!this.namespace)
36
+ throw new Error('toString() should not be called on a module without namespace, make sure this.flatExportsRecursively() is called');
37
+ const exportsStr = this.exports.map((m) => `* ${m.toString()}`).join('\n');
38
+ return `${chalk_1.default.bold.underline(this.namespace)}\n${exportsStr}`;
39
+ }
12
40
  }
13
41
  exports.Module = Module;
14
42
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../schemas/module.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;IACjB;IACE;;OAEG;IACM,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IACzB,CAAC;CACL;AAPD,wBAOC"}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../schemas/module.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wCAAoC;AAEpC,MAAa,MAAM;IAEjB,YAAmB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAE5C,gBAAgB;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,gBAAM,CAAa,CAAC;IACrE,CAAC;IAED,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC;IAED,sBAAsB;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC9C,IAAI,GAAG,YAAY,MAAM,EAAE;gBACzB,GAAG,CAAC,sBAAsB,EAAE,CAAC;gBAC7B,IAAI,GAAG,CAAC,SAAS;oBAAE,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;gBACxC,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;aACjC;YACD,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC,EAAE,EAAkB,CAAC,CAAC;IACzB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,MAAM,IAAI,KAAK,CACb,kHAAkH,CACnH,CAAC;QACJ,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;AAnCD,wBAmCC"}
@@ -0,0 +1,16 @@
1
+ import { Parameter } from '.';
2
+ import { SchemaNode } from '../schema-node';
3
+ export declare class SetAccessorSchema implements SchemaNode {
4
+ private name;
5
+ private param;
6
+ private signature;
7
+ constructor(name: string, param: Parameter, signature: string);
8
+ getSignature(): string;
9
+ toObject(): {
10
+ constructorName: string;
11
+ name: string;
12
+ param: Parameter;
13
+ signature: string;
14
+ };
15
+ toString(): string;
16
+ }
@@ -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.SetAccessorSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class SetAccessorSchema {
9
+ constructor(name, param, signature) {
10
+ this.name = name;
11
+ this.param = param;
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
+ param: this.param,
22
+ signature: this.signature,
23
+ };
24
+ }
25
+ toString() {
26
+ return `set ${chalk_1.default.bold(this.name)}(${this.param.name}: ${this.param.type})`;
27
+ }
28
+ }
29
+ exports.SetAccessorSchema = SetAccessorSchema;
30
+ //# sourceMappingURL=set-accessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-accessor.js","sourceRoot":"","sources":["../../schemas/set-accessor.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,MAAa,iBAAiB;IAC5B,YAAoB,IAAY,EAAU,KAAgB,EAAU,SAAiB;QAAjE,SAAI,GAAJ,IAAI,CAAQ;QAAU,UAAK,GAAL,KAAK,CAAW;QAAU,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IACzF,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,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,OAAO,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC;IAChF,CAAC;CACF;AAlBD,8CAkBC"}
@@ -0,0 +1,12 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ export declare class TypeIntersectionSchema implements SchemaNode {
3
+ private types;
4
+ constructor(types: SchemaNode[]);
5
+ toObject(): {
6
+ constructorName: string;
7
+ types: (Record<string, any> & {
8
+ constructorName: string;
9
+ })[];
10
+ };
11
+ toString(): string;
12
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeIntersectionSchema = void 0;
4
+ class TypeIntersectionSchema {
5
+ constructor(types) {
6
+ this.types = types;
7
+ }
8
+ toObject() {
9
+ return {
10
+ constructorName: this.constructor.name,
11
+ types: this.types.map((type) => type.toObject()),
12
+ };
13
+ }
14
+ toString() {
15
+ return `${this.types.map((type) => type.toString()).join(' & ')}`;
16
+ }
17
+ }
18
+ exports.TypeIntersectionSchema = TypeIntersectionSchema;
19
+ //# sourceMappingURL=type-intersection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-intersection.js","sourceRoot":"","sources":["../../schemas/type-intersection.ts"],"names":[],"mappings":";;;AAEA,MAAa,sBAAsB;IACjC,YAAoB,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAC3C,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACpE,CAAC;CACF;AAXD,wDAWC"}
@@ -0,0 +1,15 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ /**
3
+ * e.g. `{ a: string; b: number }`
4
+ */
5
+ export declare class TypeLiteralSchema implements SchemaNode {
6
+ private members;
7
+ constructor(members: SchemaNode[]);
8
+ toObject(): {
9
+ constructorName: string;
10
+ types: (Record<string, any> & {
11
+ constructorName: string;
12
+ })[];
13
+ };
14
+ toString(): string;
15
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeLiteralSchema = void 0;
4
+ /**
5
+ * e.g. `{ a: string; b: number }`
6
+ */
7
+ class TypeLiteralSchema {
8
+ constructor(members) {
9
+ this.members = members;
10
+ }
11
+ toObject() {
12
+ return {
13
+ constructorName: this.constructor.name,
14
+ types: this.members.map((type) => type.toObject()),
15
+ };
16
+ }
17
+ toString() {
18
+ return `{ ${this.members.map((type) => type.toString()).join('; ')} }`;
19
+ }
20
+ }
21
+ exports.TypeLiteralSchema = TypeLiteralSchema;
22
+ //# sourceMappingURL=type-literal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-literal.js","sourceRoot":"","sources":["../../schemas/type-literal.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,iBAAiB;IAC5B,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAC7C,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACzE,CAAC;CACF;AAXD,8CAWC"}
@@ -33,5 +33,12 @@ export declare class TypeRefSchema implements SchemaNode {
33
33
  * target package name. existing if type is defined in different package.
34
34
  */
35
35
  packageName?: string, node?: SchemaNode);
36
+ toObject(): {
37
+ constructorName: string;
38
+ name: string;
39
+ componentId: ComponentID;
40
+ packageName: string;
41
+ };
42
+ toString(): string;
36
43
  static from(plainSchema: PlainTypeRefSchema): TypeRefSchema;
37
44
  }
@@ -1,7 +1,11 @@
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.TypeRefSchema = void 0;
4
7
  const component_1 = require("@teambit/component");
8
+ const chalk_1 = __importDefault(require("chalk"));
5
9
  class TypeRefSchema {
6
10
  constructor(
7
11
  /**
@@ -21,6 +25,23 @@ class TypeRefSchema {
21
25
  this.packageName = packageName;
22
26
  this.node = node;
23
27
  }
28
+ toObject() {
29
+ return {
30
+ constructorName: this.constructor.name,
31
+ name: this.name,
32
+ componentId: this.componentId,
33
+ packageName: this.packageName,
34
+ };
35
+ }
36
+ toString() {
37
+ if (this.componentId) {
38
+ return `${this.componentId}/${this.name}`;
39
+ }
40
+ if (this.packageName) {
41
+ return `${chalk_1.default.dim(this.packageName)}/${this.name}`;
42
+ }
43
+ return this.name;
44
+ }
24
45
  static from(plainSchema) {
25
46
  return new TypeRefSchema(plainSchema.name, plainSchema.componentId ? component_1.ComponentID.fromString(plainSchema.componentId) : undefined, plainSchema.packageName, plainSchema.node);
26
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"type-ref.js","sourceRoot":"","sources":["../../schemas/type-ref.ts"],"names":[],"mappings":";;;AAAA,kDAAiD;AAUjD,MAAa,aAAa;IACxB;IACE;;OAEG;IACM,IAAY;IAErB;;OAEG;IACM,WAAyB;IAElC;;OAEG;IACM,WAAoB,EAEpB,IAAiB;QAZjB,SAAI,GAAJ,IAAI,CAAQ;QAKZ,gBAAW,GAAX,WAAW,CAAc;QAKzB,gBAAW,GAAX,WAAW,CAAS;QAEpB,SAAI,GAAJ,IAAI,CAAa;IACzB,CAAC;IAEJ,MAAM,CAAC,IAAI,CAAC,WAA+B;QACzC,OAAO,IAAI,aAAa,CACtB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,uBAAW,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,EACrF,WAAW,CAAC,WAAW,EACvB,WAAW,CAAC,IAAI,CACjB,CAAC;IACJ,CAAC;CACF;AA5BD,sCA4BC"}
1
+ {"version":3,"file":"type-ref.js","sourceRoot":"","sources":["../../schemas/type-ref.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiD;AACjD,kDAA0B;AAU1B,MAAa,aAAa;IACxB;IACE;;OAEG;IACM,IAAY;IAErB;;OAEG;IACM,WAAyB;IAElC;;OAEG;IACM,WAAoB,EAEpB,IAAiB;QAZjB,SAAI,GAAJ,IAAI,CAAQ;QAKZ,gBAAW,GAAX,WAAW,CAAc;QAKzB,gBAAW,GAAX,WAAW,CAAS;QAEpB,SAAI,GAAJ,IAAI,CAAa;IACzB,CAAC;IAEJ,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;SAC3C;QACD,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO,GAAG,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;SACtD;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,WAA+B;QACzC,OAAO,IAAI,aAAa,CACtB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,uBAAW,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,EACrF,WAAW,CAAC,WAAW,EACvB,WAAW,CAAC,IAAI,CACjB,CAAC;IACJ,CAAC;CACF;AA/CD,sCA+CC"}
@@ -0,0 +1,12 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ export declare class TypeUnionSchema implements SchemaNode {
3
+ private types;
4
+ constructor(types: SchemaNode[]);
5
+ toObject(): {
6
+ constructorName: string;
7
+ types: (Record<string, any> & {
8
+ constructorName: string;
9
+ })[];
10
+ };
11
+ toString(): string;
12
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeUnionSchema = void 0;
4
+ class TypeUnionSchema {
5
+ constructor(types) {
6
+ this.types = types;
7
+ }
8
+ toObject() {
9
+ return {
10
+ constructorName: this.constructor.name,
11
+ types: this.types.map((type) => type.toObject()),
12
+ };
13
+ }
14
+ toString() {
15
+ return `${this.types.map((type) => type.toString()).join(' | ')}`;
16
+ }
17
+ }
18
+ exports.TypeUnionSchema = TypeUnionSchema;
19
+ //# sourceMappingURL=type-union.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-union.js","sourceRoot":"","sources":["../../schemas/type-union.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAC1B,YAAoB,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAC3C,QAAQ;QACN,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC;IACD,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACpE,CAAC;CACF;AAXD,0CAWC"}
@@ -0,0 +1,16 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ export declare class TypeSchema implements SchemaNode {
3
+ private name;
4
+ private type;
5
+ private signature;
6
+ constructor(name: string, type: SchemaNode, signature: string);
7
+ toObject(): {
8
+ constructorName: string;
9
+ name: string;
10
+ type: Record<string, any> & {
11
+ constructorName: string;
12
+ };
13
+ signature: string;
14
+ };
15
+ toString(): string;
16
+ }
@@ -1 +1,27 @@
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.TypeSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class TypeSchema {
9
+ constructor(name, type, signature) {
10
+ this.name = name;
11
+ this.type = type;
12
+ this.signature = signature;
13
+ }
14
+ toObject() {
15
+ return {
16
+ constructorName: this.constructor.name,
17
+ name: this.name,
18
+ type: this.type.toObject(),
19
+ signature: this.signature,
20
+ };
21
+ }
22
+ toString() {
23
+ return `${chalk_1.default.bold(this.name)}: ${this.type.toString()}`;
24
+ }
25
+ }
26
+ exports.TypeSchema = TypeSchema;
1
27
  //# sourceMappingURL=type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../schemas/type.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../schemas/type.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,MAAa,UAAU;IACrB,YAAoB,IAAY,EAAU,IAAgB,EAAU,SAAiB;QAAjE,SAAI,GAAJ,IAAI,CAAQ;QAAU,SAAI,GAAJ,IAAI,CAAY;QAAU,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IACzF,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;IACD,QAAQ;QACN,OAAO,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC7D,CAAC;CACF;AAbD,gCAaC"}
@@ -0,0 +1,21 @@
1
+ import { SchemaNode } from '../schema-node';
2
+ import { TypeRefSchema } from './type-ref';
3
+ export declare class VariableSchema implements SchemaNode {
4
+ readonly name: string;
5
+ private signature;
6
+ private type;
7
+ constructor(name: string, signature: string, type: TypeRefSchema);
8
+ getSignature(): string;
9
+ toObject(): {
10
+ constructorName: string;
11
+ name: string;
12
+ signature: string;
13
+ type: {
14
+ constructorName: string;
15
+ name: string;
16
+ componentId: import("@teambit/component").ComponentID;
17
+ packageName: string;
18
+ };
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.VariableSchema = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class VariableSchema {
9
+ constructor(name, signature, type) {
10
+ this.name = name;
11
+ this.signature = signature;
12
+ this.type = type;
13
+ }
14
+ getSignature() {
15
+ return this.signature;
16
+ }
17
+ toObject() {
18
+ return {
19
+ constructorName: this.constructor.name,
20
+ name: this.name,
21
+ signature: this.signature,
22
+ type: this.type.toObject(),
23
+ };
24
+ }
25
+ toString() {
26
+ return `${chalk_1.default.bold(this.name)}: ${this.type.toString()}`;
27
+ }
28
+ }
29
+ exports.VariableSchema = VariableSchema;
30
+ //# sourceMappingURL=variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable.js","sourceRoot":"","sources":["../../schemas/variable.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,MAAa,cAAc;IACzB,YAAqB,IAAY,EAAU,SAAiB,EAAU,IAAmB;QAApE,SAAI,GAAJ,IAAI,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAQ;QAAU,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAC7F,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,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;SAC3B,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC7D,CAAC;CACF;AAlBD,wCAkBC"}
package/index.ts CHANGED
@@ -1,4 +1,22 @@
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 {
4
+ Export,
5
+ Module,
6
+ StaticProperties,
7
+ FunctionSchema,
8
+ Parameter,
9
+ TypeRefSchema,
10
+ VariableSchema,
11
+ ClassSchema,
12
+ ConstructorSchema,
13
+ TypeSchema,
14
+ TypeIntersectionSchema,
15
+ TypeUnionSchema,
16
+ TypeLiteralSchema,
17
+ IndexSignatureSchema,
18
+ InterfaceSchema,
19
+ GetAccessorSchema,
20
+ SetAccessorSchema,
21
+ } from './schemas';
4
22
  export type { JSONSchema, JSONSchemaObject } from './json-schema';
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@teambit/semantics.entities.semantic-schema",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "homepage": "https://bit.dev/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.5"
9
+ "version": "0.0.8"
10
10
  },
11
11
  "dependencies": {
12
+ "chalk": "4.1.2",
12
13
  "json-schema": "0.4.0"
13
14
  },
14
15
  "devDependencies": {
15
16
  "@types/json-schema": "7.0.9",
16
- "@types/mocha": "5.2.7",
17
+ "@types/mocha": "9.1.0",
17
18
  "@babel/runtime": "7.12.18",
18
19
  "@types/node": "12.20.4",
19
20
  "@types/jest": "26.0.20"
@@ -29,7 +30,7 @@
29
30
  },
30
31
  "devDependencies": {
31
32
  "@teambit/legacy": "-",
32
- "@types/mocha": "5.2.7",
33
+ "@types/mocha": "9.1.0",
33
34
  "@babel/runtime": "7.12.18",
34
35
  "@types/node": "12.20.4",
35
36
  "@types/jest": "26.0.20"
@@ -0,0 +1 @@
1
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.semantics_entities_semantic-schema@0.0.8/dist/semantic-schema.docs.md')]
package/schema-node.ts CHANGED
@@ -1,11 +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;
6
+
5
7
  toString(): string;
6
8
 
7
- /**
8
- * TODO: this should be made mandatory. this is the main serialization method.
9
- */
10
- toObject?(): string;
9
+ toObject(): Record<string, any> & { constructorName: string };
11
10
  }
package/schemas/class.ts CHANGED
@@ -0,0 +1,19 @@
1
+ import chalk from 'chalk';
2
+ import { SchemaNode } from '../schema-node';
3
+
4
+ export class ClassSchema implements SchemaNode {
5
+ constructor(readonly className: string, readonly members: SchemaNode[]) {}
6
+
7
+ toObject() {
8
+ return {
9
+ constructorName: this.constructor.name,
10
+ name: this.className,
11
+ members: this.members.map((member) => member.toObject()),
12
+ };
13
+ }
14
+
15
+ toString() {
16
+ const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
17
+ return `${chalk.bold.underline(this.className)}\n${membersStr}`;
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ import chalk from 'chalk';
2
+ import { SchemaNode } from '../schema-node';
3
+ import { Parameter } from './function';
4
+
5
+ export class ConstructorSchema implements SchemaNode {
6
+ constructor(readonly args: Parameter[]) {}
7
+
8
+ toString() {
9
+ const argsStr = this.args.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
10
+ return `${chalk.bold('constructor')}(${argsStr})`;
11
+ }
12
+
13
+ toObject() {
14
+ return {
15
+ constructorName: this.constructor.name,
16
+ args: this.args,
17
+ };
18
+ }
19
+ }
package/schemas/export.ts CHANGED
@@ -3,7 +3,7 @@ import { SchemaNode } from '../schema-node';
3
3
  type Primitive = string | number | boolean | null | undefined;
4
4
  export type StaticProperties = Map<string, Primitive>;
5
5
 
6
- export class Export {
6
+ export class Export implements SchemaNode {
7
7
  constructor(
8
8
  /**
9
9
  * named export identifier of the module export.
@@ -13,7 +13,7 @@ export class Export {
13
13
  /**
14
14
  * API node.
15
15
  */
16
- readonly node?: SchemaNode,
16
+ readonly nodes?: SchemaNode[],
17
17
 
18
18
  /**
19
19
  * static properties attached to this export
@@ -24,4 +24,11 @@ export class Export {
24
24
  */
25
25
  readonly staticProperties?: StaticProperties
26
26
  ) {}
27
+
28
+ toObject() {
29
+ return {
30
+ constructorName: this.constructor.name,
31
+ identifier: this.identifier,
32
+ };
33
+ }
27
34
  }
@@ -1,23 +1,44 @@
1
+ import chalk from 'chalk';
1
2
  import { SchemaNode } from '../schema-node';
2
3
  import { TypeRefSchema } from './type-ref';
3
4
 
4
- export type Argument = {
5
+ export type Parameter = {
5
6
  name: string;
7
+ type: TypeRefSchema;
6
8
  defaultValue?: any;
7
- description: any;
8
- type: string;
9
+ description?: string;
9
10
  };
10
11
 
11
12
  export class FunctionSchema implements SchemaNode {
12
13
  constructor(
13
14
  readonly name: string,
14
15
  // readonly doc: any,
15
- readonly args: Argument[],
16
+ readonly params: Parameter[],
16
17
 
17
- readonly returnType: TypeRefSchema
18
+ readonly returnType: TypeRefSchema,
19
+ private signature: string
18
20
  ) {}
19
21
 
20
22
  serialize() {}
21
23
 
22
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
+ }
23
44
  }