@teambit/schema 0.0.727 → 0.0.730
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/schema-extractor.d.ts +2 -2
- package/dist/schema.cmd.d.ts +12 -0
- package/dist/schema.cmd.js +11 -2
- package/dist/schema.cmd.js.map +1 -1
- package/dist/schema.graphql.d.ts +3 -1
- package/dist/schema.main.runtime.d.ts +4 -4
- package/dist/schema.main.runtime.js +2 -2
- package/dist/schema.main.runtime.js.map +1 -1
- package/package-tar/teambit-schema-0.0.730.tgz +0 -0
- package/package.json +11 -11
- package/{preview-1652002449479.js → preview-1652325916507.js} +2 -2
- package/package-tar/teambit-schema-0.0.727.tgz +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Component } from '@teambit/component';
|
|
2
|
-
import {
|
|
2
|
+
import { APISchema } 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<APISchema>;
|
|
8
8
|
}
|
package/dist/schema.cmd.d.ts
CHANGED
|
@@ -10,4 +10,16 @@ export declare class SchemaCommand implements Command {
|
|
|
10
10
|
options: CommandOptions;
|
|
11
11
|
constructor(schema: SchemaMain, component: ComponentMain);
|
|
12
12
|
report([idStr]: [any]): Promise<string>;
|
|
13
|
+
json([idStr]: [any]): Promise<{
|
|
14
|
+
constructorName: string;
|
|
15
|
+
module: {
|
|
16
|
+
constructorName: string;
|
|
17
|
+
namespace: string | undefined;
|
|
18
|
+
exports: (Record<string, any> & {
|
|
19
|
+
constructorName: string;
|
|
20
|
+
})[];
|
|
21
|
+
};
|
|
22
|
+
filename: string;
|
|
23
|
+
}>;
|
|
24
|
+
private getSchema;
|
|
13
25
|
}
|
package/dist/schema.cmd.js
CHANGED
|
@@ -42,12 +42,21 @@ class SchemaCommand {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async report([idStr]) {
|
|
45
|
+
const schema = await this.getSchema([idStr]);
|
|
46
|
+
return schema.toStringPerType();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async json([idStr]) {
|
|
50
|
+
const schema = await this.getSchema([idStr]);
|
|
51
|
+
return schema.toObject();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getSchema([idStr]) {
|
|
45
55
|
const host = this.component.getHost();
|
|
46
56
|
const id = await host.resolveComponentId(idStr);
|
|
47
57
|
const component = await host.get(id);
|
|
48
58
|
if (!component) throw new (_scope().ComponentNotFound)(id);
|
|
49
|
-
|
|
50
|
-
return schema.toString();
|
|
59
|
+
return this.schema.getSchema(component);
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
}
|
package/dist/schema.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["schema.cmd.ts"],"names":["SchemaCommand","constructor","schema","component","report","idStr","host","getHost","id","resolveComponentId","get","ComponentNotFound"
|
|
1
|
+
{"version":3,"sources":["schema.cmd.ts"],"names":["SchemaCommand","constructor","schema","component","report","idStr","getSchema","toStringPerType","json","toObject","host","getHost","id","resolveComponentId","get","ComponentNotFound"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,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,UAAMH,MAAM,GAAG,MAAM,KAAKI,SAAL,CAAe,CAACD,KAAD,CAAf,CAArB;AACA,WAAOH,MAAM,CAACK,eAAP,EAAP;AACD;;AAES,QAAJC,IAAI,CAAC,CAACH,KAAD,CAAD,EAAU;AAClB,UAAMH,MAAM,GAAG,MAAM,KAAKI,SAAL,CAAe,CAACD,KAAD,CAAf,CAArB;AACA,WAAOH,MAAM,CAACO,QAAP,EAAP;AACD;;AAEsB,QAATH,SAAS,CAAC,CAACD,KAAD,CAAD,EAA8B;AACnD,UAAMK,IAAI,GAAG,KAAKP,SAAL,CAAeQ,OAAf,EAAb;AACA,UAAMC,EAAE,GAAG,MAAMF,IAAI,CAACG,kBAAL,CAAwBR,KAAxB,CAAjB;AACA,UAAMF,SAAS,GAAG,MAAMO,IAAI,CAACI,GAAL,CAASF,EAAT,CAAxB;AACA,QAAI,CAACT,SAAL,EAAgB,MAAM,KAAIY,0BAAJ,EAAsBH,EAAtB,CAAN;AAEhB,WAAO,KAAKV,MAAL,CAAYI,SAAZ,CAAsBH,SAAtB,CAAP;AACD;;AAzB2C","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentMain } from '@teambit/component';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { APISchema } from '@teambit/semantics.entities.semantic-schema';\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 schema = await this.getSchema([idStr]);\n return schema.toStringPerType();\n }\n\n async json([idStr]) {\n const schema = await this.getSchema([idStr]);\n return schema.toObject();\n }\n\n private async getSchema([idStr]): Promise<APISchema> {\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 return this.schema.getSchema(component);\n }\n}\n"]}
|
package/dist/schema.graphql.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export declare function schemaSchema(schema: SchemaMain): {
|
|
|
6
6
|
ComponentHost: {
|
|
7
7
|
getSchema: (host: ComponentFactory, { id }: {
|
|
8
8
|
id: string;
|
|
9
|
-
}) => Promise<import("@teambit/semantics.entities.semantic-schema").
|
|
9
|
+
}) => Promise<import("@teambit/semantics.entities.semantic-schema").APISchema | {
|
|
10
|
+
exports: never[];
|
|
11
|
+
}>;
|
|
10
12
|
};
|
|
11
13
|
};
|
|
12
14
|
};
|
|
@@ -3,8 +3,9 @@ import { Component, ComponentMain } from '@teambit/component';
|
|
|
3
3
|
import { SlotRegistry } from '@teambit/harmony';
|
|
4
4
|
import { GraphqlMain } from '@teambit/graphql';
|
|
5
5
|
import { EnvsMain } from '@teambit/envs';
|
|
6
|
-
import { Module,
|
|
6
|
+
import { Module, APISchema } from '@teambit/semantics.entities.semantic-schema';
|
|
7
7
|
import { Parser } from './parser';
|
|
8
|
+
import { SchemaExtractor } from './schema-extractor';
|
|
8
9
|
export declare type ParserSlot = SlotRegistry<Parser>;
|
|
9
10
|
export declare type SchemaConfig = {
|
|
10
11
|
/**
|
|
@@ -35,13 +36,12 @@ export declare class SchemaMain {
|
|
|
35
36
|
* parse a module into a component schema.
|
|
36
37
|
*/
|
|
37
38
|
parseModule(path: string): Module;
|
|
38
|
-
|
|
39
|
-
getSchemaExtractor(component: Component): void;
|
|
39
|
+
getSchemaExtractor(component: Component): SchemaExtractor;
|
|
40
40
|
/**
|
|
41
41
|
* get a schema of a component.
|
|
42
42
|
* @param component target component.
|
|
43
43
|
*/
|
|
44
|
-
getSchema(component: Component): Promise<
|
|
44
|
+
getSchema(component: Component): Promise<APISchema>;
|
|
45
45
|
/**
|
|
46
46
|
* register a new parser.
|
|
47
47
|
*/
|
|
@@ -144,14 +144,14 @@ class SchemaMain {
|
|
|
144
144
|
return parser.parseModule(path);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
getSchemaExtractorContext() {}
|
|
148
|
-
|
|
149
147
|
getSchemaExtractor(component) {
|
|
150
148
|
const env = this.envs.getEnv(component).env;
|
|
151
149
|
|
|
152
150
|
if (typeof env.getSchemaExtractor === 'undefined') {
|
|
153
151
|
throw new Error(`No SchemaExtractor defined for ${env.name}`);
|
|
154
152
|
}
|
|
153
|
+
|
|
154
|
+
return env.getSchemaExtractor();
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* get a schema of a component.
|
|
@@ -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","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":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAWA;AACA;AACA;AACO,MAAMA,UAAN,CAAiB;AACtBC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,UAJC,EAMD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B,EAA4BC,GAAxC;;AACA,QAAI,OAAOA,GAAG,CAACF,kBAAX,KAAkC,WAAtC,EAAmD;AACjD,YAAM,IAAII,KAAJ,CAAW,kCAAiCF,GAAG,CAACG,IAAK,EAArD,CAAN;AACD;;AACD,UAAME,eAAgC,GAAGL,GAAG,CAACF,kBAAJ,EAAzC;AACA,WAAOO,eAAe,CAACC,OAAhB,CAAwBP,SAAxB,CAAP;AACD;AAED;AACF;AACA;;;AACEQ,EAAAA,cAAc,CAACZ,MAAD,EAA6B;AACzC,SAAKZ,UAAL,CAAgByB,QAAhB,CAAyBb,MAAzB;AACA,WAAO,IAAP;AACD;;AAUoB,eAARc,QAAQ,CACnB,CAACzB,IAAD,EAAO0B,GAAP,EAAYX,SAAZ,EAAuBY,OAAvB,CADmB,EAEnB1B,MAFmB,EAGnB,CAACF,UAAD,CAHmB,EAInB;AACA,UAAM6B,MAAM,GAAG,IAAI/B,UAAJ,CAAeE,UAAf,EAA2BC,IAA3B,EAAiCC,MAAjC,CAAf;AACAyB,IAAAA,GAAG,CAACF,QAAJ,CAAa,KAAIK,wBAAJ,EAAkBD,MAAlB,EAA0Bb,SAA1B,CAAb;AACAY,IAAAA,OAAO,CAACH,QAAR,CAAiB,6BAAaI,MAAb,CAAjB,EAHA,CAKA;AACA;AACA;AACA;;AAEA,WAAOA,MAAP;AACD;;AA1FqB;;;gCAAX/B,U,aAmEMiC,kB;gCAnENjC,U,kBAoEW,CAACkC,kBAAD,EAAaC,gBAAb,EAAwBC,oBAAxB,EAAyCC,kBAAzC,C;gCApEXrC,U,WAqEI,CAACsC,gBAAKC,QAAL,EAAD,C;gCArEJvC,U,mBAuEY;AACrBO,EAAAA,aAAa,EAAE;AADM,C;;AAsBzBiC,uBAAaC,UAAb,CAAwBzC,UAAxB","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, APISchema } 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 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 return env.getSchemaExtractor();\n }\n\n /**\n * get a schema of a component.\n * @param component target component.\n */\n async getSchema(component: Component): Promise<APISchema> {\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,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.730",
|
|
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.730"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"graphql-tag": "2.12.1",
|
|
13
13
|
"@babel/runtime": "7.12.18",
|
|
14
14
|
"core-js": "^3.0.0",
|
|
15
15
|
"@teambit/harmony": "0.3.3",
|
|
16
|
-
"@teambit/semantics.entities.semantic-schema": "0.0.
|
|
17
|
-
"@teambit/builder": "0.0.
|
|
18
|
-
"@teambit/component": "0.0.
|
|
19
|
-
"@teambit/cli": "0.0.
|
|
20
|
-
"@teambit/scope": "0.0.
|
|
21
|
-
"@teambit/envs": "0.0.
|
|
22
|
-
"@teambit/graphql": "0.0.
|
|
16
|
+
"@teambit/semantics.entities.semantic-schema": "0.0.8",
|
|
17
|
+
"@teambit/builder": "0.0.730",
|
|
18
|
+
"@teambit/component": "0.0.730",
|
|
19
|
+
"@teambit/cli": "0.0.487",
|
|
20
|
+
"@teambit/scope": "0.0.730",
|
|
21
|
+
"@teambit/envs": "0.0.730",
|
|
22
|
+
"@teambit/graphql": "0.0.730"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/react": "^17.0.8",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/node": "12.20.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@teambit/legacy": "1.0.
|
|
33
|
+
"@teambit/legacy": "1.0.266",
|
|
34
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
35
35
|
"react": "^16.8.0 || ^17.0.0"
|
|
36
36
|
},
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react": "-"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@teambit/legacy": "1.0.
|
|
61
|
+
"@teambit/legacy": "1.0.266",
|
|
62
62
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
63
63
|
"react": "^16.8.0 || ^17.0.0"
|
|
64
64
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.semantics_schema@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.semantics_schema@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.semantics_schema@0.0.730/dist/schema.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.semantics_schema@0.0.730/dist/schema.docs.mdx')]
|
|
Binary file
|