@teambit/schema 0.0.586 → 0.0.590
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/dist/index.d.ts +0 -2
- package/dist/index.js +0 -44
- package/dist/index.js.map +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/schema-extract.task.d.ts +8 -0
- package/dist/schema-extract.task.js +35 -0
- package/dist/schema-extract.task.js.map +1 -0
- package/dist/schema-extractor.d.ts +2 -2
- package/dist/schema.cmd.d.ts +13 -0
- package/dist/schema.cmd.js +57 -0
- package/dist/schema.cmd.js.map +1 -0
- package/dist/schema.graphql.d.ts +1 -3
- package/dist/schema.main.runtime.d.ts +7 -5
- package/dist/schema.main.runtime.js +37 -9
- package/dist/schema.main.runtime.js.map +1 -1
- package/package-tar/teambit-schema-0.0.590.tgz +0 -0
- package/package.json +11 -8
- package/dist/schemas/export.d.ts +0 -30
- package/dist/schemas/export.js +0 -30
- package/dist/schemas/export.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -2
- package/dist/schemas/index.js +0 -45
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/module.d.ts +0 -12
- package/dist/schemas/module.js +0 -21
- package/dist/schemas/module.js.map +0 -1
- package/dist/semantic-schema.d.ts +0 -6
- package/dist/semantic-schema.js +0 -3
- package/dist/semantic-schema.js.map +0 -1
- package/package-tar/teambit-schema-0.0.586.tgz +0 -0
- package/schemas/export.ts +0 -20
- package/schemas/index.ts +0 -2
- package/schemas/module.ts +0 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { Parser } from './parser';
|
|
2
2
|
export { SchemaExtractor } from './schema-extractor';
|
|
3
|
-
export { Export, Module, StaticProperties } from './schemas';
|
|
4
3
|
export type { SchemaMain } from './schema.main.runtime';
|
|
5
4
|
export { SchemaAspect } from './schema.aspect';
|
|
6
|
-
export { SemanticSchema } from './semantic-schema';
|
package/dist/index.js
CHANGED
|
@@ -3,18 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "Export", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _schemas().Export;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Module", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _schemas().Module;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
6
|
Object.defineProperty(exports, "Parser", {
|
|
19
7
|
enumerable: true,
|
|
20
8
|
get: function () {
|
|
@@ -33,18 +21,6 @@ Object.defineProperty(exports, "SchemaExtractor", {
|
|
|
33
21
|
return _schemaExtractor().SchemaExtractor;
|
|
34
22
|
}
|
|
35
23
|
});
|
|
36
|
-
Object.defineProperty(exports, "SemanticSchema", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _semanticSchema().SemanticSchema;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "StaticProperties", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _schemas().StaticProperties;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
24
|
|
|
49
25
|
function _parser() {
|
|
50
26
|
const data = require("./parser");
|
|
@@ -66,16 +42,6 @@ function _schemaExtractor() {
|
|
|
66
42
|
return data;
|
|
67
43
|
}
|
|
68
44
|
|
|
69
|
-
function _schemas() {
|
|
70
|
-
const data = require("./schemas");
|
|
71
|
-
|
|
72
|
-
_schemas = function () {
|
|
73
|
-
return data;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
return data;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
45
|
function _schema() {
|
|
80
46
|
const data = require("./schema.aspect");
|
|
81
47
|
|
|
@@ -86,14 +52,4 @@ function _schema() {
|
|
|
86
52
|
return data;
|
|
87
53
|
}
|
|
88
54
|
|
|
89
|
-
function _semanticSchema() {
|
|
90
|
-
const data = require("./semantic-schema");
|
|
91
|
-
|
|
92
|
-
_semanticSchema = function () {
|
|
93
|
-
return data;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
return data;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
55
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { Parser } from './parser';\nexport { SchemaExtractor } from './schema-extractor';\nexport type { SchemaMain } from './schema.main.runtime';\nexport { SchemaAspect } from './schema.aspect';\n"]}
|
package/dist/parser.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuildTask, BuiltTaskResult } from '@teambit/builder';
|
|
2
|
+
export declare class SchemaExtract implements BuildTask {
|
|
3
|
+
readonly aspectId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
constructor(aspectId: string);
|
|
7
|
+
execute(): Promise<BuiltTaskResult>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.SchemaExtract = void 0;
|
|
9
|
+
|
|
10
|
+
function _defineProperty2() {
|
|
11
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
|
|
13
|
+
_defineProperty2 = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class SchemaExtract {
|
|
21
|
+
constructor(aspectId) {
|
|
22
|
+
this.aspectId = aspectId;
|
|
23
|
+
(0, _defineProperty2().default)(this, "name", 'schema-extraction');
|
|
24
|
+
(0, _defineProperty2().default)(this, "description", 'extract api schema for a set of components');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
execute() {
|
|
28
|
+
throw new Error('Method not implemented.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.SchemaExtract = SchemaExtract;
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=schema-extract.task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["schema-extract.task.ts"],"names":["SchemaExtract","constructor","aspectId","execute","Error"],"mappings":";;;;;;;;;;;;;;;;;;;AAEO,MAAMA,aAAN,CAAyC;AAI9CC,EAAAA,WAAW,CAAUC,QAAV,EAA4B;AAAA,SAAlBA,QAAkB,GAAlBA,QAAkB;AAAA,kDAHhC,mBAGgC;AAAA,yDAFzB,4CAEyB;AAAE;;AAEzCC,EAAAA,OAAO,GAA6B;AAClC,UAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;AAR6C","sourcesContent":["import { BuildTask, BuiltTaskResult } from '@teambit/builder';\n\nexport class SchemaExtract implements BuildTask {\n name = 'schema-extraction';\n description = 'extract api schema for a set of components';\n\n constructor(readonly aspectId: string) {}\n\n execute(): Promise<BuiltTaskResult> {\n throw new Error('Method not implemented.');\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Component } from '@teambit/component';
|
|
2
|
-
import {
|
|
2
|
+
import { SemanticSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
3
3
|
export interface SchemaExtractor {
|
|
4
4
|
/**
|
|
5
5
|
* extract a semantic schema from a component.
|
|
6
6
|
*/
|
|
7
|
-
extract(component: Component): Promise<
|
|
7
|
+
extract(component: Component): Promise<SemanticSchema>;
|
|
8
8
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { ComponentMain } from '@teambit/component';
|
|
3
|
+
import type { SchemaMain } from './schema.main.runtime';
|
|
4
|
+
export declare class SchemaCommand implements Command {
|
|
5
|
+
private schema;
|
|
6
|
+
private component;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
group: string;
|
|
10
|
+
options: CommandOptions;
|
|
11
|
+
constructor(schema: SchemaMain, component: ComponentMain);
|
|
12
|
+
report([idStr]: [any]): Promise<string>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.promise.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.SchemaCommand = void 0;
|
|
13
|
+
|
|
14
|
+
function _defineProperty2() {
|
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
_defineProperty2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _scope() {
|
|
25
|
+
const data = require("@teambit/scope");
|
|
26
|
+
|
|
27
|
+
_scope = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class SchemaCommand {
|
|
35
|
+
constructor(schema, component) {
|
|
36
|
+
this.schema = schema;
|
|
37
|
+
this.component = component;
|
|
38
|
+
(0, _defineProperty2().default)(this, "name", 'schema <id>');
|
|
39
|
+
(0, _defineProperty2().default)(this, "description", 'shows the API schema of a certain component.');
|
|
40
|
+
(0, _defineProperty2().default)(this, "group", 'component');
|
|
41
|
+
(0, _defineProperty2().default)(this, "options", [['j', 'json', 'return the component data in json format']]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async report([idStr]) {
|
|
45
|
+
const host = this.component.getHost();
|
|
46
|
+
const id = await host.resolveComponentId(idStr);
|
|
47
|
+
const component = await host.get(id);
|
|
48
|
+
if (!component) throw new (_scope().ComponentNotFound)(id);
|
|
49
|
+
const schema = await this.schema.getSchema(component);
|
|
50
|
+
return schema.toString();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.SchemaCommand = SchemaCommand;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=schema.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["schema.cmd.ts"],"names":["SchemaCommand","constructor","schema","component","report","idStr","host","getHost","id","resolveComponentId","get","ComponentNotFound","getSchema","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,aAAN,CAAuC;AAM5CC,EAAAA,WAAW,CAASC,MAAT,EAAqCC,SAArC,EAA+D;AAAA,SAAtDD,MAAsD,GAAtDA,MAAsD;AAAA,SAA1BC,SAA0B,GAA1BA,SAA0B;AAAA,kDALnE,aAKmE;AAAA,yDAJ5D,8CAI4D;AAAA,mDAHlE,WAGkE;AAAA,qDAFhE,CAAC,CAAC,GAAD,EAAM,MAAN,EAAc,0CAAd,CAAD,CAEgE;AAAE;;AAEhE,QAANC,MAAM,CAAC,CAACC,KAAD,CAAD,EAAU;AACpB,UAAMC,IAAI,GAAG,KAAKH,SAAL,CAAeI,OAAf,EAAb;AACA,UAAMC,EAAE,GAAG,MAAMF,IAAI,CAACG,kBAAL,CAAwBJ,KAAxB,CAAjB;AACA,UAAMF,SAAS,GAAG,MAAMG,IAAI,CAACI,GAAL,CAASF,EAAT,CAAxB;AACA,QAAI,CAACL,SAAL,EAAgB,MAAM,KAAIQ,0BAAJ,EAAsBH,EAAtB,CAAN;AAEhB,UAAMN,MAAM,GAAG,MAAM,KAAKA,MAAL,CAAYU,SAAZ,CAAsBT,SAAtB,CAArB;AAEA,WAAOD,MAAM,CAACW,QAAP,EAAP;AACD;;AAjB2C","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentMain } from '@teambit/component';\nimport { ComponentNotFound } from '@teambit/scope';\nimport type { SchemaMain } from './schema.main.runtime';\n\nexport class SchemaCommand implements Command {\n name = 'schema <id>';\n description = 'shows the API schema of a certain component.';\n group = 'component';\n options = [['j', 'json', 'return the component data in json format']] as CommandOptions;\n\n constructor(private schema: SchemaMain, private component: ComponentMain) {}\n\n async report([idStr]) {\n const host = this.component.getHost();\n const id = await host.resolveComponentId(idStr);\n const component = await host.get(id);\n if (!component) throw new ComponentNotFound(id);\n\n const schema = await this.schema.getSchema(component);\n\n return schema.toString();\n }\n}\n"]}
|
package/dist/schema.graphql.d.ts
CHANGED
|
@@ -6,9 +6,7 @@ export declare function schemaSchema(schema: SchemaMain): {
|
|
|
6
6
|
ComponentHost: {
|
|
7
7
|
getSchema: (host: ComponentFactory, { id }: {
|
|
8
8
|
id: string;
|
|
9
|
-
}) => Promise<
|
|
10
|
-
exports: never[];
|
|
11
|
-
}>;
|
|
9
|
+
}) => Promise<import("@teambit/semantics.entities.semantic-schema").SemanticSchema>;
|
|
12
10
|
};
|
|
13
11
|
};
|
|
14
12
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { Component, ComponentMain } from '@teambit/component';
|
|
2
3
|
import { SlotRegistry } from '@teambit/harmony';
|
|
3
4
|
import { GraphqlMain } from '@teambit/graphql';
|
|
4
5
|
import { EnvsMain } from '@teambit/envs';
|
|
6
|
+
import { Module, SemanticSchema } from '@teambit/semantics.entities.semantic-schema';
|
|
5
7
|
import { Parser } from './parser';
|
|
6
|
-
import { Module } from './schemas';
|
|
7
|
-
import { SemanticSchema } from './semantic-schema';
|
|
8
8
|
export declare type ParserSlot = SlotRegistry<Parser>;
|
|
9
9
|
export declare type SchemaConfig = {
|
|
10
10
|
/**
|
|
@@ -35,6 +35,8 @@ export declare class SchemaMain {
|
|
|
35
35
|
* parse a module into a component schema.
|
|
36
36
|
*/
|
|
37
37
|
parseModule(path: string): Module;
|
|
38
|
+
private getSchemaExtractorContext;
|
|
39
|
+
getSchemaExtractor(component: Component): void;
|
|
38
40
|
/**
|
|
39
41
|
* get a schema of a component.
|
|
40
42
|
* @param component target component.
|
|
@@ -46,9 +48,9 @@ export declare class SchemaMain {
|
|
|
46
48
|
registerParser(parser: Parser): SchemaMain;
|
|
47
49
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
48
50
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
51
|
+
static slots: ((registerFn: () => string) => SlotRegistry<Parser>)[];
|
|
49
52
|
static defaultConfig: {
|
|
50
53
|
defaultParser: string;
|
|
51
54
|
};
|
|
52
|
-
static
|
|
53
|
-
static provider([envs, graphql]: [EnvsMain, GraphqlMain], config: SchemaConfig, [parserSlot]: [ParserSlot]): Promise<SchemaMain>;
|
|
55
|
+
static provider([envs, cli, component, graphql]: [EnvsMain, CLIMain, ComponentMain, GraphqlMain], config: SchemaConfig, [parserSlot]: [ParserSlot]): Promise<SchemaMain>;
|
|
54
56
|
}
|
|
@@ -33,6 +33,16 @@ function _cli() {
|
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
function _component() {
|
|
37
|
+
const data = _interopRequireDefault(require("@teambit/component"));
|
|
38
|
+
|
|
39
|
+
_component = function () {
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
function _harmony() {
|
|
37
47
|
const data = require("@teambit/harmony");
|
|
38
48
|
|
|
@@ -74,7 +84,7 @@ function _schema() {
|
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
function _schema2() {
|
|
77
|
-
const data = require("./schema.
|
|
87
|
+
const data = require("./schema.cmd");
|
|
78
88
|
|
|
79
89
|
_schema2 = function () {
|
|
80
90
|
return data;
|
|
@@ -83,6 +93,16 @@ function _schema2() {
|
|
|
83
93
|
return data;
|
|
84
94
|
}
|
|
85
95
|
|
|
96
|
+
function _schema3() {
|
|
97
|
+
const data = require("./schema.graphql");
|
|
98
|
+
|
|
99
|
+
_schema3 = function () {
|
|
100
|
+
return data;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
|
|
86
106
|
/**
|
|
87
107
|
* extension for extracting component schemas.
|
|
88
108
|
*/
|
|
@@ -123,6 +143,16 @@ class SchemaMain {
|
|
|
123
143
|
const [, parser] = maybeParser;
|
|
124
144
|
return parser.parseModule(path);
|
|
125
145
|
}
|
|
146
|
+
|
|
147
|
+
getSchemaExtractorContext() {}
|
|
148
|
+
|
|
149
|
+
getSchemaExtractor(component) {
|
|
150
|
+
const env = this.envs.getEnv(component).env;
|
|
151
|
+
|
|
152
|
+
if (typeof env.getSchemaExtractor === 'undefined') {
|
|
153
|
+
throw new Error(`No SchemaExtractor defined for ${env.name}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
126
156
|
/**
|
|
127
157
|
* get a schema of a component.
|
|
128
158
|
* @param component target component.
|
|
@@ -137,10 +167,7 @@ class SchemaMain {
|
|
|
137
167
|
}
|
|
138
168
|
|
|
139
169
|
const schemaExtractor = env.getSchemaExtractor();
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
exports: []
|
|
143
|
-
};
|
|
170
|
+
return schemaExtractor.extract(component);
|
|
144
171
|
}
|
|
145
172
|
/**
|
|
146
173
|
* register a new parser.
|
|
@@ -152,9 +179,10 @@ class SchemaMain {
|
|
|
152
179
|
return this;
|
|
153
180
|
}
|
|
154
181
|
|
|
155
|
-
static async provider([envs, graphql], config, [parserSlot]) {
|
|
182
|
+
static async provider([envs, cli, component, graphql], config, [parserSlot]) {
|
|
156
183
|
const schema = new SchemaMain(parserSlot, envs, config);
|
|
157
|
-
|
|
184
|
+
cli.register(new (_schema2().SchemaCommand)(schema, component));
|
|
185
|
+
graphql.register((0, _schema3().schemaSchema)(schema)); // workspace.onComponentLoad(async (component) => {
|
|
158
186
|
// const apiSchema = await schema.getSchema(component);
|
|
159
187
|
// return {};
|
|
160
188
|
// });
|
|
@@ -166,11 +194,11 @@ class SchemaMain {
|
|
|
166
194
|
|
|
167
195
|
exports.SchemaMain = SchemaMain;
|
|
168
196
|
(0, _defineProperty2().default)(SchemaMain, "runtime", _cli().MainRuntime);
|
|
169
|
-
(0, _defineProperty2().default)(SchemaMain, "dependencies", [_envs().EnvsAspect, _graphql().default]);
|
|
197
|
+
(0, _defineProperty2().default)(SchemaMain, "dependencies", [_envs().EnvsAspect, _cli().CLIAspect, _component().default, _graphql().default]);
|
|
198
|
+
(0, _defineProperty2().default)(SchemaMain, "slots", [_harmony().Slot.withType()]);
|
|
170
199
|
(0, _defineProperty2().default)(SchemaMain, "defaultConfig", {
|
|
171
200
|
defaultParser: 'teambit.typescript/typescript'
|
|
172
201
|
});
|
|
173
|
-
(0, _defineProperty2().default)(SchemaMain, "slots", [_harmony().Slot.withType()]);
|
|
174
202
|
|
|
175
203
|
_schema().SchemaAspect.addRuntime(SchemaMain);
|
|
176
204
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["schema.main.runtime.ts"],"names":["SchemaMain","constructor","parserSlot","envs","config","getDefaultParser","get","defaultParser","parseModule","path","parsers","toArray","maybeParser","find","parser","match","extension","
|
|
1
|
+
{"version":3,"sources":["schema.main.runtime.ts"],"names":["SchemaMain","constructor","parserSlot","envs","config","getDefaultParser","get","defaultParser","parseModule","path","parsers","toArray","maybeParser","find","parser","match","extension","getSchemaExtractorContext","getSchemaExtractor","component","env","getEnv","Error","name","getSchema","schemaExtractor","extract","registerParser","register","provider","cli","graphql","schema","SchemaCommand","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","GraphqlAspect","Slot","withType","SchemaAspect","addRuntime"],"mappings":"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","sourcesContent":["import { MainRuntime, CLIMain, CLIAspect } from '@teambit/cli';\nimport ComponentAspect, { Component, ComponentMain } from '@teambit/component';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { Module, SemanticSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { Parser } from './parser';\nimport { SchemaAspect } from './schema.aspect';\nimport { SchemaExtractor } from './schema-extractor';\nimport { SchemaCommand } from './schema.cmd';\nimport { schemaSchema } from './schema.graphql';\n\nexport type ParserSlot = SlotRegistry<Parser>;\n\nexport type SchemaConfig = {\n /**\n * default parser\n */\n defaultParser: string;\n};\n\n/**\n * extension for extracting component schemas.\n */\nexport class SchemaMain {\n constructor(\n /**\n * parsers slot.\n */\n private parserSlot: ParserSlot,\n\n private envs: EnvsMain,\n\n private config: SchemaConfig\n ) {}\n\n /**\n * get the default parser.\n */\n getDefaultParser(): Parser {\n return this.parserSlot.get(this.config.defaultParser) as Parser;\n }\n\n /**\n * parse a module into a component schema.\n */\n parseModule(path: string): Module {\n const parsers = this.parserSlot.toArray();\n let maybeParser = parsers.find(([, parser]) => {\n const match = path.match(parser.extension);\n return match;\n });\n\n if (!maybeParser) {\n maybeParser = [this.config.defaultParser, this.getDefaultParser()];\n }\n\n const [, parser] = maybeParser;\n return parser.parseModule(path);\n }\n\n private getSchemaExtractorContext() {}\n\n getSchemaExtractor(component: Component) {\n const env = this.envs.getEnv(component).env;\n if (typeof env.getSchemaExtractor === 'undefined') {\n throw new Error(`No SchemaExtractor defined for ${env.name}`);\n }\n }\n\n /**\n * get a schema of a component.\n * @param component target component.\n */\n async getSchema(component: Component): Promise<SemanticSchema> {\n const env = this.envs.getEnv(component).env;\n if (typeof env.getSchemaExtractor === 'undefined') {\n throw new Error(`No SchemaExtractor defined for ${env.name}`);\n }\n const schemaExtractor: SchemaExtractor = env.getSchemaExtractor();\n return schemaExtractor.extract(component);\n }\n\n /**\n * register a new parser.\n */\n registerParser(parser: Parser): SchemaMain {\n this.parserSlot.register(parser);\n return this;\n }\n\n static runtime = MainRuntime;\n static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, GraphqlAspect];\n static slots = [Slot.withType<Parser>()];\n\n static defaultConfig = {\n defaultParser: 'teambit.typescript/typescript',\n };\n\n static async provider(\n [envs, cli, component, graphql]: [EnvsMain, CLIMain, ComponentMain, GraphqlMain],\n config: SchemaConfig,\n [parserSlot]: [ParserSlot]\n ) {\n const schema = new SchemaMain(parserSlot, envs, config);\n cli.register(new SchemaCommand(schema, component));\n graphql.register(schemaSchema(schema));\n\n // workspace.onComponentLoad(async (component) => {\n // const apiSchema = await schema.getSchema(component);\n // return {};\n // });\n\n return schema;\n }\n}\n\nSchemaAspect.addRuntime(SchemaMain);\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.590",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/semantics/schema",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.semantics",
|
|
8
8
|
"name": "schema",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.590"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
13
13
|
"graphql-tag": "2.12.1",
|
|
14
14
|
"@babel/runtime": "7.12.18",
|
|
15
15
|
"core-js": "^3.0.0",
|
|
16
|
-
"@teambit/
|
|
17
|
-
"@teambit/
|
|
18
|
-
"@teambit/
|
|
19
|
-
"@teambit/
|
|
16
|
+
"@teambit/semantics.entities.semantic-schema": "0.0.2",
|
|
17
|
+
"@teambit/builder": "0.0.590",
|
|
18
|
+
"@teambit/component": "0.0.590",
|
|
19
|
+
"@teambit/cli": "0.0.405",
|
|
20
|
+
"@teambit/scope": "0.0.590",
|
|
21
|
+
"@teambit/envs": "0.0.590",
|
|
22
|
+
"@teambit/graphql": "0.0.590"
|
|
20
23
|
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@types/mocha": "5.2.7",
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
"@types/node": "12.20.4"
|
|
28
31
|
},
|
|
29
32
|
"peerDependencies": {
|
|
30
|
-
"@teambit/legacy": "1.0.
|
|
33
|
+
"@teambit/legacy": "1.0.191",
|
|
31
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
32
35
|
"react": "^16.8.0 || ^17.0.0"
|
|
33
36
|
},
|
|
@@ -55,7 +58,7 @@
|
|
|
55
58
|
"react": "-"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
|
-
"@teambit/legacy": "1.0.
|
|
61
|
+
"@teambit/legacy": "1.0.191",
|
|
59
62
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
60
63
|
"react": "^16.8.0 || ^17.0.0"
|
|
61
64
|
}
|
package/dist/schemas/export.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
declare type Primitive = string | number | boolean | null | undefined;
|
|
2
|
-
export declare type StaticProperties = Map<string, Primitive>;
|
|
3
|
-
export declare class Export {
|
|
4
|
-
/**
|
|
5
|
-
* named export identifier of the module export.
|
|
6
|
-
*/
|
|
7
|
-
readonly identifier: string;
|
|
8
|
-
/**
|
|
9
|
-
* static properties attached to this export
|
|
10
|
-
* @example
|
|
11
|
-
* export hello = () => {};
|
|
12
|
-
* hello.value = "text"; // <-- staticProperty
|
|
13
|
-
* hello.count = 3; // <-- static property
|
|
14
|
-
*/
|
|
15
|
-
readonly staticProperties?: StaticProperties | undefined;
|
|
16
|
-
constructor(
|
|
17
|
-
/**
|
|
18
|
-
* named export identifier of the module export.
|
|
19
|
-
*/
|
|
20
|
-
identifier: string,
|
|
21
|
-
/**
|
|
22
|
-
* static properties attached to this export
|
|
23
|
-
* @example
|
|
24
|
-
* export hello = () => {};
|
|
25
|
-
* hello.value = "text"; // <-- staticProperty
|
|
26
|
-
* hello.count = 3; // <-- static property
|
|
27
|
-
*/
|
|
28
|
-
staticProperties?: StaticProperties | undefined);
|
|
29
|
-
}
|
|
30
|
-
export {};
|
package/dist/schemas/export.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Export = void 0;
|
|
7
|
-
|
|
8
|
-
class Export {
|
|
9
|
-
constructor(
|
|
10
|
-
/**
|
|
11
|
-
* named export identifier of the module export.
|
|
12
|
-
*/
|
|
13
|
-
identifier,
|
|
14
|
-
/**
|
|
15
|
-
* static properties attached to this export
|
|
16
|
-
* @example
|
|
17
|
-
* export hello = () => {};
|
|
18
|
-
* hello.value = "text"; // <-- staticProperty
|
|
19
|
-
* hello.count = 3; // <-- static property
|
|
20
|
-
*/
|
|
21
|
-
staticProperties) {
|
|
22
|
-
this.identifier = identifier;
|
|
23
|
-
this.staticProperties = staticProperties;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
exports.Export = Export;
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=export.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["export.ts"],"names":["Export","constructor","identifier","staticProperties"],"mappings":";;;;;;;AAGO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW;AACT;AACJ;AACA;AACaC,EAAAA,UAJA;AAMT;AACJ;AACA;AACA;AACA;AACA;AACA;AACaC,EAAAA,gBAbA,EAcT;AAAA,SAVSD,UAUT,GAVSA,UAUT;AAAA,SADSC,gBACT,GADSA,gBACT;AAAE;;AAfc","sourcesContent":["type Primitive = string | number | boolean | null | undefined;\nexport type StaticProperties = Map<string, Primitive>;\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"]}
|
package/dist/schemas/index.d.ts
DELETED
package/dist/schemas/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Export", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _export().Export;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Module", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _module().Module;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "StaticProperties", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _export().StaticProperties;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
function _module() {
|
|
26
|
-
const data = require("./module");
|
|
27
|
-
|
|
28
|
-
_module = function () {
|
|
29
|
-
return data;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return data;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _export() {
|
|
36
|
-
const data = require("./export");
|
|
37
|
-
|
|
38
|
-
_export = function () {
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return data;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { Module } from './module';\nexport { Export, StaticProperties } from './export';\n"]}
|
package/dist/schemas/module.d.ts
DELETED
package/dist/schemas/module.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Module = void 0;
|
|
7
|
-
|
|
8
|
-
class Module {
|
|
9
|
-
constructor(
|
|
10
|
-
/**
|
|
11
|
-
* all module exports.
|
|
12
|
-
*/
|
|
13
|
-
exports) {
|
|
14
|
-
this.exports = exports;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
exports.Module = Module;
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["module.ts"],"names":["Module","constructor","exports"],"mappings":";;;;;;;AAEO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW;AACT;AACJ;AACA;AACaC,EAAAA,OAJA,EAKT;AAAA,SADSA,OACT,GADSA,OACT;AAAE;;AANc","sourcesContent":["import { Export } from './export';\n\nexport class Module {\n constructor(\n /**\n * all module exports.\n */\n readonly exports: Export[]\n ) {}\n}\n"]}
|
package/dist/semantic-schema.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
Binary file
|
package/schemas/export.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type Primitive = string | number | boolean | null | undefined;
|
|
2
|
-
export type StaticProperties = Map<string, Primitive>;
|
|
3
|
-
|
|
4
|
-
export class Export {
|
|
5
|
-
constructor(
|
|
6
|
-
/**
|
|
7
|
-
* named export identifier of the module export.
|
|
8
|
-
*/
|
|
9
|
-
readonly identifier: string,
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* static properties attached to this export
|
|
13
|
-
* @example
|
|
14
|
-
* export hello = () => {};
|
|
15
|
-
* hello.value = "text"; // <-- staticProperty
|
|
16
|
-
* hello.count = 3; // <-- static property
|
|
17
|
-
*/
|
|
18
|
-
readonly staticProperties?: StaticProperties
|
|
19
|
-
) {}
|
|
20
|
-
}
|
package/schemas/index.ts
DELETED