@teambit/semantics.entities.semantic-schema 0.0.0-1f2fc581386428c6a67d6b518992c0fd9201fe43

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 (233) hide show
  1. package/api-schema.ts +168 -0
  2. package/dist/api-schema.d.ts +37 -0
  3. package/dist/api-schema.js +171 -0
  4. package/dist/api-schema.js.map +1 -0
  5. package/dist/export.d.ts +38 -0
  6. package/dist/export.js +37 -0
  7. package/dist/export.js.map +1 -0
  8. package/dist/index.d.ts +11 -0
  9. package/dist/index.js +137 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/schema-node-constructor.d.ts +7 -0
  12. package/dist/schema-node-constructor.js +3 -0
  13. package/dist/schema-node-constructor.js.map +1 -0
  14. package/dist/schema-node.d.ts +51 -0
  15. package/dist/schema-node.js +67 -0
  16. package/dist/schema-node.js.map +1 -0
  17. package/dist/schema-registry.d.ts +17 -0
  18. package/dist/schema-registry.js +63 -0
  19. package/dist/schema-registry.js.map +1 -0
  20. package/dist/schemas/array-literal-expression.d.ts +16 -0
  21. package/dist/schemas/array-literal-expression.js +48 -0
  22. package/dist/schemas/array-literal-expression.js.map +1 -0
  23. package/dist/schemas/class.d.ts +60 -0
  24. package/dist/schemas/class.js +126 -0
  25. package/dist/schemas/class.js.map +1 -0
  26. package/dist/schemas/conditional-type.d.ts +26 -0
  27. package/dist/schemas/conditional-type.js +67 -0
  28. package/dist/schemas/conditional-type.js.map +1 -0
  29. package/dist/schemas/constructor.d.ts +10 -0
  30. package/dist/schemas/constructor.js +51 -0
  31. package/dist/schemas/constructor.js.map +1 -0
  32. package/dist/schemas/decorator.d.ts +36 -0
  33. package/dist/schemas/decorator.js +70 -0
  34. package/dist/schemas/decorator.js.map +1 -0
  35. package/dist/schemas/docs/doc.d.ts +31 -0
  36. package/dist/schemas/docs/doc.js +74 -0
  37. package/dist/schemas/docs/doc.js.map +1 -0
  38. package/dist/schemas/docs/index.d.ts +4 -0
  39. package/dist/schemas/docs/index.js +59 -0
  40. package/dist/schemas/docs/index.js.map +1 -0
  41. package/dist/schemas/docs/property-like-tag.d.ts +26 -0
  42. package/dist/schemas/docs/property-like-tag.js +59 -0
  43. package/dist/schemas/docs/property-like-tag.js.map +1 -0
  44. package/dist/schemas/docs/return-tag.d.ts +25 -0
  45. package/dist/schemas/docs/return-tag.js +55 -0
  46. package/dist/schemas/docs/return-tag.js.map +1 -0
  47. package/dist/schemas/docs/tag.d.ts +46 -0
  48. package/dist/schemas/docs/tag.js +75 -0
  49. package/dist/schemas/docs/tag.js.map +1 -0
  50. package/dist/schemas/enum-member.d.ts +37 -0
  51. package/dist/schemas/enum-member.js +66 -0
  52. package/dist/schemas/enum-member.js.map +1 -0
  53. package/dist/schemas/enum.d.ts +38 -0
  54. package/dist/schemas/enum.js +87 -0
  55. package/dist/schemas/enum.js.map +1 -0
  56. package/dist/schemas/export.d.ts +42 -0
  57. package/dist/schemas/export.js +92 -0
  58. package/dist/schemas/export.js.map +1 -0
  59. package/dist/schemas/expression-with-arguments.d.ts +20 -0
  60. package/dist/schemas/expression-with-arguments.js +59 -0
  61. package/dist/schemas/expression-with-arguments.js.map +1 -0
  62. package/dist/schemas/function-like.d.ts +67 -0
  63. package/dist/schemas/function-like.js +147 -0
  64. package/dist/schemas/function-like.js.map +1 -0
  65. package/dist/schemas/get-accessor.d.ts +23 -0
  66. package/dist/schemas/get-accessor.js +73 -0
  67. package/dist/schemas/get-accessor.js.map +1 -0
  68. package/dist/schemas/ignored.d.ts +18 -0
  69. package/dist/schemas/ignored.js +54 -0
  70. package/dist/schemas/ignored.js.map +1 -0
  71. package/dist/schemas/index-signature.d.ts +24 -0
  72. package/dist/schemas/index-signature.js +65 -0
  73. package/dist/schemas/index-signature.js.map +1 -0
  74. package/dist/schemas/index.d.ts +49 -0
  75. package/dist/schemas/index.js +623 -0
  76. package/dist/schemas/index.js.map +1 -0
  77. package/dist/schemas/indexed-access-type.d.ts +18 -0
  78. package/dist/schemas/indexed-access-type.js +55 -0
  79. package/dist/schemas/indexed-access-type.js.map +1 -0
  80. package/dist/schemas/inference-type.d.ts +23 -0
  81. package/dist/schemas/inference-type.js +65 -0
  82. package/dist/schemas/inference-type.js.map +1 -0
  83. package/dist/schemas/interface.d.ts +50 -0
  84. package/dist/schemas/interface.js +108 -0
  85. package/dist/schemas/interface.js.map +1 -0
  86. package/dist/schemas/keyword-type.d.ts +16 -0
  87. package/dist/schemas/keyword-type.js +43 -0
  88. package/dist/schemas/keyword-type.js.map +1 -0
  89. package/dist/schemas/literal-type.d.ts +16 -0
  90. package/dist/schemas/literal-type.js +43 -0
  91. package/dist/schemas/literal-type.js.map +1 -0
  92. package/dist/schemas/literal-value.d.ts +13 -0
  93. package/dist/schemas/literal-value.js +41 -0
  94. package/dist/schemas/literal-value.js.map +1 -0
  95. package/dist/schemas/module.d.ts +23 -0
  96. package/dist/schemas/module.js +87 -0
  97. package/dist/schemas/module.js.map +1 -0
  98. package/dist/schemas/named-tuple.d.ts +20 -0
  99. package/dist/schemas/named-tuple.js +53 -0
  100. package/dist/schemas/named-tuple.js.map +1 -0
  101. package/dist/schemas/object-literal-expression.d.ts +19 -0
  102. package/dist/schemas/object-literal-expression.js +52 -0
  103. package/dist/schemas/object-literal-expression.js.map +1 -0
  104. package/dist/schemas/parameter.d.ts +28 -0
  105. package/dist/schemas/parameter.js +95 -0
  106. package/dist/schemas/parameter.js.map +1 -0
  107. package/dist/schemas/parenthesized-type.d.ts +22 -0
  108. package/dist/schemas/parenthesized-type.js +54 -0
  109. package/dist/schemas/parenthesized-type.js.map +1 -0
  110. package/dist/schemas/property-assignment.d.ts +38 -0
  111. package/dist/schemas/property-assignment.js +67 -0
  112. package/dist/schemas/property-assignment.js.map +1 -0
  113. package/dist/schemas/set-accessor.d.ts +29 -0
  114. package/dist/schemas/set-accessor.js +65 -0
  115. package/dist/schemas/set-accessor.js.map +1 -0
  116. package/dist/schemas/template-literal-type-span.d.ts +20 -0
  117. package/dist/schemas/template-literal-type-span.js +53 -0
  118. package/dist/schemas/template-literal-type-span.js.map +1 -0
  119. package/dist/schemas/template-literal-type.d.ts +23 -0
  120. package/dist/schemas/template-literal-type.js +52 -0
  121. package/dist/schemas/template-literal-type.js.map +1 -0
  122. package/dist/schemas/this-type.d.ts +13 -0
  123. package/dist/schemas/this-type.js +37 -0
  124. package/dist/schemas/this-type.js.map +1 -0
  125. package/dist/schemas/tuple-type.d.ts +17 -0
  126. package/dist/schemas/tuple-type.js +47 -0
  127. package/dist/schemas/tuple-type.js.map +1 -0
  128. package/dist/schemas/type-array.d.ts +18 -0
  129. package/dist/schemas/type-array.js +50 -0
  130. package/dist/schemas/type-array.js.map +1 -0
  131. package/dist/schemas/type-intersection.d.ts +18 -0
  132. package/dist/schemas/type-intersection.js +50 -0
  133. package/dist/schemas/type-intersection.js.map +1 -0
  134. package/dist/schemas/type-literal.d.ts +19 -0
  135. package/dist/schemas/type-literal.js +64 -0
  136. package/dist/schemas/type-literal.js.map +1 -0
  137. package/dist/schemas/type-operator.d.ts +20 -0
  138. package/dist/schemas/type-operator.js +53 -0
  139. package/dist/schemas/type-operator.js.map +1 -0
  140. package/dist/schemas/type-predicate.d.ts +34 -0
  141. package/dist/schemas/type-predicate.js +75 -0
  142. package/dist/schemas/type-predicate.js.map +1 -0
  143. package/dist/schemas/type-query.d.ts +24 -0
  144. package/dist/schemas/type-query.js +59 -0
  145. package/dist/schemas/type-query.js.map +1 -0
  146. package/dist/schemas/type-ref.d.ts +81 -0
  147. package/dist/schemas/type-ref.js +159 -0
  148. package/dist/schemas/type-ref.js.map +1 -0
  149. package/dist/schemas/type-union.d.ts +18 -0
  150. package/dist/schemas/type-union.js +56 -0
  151. package/dist/schemas/type-union.js.map +1 -0
  152. package/dist/schemas/type.d.ts +24 -0
  153. package/dist/schemas/type.js +80 -0
  154. package/dist/schemas/type.js.map +1 -0
  155. package/dist/schemas/unimplemented-schema.d.ts +15 -0
  156. package/dist/schemas/unimplemented-schema.js +43 -0
  157. package/dist/schemas/unimplemented-schema.js.map +1 -0
  158. package/dist/schemas/unknown-schema.d.ts +19 -0
  159. package/dist/schemas/unknown-schema.js +47 -0
  160. package/dist/schemas/unknown-schema.js.map +1 -0
  161. package/dist/schemas/unresolved-schema.d.ts +15 -0
  162. package/dist/schemas/unresolved-schema.js +41 -0
  163. package/dist/schemas/unresolved-schema.js.map +1 -0
  164. package/dist/schemas/variable-like.d.ts +48 -0
  165. package/dist/schemas/variable-like.js +95 -0
  166. package/dist/schemas/variable-like.js.map +1 -0
  167. package/dist/semantic-schema.docs.md +6 -0
  168. package/dist/type.d.ts +1 -0
  169. package/dist/type.js +3 -0
  170. package/dist/type.js.map +1 -0
  171. package/dist/unknown-schema-factory.d.ts +4 -0
  172. package/dist/unknown-schema-factory.js +19 -0
  173. package/dist/unknown-schema-factory.js.map +1 -0
  174. package/export.ts +31 -0
  175. package/index.ts +13 -0
  176. package/package.json +52 -0
  177. package/schema-node-constructor.ts +8 -0
  178. package/schema-node.ts +96 -0
  179. package/schema-registry.ts +53 -0
  180. package/schemas/array-literal-expression.ts +34 -0
  181. package/schemas/class.ts +136 -0
  182. package/schemas/conditional-type.ts +64 -0
  183. package/schemas/constructor.ts +29 -0
  184. package/schemas/decorator.ts +55 -0
  185. package/schemas/docs/doc.ts +70 -0
  186. package/schemas/docs/index.ts +4 -0
  187. package/schemas/docs/property-like-tag.ts +47 -0
  188. package/schemas/docs/return-tag.ts +44 -0
  189. package/schemas/docs/tag.ts +67 -0
  190. package/schemas/enum-member.ts +58 -0
  191. package/schemas/enum.ts +74 -0
  192. package/schemas/export.ts +92 -0
  193. package/schemas/expression-with-arguments.ts +52 -0
  194. package/schemas/function-like.ts +155 -0
  195. package/schemas/get-accessor.ts +58 -0
  196. package/schemas/ignored.ts +45 -0
  197. package/schemas/index-signature.ts +50 -0
  198. package/schemas/index.ts +49 -0
  199. package/schemas/indexed-access-type.ts +48 -0
  200. package/schemas/inference-type.ts +61 -0
  201. package/schemas/interface.ts +95 -0
  202. package/schemas/keyword-type.ts +35 -0
  203. package/schemas/literal-type.ts +35 -0
  204. package/schemas/literal-value.ts +33 -0
  205. package/schemas/module.ts +88 -0
  206. package/schemas/named-tuple.ts +40 -0
  207. package/schemas/object-literal-expression.ts +43 -0
  208. package/schemas/parameter.ts +105 -0
  209. package/schemas/parenthesized-type.ts +43 -0
  210. package/schemas/property-assignment.ts +51 -0
  211. package/schemas/set-accessor.ts +48 -0
  212. package/schemas/template-literal-type-span.ts +43 -0
  213. package/schemas/template-literal-type.ts +41 -0
  214. package/schemas/this-type.ts +28 -0
  215. package/schemas/tuple-type.ts +36 -0
  216. package/schemas/type-array.ts +40 -0
  217. package/schemas/type-intersection.ts +40 -0
  218. package/schemas/type-literal.ts +61 -0
  219. package/schemas/type-operator.ts +42 -0
  220. package/schemas/type-predicate.ts +65 -0
  221. package/schemas/type-query.ts +50 -0
  222. package/schemas/type-ref.ts +144 -0
  223. package/schemas/type-union.ts +42 -0
  224. package/schemas/type.ts +62 -0
  225. package/schemas/unimplemented-schema.ts +36 -0
  226. package/schemas/unknown-schema.ts +39 -0
  227. package/schemas/unresolved-schema.ts +33 -0
  228. package/schemas/variable-like.ts +77 -0
  229. package/semantic-schema.docs.md +6 -0
  230. package/type.ts +1 -0
  231. package/types/asset.d.ts +41 -0
  232. package/types/style.d.ts +42 -0
  233. package/unknown-schema-factory.ts +10 -0
package/api-schema.ts ADDED
@@ -0,0 +1,168 @@
1
+ import chalk from 'chalk';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ import { ExportSchema, ModuleSchema } from './schemas';
4
+ import type { SchemaLocation } from './schema-node';
5
+ import { SchemaNode } from './schema-node';
6
+ import { TagName } from './schemas/docs/tag';
7
+ import { SchemaRegistry } from './schema-registry';
8
+
9
+ export class APISchema extends SchemaNode {
10
+ readonly module: ModuleSchema; // index
11
+
12
+ readonly internals: ModuleSchema[];
13
+
14
+ readonly componentId: ComponentID;
15
+
16
+ readonly taggedModuleExports: SchemaNode[];
17
+
18
+ constructor(
19
+ readonly location: SchemaLocation,
20
+ module: ModuleSchema,
21
+ internals: ModuleSchema[],
22
+ componentId: ComponentID,
23
+ taggedModuleExports: SchemaNode[] = []
24
+ ) {
25
+ super();
26
+ this.module = module;
27
+ this.internals = internals;
28
+ this.componentId = componentId;
29
+ taggedModuleExports = (taggedModuleExports.length && taggedModuleExports) || this.listTaggedExports(module);
30
+ this.taggedModuleExports = taggedModuleExports;
31
+ }
32
+
33
+ listTaggedExports(module?: ModuleSchema): SchemaNode[] {
34
+ if (!module) return [];
35
+ return module.exports
36
+ .filter((e) => {
37
+ if (ExportSchema.isExportSchema(e)) {
38
+ return e.exportNode.doc?.hasTag(TagName.exports) || e.doc?.hasTag(TagName.exports);
39
+ }
40
+ return e.doc?.hasTag(TagName.exports);
41
+ })
42
+ .map((e) => {
43
+ if (ExportSchema.isExportSchema(e)) {
44
+ return e.exportNode;
45
+ }
46
+ return e;
47
+ });
48
+ }
49
+
50
+ toString() {
51
+ return JSON.stringify(
52
+ this.module.exports.map((exp) => exp.toObject()),
53
+ undefined,
54
+ 2
55
+ );
56
+ }
57
+
58
+ toStringPerType() {
59
+ const title = chalk.inverse(`API Schema of ${this.componentId.toString()}\n`);
60
+
61
+ const exportGroups = this.module.exports.reduce(
62
+ (acc, exp) => {
63
+ const node = ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;
64
+
65
+ const displayName = node.displaySchemaName;
66
+
67
+ (acc[displayName] = acc[displayName] || []).push(exp);
68
+ return acc;
69
+ },
70
+ {} as { [key: string]: SchemaNode[] }
71
+ );
72
+
73
+ const sortedDisplayNames = Object.keys(exportGroups).sort();
74
+
75
+ if (sortedDisplayNames.length === 0) {
76
+ return title;
77
+ }
78
+
79
+ const sections = sortedDisplayNames.map((displayName) => {
80
+ const exports = exportGroups[displayName];
81
+ const sectionBody = exports.map((c) => c.toString({ color: true })).join('\n');
82
+
83
+ return `${chalk.green.bold(displayName)}\n${sectionBody}`;
84
+ });
85
+
86
+ return title + sections.join('\n\n') + '\n\n';
87
+ }
88
+
89
+ toFullSignature(options: { showDocs?: boolean; showTitles?: boolean } = { showDocs: true }): string {
90
+ const title = `API Schema of ${this.componentId.toString()}\n\n`;
91
+
92
+ const exportGroups: { [key: string]: SchemaNode[] } = {};
93
+
94
+ for (const exp of this.module.exports) {
95
+ const node = ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;
96
+ const constructorName = node.constructor.name;
97
+
98
+ if (!exportGroups[constructorName]) {
99
+ exportGroups[constructorName] = [];
100
+ }
101
+
102
+ exportGroups[constructorName].push(exp);
103
+ }
104
+
105
+ let output = options.showTitles ? title : '';
106
+
107
+ for (const [sectionName, exports] of Object.entries(exportGroups)) {
108
+ const readableSectionName = options.showTitles ? this.getReadableSectionName(sectionName) : '';
109
+
110
+ output += `${readableSectionName}\n\n`;
111
+
112
+ const sectionBody = exports.map((exp) => exp.toFullSignature(options)).join('\n\n');
113
+
114
+ output += `${sectionBody}\n\n`;
115
+ }
116
+
117
+ return output.trim();
118
+ }
119
+
120
+ private getReadableSectionName(constructorName: string): string {
121
+ const sectionNameMap: { [key: string]: string } = {
122
+ ModuleSchema: 'Namespaces',
123
+ ClassSchema: 'Classes',
124
+ InterfaceSchema: 'Interfaces',
125
+ FunctionLikeSchema: 'Functions',
126
+ VariableLikeSchema: 'Variables',
127
+ TypeSchema: 'Types',
128
+ EnumSchema: 'Enums',
129
+ TypeRefSchema: 'Type References',
130
+ UnresolvedSchema: 'Unresolved',
131
+ ReactSchema: 'React Components',
132
+ };
133
+
134
+ return sectionNameMap[constructorName] || constructorName;
135
+ }
136
+
137
+ listSignatures() {
138
+ return this.module.exports.map((exp) => exp.signature);
139
+ }
140
+
141
+ toObject() {
142
+ return {
143
+ ...super.toObject(),
144
+ module: this.module.toObject(),
145
+ internals: this.internals.map((i) => i.toObject()),
146
+ componentId: this.componentId.toObject(),
147
+ taggedModuleExports: this.taggedModuleExports.map((e) => e.toObject()),
148
+ };
149
+ }
150
+
151
+ static fromObject(obj: Record<string, any>): APISchema {
152
+ const location: SchemaLocation = obj.location;
153
+ const module: ModuleSchema = ModuleSchema.fromObject(obj.module);
154
+ const internals: ModuleSchema[] = (obj.internals || []).map((i: any) => ModuleSchema.fromObject(i));
155
+ const componentId: ComponentID = ComponentID.fromObject(obj.componentId);
156
+ const taggedModuleExports = (obj.taggedModuleExports || []).map((e: any) => SchemaRegistry.fromObject(e));
157
+ return new APISchema(location, module, internals, componentId, taggedModuleExports);
158
+ }
159
+
160
+ static empty(componentId: ComponentID) {
161
+ return new APISchema(
162
+ { filePath: '', line: 0, character: 0 },
163
+ new ModuleSchema({ filePath: '', line: 0, character: 0 }, [], []),
164
+ [],
165
+ componentId
166
+ );
167
+ }
168
+ }
@@ -0,0 +1,37 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ import { ModuleSchema } from './schemas';
3
+ import type { SchemaLocation } from './schema-node';
4
+ import { SchemaNode } from './schema-node';
5
+ export declare class APISchema extends SchemaNode {
6
+ readonly location: SchemaLocation;
7
+ readonly module: ModuleSchema;
8
+ readonly internals: ModuleSchema[];
9
+ readonly componentId: ComponentID;
10
+ readonly taggedModuleExports: SchemaNode[];
11
+ constructor(location: SchemaLocation, module: ModuleSchema, internals: ModuleSchema[], componentId: ComponentID, taggedModuleExports?: SchemaNode[]);
12
+ listTaggedExports(module?: ModuleSchema): SchemaNode[];
13
+ toString(): string;
14
+ toStringPerType(): string;
15
+ toFullSignature(options?: {
16
+ showDocs?: boolean;
17
+ showTitles?: boolean;
18
+ }): string;
19
+ private getReadableSectionName;
20
+ listSignatures(): (string | undefined)[];
21
+ toObject(): {
22
+ module: {
23
+ exports: Record<string, any>[];
24
+ internals: Record<string, any>[];
25
+ namespace: string | undefined;
26
+ };
27
+ internals: {
28
+ exports: Record<string, any>[];
29
+ internals: Record<string, any>[];
30
+ namespace: string | undefined;
31
+ }[];
32
+ componentId: import("@teambit/component-id").ComponentIdObj;
33
+ taggedModuleExports: Record<string, any>[];
34
+ };
35
+ static fromObject(obj: Record<string, any>): APISchema;
36
+ static empty(componentId: ComponentID): APISchema;
37
+ }
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.APISchema = void 0;
7
+ function _chalk() {
8
+ const data = _interopRequireDefault(require("chalk"));
9
+ _chalk = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _componentId() {
15
+ const data = require("@teambit/component-id");
16
+ _componentId = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _schemas() {
22
+ const data = require("./schemas");
23
+ _schemas = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _schemaNode() {
29
+ const data = require("./schema-node");
30
+ _schemaNode = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _tag() {
36
+ const data = require("./schemas/docs/tag");
37
+ _tag = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _schemaRegistry() {
43
+ const data = require("./schema-registry");
44
+ _schemaRegistry = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
50
+ class APISchema extends _schemaNode().SchemaNode {
51
+ // index
52
+
53
+ constructor(location, module, internals, componentId, taggedModuleExports = []) {
54
+ super();
55
+ this.location = location;
56
+ this.module = module;
57
+ this.internals = internals;
58
+ this.componentId = componentId;
59
+ taggedModuleExports = taggedModuleExports.length && taggedModuleExports || this.listTaggedExports(module);
60
+ this.taggedModuleExports = taggedModuleExports;
61
+ }
62
+ listTaggedExports(module) {
63
+ if (!module) return [];
64
+ return module.exports.filter(e => {
65
+ if (_schemas().ExportSchema.isExportSchema(e)) {
66
+ return e.exportNode.doc?.hasTag(_tag().TagName.exports) || e.doc?.hasTag(_tag().TagName.exports);
67
+ }
68
+ return e.doc?.hasTag(_tag().TagName.exports);
69
+ }).map(e => {
70
+ if (_schemas().ExportSchema.isExportSchema(e)) {
71
+ return e.exportNode;
72
+ }
73
+ return e;
74
+ });
75
+ }
76
+ toString() {
77
+ return JSON.stringify(this.module.exports.map(exp => exp.toObject()), undefined, 2);
78
+ }
79
+ toStringPerType() {
80
+ const title = _chalk().default.inverse(`API Schema of ${this.componentId.toString()}\n`);
81
+ const exportGroups = this.module.exports.reduce((acc, exp) => {
82
+ const node = _schemas().ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;
83
+ const displayName = node.displaySchemaName;
84
+ (acc[displayName] = acc[displayName] || []).push(exp);
85
+ return acc;
86
+ }, {});
87
+ const sortedDisplayNames = Object.keys(exportGroups).sort();
88
+ if (sortedDisplayNames.length === 0) {
89
+ return title;
90
+ }
91
+ const sections = sortedDisplayNames.map(displayName => {
92
+ const exports = exportGroups[displayName];
93
+ const sectionBody = exports.map(c => c.toString({
94
+ color: true
95
+ })).join('\n');
96
+ return `${_chalk().default.green.bold(displayName)}\n${sectionBody}`;
97
+ });
98
+ return title + sections.join('\n\n') + '\n\n';
99
+ }
100
+ toFullSignature(options = {
101
+ showDocs: true
102
+ }) {
103
+ const title = `API Schema of ${this.componentId.toString()}\n\n`;
104
+ const exportGroups = {};
105
+ for (const exp of this.module.exports) {
106
+ const node = _schemas().ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;
107
+ const constructorName = node.constructor.name;
108
+ if (!exportGroups[constructorName]) {
109
+ exportGroups[constructorName] = [];
110
+ }
111
+ exportGroups[constructorName].push(exp);
112
+ }
113
+ let output = options.showTitles ? title : '';
114
+ for (const [sectionName, exports] of Object.entries(exportGroups)) {
115
+ const readableSectionName = options.showTitles ? this.getReadableSectionName(sectionName) : '';
116
+ output += `${readableSectionName}\n\n`;
117
+ const sectionBody = exports.map(exp => exp.toFullSignature(options)).join('\n\n');
118
+ output += `${sectionBody}\n\n`;
119
+ }
120
+ return output.trim();
121
+ }
122
+ getReadableSectionName(constructorName) {
123
+ const sectionNameMap = {
124
+ ModuleSchema: 'Namespaces',
125
+ ClassSchema: 'Classes',
126
+ InterfaceSchema: 'Interfaces',
127
+ FunctionLikeSchema: 'Functions',
128
+ VariableLikeSchema: 'Variables',
129
+ TypeSchema: 'Types',
130
+ EnumSchema: 'Enums',
131
+ TypeRefSchema: 'Type References',
132
+ UnresolvedSchema: 'Unresolved',
133
+ ReactSchema: 'React Components'
134
+ };
135
+ return sectionNameMap[constructorName] || constructorName;
136
+ }
137
+ listSignatures() {
138
+ return this.module.exports.map(exp => exp.signature);
139
+ }
140
+ toObject() {
141
+ return {
142
+ ...super.toObject(),
143
+ module: this.module.toObject(),
144
+ internals: this.internals.map(i => i.toObject()),
145
+ componentId: this.componentId.toObject(),
146
+ taggedModuleExports: this.taggedModuleExports.map(e => e.toObject())
147
+ };
148
+ }
149
+ static fromObject(obj) {
150
+ const location = obj.location;
151
+ const module = _schemas().ModuleSchema.fromObject(obj.module);
152
+ const internals = (obj.internals || []).map(i => _schemas().ModuleSchema.fromObject(i));
153
+ const componentId = _componentId().ComponentID.fromObject(obj.componentId);
154
+ const taggedModuleExports = (obj.taggedModuleExports || []).map(e => _schemaRegistry().SchemaRegistry.fromObject(e));
155
+ return new APISchema(location, module, internals, componentId, taggedModuleExports);
156
+ }
157
+ static empty(componentId) {
158
+ return new APISchema({
159
+ filePath: '',
160
+ line: 0,
161
+ character: 0
162
+ }, new (_schemas().ModuleSchema)({
163
+ filePath: '',
164
+ line: 0,
165
+ character: 0
166
+ }, [], []), [], componentId);
167
+ }
168
+ }
169
+ exports.APISchema = APISchema;
170
+
171
+ //# sourceMappingURL=api-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentId","_schemas","_schemaNode","_tag","_schemaRegistry","e","__esModule","default","APISchema","SchemaNode","constructor","location","module","internals","componentId","taggedModuleExports","length","listTaggedExports","exports","filter","ExportSchema","isExportSchema","exportNode","doc","hasTag","TagName","map","toString","JSON","stringify","exp","toObject","undefined","toStringPerType","title","chalk","inverse","exportGroups","reduce","acc","node","displayName","displaySchemaName","push","sortedDisplayNames","Object","keys","sort","sections","sectionBody","c","color","join","green","bold","toFullSignature","options","showDocs","constructorName","name","output","showTitles","sectionName","entries","readableSectionName","getReadableSectionName","trim","sectionNameMap","ModuleSchema","ClassSchema","InterfaceSchema","FunctionLikeSchema","VariableLikeSchema","TypeSchema","EnumSchema","TypeRefSchema","UnresolvedSchema","ReactSchema","listSignatures","signature","i","fromObject","obj","ComponentID","SchemaRegistry","empty","filePath","line","character"],"sources":["api-schema.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport { ExportSchema, ModuleSchema } from './schemas';\nimport type { SchemaLocation } from './schema-node';\nimport { SchemaNode } from './schema-node';\nimport { TagName } from './schemas/docs/tag';\nimport { SchemaRegistry } from './schema-registry';\n\nexport class APISchema extends SchemaNode {\n readonly module: ModuleSchema; // index\n\n readonly internals: ModuleSchema[];\n\n readonly componentId: ComponentID;\n\n readonly taggedModuleExports: SchemaNode[];\n\n constructor(\n readonly location: SchemaLocation,\n module: ModuleSchema,\n internals: ModuleSchema[],\n componentId: ComponentID,\n taggedModuleExports: SchemaNode[] = []\n ) {\n super();\n this.module = module;\n this.internals = internals;\n this.componentId = componentId;\n taggedModuleExports = (taggedModuleExports.length && taggedModuleExports) || this.listTaggedExports(module);\n this.taggedModuleExports = taggedModuleExports;\n }\n\n listTaggedExports(module?: ModuleSchema): SchemaNode[] {\n if (!module) return [];\n return module.exports\n .filter((e) => {\n if (ExportSchema.isExportSchema(e)) {\n return e.exportNode.doc?.hasTag(TagName.exports) || e.doc?.hasTag(TagName.exports);\n }\n return e.doc?.hasTag(TagName.exports);\n })\n .map((e) => {\n if (ExportSchema.isExportSchema(e)) {\n return e.exportNode;\n }\n return e;\n });\n }\n\n toString() {\n return JSON.stringify(\n this.module.exports.map((exp) => exp.toObject()),\n undefined,\n 2\n );\n }\n\n toStringPerType() {\n const title = chalk.inverse(`API Schema of ${this.componentId.toString()}\\n`);\n\n const exportGroups = this.module.exports.reduce(\n (acc, exp) => {\n const node = ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;\n\n const displayName = node.displaySchemaName;\n\n (acc[displayName] = acc[displayName] || []).push(exp);\n return acc;\n },\n {} as { [key: string]: SchemaNode[] }\n );\n\n const sortedDisplayNames = Object.keys(exportGroups).sort();\n\n if (sortedDisplayNames.length === 0) {\n return title;\n }\n\n const sections = sortedDisplayNames.map((displayName) => {\n const exports = exportGroups[displayName];\n const sectionBody = exports.map((c) => c.toString({ color: true })).join('\\n');\n\n return `${chalk.green.bold(displayName)}\\n${sectionBody}`;\n });\n\n return title + sections.join('\\n\\n') + '\\n\\n';\n }\n\n toFullSignature(options: { showDocs?: boolean; showTitles?: boolean } = { showDocs: true }): string {\n const title = `API Schema of ${this.componentId.toString()}\\n\\n`;\n\n const exportGroups: { [key: string]: SchemaNode[] } = {};\n\n for (const exp of this.module.exports) {\n const node = ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;\n const constructorName = node.constructor.name;\n\n if (!exportGroups[constructorName]) {\n exportGroups[constructorName] = [];\n }\n\n exportGroups[constructorName].push(exp);\n }\n\n let output = options.showTitles ? title : '';\n\n for (const [sectionName, exports] of Object.entries(exportGroups)) {\n const readableSectionName = options.showTitles ? this.getReadableSectionName(sectionName) : '';\n\n output += `${readableSectionName}\\n\\n`;\n\n const sectionBody = exports.map((exp) => exp.toFullSignature(options)).join('\\n\\n');\n\n output += `${sectionBody}\\n\\n`;\n }\n\n return output.trim();\n }\n\n private getReadableSectionName(constructorName: string): string {\n const sectionNameMap: { [key: string]: string } = {\n ModuleSchema: 'Namespaces',\n ClassSchema: 'Classes',\n InterfaceSchema: 'Interfaces',\n FunctionLikeSchema: 'Functions',\n VariableLikeSchema: 'Variables',\n TypeSchema: 'Types',\n EnumSchema: 'Enums',\n TypeRefSchema: 'Type References',\n UnresolvedSchema: 'Unresolved',\n ReactSchema: 'React Components',\n };\n\n return sectionNameMap[constructorName] || constructorName;\n }\n\n listSignatures() {\n return this.module.exports.map((exp) => exp.signature);\n }\n\n toObject() {\n return {\n ...super.toObject(),\n module: this.module.toObject(),\n internals: this.internals.map((i) => i.toObject()),\n componentId: this.componentId.toObject(),\n taggedModuleExports: this.taggedModuleExports.map((e) => e.toObject()),\n };\n }\n\n static fromObject(obj: Record<string, any>): APISchema {\n const location: SchemaLocation = obj.location;\n const module: ModuleSchema = ModuleSchema.fromObject(obj.module);\n const internals: ModuleSchema[] = (obj.internals || []).map((i: any) => ModuleSchema.fromObject(i));\n const componentId: ComponentID = ComponentID.fromObject(obj.componentId);\n const taggedModuleExports = (obj.taggedModuleExports || []).map((e: any) => SchemaRegistry.fromObject(e));\n return new APISchema(location, module, internals, componentId, taggedModuleExports);\n }\n\n static empty(componentId: ComponentID) {\n return new APISchema(\n { filePath: '', line: 0, character: 0 },\n new ModuleSchema({ filePath: '', line: 0, character: 0 }, [], []),\n [],\n componentId\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,KAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,IAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;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E,CAAC;EACH;EAEA,OAAOkD,UAAUA,CAACC,GAAwB,EAAa;IACrD,MAAMvE,QAAwB,GAAGuE,GAAG,CAACvE,QAAQ;IAC7C,MAAMC,MAAoB,GAAGwD,uBAAY,CAACa,UAAU,CAACC,GAAG,CAACtE,MAAM,CAAC;IAChE,MAAMC,SAAyB,GAAG,CAACqE,GAAG,CAACrE,SAAS,IAAI,EAAE,EAAEa,GAAG,CAAEsD,CAAM,IAAKZ,uBAAY,CAACa,UAAU,CAACD,CAAC,CAAC,CAAC;IACnG,MAAMlE,WAAwB,GAAGqE,0BAAW,CAACF,UAAU,CAACC,GAAG,CAACpE,WAAW,CAAC;IACxE,MAAMC,mBAAmB,GAAG,CAACmE,GAAG,CAACnE,mBAAmB,IAAI,EAAE,EAAEW,GAAG,CAAErB,CAAM,IAAK+E,gCAAc,CAACH,UAAU,CAAC5E,CAAC,CAAC,CAAC;IACzG,OAAO,IAAIG,SAAS,CAACG,QAAQ,EAAEC,MAAM,EAAEC,SAAS,EAAEC,WAAW,EAAEC,mBAAmB,CAAC;EACrF;EAEA,OAAOsE,KAAKA,CAACvE,WAAwB,EAAE;IACrC,OAAO,IAAIN,SAAS,CAClB;MAAE8E,QAAQ,EAAE,EAAE;MAAEC,IAAI,EAAE,CAAC;MAAEC,SAAS,EAAE;IAAE,CAAC,EACvC,KAAIpB,uBAAY,EAAC;MAAEkB,QAAQ,EAAE,EAAE;MAAEC,IAAI,EAAE,CAAC;MAAEC,SAAS,EAAE;IAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EACjE,EAAE,EACF1E,WACF,CAAC;EACH;AACF;AAACI,OAAA,CAAAV,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ type Primitive = string | number | boolean | null | undefined;
2
+ export type StaticProperties = Map<string, Primitive>;
3
+ /**
4
+ * @todo: this was implemented before all other schemas and is used only for composition.
5
+ * it needs to be align with other schemas.
6
+ */
7
+ export declare class Export {
8
+ /**
9
+ * named export identifier of the module export.
10
+ */
11
+ readonly identifier: string;
12
+ /**
13
+ * static properties attached to this export
14
+ * @example
15
+ * export hello = () => {};
16
+ * hello.value = "text"; // <-- staticProperty
17
+ * hello.count = 3; // <-- static property
18
+ */
19
+ readonly staticProperties?: StaticProperties | undefined;
20
+ constructor(
21
+ /**
22
+ * named export identifier of the module export.
23
+ */
24
+ identifier: string,
25
+ /**
26
+ * static properties attached to this export
27
+ * @example
28
+ * export hello = () => {};
29
+ * hello.value = "text"; // <-- staticProperty
30
+ * hello.count = 3; // <-- static property
31
+ */
32
+ staticProperties?: StaticProperties | undefined);
33
+ toObject(): {
34
+ constructorName: string;
35
+ identifier: string;
36
+ };
37
+ }
38
+ export {};
package/dist/export.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Export = void 0;
7
+ /**
8
+ * @todo: this was implemented before all other schemas and is used only for composition.
9
+ * it needs to be align with other schemas.
10
+ */
11
+ class Export {
12
+ constructor(
13
+ /**
14
+ * named export identifier of the module export.
15
+ */
16
+ identifier,
17
+ /**
18
+ * static properties attached to this export
19
+ * @example
20
+ * export hello = () => {};
21
+ * hello.value = "text"; // <-- staticProperty
22
+ * hello.count = 3; // <-- static property
23
+ */
24
+ staticProperties) {
25
+ this.identifier = identifier;
26
+ this.staticProperties = staticProperties;
27
+ }
28
+ toObject() {
29
+ return {
30
+ constructorName: this.constructor.name,
31
+ identifier: this.identifier
32
+ };
33
+ }
34
+ }
35
+ exports.Export = Export;
36
+
37
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Export","constructor","identifier","staticProperties","toObject","constructorName","name","exports"],"sources":["export.ts"],"sourcesContent":["type Primitive = string | number | boolean | null | undefined;\nexport type StaticProperties = Map<string, Primitive>;\n\n/**\n * @todo: this was implemented before all other schemas and is used only for composition.\n * it needs to be align with other schemas.\n */\nexport class Export {\n constructor(\n /**\n * named export identifier of the module export.\n */\n readonly identifier: string,\n\n /**\n * static properties attached to this export\n * @example\n * export hello = () => {};\n * hello.value = \"text\"; // <-- staticProperty\n * hello.count = 3; // <-- static property\n */\n readonly staticProperties?: StaticProperties\n ) {}\n\n toObject() {\n return {\n constructorName: this.constructor.name,\n identifier: this.identifier,\n };\n }\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACO,MAAMA,MAAM,CAAC;EAClBC,WAAWA;EACT;AACJ;AACA;EACaC,UAAkB;EAE3B;AACJ;AACA;AACA;AACA;AACA;AACA;EACaC,gBAAmC,EAC5C;IAAA,KAVSD,UAAkB,GAAlBA,UAAkB;IAAA,KASlBC,gBAAmC,GAAnCA,gBAAmC;EAC3C;EAEHC,QAAQA,CAAA,EAAG;IACT,OAAO;MACLC,eAAe,EAAE,IAAI,CAACJ,WAAW,CAACK,IAAI;MACtCJ,UAAU,EAAE,IAAI,CAACA;IACnB,CAAC;EACH;AACF;AAACK,OAAA,CAAAP,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import * as Schemas from './schemas';
2
+ export { SchemaNode, ISchemaNode } from './schema-node';
3
+ export { APISchema } from './api-schema';
4
+ export { Export, StaticProperties } from './export';
5
+ export type { SchemaLocation as Location } from './schema-node';
6
+ export { TagName } from './schemas/docs/tag';
7
+ export { SchemaRegistry } from './schema-registry';
8
+ export { SchemaNodeConstructor } from './schema-node-constructor';
9
+ export { Modifier } from './schemas/function-like';
10
+ export { Schemas };
11
+ export * from './schemas';
package/dist/index.js ADDED
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ Schemas: true,
8
+ SchemaNode: true,
9
+ ISchemaNode: true,
10
+ APISchema: true,
11
+ Export: true,
12
+ StaticProperties: true,
13
+ TagName: true,
14
+ SchemaRegistry: true,
15
+ SchemaNodeConstructor: true,
16
+ Modifier: true
17
+ };
18
+ Object.defineProperty(exports, "APISchema", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _apiSchema().APISchema;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "Export", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _export().Export;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "ISchemaNode", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _schemaNode().ISchemaNode;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "Modifier", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _functionLike().Modifier;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "SchemaNode", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _schemaNode().SchemaNode;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "SchemaNodeConstructor", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _schemaNodeConstructor().SchemaNodeConstructor;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "SchemaRegistry", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _schemaRegistry().SchemaRegistry;
58
+ }
59
+ });
60
+ exports.Schemas = void 0;
61
+ Object.defineProperty(exports, "StaticProperties", {
62
+ enumerable: true,
63
+ get: function () {
64
+ return _export().StaticProperties;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "TagName", {
68
+ enumerable: true,
69
+ get: function () {
70
+ return _tag().TagName;
71
+ }
72
+ });
73
+ var Schemas = _interopRequireWildcard(require("./schemas"));
74
+ exports.Schemas = Schemas;
75
+ Object.keys(Schemas).forEach(function (key) {
76
+ if (key === "default" || key === "__esModule") return;
77
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
78
+ if (key in exports && exports[key] === Schemas[key]) return;
79
+ Object.defineProperty(exports, key, {
80
+ enumerable: true,
81
+ get: function () {
82
+ return Schemas[key];
83
+ }
84
+ });
85
+ });
86
+ function _schemaNode() {
87
+ const data = require("./schema-node");
88
+ _schemaNode = function () {
89
+ return data;
90
+ };
91
+ return data;
92
+ }
93
+ function _apiSchema() {
94
+ const data = require("./api-schema");
95
+ _apiSchema = function () {
96
+ return data;
97
+ };
98
+ return data;
99
+ }
100
+ function _export() {
101
+ const data = require("./export");
102
+ _export = function () {
103
+ return data;
104
+ };
105
+ return data;
106
+ }
107
+ function _tag() {
108
+ const data = require("./schemas/docs/tag");
109
+ _tag = function () {
110
+ return data;
111
+ };
112
+ return data;
113
+ }
114
+ function _schemaRegistry() {
115
+ const data = require("./schema-registry");
116
+ _schemaRegistry = function () {
117
+ return data;
118
+ };
119
+ return data;
120
+ }
121
+ function _schemaNodeConstructor() {
122
+ const data = require("./schema-node-constructor");
123
+ _schemaNodeConstructor = function () {
124
+ return data;
125
+ };
126
+ return data;
127
+ }
128
+ function _functionLike() {
129
+ const data = require("./schemas/function-like");
130
+ _functionLike = function () {
131
+ return data;
132
+ };
133
+ return data;
134
+ }
135
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
136
+
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Schemas","_interopRequireWildcard","require","exports","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_schemaNode","data","_apiSchema","_export","_tag","_schemaRegistry","_schemaNodeConstructor","_functionLike","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor"],"sources":["index.ts"],"sourcesContent":["import * as Schemas from './schemas';\n\nexport { SchemaNode, ISchemaNode } from './schema-node';\nexport { APISchema } from './api-schema';\nexport { Export, StaticProperties } from './export';\nexport type { SchemaLocation as Location } from './schema-node';\nexport { TagName } from './schemas/docs/tag';\nexport { SchemaRegistry } from './schema-registry';\nexport { SchemaNodeConstructor } from './schema-node-constructor';\nexport { Modifier } from './schemas/function-like';\nexport { Schemas };\n\nexport * from './schemas';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAqCC,OAAA,CAAAH,OAAA,GAAAA,OAAA;AAYrCI,MAAA,CAAAC,IAAA,CAAAL,OAAA,EAAAM,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAJ,OAAA,IAAAA,OAAA,CAAAI,GAAA,MAAAP,OAAA,CAAAO,GAAA;EAAAH,MAAA,CAAAQ,cAAA,CAAAT,OAAA,EAAAI,GAAA;IAAAM,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAd,OAAA,CAAAO,GAAA;IAAA;EAAA;AAAA;AAVA,SAAAQ,YAAA;EAAA,MAAAC,IAAA,GAAAd,OAAA;EAAAa,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAC,WAAA;EAAA,MAAAD,IAAA,GAAAd,OAAA;EAAAe,UAAA,YAAAA,CAAA;IAAA,OAAAD,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAd,OAAA;EAAAgB,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,KAAA;E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,CAAAb,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAhB,GAAA,IAAAgB,CAAA,CAAAK,GAAA,IAAAN,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { SchemaNode } from './schema-node';
2
+ export interface SchemaNodeConstructor {
3
+ new (...args: any[]): SchemaNode;
4
+ readonly prototype: SchemaNode;
5
+ name: string;
6
+ fromObject(obj: Record<string, any>): SchemaNode;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ //# sourceMappingURL=schema-node-constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["schema-node-constructor.ts"],"sourcesContent":["import type { SchemaNode } from './schema-node';\n\nexport interface SchemaNodeConstructor {\n new (...args: any[]): SchemaNode;\n readonly prototype: SchemaNode;\n name: string;\n fromObject(obj: Record<string, any>): SchemaNode;\n}\n"],"mappings":"","ignoreList":[]}