@teambit/schema 0.0.738 → 0.0.741
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/mock/button/button.composition.d.ts +5 -0
- package/dist/mock/button/button.composition.js +63 -0
- package/dist/mock/button/button.composition.js.map +1 -0
- package/dist/mock/button/button.d.ts +20 -0
- package/dist/mock/button/button.js +97 -0
- package/dist/mock/button/button.js.map +1 -0
- package/dist/mock/button/index.d.ts +80 -0
- package/dist/mock/button/index.js +207 -0
- package/dist/mock/button/index.js.map +1 -0
- package/dist/mock/button-schemas.json +1438 -0
- package/dist/schema.graphql.d.ts +1 -0
- package/dist/schema.graphql.js +13 -5
- package/dist/schema.graphql.js.map +1 -1
- package/dist/schema.main.runtime.d.ts +2 -0
- package/dist/schema.main.runtime.js +18 -1
- package/dist/schema.main.runtime.js.map +1 -1
- package/dist/schema.spec.d.ts +1 -0
- package/dist/schema.spec.js +148 -0
- package/dist/schema.spec.js.map +1 -0
- package/mock/button/button.composition.tsx +25 -0
- package/mock/button/button.tsx +63 -0
- package/mock/button/index.ts +116 -0
- package/mock/button-schemas.json +1438 -0
- package/package-tar/teambit-schema-0.0.741.tgz +0 -0
- package/package.json +19 -12
- package/preview-1653494536947.js +2 -0
- package/package-tar/teambit-schema-0.0.738.tgz +0 -0
- package/preview-1653227849497.js +0 -2
package/dist/schema.graphql.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { SchemaMain } from './schema.main.runtime';
|
|
|
3
3
|
export declare function schemaSchema(schema: SchemaMain): {
|
|
4
4
|
typeDefs: import("graphql").DocumentNode;
|
|
5
5
|
resolvers: {
|
|
6
|
+
JSONObject: import("graphql").GraphQLScalarType;
|
|
6
7
|
ComponentHost: {
|
|
7
8
|
getSchema: (host: ComponentFactory, { id }: {
|
|
8
9
|
id: string;
|
package/dist/schema.graphql.js
CHANGED
|
@@ -9,6 +9,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.schemaSchema = schemaSchema;
|
|
11
11
|
|
|
12
|
+
function _graphqlTypeJson() {
|
|
13
|
+
const data = require("graphql-type-json");
|
|
14
|
+
|
|
15
|
+
_graphqlTypeJson = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
function _graphqlTag() {
|
|
13
23
|
const data = _interopRequireDefault(require("graphql-tag"));
|
|
14
24
|
|
|
@@ -22,15 +32,13 @@ function _graphqlTag() {
|
|
|
22
32
|
function schemaSchema(schema) {
|
|
23
33
|
return {
|
|
24
34
|
typeDefs: (0, _graphqlTag().default)`
|
|
35
|
+
scalar JSONObject
|
|
25
36
|
extend type ComponentHost {
|
|
26
|
-
getSchema(id: String!):
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type SchemaDocs {
|
|
30
|
-
exports: [String]
|
|
37
|
+
getSchema(id: String!): JSONObject
|
|
31
38
|
}
|
|
32
39
|
`,
|
|
33
40
|
resolvers: {
|
|
41
|
+
JSONObject: _graphqlTypeJson().GraphQLJSONObject,
|
|
34
42
|
ComponentHost: {
|
|
35
43
|
getSchema: async (host, {
|
|
36
44
|
id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["schemaSchema","schema","typeDefs","gql","resolvers","ComponentHost","getSchema","host","id","componentId","resolveComponentId","component","get","empty","exports","docs"],"sources":["schema.graphql.ts"],"sourcesContent":["import { ComponentFactory } from '@teambit/component';\nimport gql from 'graphql-tag';\n\nimport { SchemaMain } from './schema.main.runtime';\n\nexport function schemaSchema(schema: SchemaMain) {\n return {\n typeDefs: gql`\n extend type ComponentHost {\n getSchema(id: String!):
|
|
1
|
+
{"version":3,"names":["schemaSchema","schema","typeDefs","gql","resolvers","JSONObject","GraphQLJSONObject","ComponentHost","getSchema","host","id","componentId","resolveComponentId","component","get","empty","exports","docs"],"sources":["schema.graphql.ts"],"sourcesContent":["import { ComponentFactory } from '@teambit/component';\nimport { GraphQLJSONObject } from 'graphql-type-json';\nimport gql from 'graphql-tag';\n\nimport { SchemaMain } from './schema.main.runtime';\n\nexport function schemaSchema(schema: SchemaMain) {\n return {\n typeDefs: gql`\n scalar JSONObject\n extend type ComponentHost {\n getSchema(id: String!): JSONObject\n }\n `,\n resolvers: {\n JSONObject: GraphQLJSONObject,\n ComponentHost: {\n getSchema: async (host: ComponentFactory, { id }: { id: string }) => {\n const componentId = await host.resolveComponentId(id);\n const component = await host.get(componentId);\n const empty = {\n exports: [],\n };\n\n if (!component) return empty;\n const docs = await schema.getSchema(component);\n if (!docs) return empty;\n\n return docs;\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,SAASA,YAAT,CAAsBC,MAAtB,EAA0C;EAC/C,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAA,CAAI;AAClB;AACA;AACA;AACA;AACA,KANS;IAOLC,SAAS,EAAE;MACTC,UAAU,EAAEC,oCADH;MAETC,aAAa,EAAE;QACbC,SAAS,EAAE,OAAOC,IAAP,EAA+B;UAAEC;QAAF,CAA/B,KAA0D;UACnE,MAAMC,WAAW,GAAG,MAAMF,IAAI,CAACG,kBAAL,CAAwBF,EAAxB,CAA1B;UACA,MAAMG,SAAS,GAAG,MAAMJ,IAAI,CAACK,GAAL,CAASH,WAAT,CAAxB;UACA,MAAMI,KAAK,GAAG;YACZC,OAAO,EAAE;UADG,CAAd;UAIA,IAAI,CAACH,SAAL,EAAgB,OAAOE,KAAP;UAChB,MAAME,IAAI,GAAG,MAAMhB,MAAM,CAACO,SAAP,CAAiBK,SAAjB,CAAnB;UACA,IAAI,CAACI,IAAL,EAAW,OAAOF,KAAP;UAEX,OAAOE,IAAP;QACD;MAbY;IAFN;EAPN,CAAP;AA0BD"}
|
|
@@ -42,6 +42,7 @@ export declare class SchemaMain {
|
|
|
42
42
|
* @param component target component.
|
|
43
43
|
*/
|
|
44
44
|
getSchema(component: Component): Promise<APISchema>;
|
|
45
|
+
getSchemaFromObject(obj: Record<string, any>): APISchema;
|
|
45
46
|
/**
|
|
46
47
|
* register a new parser.
|
|
47
48
|
*/
|
|
@@ -54,3 +55,4 @@ export declare class SchemaMain {
|
|
|
54
55
|
};
|
|
55
56
|
static provider([envs, cli, component, graphql]: [EnvsMain, CLIMain, ComponentMain, GraphqlMain], config: SchemaConfig, [parserSlot]: [ParserSlot]): Promise<SchemaMain>;
|
|
56
57
|
}
|
|
58
|
+
export default SchemaMain;
|
|
@@ -11,7 +11,7 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", {
|
|
12
12
|
value: true
|
|
13
13
|
});
|
|
14
|
-
exports.SchemaMain = void 0;
|
|
14
|
+
exports.default = exports.SchemaMain = void 0;
|
|
15
15
|
|
|
16
16
|
function _defineProperty2() {
|
|
17
17
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -73,6 +73,16 @@ function _envs() {
|
|
|
73
73
|
return data;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
function _semanticsEntities() {
|
|
77
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
78
|
+
|
|
79
|
+
_semanticsEntities = function () {
|
|
80
|
+
return data;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
function _schema() {
|
|
77
87
|
const data = require("./schema.aspect");
|
|
78
88
|
|
|
@@ -169,6 +179,10 @@ class SchemaMain {
|
|
|
169
179
|
const schemaExtractor = env.getSchemaExtractor();
|
|
170
180
|
return schemaExtractor.extract(component);
|
|
171
181
|
}
|
|
182
|
+
|
|
183
|
+
getSchemaFromObject(obj) {
|
|
184
|
+
return _semanticsEntities().APISchema.fromObject(obj);
|
|
185
|
+
}
|
|
172
186
|
/**
|
|
173
187
|
* register a new parser.
|
|
174
188
|
*/
|
|
@@ -202,4 +216,7 @@ exports.SchemaMain = SchemaMain;
|
|
|
202
216
|
|
|
203
217
|
_schema().SchemaAspect.addRuntime(SchemaMain);
|
|
204
218
|
|
|
219
|
+
var _default = SchemaMain;
|
|
220
|
+
exports.default = _default;
|
|
221
|
+
|
|
205
222
|
//# sourceMappingURL=schema.main.runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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","schemaSchema","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","GraphqlAspect","Slot","withType","SchemaAspect","addRuntime"],"sources":["schema.main.runtime.ts"],"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 { APISchema, Export } 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): Export[] {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;
|
|
1
|
+
{"version":3,"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","getSchemaFromObject","obj","APISchema","fromObject","registerParser","register","provider","cli","graphql","schema","SchemaCommand","schemaSchema","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","GraphqlAspect","Slot","withType","SchemaAspect","addRuntime"],"sources":["schema.main.runtime.ts"],"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 { APISchema, Export } 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): Export[] {\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 getSchemaFromObject(obj: Record<string, any>): APISchema {\n return APISchema.fromObject(obj);\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\nexport default SchemaMain;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA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C,U,aAuEMsC,kB;gCAvENtC,U,kBAwEW,CAACuC,kBAAD,EAAaC,gBAAb,EAAwBC,oBAAxB,EAAyCC,kBAAzC,C;gCAxEX1C,U,WAyEI,CAAC2C,eAAA,CAAKC,QAAL,EAAD,C;gCAzEJ5C,U,mBA2EY;EACrBO,aAAa,EAAE;AADM,C;;AAsBzBsC,sBAAA,CAAaC,UAAb,CAAwB9C,UAAxB;;eAEeA,U"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
function _path() {
|
|
8
|
+
const data = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
_path = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _fsExtra() {
|
|
18
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
19
|
+
|
|
20
|
+
_fsExtra = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _semanticsEntities() {
|
|
28
|
+
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
29
|
+
|
|
30
|
+
_semanticsEntities = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _harmonyTesting() {
|
|
38
|
+
const data = require("@teambit/harmony.testing.load-aspect");
|
|
39
|
+
|
|
40
|
+
_harmonyTesting = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _workspaceTesting() {
|
|
48
|
+
const data = require("@teambit/workspace.testing.mock-workspace");
|
|
49
|
+
|
|
50
|
+
_workspaceTesting = function () {
|
|
51
|
+
return data;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _workspace() {
|
|
58
|
+
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
59
|
+
|
|
60
|
+
_workspace = function () {
|
|
61
|
+
return data;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _() {
|
|
68
|
+
const data = require(".");
|
|
69
|
+
|
|
70
|
+
_ = function () {
|
|
71
|
+
return data;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return data;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
describe('SchemaAspect', function () {
|
|
78
|
+
let schema;
|
|
79
|
+
let workspace;
|
|
80
|
+
let workspaceData;
|
|
81
|
+
beforeAll(async () => {
|
|
82
|
+
workspaceData = (0, _workspaceTesting().mockWorkspace)();
|
|
83
|
+
});
|
|
84
|
+
afterAll(async () => {
|
|
85
|
+
await (0, _workspaceTesting().destroyWorkspace)(workspaceData);
|
|
86
|
+
});
|
|
87
|
+
describe('getSchema()', () => {
|
|
88
|
+
let apiSchema;
|
|
89
|
+
beforeAll(async () => {
|
|
90
|
+
const {
|
|
91
|
+
workspacePath
|
|
92
|
+
} = workspaceData; // eslint-disable-next-line no-console
|
|
93
|
+
|
|
94
|
+
console.log('workspace created at ', workspacePath);
|
|
95
|
+
|
|
96
|
+
const compDir = _path().default.join(workspacePath, 'button');
|
|
97
|
+
|
|
98
|
+
const src = _path().default.join(getMockDir(), 'button');
|
|
99
|
+
|
|
100
|
+
await _fsExtra().default.copy(src, compDir);
|
|
101
|
+
workspace = await (0, _harmonyTesting().loadAspect)(_workspace().default, workspacePath);
|
|
102
|
+
await workspace.track({
|
|
103
|
+
rootDir: compDir
|
|
104
|
+
});
|
|
105
|
+
await workspace.bitMap.write();
|
|
106
|
+
schema = await (0, _harmonyTesting().loadAspect)(_().SchemaAspect, workspacePath);
|
|
107
|
+
const compId = await workspace.resolveComponentId('button');
|
|
108
|
+
const comp = await workspace.get(compId);
|
|
109
|
+
apiSchema = await schema.getSchema(comp);
|
|
110
|
+
});
|
|
111
|
+
it('should be able to generate JSON object with all schemas', async () => {
|
|
112
|
+
const results = apiSchema.toObject();
|
|
113
|
+
|
|
114
|
+
const expectedJsonPath = _path().default.join(getMockDir(), 'button-schemas.json'); // uncomment the next line temporarily to sync the expected json with new schema changes
|
|
115
|
+
// fs.outputFileSync(expectedJsonPath, JSON.stringify(results, undefined, 2));
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const expectedJson = _fsExtra().default.readJsonSync(expectedJsonPath); // @ts-ignore it exists on Jest. for some reason ts assumes this is Jasmine.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
expect(results).toMatchObject(expectedJson);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe('getSchemaFromObject', () => {
|
|
125
|
+
it('should be able to deserialize an JSON object to SchemaNode instances', () => {
|
|
126
|
+
const jsonPath = _path().default.join(getMockDir(), 'button-schemas.json');
|
|
127
|
+
|
|
128
|
+
const json = _fsExtra().default.readJsonSync(jsonPath);
|
|
129
|
+
|
|
130
|
+
const apiSchema = schema.getSchemaFromObject(json);
|
|
131
|
+
expect(apiSchema instanceof _semanticsEntities().APISchema).toBeTruthy(); // @ts-ignore it exists on Jest. for some reason ts assumes this is Jasmine.
|
|
132
|
+
|
|
133
|
+
expect(apiSchema.toObject()).toMatchObject(json);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
function getCurrentDir() {
|
|
139
|
+
const currentDir = __dirname;
|
|
140
|
+
if (currentDir.endsWith(`${_path().default.sep}dist`)) return currentDir.slice(0, -5);
|
|
141
|
+
return currentDir;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function getMockDir() {
|
|
145
|
+
return _path().default.join(getCurrentDir(), 'mock');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=schema.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["describe","schema","workspace","workspaceData","beforeAll","mockWorkspace","afterAll","destroyWorkspace","apiSchema","workspacePath","console","log","compDir","path","join","src","getMockDir","fs","copy","loadAspect","WorkspaceAspect","track","rootDir","bitMap","write","SchemaAspect","compId","resolveComponentId","comp","get","getSchema","it","results","toObject","expectedJsonPath","expectedJson","readJsonSync","expect","toMatchObject","jsonPath","json","getSchemaFromObject","APISchema","toBeTruthy","getCurrentDir","currentDir","__dirname","endsWith","sep","slice"],"sources":["schema.spec.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport { APISchema } from '@teambit/semantics.entities.semantic-schema';\nimport { loadAspect } from '@teambit/harmony.testing.load-aspect';\nimport { mockWorkspace, destroyWorkspace, WorkspaceData } from '@teambit/workspace.testing.mock-workspace';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { SchemaMain } from './schema.main.runtime';\nimport { SchemaAspect } from '.';\n\ndescribe('SchemaAspect', function () {\n let schema: SchemaMain;\n let workspace: Workspace;\n let workspaceData: WorkspaceData;\n beforeAll(async () => {\n workspaceData = mockWorkspace();\n });\n afterAll(async () => {\n await destroyWorkspace(workspaceData);\n });\n describe('getSchema()', () => {\n let apiSchema: APISchema;\n beforeAll(async () => {\n const { workspacePath } = workspaceData;\n // eslint-disable-next-line no-console\n console.log('workspace created at ', workspacePath);\n const compDir = path.join(workspacePath, 'button');\n const src = path.join(getMockDir(), 'button');\n await fs.copy(src, compDir);\n workspace = await loadAspect(WorkspaceAspect, workspacePath);\n await workspace.track({ rootDir: compDir });\n await workspace.bitMap.write();\n schema = await loadAspect(SchemaAspect, workspacePath);\n const compId = await workspace.resolveComponentId('button');\n const comp = await workspace.get(compId);\n apiSchema = await schema.getSchema(comp);\n });\n it('should be able to generate JSON object with all schemas', async () => {\n const results = apiSchema.toObject();\n const expectedJsonPath = path.join(getMockDir(), 'button-schemas.json');\n // uncomment the next line temporarily to sync the expected json with new schema changes\n // fs.outputFileSync(expectedJsonPath, JSON.stringify(results, undefined, 2));\n const expectedJson = fs.readJsonSync(expectedJsonPath);\n // @ts-ignore it exists on Jest. for some reason ts assumes this is Jasmine.\n expect(results).toMatchObject(expectedJson);\n });\n });\n describe('getSchemaFromObject', () => {\n it('should be able to deserialize an JSON object to SchemaNode instances', () => {\n const jsonPath = path.join(getMockDir(), 'button-schemas.json');\n const json = fs.readJsonSync(jsonPath);\n const apiSchema = schema.getSchemaFromObject(json);\n expect(apiSchema instanceof APISchema).toBeTruthy();\n // @ts-ignore it exists on Jest. for some reason ts assumes this is Jasmine.\n expect(apiSchema.toObject()).toMatchObject(json);\n });\n });\n});\n\nfunction getCurrentDir() {\n const currentDir = __dirname;\n if (currentDir.endsWith(`${path.sep}dist`)) return currentDir.slice(0, -5);\n return currentDir;\n}\n\nfunction getMockDir() {\n return path.join(getCurrentDir(), 'mock');\n}\n"],"mappings":";;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEAA,QAAQ,CAAC,cAAD,EAAiB,YAAY;EACnC,IAAIC,MAAJ;EACA,IAAIC,SAAJ;EACA,IAAIC,aAAJ;EACAC,SAAS,CAAC,YAAY;IACpBD,aAAa,GAAG,IAAAE,iCAAA,GAAhB;EACD,CAFQ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} from './button';
|
|
5
|
+
|
|
6
|
+
export const BasicButton = () => {
|
|
7
|
+
return <Button>click me</Button>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ButtonWithCustomStyles = () => {
|
|
11
|
+
return <Button style={{ background: 'red' }}>click me</Button>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const ButtonWithIcon = () => {
|
|
15
|
+
return (
|
|
16
|
+
<Button>
|
|
17
|
+
{/* <Image src="https://static.bit.dev/bit-logo.svg" /> */}
|
|
18
|
+
click me
|
|
19
|
+
</Button>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const ButtonAsALink = () => {
|
|
24
|
+
return <Button href="https://bit.dev">Bit</Button>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved */
|
|
2
|
+
import React, { ReactNode, useRef } from 'react';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
// import { useButton } from '@react-aria/button';
|
|
5
|
+
import { Link } from '@teambit/base-react.navigation.link';
|
|
6
|
+
|
|
7
|
+
export type ButtonElementType = 'a' | 'button';
|
|
8
|
+
|
|
9
|
+
export type ButtonProps = {
|
|
10
|
+
/**
|
|
11
|
+
* children of the Button.
|
|
12
|
+
*/
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* link to target page. once href is used, Button is considered an A tag.
|
|
17
|
+
*/
|
|
18
|
+
href?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* class names to inject.
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
25
|
+
|
|
26
|
+
export function Button(props: ButtonProps) {
|
|
27
|
+
const ref = useRef();
|
|
28
|
+
|
|
29
|
+
// const { buttonProps } = useButton(
|
|
30
|
+
// {
|
|
31
|
+
// ...props,
|
|
32
|
+
// elementType: props.href ? 'a' : undefined,
|
|
33
|
+
// },
|
|
34
|
+
// // @ts-ignore figure this out.
|
|
35
|
+
// ref
|
|
36
|
+
// );
|
|
37
|
+
|
|
38
|
+
const allProps = {
|
|
39
|
+
// ...buttonProps,
|
|
40
|
+
...props,
|
|
41
|
+
};
|
|
42
|
+
const external = props.href?.startsWith('http:') || props.href?.startsWith('https:');
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
{!props.href ? (
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
<button className={props.className} ref={ref} {...allProps}>
|
|
49
|
+
{props.children}
|
|
50
|
+
</button>
|
|
51
|
+
) : (
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
<Link external={external} ref={ref} className={props.className} {...allProps}>
|
|
54
|
+
{props.children}
|
|
55
|
+
</Link>
|
|
56
|
+
)}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class Bar {
|
|
62
|
+
foo() {}
|
|
63
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
/* eslint-disable @typescript-eslint/prefer-as-const */
|
|
5
|
+
/* eslint-disable one-var */
|
|
6
|
+
/* eslint-disable max-classes-per-file */
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param a this is A
|
|
10
|
+
* @param b this is B
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export function myFunc(a = 4, b = 5): number {
|
|
14
|
+
return a + b;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export * from './button';
|
|
18
|
+
|
|
19
|
+
export function Hi() {}
|
|
20
|
+
|
|
21
|
+
export const a = 4,
|
|
22
|
+
b: 5 = 5;
|
|
23
|
+
|
|
24
|
+
export * as Compositions from './button.composition';
|
|
25
|
+
|
|
26
|
+
export const HiThere = 'HiThere';
|
|
27
|
+
|
|
28
|
+
export const Function = () => {};
|
|
29
|
+
|
|
30
|
+
export const Array = ['hi', 'there'];
|
|
31
|
+
|
|
32
|
+
class Foo {}
|
|
33
|
+
|
|
34
|
+
class ClassSomething {
|
|
35
|
+
app = '';
|
|
36
|
+
constructor(readonly da: 'dsa') {}
|
|
37
|
+
|
|
38
|
+
a() {
|
|
39
|
+
return new Foo();
|
|
40
|
+
}
|
|
41
|
+
get getter() {
|
|
42
|
+
return 'hi';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set setter(a: boolean) {}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { ClassSomething };
|
|
49
|
+
|
|
50
|
+
export type IndexSig = { [key: string]: boolean };
|
|
51
|
+
|
|
52
|
+
export interface Hello {
|
|
53
|
+
propertySig: () => void;
|
|
54
|
+
methodSig(): string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const obj = { a: 1, b: 2 };
|
|
58
|
+
|
|
59
|
+
export const a1: typeof obj = { a: 5, b: 9 };
|
|
60
|
+
|
|
61
|
+
export type TypeOperator = keyof typeof obj;
|
|
62
|
+
|
|
63
|
+
// this is for Jump in the definition
|
|
64
|
+
class Bar {
|
|
65
|
+
foo() {}
|
|
66
|
+
}
|
|
67
|
+
export const getBar = (bar: Bar) => new Bar();
|
|
68
|
+
|
|
69
|
+
export const tuple = ([a, b, c]: [string, Function, Record<string, any>]) => {};
|
|
70
|
+
|
|
71
|
+
export enum Food {
|
|
72
|
+
Falafel,
|
|
73
|
+
Hummus,
|
|
74
|
+
Tahini,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function getPromise(): Promise<string> {
|
|
78
|
+
return 'promise';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class T1 {}
|
|
82
|
+
class T2 {}
|
|
83
|
+
class T3<T, K> {}
|
|
84
|
+
export type TypeRefWithArgs = T3<T1, T2>;
|
|
85
|
+
|
|
86
|
+
export type ParenthesizedType = (T1 | T2)[];
|
|
87
|
+
|
|
88
|
+
export function typePredicateFn(str: any): str is string {
|
|
89
|
+
return str;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function typePredicateNoTypeFn(condition: any, msg?: string): asserts condition {}
|
|
93
|
+
|
|
94
|
+
export async function objectBindingElements({ prop = 1 }) {
|
|
95
|
+
return prop;
|
|
96
|
+
}
|
|
97
|
+
export async function arrayBindingElements([prop]: [string]) {
|
|
98
|
+
return prop;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface config {
|
|
102
|
+
someField: { a: string; b: boolean };
|
|
103
|
+
}
|
|
104
|
+
export type IndexedAccessType = config['someField'];
|
|
105
|
+
|
|
106
|
+
const computedName = 'str';
|
|
107
|
+
export interface ComputedNameWithType {
|
|
108
|
+
[computedName]: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface ComputedNameNoType {
|
|
111
|
+
[computedName];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type World1 = 'world1-a' | 'world1-b';
|
|
115
|
+
type World2 = 'world2';
|
|
116
|
+
export type templateLiteralType = `hello ${World1} hi ${World2}`;
|