@teambit/schema 0.0.555 → 0.0.556
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/package.json +14 -8
- package/exceptions/index.ts +0 -1
- package/exceptions/parser-not-found.ts +0 -8
- package/index.ts +0 -6
- package/package-tar/teambit-schema-0.0.555.tgz +0 -0
- package/parser.ts +0 -13
- package/schema-extractor.ts +0 -9
- package/schema.aspect.ts +0 -5
- package/schema.graphql.ts +0 -35
- package/schema.main.runtime.ts +0 -109
- package/schema.service.ts +0 -10
- package/schemas/export.ts +0 -20
- package/schemas/index.ts +0 -2
- package/schemas/module.ts +0 -10
- package/semantic-schema.ts +0 -6
- package/tsconfig.json +0 -34
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.556",
|
|
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.556"
|
|
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/component": "0.0.
|
|
17
|
-
"@teambit/cli": "0.0.
|
|
18
|
-
"@teambit/envs": "0.0.
|
|
19
|
-
"@teambit/graphql": "0.0.
|
|
16
|
+
"@teambit/component": "0.0.556",
|
|
17
|
+
"@teambit/cli": "0.0.387",
|
|
18
|
+
"@teambit/envs": "0.0.556",
|
|
19
|
+
"@teambit/graphql": "0.0.556"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/mocha": "5.2.7",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@types/node": "12.20.4"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@teambit/legacy": "1.0.
|
|
30
|
+
"@teambit/legacy": "1.0.173",
|
|
31
31
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0"
|
|
33
33
|
},
|
|
@@ -55,12 +55,18 @@
|
|
|
55
55
|
"react": "-"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@teambit/legacy": "1.0.
|
|
58
|
+
"@teambit/legacy": "1.0.173",
|
|
59
59
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
67
|
+
"README.md",
|
|
68
|
+
"README.mdx"
|
|
69
|
+
],
|
|
64
70
|
"private": false,
|
|
65
71
|
"engines": {
|
|
66
72
|
"node": ">=12.22.0"
|
package/exceptions/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ParserNotFound } from './parser-not-found';
|
package/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Parser } from './parser';
|
|
2
|
-
export { SchemaExtractor } from './schema-extractor';
|
|
3
|
-
export { Export, Module, StaticProperties } from './schemas';
|
|
4
|
-
export type { SchemaMain } from './schema.main.runtime';
|
|
5
|
-
export { SchemaAspect } from './schema.aspect';
|
|
6
|
-
export { SemanticSchema } from './semantic-schema';
|
|
Binary file
|
package/parser.ts
DELETED
package/schema-extractor.ts
DELETED
package/schema.aspect.ts
DELETED
package/schema.graphql.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ComponentFactory } from '@teambit/component';
|
|
2
|
-
import gql from 'graphql-tag';
|
|
3
|
-
|
|
4
|
-
import { SchemaMain } from './schema.main.runtime';
|
|
5
|
-
|
|
6
|
-
export function schemaSchema(schema: SchemaMain) {
|
|
7
|
-
return {
|
|
8
|
-
typeDefs: gql`
|
|
9
|
-
extend type ComponentHost {
|
|
10
|
-
getSchema(id: String!): SchemaDocs
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type SchemaDocs {
|
|
14
|
-
exports: [String]
|
|
15
|
-
}
|
|
16
|
-
`,
|
|
17
|
-
resolvers: {
|
|
18
|
-
ComponentHost: {
|
|
19
|
-
getSchema: async (host: ComponentFactory, { id }: { id: string }) => {
|
|
20
|
-
const componentId = await host.resolveComponentId(id);
|
|
21
|
-
const component = await host.get(componentId);
|
|
22
|
-
const empty = {
|
|
23
|
-
exports: [],
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (!component) return empty;
|
|
27
|
-
const docs = await schema.getSchema(component);
|
|
28
|
-
if (!docs) return empty;
|
|
29
|
-
|
|
30
|
-
return docs;
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
package/schema.main.runtime.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { MainRuntime } from '@teambit/cli';
|
|
2
|
-
import { Component } from '@teambit/component';
|
|
3
|
-
import { Slot, SlotRegistry } from '@teambit/harmony';
|
|
4
|
-
import GraphqlAspect, { GraphqlMain } from '@teambit/graphql';
|
|
5
|
-
import { EnvsAspect, EnvsMain } from '@teambit/envs';
|
|
6
|
-
import { Parser } from './parser';
|
|
7
|
-
import { SchemaAspect } from './schema.aspect';
|
|
8
|
-
import { Module } from './schemas';
|
|
9
|
-
import { SemanticSchema } from './semantic-schema';
|
|
10
|
-
import { SchemaExtractor } from './schema-extractor';
|
|
11
|
-
import { schemaSchema } from './schema.graphql';
|
|
12
|
-
|
|
13
|
-
export type ParserSlot = SlotRegistry<Parser>;
|
|
14
|
-
|
|
15
|
-
export type SchemaConfig = {
|
|
16
|
-
/**
|
|
17
|
-
* default parser
|
|
18
|
-
*/
|
|
19
|
-
defaultParser: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* extension for extracting component schemas.
|
|
24
|
-
*/
|
|
25
|
-
export class SchemaMain {
|
|
26
|
-
constructor(
|
|
27
|
-
/**
|
|
28
|
-
* parsers slot.
|
|
29
|
-
*/
|
|
30
|
-
private parserSlot: ParserSlot,
|
|
31
|
-
|
|
32
|
-
private envs: EnvsMain,
|
|
33
|
-
|
|
34
|
-
private config: SchemaConfig
|
|
35
|
-
) {}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* get the default parser.
|
|
39
|
-
*/
|
|
40
|
-
getDefaultParser(): Parser {
|
|
41
|
-
return this.parserSlot.get(this.config.defaultParser) as Parser;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* parse a module into a component schema.
|
|
46
|
-
*/
|
|
47
|
-
parseModule(path: string): Module {
|
|
48
|
-
const parsers = this.parserSlot.toArray();
|
|
49
|
-
let maybeParser = parsers.find(([, parser]) => {
|
|
50
|
-
const match = path.match(parser.extension);
|
|
51
|
-
return match;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (!maybeParser) {
|
|
55
|
-
maybeParser = [this.config.defaultParser, this.getDefaultParser()];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const [, parser] = maybeParser;
|
|
59
|
-
return parser.parseModule(path);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* get a schema of a component.
|
|
64
|
-
* @param component target component.
|
|
65
|
-
*/
|
|
66
|
-
async getSchema(component: Component): Promise<SemanticSchema> {
|
|
67
|
-
const env = this.envs.getEnv(component).env;
|
|
68
|
-
if (typeof env.getSchemaExtractor === 'undefined') {
|
|
69
|
-
throw new Error(`No SchemaExtractor defined for ${env.name}`);
|
|
70
|
-
}
|
|
71
|
-
const schemaExtractor: SchemaExtractor = env.getSchemaExtractor();
|
|
72
|
-
await schemaExtractor.extract(component);
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
exports: [],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* register a new parser.
|
|
81
|
-
*/
|
|
82
|
-
registerParser(parser: Parser): SchemaMain {
|
|
83
|
-
this.parserSlot.register(parser);
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static runtime = MainRuntime;
|
|
88
|
-
|
|
89
|
-
static dependencies = [EnvsAspect, GraphqlAspect];
|
|
90
|
-
|
|
91
|
-
static defaultConfig = {
|
|
92
|
-
defaultParser: 'teambit.typescript/typescript',
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
static slots = [Slot.withType<Parser>()];
|
|
96
|
-
|
|
97
|
-
static async provider([envs, graphql]: [EnvsMain, GraphqlMain], config: SchemaConfig, [parserSlot]: [ParserSlot]) {
|
|
98
|
-
const schema = new SchemaMain(parserSlot, envs, config);
|
|
99
|
-
graphql.register(schemaSchema(schema));
|
|
100
|
-
// workspace.onComponentLoad(async (component) => {
|
|
101
|
-
// const apiSchema = await schema.getSchema(component);
|
|
102
|
-
// return {};
|
|
103
|
-
// });
|
|
104
|
-
|
|
105
|
-
return schema;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
SchemaAspect.addRuntime(SchemaMain);
|
package/schema.service.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { EnvService, ExecutionContext } from '@teambit/envs';
|
|
2
|
-
// import { APISchema } from './schema';
|
|
3
|
-
|
|
4
|
-
export class SchemaService implements EnvService<{}> {
|
|
5
|
-
name = 'schema';
|
|
6
|
-
|
|
7
|
-
async run(context: ExecutionContext) {
|
|
8
|
-
return { errors: [], context };
|
|
9
|
-
}
|
|
10
|
-
}
|
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
package/schemas/module.ts
DELETED
package/semantic-schema.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"es2019",
|
|
5
|
-
"DOM",
|
|
6
|
-
"ES6",
|
|
7
|
-
"DOM.Iterable",
|
|
8
|
-
"ScriptHost"
|
|
9
|
-
],
|
|
10
|
-
"target": "es2015",
|
|
11
|
-
"module": "commonjs",
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
|
-
"composite": true,
|
|
20
|
-
"emitDeclarationOnly": true,
|
|
21
|
-
"experimentalDecorators": true,
|
|
22
|
-
"emitDecoratorMetadata": true,
|
|
23
|
-
"allowSyntheticDefaultImports": true,
|
|
24
|
-
"strictPropertyInitialization": false,
|
|
25
|
-
"strict": true,
|
|
26
|
-
"noImplicitAny": false,
|
|
27
|
-
"rootDir": ".",
|
|
28
|
-
"preserveConstEnums": true,
|
|
29
|
-
"resolveJsonModule": true
|
|
30
|
-
},
|
|
31
|
-
"exclude": [
|
|
32
|
-
"dist"
|
|
33
|
-
]
|
|
34
|
-
}
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|