@teambit/graph 0.0.886 → 0.0.887

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.
@@ -7,5 +7,5 @@ export declare class GraphBuilder {
7
7
  private componentAspect;
8
8
  constructor(componentAspect: ComponentMain);
9
9
  getGraph(ids?: ComponentID[], opts?: GetGraphOpts): Promise<ComponentGraph>;
10
- private buildFromLegacy;
10
+ private toComponentGraph;
11
11
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.array.iterator.js");
4
3
  require("core-js/modules/es.promise.js");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
@@ -33,31 +32,20 @@ class GraphBuilder {
33
32
  }
34
33
  async getGraph(ids, opts = {}) {
35
34
  const componentHost = opts.host || this.componentAspect.getHost();
36
- const legacyGraph = await componentHost.getLegacyGraph(ids, false);
37
- const graph = await this.buildFromLegacy(legacyGraph, {
38
- host: opts.host
39
- });
40
- graph.seederIds = ids || (await componentHost.listIds());
41
- return graph;
35
+ const graph = await componentHost.getGraph(ids, false);
36
+ const componentGraph = await this.toComponentGraph(graph);
37
+ componentGraph.seederIds = ids || (await componentHost.listIds());
38
+ return componentGraph;
42
39
  }
43
- async buildFromLegacy(legacyGraph, opts = {}) {
40
+ async toComponentGraph(graph) {
44
41
  const newGraph = new (_componentGraph().ComponentGraph)();
45
- const componentHost = opts.host || this.componentAspect.getHost();
46
- const setNodeP = legacyGraph.nodes().map(async nodeId => {
47
- const componentId = await componentHost.resolveComponentId(nodeId);
48
- const component = await componentHost.get(componentId);
49
- if (component) {
50
- newGraph.setNode(new (_graph().Node)(componentId.toString(), component));
51
- }
42
+ graph.nodes.forEach(node => {
43
+ newGraph.setNode(node);
52
44
  });
53
- await Promise.all(setNodeP);
54
- const setEdgePromise = legacyGraph.edges().map(async edgeId => {
55
- const source = await componentHost.resolveComponentId(edgeId.v);
56
- const target = await componentHost.resolveComponentId(edgeId.w);
57
- const edgeObj = legacyGraph.edge(edgeId.v, edgeId.w) === 'dependencies' ? new (_dependency().Dependency)('runtime') : new (_dependency().Dependency)('dev');
58
- newGraph.setEdge(new (_graph().Edge)(source.toString(), target.toString(), edgeObj));
45
+ graph.edges.forEach(edge => {
46
+ const edgeObj = edge.attr === 'dependencies' ? new (_dependency().Dependency)('runtime') : new (_dependency().Dependency)('dev');
47
+ newGraph.setEdge(new (_graph().Edge)(edge.sourceId, edge.targetId, edgeObj));
59
48
  });
60
- await Promise.all(setEdgePromise);
61
49
  return newGraph;
62
50
  }
63
51
  }
@@ -1 +1 @@
1
- {"version":3,"names":["GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","legacyGraph","getLegacyGraph","graph","buildFromLegacy","seederIds","listIds","newGraph","ComponentGraph","setNodeP","nodes","map","nodeId","componentId","resolveComponentId","component","get","setNode","Node","toString","Promise","all","setEdgePromise","edges","edgeId","source","v","target","w","edgeObj","edge","Dependency","setEdge","Edge"],"sources":["graph-builder.ts"],"sourcesContent":["import { ComponentFactory, ComponentID, ComponentMain } from '@teambit/component';\nimport { Node, Edge } from '@teambit/graph.cleargraph';\nimport type LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport { ComponentGraph } from './component-graph';\nimport { Dependency } from './model/dependency';\n\nexport type GetGraphOpts = {\n host?: ComponentFactory;\n};\n\ntype BuildFromLegacyGraphOpts = {\n host?: ComponentFactory;\n};\n\nexport class GraphBuilder {\n constructor(private componentAspect: ComponentMain) {}\n\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const legacyGraph = await componentHost.getLegacyGraph(ids, false);\n const graph = await this.buildFromLegacy(legacyGraph, { host: opts.host });\n graph.seederIds = ids || (await componentHost.listIds());\n return graph;\n }\n\n private async buildFromLegacy(\n legacyGraph: LegacyGraph,\n opts: BuildFromLegacyGraphOpts = {}\n ): Promise<ComponentGraph> {\n const newGraph = new ComponentGraph();\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const setNodeP = legacyGraph.nodes().map(async (nodeId) => {\n const componentId = await componentHost.resolveComponentId(nodeId);\n const component = await componentHost.get(componentId);\n if (component) {\n newGraph.setNode(new Node(componentId.toString(), component));\n }\n });\n await Promise.all(setNodeP);\n\n const setEdgePromise = legacyGraph.edges().map(async (edgeId) => {\n const source = await componentHost.resolveComponentId(edgeId.v);\n const target = await componentHost.resolveComponentId(edgeId.w);\n const edgeObj =\n legacyGraph.edge(edgeId.v, edgeId.w) === 'dependencies' ? new Dependency('runtime') : new Dependency('dev');\n newGraph.setEdge(new Edge(source.toString(), target.toString(), edgeObj));\n });\n await Promise.all(setEdgePromise);\n\n return newGraph;\n }\n}\n"],"mappings":";;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUO,MAAMA,YAAY,CAAC;EACxBC,WAAW,CAASC,eAA8B,EAAE;IAAA,KAAhCA,eAA8B,GAA9BA,eAA8B;EAAG;EAErD,MAAMC,QAAQ,CAACC,GAAmB,EAAEC,IAAkB,GAAG,CAAC,CAAC,EAA2B;IACpF,MAAMC,aAAa,GAAGD,IAAI,CAACE,IAAI,IAAI,IAAI,CAACL,eAAe,CAACM,OAAO,EAAE;IAEjE,MAAMC,WAAW,GAAG,MAAMH,aAAa,CAACI,cAAc,CAACN,GAAG,EAAE,KAAK,CAAC;IAClE,MAAMO,KAAK,GAAG,MAAM,IAAI,CAACC,eAAe,CAACH,WAAW,EAAE;MAAEF,IAAI,EAAEF,IAAI,CAACE;IAAK,CAAC,CAAC;IAC1EI,KAAK,CAACE,SAAS,GAAGT,GAAG,KAAK,MAAME,aAAa,CAACQ,OAAO,EAAE,CAAC;IACxD,OAAOH,KAAK;EACd;EAEA,MAAcC,eAAe,CAC3BH,WAAwB,EACxBJ,IAA8B,GAA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AG,CAACC,cAAc,CAAC;IAEjC,OAAOf,QAAQ;EACjB;AACF;AAAC"}
1
+ {"version":3,"names":["GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","graph","componentGraph","toComponentGraph","seederIds","listIds","newGraph","ComponentGraph","nodes","forEach","node","setNode","edges","edge","edgeObj","attr","Dependency","setEdge","Edge","sourceId","targetId"],"sources":["graph-builder.ts"],"sourcesContent":["import { Component, ComponentFactory, ComponentID, ComponentMain } from '@teambit/component';\nimport { Edge, Graph } from '@teambit/graph.cleargraph';\nimport { ComponentGraph } from './component-graph';\nimport { Dependency } from './model/dependency';\n\nexport type GetGraphOpts = {\n host?: ComponentFactory;\n};\n\nexport class GraphBuilder {\n constructor(private componentAspect: ComponentMain) {}\n\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const graph = await componentHost.getGraph(ids, false);\n const componentGraph = await this.toComponentGraph(graph);\n componentGraph.seederIds = ids || (await componentHost.listIds());\n return componentGraph;\n }\n\n private async toComponentGraph(graph: Graph<Component, string>): Promise<ComponentGraph> {\n const newGraph = new ComponentGraph();\n graph.nodes.forEach((node) => {\n newGraph.setNode(node);\n });\n graph.edges.forEach((edge) => {\n const edgeObj = edge.attr === 'dependencies' ? new Dependency('runtime') : new Dependency('dev');\n newGraph.setEdge(new Edge(edge.sourceId, edge.targetId, edgeObj));\n });\n return newGraph;\n }\n}\n"],"mappings":";;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMO,MAAMA,YAAY,CAAC;EACxBC,WAAW,CAASC,eAA8B,EAAE;IAAA,KAAhCA,eAA8B,GAA9BA,eAA8B;EAAG;EAErD,MAAMC,QAAQ,CAACC,GAAmB,EAAEC,IAAkB,GAAG,CAAC,CAAC,EAA2B;IACpF,MAAMC,aAAa,GAAGD,IAAI,CAACE,IAAI,IAAI,IAAI,CAACL,eAAe,CAACM,OAAO,EAAE;IAEjE,MAAMC,KAAK,GAAG,MAAMH,aAAa,CAACH,QAAQ,CAACC,GAAG,EAAE,KAAK,CAAC;IACtD,MAAMM,cAAc,GAAG,MAAM,IAAI,CAACC,gBAAgB,CAACF,KAAK,CAAC;IACzDC,cAAc,CAACE,SAAS,GAAGR,GAAG,KAAK,MAAME,aAAa,CAACO,OAAO,EAAE,CAAC;IACjE,OAAOH,cAAc;EACvB;EAEA,MAAcC,gBAAgB,CAACF,KAA+B,EAA2B;IACvF,MAAMK,QAAQ,GAAG,KAAIC,gCAAc,GAAE;IACrCN,KAAK,CAACO,KAAK,CAACC,OAAO,CAAEC,IAAI,IAAK;MAC5BJ,QAAQ,CAACK,OAAO,CAACD,IAAI,CAAC;IACxB,CAAC,CAAC;IACFT,KAAK,CAACW,KAAK,CAACH,OAAO,CAAEI,IAAI,IAAK;MAC5B,MAAMC,OAAO,GAAGD,IAAI,CAACE,IAAI,KAAK,cAAc,GAAG,KAAIC,wBAAU,EAAC,SAAS,CAAC,GAAG,KAAIA,wBAAU,EAAC,KAAK,CAAC;MAChGV,QAAQ,CAACW,OAAO,CAAC,KAAIC,aAAI,EAACL,IAAI,CAACM,QAAQ,EAAEN,IAAI,CAACO,QAAQ,EAAEN,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IACF,OAAOR,QAAQ;EACjB;AACF;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/graph",
3
- "version": "0.0.886",
3
+ "version": "0.0.887",
4
4
  "homepage": "https://bit.dev/teambit/component/graph",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "graph",
9
- "version": "0.0.886"
9
+ "version": "0.0.887"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -15,9 +15,9 @@
15
15
  "lodash": "4.17.21",
16
16
  "classnames": "2.2.6",
17
17
  "react-flow-renderer": "8.3.7",
18
- "semver": "7.3.4",
19
18
  "dagre": "0.8.5",
20
- "@babel/runtime": "7.12.18",
19
+ "semver": "7.3.4",
20
+ "@babel/runtime": "7.20.0",
21
21
  "core-js": "^3.0.0",
22
22
  "@teambit/graph.cleargraph": "0.0.1",
23
23
  "@teambit/harmony": "0.3.3",
@@ -26,32 +26,32 @@
26
26
  "@teambit/base-ui.text.muted-text": "1.0.1",
27
27
  "@teambit/evangelist.input.checkbox.label": "1.0.3",
28
28
  "@teambit/documenter.ui.heading": "4.1.1",
29
- "@teambit/component": "0.0.886",
30
- "@teambit/cli": "0.0.594",
31
- "@teambit/legacy-bit-id": "0.0.414",
32
- "@teambit/graphql": "0.0.886",
33
- "@teambit/logger": "0.0.687",
34
- "@teambit/component-compare": "0.0.134",
35
- "@teambit/ui": "0.0.886",
36
- "@teambit/component.modules.component-url": "0.0.141",
37
- "@teambit/component.ui.deprecation-icon": "0.0.500",
38
- "@teambit/design.ui.styles.ellipsis": "0.0.353",
39
- "@teambit/envs.ui.env-icon": "0.0.492",
40
- "@teambit/component.ui.compare": "0.0.108",
41
- "@teambit/design.ui.round-loader": "0.0.352",
42
- "@teambit/design.ui.pages.not-found": "0.0.363",
43
- "@teambit/design.ui.pages.server-error": "0.0.363",
44
- "@teambit/ui-foundation.ui.full-loader": "0.0.492",
45
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.496",
46
- "@teambit/ui-foundation.ui.react-router.use-query": "0.0.493"
29
+ "@teambit/component": "0.0.887",
30
+ "@teambit/cli": "0.0.595",
31
+ "@teambit/legacy-bit-id": "0.0.415",
32
+ "@teambit/graphql": "0.0.887",
33
+ "@teambit/logger": "0.0.688",
34
+ "@teambit/component-compare": "0.0.135",
35
+ "@teambit/ui": "0.0.887",
36
+ "@teambit/component.modules.component-url": "0.0.142",
37
+ "@teambit/component.ui.deprecation-icon": "0.0.501",
38
+ "@teambit/design.ui.styles.ellipsis": "0.0.354",
39
+ "@teambit/envs.ui.env-icon": "0.0.493",
40
+ "@teambit/component.ui.compare": "0.0.109",
41
+ "@teambit/design.ui.round-loader": "0.0.353",
42
+ "@teambit/design.ui.pages.not-found": "0.0.364",
43
+ "@teambit/design.ui.pages.server-error": "0.0.364",
44
+ "@teambit/ui-foundation.ui.full-loader": "0.0.493",
45
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.497",
46
+ "@teambit/ui-foundation.ui.react-router.use-query": "0.0.494"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/graphlib": "2.1.7",
50
50
  "@types/react": "^17.0.8",
51
51
  "@types/lodash": "4.14.165",
52
52
  "@types/classnames": "2.2.11",
53
- "@types/semver": "7.3.4",
54
53
  "@types/dagre": "0.7.44",
54
+ "@types/semver": "7.3.4",
55
55
  "@types/mocha": "9.1.0",
56
56
  "@types/testing-library__jest-dom": "5.9.5",
57
57
  "@types/jest": "^26.0.0",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@apollo/client": "^3.6.0",
63
- "@teambit/legacy": "1.0.377",
63
+ "@teambit/legacy": "1.0.379",
64
64
  "react-dom": "^16.8.0 || ^17.0.0",
65
65
  "react": "^16.8.0 || ^17.0.0"
66
66
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.886/dist/graph.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.886/dist/graph.docs.md';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.887/dist/graph.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.887/dist/graph.docs.md';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];