@teambit/semantics.entities.semantic-schema 0.0.0-e4ef0e951da794f03096a5cc407420f4cde8b878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-schema.ts +167 -0
- package/dist/api-schema.d.ts +36 -0
- package/dist/api-schema.js +171 -0
- package/dist/api-schema.js.map +1 -0
- package/dist/export.d.ts +38 -0
- package/dist/export.js +37 -0
- package/dist/export.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +137 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-node-constructor.d.ts +7 -0
- package/dist/schema-node-constructor.js +3 -0
- package/dist/schema-node-constructor.js.map +1 -0
- package/dist/schema-node.d.ts +51 -0
- package/dist/schema-node.js +67 -0
- package/dist/schema-node.js.map +1 -0
- package/dist/schema-registry.d.ts +17 -0
- package/dist/schema-registry.js +63 -0
- package/dist/schema-registry.js.map +1 -0
- package/dist/schemas/array-literal-expression.d.ts +15 -0
- package/dist/schemas/array-literal-expression.js +48 -0
- package/dist/schemas/array-literal-expression.js.map +1 -0
- package/dist/schemas/class.d.ts +59 -0
- package/dist/schemas/class.js +126 -0
- package/dist/schemas/class.js.map +1 -0
- package/dist/schemas/conditional-type.d.ts +25 -0
- package/dist/schemas/conditional-type.js +67 -0
- package/dist/schemas/conditional-type.js.map +1 -0
- package/dist/schemas/constructor.d.ts +9 -0
- package/dist/schemas/constructor.js +51 -0
- package/dist/schemas/constructor.js.map +1 -0
- package/dist/schemas/decorator.d.ts +35 -0
- package/dist/schemas/decorator.js +70 -0
- package/dist/schemas/decorator.js.map +1 -0
- package/dist/schemas/docs/doc.d.ts +30 -0
- package/dist/schemas/docs/doc.js +74 -0
- package/dist/schemas/docs/doc.js.map +1 -0
- package/dist/schemas/docs/index.d.ts +4 -0
- package/dist/schemas/docs/index.js +59 -0
- package/dist/schemas/docs/index.js.map +1 -0
- package/dist/schemas/docs/property-like-tag.d.ts +26 -0
- package/dist/schemas/docs/property-like-tag.js +59 -0
- package/dist/schemas/docs/property-like-tag.js.map +1 -0
- package/dist/schemas/docs/return-tag.d.ts +25 -0
- package/dist/schemas/docs/return-tag.js +55 -0
- package/dist/schemas/docs/return-tag.js.map +1 -0
- package/dist/schemas/docs/tag.d.ts +45 -0
- package/dist/schemas/docs/tag.js +75 -0
- package/dist/schemas/docs/tag.js.map +1 -0
- package/dist/schemas/enum-member.d.ts +36 -0
- package/dist/schemas/enum-member.js +66 -0
- package/dist/schemas/enum-member.js.map +1 -0
- package/dist/schemas/enum.d.ts +37 -0
- package/dist/schemas/enum.js +87 -0
- package/dist/schemas/enum.js.map +1 -0
- package/dist/schemas/export.d.ts +41 -0
- package/dist/schemas/export.js +92 -0
- package/dist/schemas/export.js.map +1 -0
- package/dist/schemas/expression-with-arguments.d.ts +19 -0
- package/dist/schemas/expression-with-arguments.js +59 -0
- package/dist/schemas/expression-with-arguments.js.map +1 -0
- package/dist/schemas/function-like.d.ts +66 -0
- package/dist/schemas/function-like.js +147 -0
- package/dist/schemas/function-like.js.map +1 -0
- package/dist/schemas/get-accessor.d.ts +22 -0
- package/dist/schemas/get-accessor.js +73 -0
- package/dist/schemas/get-accessor.js.map +1 -0
- package/dist/schemas/ignored.d.ts +17 -0
- package/dist/schemas/ignored.js +54 -0
- package/dist/schemas/ignored.js.map +1 -0
- package/dist/schemas/index-signature.d.ts +23 -0
- package/dist/schemas/index-signature.js +65 -0
- package/dist/schemas/index-signature.js.map +1 -0
- package/dist/schemas/index.d.ts +49 -0
- package/dist/schemas/index.js +623 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/indexed-access-type.d.ts +17 -0
- package/dist/schemas/indexed-access-type.js +55 -0
- package/dist/schemas/indexed-access-type.js.map +1 -0
- package/dist/schemas/inference-type.d.ts +22 -0
- package/dist/schemas/inference-type.js +65 -0
- package/dist/schemas/inference-type.js.map +1 -0
- package/dist/schemas/interface.d.ts +49 -0
- package/dist/schemas/interface.js +108 -0
- package/dist/schemas/interface.js.map +1 -0
- package/dist/schemas/keyword-type.d.ts +15 -0
- package/dist/schemas/keyword-type.js +43 -0
- package/dist/schemas/keyword-type.js.map +1 -0
- package/dist/schemas/literal-type.d.ts +15 -0
- package/dist/schemas/literal-type.js +43 -0
- package/dist/schemas/literal-type.js.map +1 -0
- package/dist/schemas/literal-value.d.ts +12 -0
- package/dist/schemas/literal-value.js +41 -0
- package/dist/schemas/literal-value.js.map +1 -0
- package/dist/schemas/module.d.ts +22 -0
- package/dist/schemas/module.js +87 -0
- package/dist/schemas/module.js.map +1 -0
- package/dist/schemas/named-tuple.d.ts +19 -0
- package/dist/schemas/named-tuple.js +53 -0
- package/dist/schemas/named-tuple.js.map +1 -0
- package/dist/schemas/object-literal-expression.d.ts +18 -0
- package/dist/schemas/object-literal-expression.js +52 -0
- package/dist/schemas/object-literal-expression.js.map +1 -0
- package/dist/schemas/parameter.d.ts +27 -0
- package/dist/schemas/parameter.js +95 -0
- package/dist/schemas/parameter.js.map +1 -0
- package/dist/schemas/parenthesized-type.d.ts +21 -0
- package/dist/schemas/parenthesized-type.js +54 -0
- package/dist/schemas/parenthesized-type.js.map +1 -0
- package/dist/schemas/property-assignment.d.ts +37 -0
- package/dist/schemas/property-assignment.js +67 -0
- package/dist/schemas/property-assignment.js.map +1 -0
- package/dist/schemas/set-accessor.d.ts +28 -0
- package/dist/schemas/set-accessor.js +65 -0
- package/dist/schemas/set-accessor.js.map +1 -0
- package/dist/schemas/template-literal-type-span.d.ts +19 -0
- package/dist/schemas/template-literal-type-span.js +53 -0
- package/dist/schemas/template-literal-type-span.js.map +1 -0
- package/dist/schemas/template-literal-type.d.ts +22 -0
- package/dist/schemas/template-literal-type.js +52 -0
- package/dist/schemas/template-literal-type.js.map +1 -0
- package/dist/schemas/this-type.d.ts +12 -0
- package/dist/schemas/this-type.js +37 -0
- package/dist/schemas/this-type.js.map +1 -0
- package/dist/schemas/tuple-type.d.ts +16 -0
- package/dist/schemas/tuple-type.js +47 -0
- package/dist/schemas/tuple-type.js.map +1 -0
- package/dist/schemas/type-array.d.ts +17 -0
- package/dist/schemas/type-array.js +50 -0
- package/dist/schemas/type-array.js.map +1 -0
- package/dist/schemas/type-intersection.d.ts +17 -0
- package/dist/schemas/type-intersection.js +50 -0
- package/dist/schemas/type-intersection.js.map +1 -0
- package/dist/schemas/type-literal.d.ts +18 -0
- package/dist/schemas/type-literal.js +64 -0
- package/dist/schemas/type-literal.js.map +1 -0
- package/dist/schemas/type-operator.d.ts +19 -0
- package/dist/schemas/type-operator.js +53 -0
- package/dist/schemas/type-operator.js.map +1 -0
- package/dist/schemas/type-predicate.d.ts +33 -0
- package/dist/schemas/type-predicate.js +75 -0
- package/dist/schemas/type-predicate.js.map +1 -0
- package/dist/schemas/type-query.d.ts +23 -0
- package/dist/schemas/type-query.js +59 -0
- package/dist/schemas/type-query.js.map +1 -0
- package/dist/schemas/type-ref.d.ts +80 -0
- package/dist/schemas/type-ref.js +159 -0
- package/dist/schemas/type-ref.js.map +1 -0
- package/dist/schemas/type-union.d.ts +17 -0
- package/dist/schemas/type-union.js +56 -0
- package/dist/schemas/type-union.js.map +1 -0
- package/dist/schemas/type.d.ts +23 -0
- package/dist/schemas/type.js +80 -0
- package/dist/schemas/type.js.map +1 -0
- package/dist/schemas/unimplemented-schema.d.ts +14 -0
- package/dist/schemas/unimplemented-schema.js +43 -0
- package/dist/schemas/unimplemented-schema.js.map +1 -0
- package/dist/schemas/unknown-schema.d.ts +18 -0
- package/dist/schemas/unknown-schema.js +47 -0
- package/dist/schemas/unknown-schema.js.map +1 -0
- package/dist/schemas/unresolved-schema.d.ts +14 -0
- package/dist/schemas/unresolved-schema.js +41 -0
- package/dist/schemas/unresolved-schema.js.map +1 -0
- package/dist/schemas/variable-like.d.ts +47 -0
- package/dist/schemas/variable-like.js +95 -0
- package/dist/schemas/variable-like.js.map +1 -0
- package/dist/semantic-schema.docs.md +6 -0
- package/dist/type.d.ts +1 -0
- package/dist/type.js +3 -0
- package/dist/type.js.map +1 -0
- package/dist/unknown-schema-factory.d.ts +4 -0
- package/dist/unknown-schema-factory.js +19 -0
- package/dist/unknown-schema-factory.js.map +1 -0
- package/export.ts +31 -0
- package/index.ts +13 -0
- package/package.json +46 -0
- package/schema-node-constructor.ts +8 -0
- package/schema-node.ts +96 -0
- package/schema-registry.ts +53 -0
- package/schemas/array-literal-expression.ts +33 -0
- package/schemas/class.ts +135 -0
- package/schemas/conditional-type.ts +63 -0
- package/schemas/constructor.ts +28 -0
- package/schemas/decorator.ts +54 -0
- package/schemas/docs/doc.ts +69 -0
- package/schemas/docs/index.ts +4 -0
- package/schemas/docs/property-like-tag.ts +47 -0
- package/schemas/docs/return-tag.ts +44 -0
- package/schemas/docs/tag.ts +66 -0
- package/schemas/enum-member.ts +57 -0
- package/schemas/enum.ts +73 -0
- package/schemas/export.ts +91 -0
- package/schemas/expression-with-arguments.ts +51 -0
- package/schemas/function-like.ts +154 -0
- package/schemas/get-accessor.ts +57 -0
- package/schemas/ignored.ts +43 -0
- package/schemas/index-signature.ts +49 -0
- package/schemas/index.ts +49 -0
- package/schemas/indexed-access-type.ts +47 -0
- package/schemas/inference-type.ts +60 -0
- package/schemas/interface.ts +94 -0
- package/schemas/keyword-type.ts +34 -0
- package/schemas/literal-type.ts +34 -0
- package/schemas/literal-value.ts +32 -0
- package/schemas/module.ts +87 -0
- package/schemas/named-tuple.ts +39 -0
- package/schemas/object-literal-expression.ts +42 -0
- package/schemas/parameter.ts +104 -0
- package/schemas/parenthesized-type.ts +42 -0
- package/schemas/property-assignment.ts +50 -0
- package/schemas/set-accessor.ts +47 -0
- package/schemas/template-literal-type-span.ts +42 -0
- package/schemas/template-literal-type.ts +40 -0
- package/schemas/this-type.ts +27 -0
- package/schemas/tuple-type.ts +35 -0
- package/schemas/type-array.ts +39 -0
- package/schemas/type-intersection.ts +39 -0
- package/schemas/type-literal.ts +60 -0
- package/schemas/type-operator.ts +41 -0
- package/schemas/type-predicate.ts +64 -0
- package/schemas/type-query.ts +49 -0
- package/schemas/type-ref.ts +143 -0
- package/schemas/type-union.ts +41 -0
- package/schemas/type.ts +61 -0
- package/schemas/unimplemented-schema.ts +35 -0
- package/schemas/unknown-schema.ts +38 -0
- package/schemas/unresolved-schema.ts +32 -0
- package/schemas/variable-like.ts +76 -0
- package/semantic-schema.docs.md +6 -0
- package/type.ts +1 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
- package/unknown-schema-factory.ts +10 -0
package/api-schema.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { ComponentID } from '@teambit/component-id';
|
|
3
|
+
import { ExportSchema, ModuleSchema } from './schemas';
|
|
4
|
+
import { SchemaLocation, SchemaNode } from './schema-node';
|
|
5
|
+
import { TagName } from './schemas/docs/tag';
|
|
6
|
+
import { SchemaRegistry } from './schema-registry';
|
|
7
|
+
|
|
8
|
+
export class APISchema extends SchemaNode {
|
|
9
|
+
readonly module: ModuleSchema; // index
|
|
10
|
+
|
|
11
|
+
readonly internals: ModuleSchema[];
|
|
12
|
+
|
|
13
|
+
readonly componentId: ComponentID;
|
|
14
|
+
|
|
15
|
+
readonly taggedModuleExports: SchemaNode[];
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
readonly location: SchemaLocation,
|
|
19
|
+
module: ModuleSchema,
|
|
20
|
+
internals: ModuleSchema[],
|
|
21
|
+
componentId: ComponentID,
|
|
22
|
+
taggedModuleExports: SchemaNode[] = []
|
|
23
|
+
) {
|
|
24
|
+
super();
|
|
25
|
+
this.module = module;
|
|
26
|
+
this.internals = internals;
|
|
27
|
+
this.componentId = componentId;
|
|
28
|
+
taggedModuleExports = (taggedModuleExports.length && taggedModuleExports) || this.listTaggedExports(module);
|
|
29
|
+
this.taggedModuleExports = taggedModuleExports;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
listTaggedExports(module?: ModuleSchema): SchemaNode[] {
|
|
33
|
+
if (!module) return [];
|
|
34
|
+
return module.exports
|
|
35
|
+
.filter((e) => {
|
|
36
|
+
if (ExportSchema.isExportSchema(e)) {
|
|
37
|
+
return e.exportNode.doc?.hasTag(TagName.exports) || e.doc?.hasTag(TagName.exports);
|
|
38
|
+
}
|
|
39
|
+
return e.doc?.hasTag(TagName.exports);
|
|
40
|
+
})
|
|
41
|
+
.map((e) => {
|
|
42
|
+
if (ExportSchema.isExportSchema(e)) {
|
|
43
|
+
return e.exportNode;
|
|
44
|
+
}
|
|
45
|
+
return e;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
toString() {
|
|
50
|
+
return JSON.stringify(
|
|
51
|
+
this.module.exports.map((exp) => exp.toObject()),
|
|
52
|
+
undefined,
|
|
53
|
+
2
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
toStringPerType() {
|
|
58
|
+
const title = chalk.inverse(`API Schema of ${this.componentId.toString()}\n`);
|
|
59
|
+
|
|
60
|
+
const exportGroups = this.module.exports.reduce(
|
|
61
|
+
(acc, exp) => {
|
|
62
|
+
const node = ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;
|
|
63
|
+
|
|
64
|
+
const displayName = node.displaySchemaName;
|
|
65
|
+
|
|
66
|
+
(acc[displayName] = acc[displayName] || []).push(exp);
|
|
67
|
+
return acc;
|
|
68
|
+
},
|
|
69
|
+
{} as { [key: string]: SchemaNode[] }
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const sortedDisplayNames = Object.keys(exportGroups).sort();
|
|
73
|
+
|
|
74
|
+
if (sortedDisplayNames.length === 0) {
|
|
75
|
+
return title;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const sections = sortedDisplayNames.map((displayName) => {
|
|
79
|
+
const exports = exportGroups[displayName];
|
|
80
|
+
const sectionBody = exports.map((c) => c.toString({ color: true })).join('\n');
|
|
81
|
+
|
|
82
|
+
return `${chalk.green.bold(displayName)}\n${sectionBody}`;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return title + sections.join('\n\n') + '\n\n';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
toFullSignature(options: { showDocs?: boolean; showTitles?: boolean } = { showDocs: true }): string {
|
|
89
|
+
const title = `API Schema of ${this.componentId.toString()}\n\n`;
|
|
90
|
+
|
|
91
|
+
const exportGroups: { [key: string]: SchemaNode[] } = {};
|
|
92
|
+
|
|
93
|
+
for (const exp of this.module.exports) {
|
|
94
|
+
const node = ExportSchema.isExportSchema(exp) ? exp.exportNode : exp;
|
|
95
|
+
const constructorName = node.constructor.name;
|
|
96
|
+
|
|
97
|
+
if (!exportGroups[constructorName]) {
|
|
98
|
+
exportGroups[constructorName] = [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
exportGroups[constructorName].push(exp);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let output = options.showTitles ? title : '';
|
|
105
|
+
|
|
106
|
+
for (const [sectionName, exports] of Object.entries(exportGroups)) {
|
|
107
|
+
const readableSectionName = options.showTitles ? this.getReadableSectionName(sectionName) : '';
|
|
108
|
+
|
|
109
|
+
output += `${readableSectionName}\n\n`;
|
|
110
|
+
|
|
111
|
+
const sectionBody = exports.map((exp) => exp.toFullSignature(options)).join('\n\n');
|
|
112
|
+
|
|
113
|
+
output += `${sectionBody}\n\n`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return output.trim();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private getReadableSectionName(constructorName: string): string {
|
|
120
|
+
const sectionNameMap: { [key: string]: string } = {
|
|
121
|
+
ModuleSchema: 'Namespaces',
|
|
122
|
+
ClassSchema: 'Classes',
|
|
123
|
+
InterfaceSchema: 'Interfaces',
|
|
124
|
+
FunctionLikeSchema: 'Functions',
|
|
125
|
+
VariableLikeSchema: 'Variables',
|
|
126
|
+
TypeSchema: 'Types',
|
|
127
|
+
EnumSchema: 'Enums',
|
|
128
|
+
TypeRefSchema: 'Type References',
|
|
129
|
+
UnresolvedSchema: 'Unresolved',
|
|
130
|
+
ReactSchema: 'React Components',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return sectionNameMap[constructorName] || constructorName;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
listSignatures() {
|
|
137
|
+
return this.module.exports.map((exp) => exp.signature);
|
|
138
|
+
}
|
|
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
|
+
|
|
150
|
+
static fromObject(obj: Record<string, any>): APISchema {
|
|
151
|
+
const location: SchemaLocation = obj.location;
|
|
152
|
+
const module: ModuleSchema = ModuleSchema.fromObject(obj.module);
|
|
153
|
+
const internals: ModuleSchema[] = (obj.internals || []).map((i: any) => ModuleSchema.fromObject(i));
|
|
154
|
+
const componentId: ComponentID = ComponentID.fromObject(obj.componentId);
|
|
155
|
+
const taggedModuleExports = (obj.taggedModuleExports || []).map((e: any) => SchemaRegistry.fromObject(e));
|
|
156
|
+
return new APISchema(location, module, internals, componentId, taggedModuleExports);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static empty(componentId: ComponentID) {
|
|
160
|
+
return new APISchema(
|
|
161
|
+
{ filePath: '', line: 0, character: 0 },
|
|
162
|
+
new ModuleSchema({ filePath: '', line: 0, character: 0 }, [], []),
|
|
163
|
+
[],
|
|
164
|
+
componentId
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
import { ModuleSchema } from './schemas';
|
|
3
|
+
import { SchemaLocation, SchemaNode } from './schema-node';
|
|
4
|
+
export declare class APISchema extends SchemaNode {
|
|
5
|
+
readonly location: SchemaLocation;
|
|
6
|
+
readonly module: ModuleSchema;
|
|
7
|
+
readonly internals: ModuleSchema[];
|
|
8
|
+
readonly componentId: ComponentID;
|
|
9
|
+
readonly taggedModuleExports: SchemaNode[];
|
|
10
|
+
constructor(location: SchemaLocation, module: ModuleSchema, internals: ModuleSchema[], componentId: ComponentID, taggedModuleExports?: SchemaNode[]);
|
|
11
|
+
listTaggedExports(module?: ModuleSchema): SchemaNode[];
|
|
12
|
+
toString(): string;
|
|
13
|
+
toStringPerType(): string;
|
|
14
|
+
toFullSignature(options?: {
|
|
15
|
+
showDocs?: boolean;
|
|
16
|
+
showTitles?: boolean;
|
|
17
|
+
}): string;
|
|
18
|
+
private getReadableSectionName;
|
|
19
|
+
listSignatures(): (string | undefined)[];
|
|
20
|
+
toObject(): {
|
|
21
|
+
module: {
|
|
22
|
+
exports: Record<string, any>[];
|
|
23
|
+
internals: Record<string, any>[];
|
|
24
|
+
namespace: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
internals: {
|
|
27
|
+
exports: Record<string, any>[];
|
|
28
|
+
internals: Record<string, any>[];
|
|
29
|
+
namespace: string | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
componentId: import("@teambit/component-id").ComponentIdObj;
|
|
32
|
+
taggedModuleExports: Record<string, any>[];
|
|
33
|
+
};
|
|
34
|
+
static fromObject(obj: Record<string, any>): APISchema;
|
|
35
|
+
static empty(componentId: ComponentID): APISchema;
|
|
36
|
+
}
|
|
@@ -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 { SchemaLocation, 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;AACA,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;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,gBAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,eAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAmD,SAAAC,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5C,MAAMG,SAAS,SAASC,wBAAU,CAAC;EACT;;EAQ/BC,WAAWA,CACAC,QAAwB,EACjCC,MAAoB,EACpBC,S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BAAW,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":[]}
|
package/dist/export.d.ts
ADDED
|
@@ -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":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -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;EAA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AAA,CAAAC,IAAA,CAAAa,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAzB,MAAA,CAAAQ,cAAA,KAAAR,MAAA,CAAAgC,wBAAA,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 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["schema-node-constructor.ts"],"sourcesContent":["import { 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":[]}
|