@teambit/graph 1.0.106 → 1.0.108

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.
Files changed (55) hide show
  1. package/component-id-graph.ts +76 -0
  2. package/dist/component-graph/component-graph.d.ts +2 -2
  3. package/dist/component-graph/component-graph.js +2 -3
  4. package/dist/component-graph/component-graph.js.map +1 -1
  5. package/dist/component-id-graph.d.ts +4 -4
  6. package/dist/duplicate-dependency.d.ts +1 -1
  7. package/dist/graph-builder.d.ts +1 -1
  8. package/dist/graph-cmd.d.ts +1 -1
  9. package/dist/graph.compare.section.d.ts +2 -2
  10. package/dist/graph.composition.d.ts +2 -2
  11. package/dist/graph.main.runtime.d.ts +1 -1
  12. package/dist/graph.ui.runtime.d.ts +3 -3
  13. package/dist/model/dependency/dependency.d.ts +1 -1
  14. package/dist/model/graph-filters/graph-filters.d.ts +1 -1
  15. package/dist/object-list-to-graph.d.ts +2 -2
  16. package/dist/object-list-to-graph.js +2 -2
  17. package/dist/object-list-to-graph.js.map +1 -1
  18. package/dist/{preview-1703505948637.js → preview-1703647408454.js} +2 -2
  19. package/dist/ui/component-node/component-node.d.ts +2 -2
  20. package/dist/ui/dependencies-compare/compare-node-model.d.ts +1 -1
  21. package/dist/ui/dependencies-compare/dependencies-compare.d.ts +2 -2
  22. package/dist/ui/dependencies-compare/dependencies-compare.js +9 -13
  23. package/dist/ui/dependencies-compare/dependencies-compare.js.map +1 -1
  24. package/dist/ui/dependencies-compare/dependency-compare-node.d.ts +3 -3
  25. package/dist/ui/dependencies-compare/diff-graph.d.ts +1 -1
  26. package/dist/ui/dependencies-compare/diff-graph.js +4 -7
  27. package/dist/ui/dependencies-compare/diff-graph.js.map +1 -1
  28. package/dist/ui/dependencies-graph/calc-elements.d.ts +1 -1
  29. package/dist/ui/dependencies-graph/dep-edge/dep-edge.d.ts +1 -1
  30. package/dist/ui/dependencies-graph/dependencies-graph.d.ts +3 -3
  31. package/dist/ui/dependencies-graph/dependencies-graph.js +4 -5
  32. package/dist/ui/dependencies-graph/dependencies-graph.js.map +1 -1
  33. package/dist/ui/dependencies-graph/graph-context.d.ts +2 -2
  34. package/dist/ui/dependencies-graph/minimap.js +1 -2
  35. package/dist/ui/dependencies-graph/minimap.js.map +1 -1
  36. package/dist/ui/graph-page/graph-filters.d.ts +3 -3
  37. package/dist/ui/graph-page/graph-page.d.ts +3 -3
  38. package/dist/ui/graph.section.d.ts +2 -2
  39. package/dist/ui/query/get-graph.query.d.ts +4 -4
  40. package/dist/ui/query/use-graph-query.d.ts +2 -2
  41. package/dist/ui/query/use-graph-query.js +1 -1
  42. package/dist/ui/query/use-graph-query.js.map +1 -1
  43. package/dist/ui/query/use-graph.d.ts +2 -2
  44. package/duplicate-dependency.ts +18 -0
  45. package/edge-type.ts +5 -0
  46. package/graph-builder.ts +47 -0
  47. package/graph-cmd.ts +111 -0
  48. package/graph.aspect.ts +9 -0
  49. package/graph.graphql.ts +94 -0
  50. package/graph.main.runtime.ts +49 -0
  51. package/index.ts +25 -0
  52. package/object-list-to-graph.ts +66 -0
  53. package/package.json +20 -27
  54. package/tsconfig.json +16 -21
  55. package/types/asset.d.ts +15 -3
@@ -0,0 +1,66 @@
1
+ import { Graph, Node, Edge } from '@teambit/graph.cleargraph';
2
+ import { uniqBy } from 'lodash';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ import type { ObjectList } from '@teambit/legacy/dist/scope/objects/object-list';
5
+ import { BitObjectList } from '@teambit/legacy/dist/scope/objects/bit-object-list';
6
+ import { getAllVersionsInfo } from '@teambit/legacy/dist/scope/component-ops/traverse-versions';
7
+ import { Dependency } from './model/dependency';
8
+
9
+ type BitIdNode = Node<ComponentID>;
10
+ type DependencyEdge = Edge<Dependency>;
11
+
12
+ export class IdGraph extends Graph<ComponentID, Dependency> {
13
+ constructor(nodes: BitIdNode[] = [], edges: DependencyEdge[] = []) {
14
+ super(nodes, edges);
15
+ }
16
+ }
17
+
18
+ export async function objectListToGraph(objectList: ObjectList): Promise<IdGraph> {
19
+ const bitObjectsList = await objectList.toBitObjects();
20
+
21
+ return bitObjectListToGraph(bitObjectsList);
22
+ }
23
+
24
+ export async function bitObjectListToGraph(bitObjectsList: BitObjectList): Promise<IdGraph> {
25
+ const exportMetadata = bitObjectsList.getExportMetadata();
26
+ const components = bitObjectsList.getComponents();
27
+ const versions = bitObjectsList.getVersions();
28
+ const nodes: BitIdNode[] = [];
29
+ const edges: DependencyEdge[] = [];
30
+ await Promise.all(
31
+ components.map(async (component) => {
32
+ const compFromMetadata = exportMetadata?.exportVersions.find((c) =>
33
+ c.id.isEqualWithoutVersion(component.toComponentId())
34
+ );
35
+ const startFrom = compFromMetadata?.head;
36
+ const versionsInfo = await getAllVersionsInfo({
37
+ modelComponent: component,
38
+ versionObjects: versions,
39
+ startFrom,
40
+ throws: false,
41
+ });
42
+ versionsInfo.forEach((versionInfo) => {
43
+ const id = component.toComponentId().changeVersion(versionInfo.tag || versionInfo.ref.toString());
44
+ const idStr = id.toString();
45
+ nodes.push(new Node(idStr, id));
46
+ if (!versionInfo.version) {
47
+ return;
48
+ }
49
+ const { dependencies, devDependencies, extensionDependencies } = versionInfo.version.depsIdsGroupedByType;
50
+ const addDep = (depId: ComponentID, edge: Dependency) => {
51
+ const depIdStr = depId.toString();
52
+ nodes.push(new Node(depIdStr, depId));
53
+ edges.push(new Edge(idStr, depIdStr, edge));
54
+ };
55
+ const runTime = new Dependency('runtime');
56
+ const dev = new Dependency('dev');
57
+ dependencies.forEach((depId) => addDep(depId, runTime));
58
+ [...devDependencies, ...extensionDependencies].forEach((depId) => addDep(depId, dev));
59
+ });
60
+ })
61
+ );
62
+ const uniqNodes = uniqBy(nodes, 'id');
63
+ const idGraph = new IdGraph(uniqNodes, edges);
64
+
65
+ return idGraph;
66
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/graph",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "homepage": "https://bit.cloud/teambit/component/graph",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "graph",
9
- "version": "1.0.106"
9
+ "version": "1.0.108"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -17,21 +17,19 @@
17
17
  "react-flow-renderer": "8.3.7",
18
18
  "semver": "7.5.2",
19
19
  "dagre": "0.8.5",
20
- "core-js": "^3.0.0",
21
- "@babel/runtime": "7.20.0",
22
20
  "@teambit/graph.cleargraph": "0.0.1",
23
21
  "@teambit/component-id": "1.2.0",
24
22
  "@teambit/harmony": "0.4.6",
25
23
  "@teambit/component.ui.component-compare.models.component-compare-change-type": "0.0.7",
26
24
  "@teambit/component.ui.component-compare.models.component-compare-props": "0.0.101",
27
- "@teambit/component.ui.component-compare.context": "0.0.116",
28
- "@teambit/design.ui.round-loader": "0.0.355",
29
25
  "@teambit/base-ui.routing.nav-link": "1.0.0",
30
26
  "@teambit/base-ui.surfaces.card": "1.0.1",
31
27
  "@teambit/base-ui.text.muted-text": "1.0.1",
32
- "@teambit/component.ui.component-compare.status-resolver": "0.0.9",
33
28
  "@teambit/component.ui.deprecation-icon": "0.0.509",
34
29
  "@teambit/design.ui.styles.ellipsis": "0.0.357",
30
+ "@teambit/component.ui.component-compare.context": "0.0.116",
31
+ "@teambit/design.ui.round-loader": "0.0.355",
32
+ "@teambit/component.ui.component-compare.status-resolver": "0.0.9",
35
33
  "@teambit/evangelist.input.checkbox.label": "1.0.3",
36
34
  "@teambit/design.ui.pages.not-found": "0.0.366",
37
35
  "@teambit/design.ui.pages.server-error": "0.0.366",
@@ -39,33 +37,31 @@
39
37
  "@teambit/ui-foundation.ui.full-loader": "0.0.500",
40
38
  "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.505",
41
39
  "@teambit/ui-foundation.ui.react-router.use-query": "0.0.501",
42
- "@teambit/component": "1.0.106",
43
- "@teambit/cli": "0.0.839",
44
- "@teambit/graphql": "1.0.106",
45
- "@teambit/logger": "0.0.932",
46
- "@teambit/component-compare": "1.0.106",
47
- "@teambit/ui": "1.0.106",
40
+ "@teambit/component": "1.0.108",
41
+ "@teambit/cli": "0.0.840",
42
+ "@teambit/graphql": "1.0.108",
43
+ "@teambit/logger": "0.0.933",
44
+ "@teambit/component-compare": "1.0.108",
45
+ "@teambit/ui": "1.0.108",
48
46
  "@teambit/component.modules.component-url": "0.0.165",
49
47
  "@teambit/envs.ui.env-icon": "0.0.503"
50
48
  },
51
49
  "devDependencies": {
52
50
  "@types/lodash": "4.14.165",
53
51
  "@types/graphlib": "2.1.7",
54
- "@types/react": "^17.0.8",
55
52
  "@types/classnames": "2.2.11",
56
53
  "@types/semver": "7.3.4",
57
54
  "@types/dagre": "0.7.44",
58
55
  "@types/mocha": "9.1.0",
59
- "@types/node": "12.20.4",
60
- "@types/react-dom": "^17.0.5",
61
- "@types/jest": "^26.0.0",
62
- "@types/testing-library__jest-dom": "5.9.5"
56
+ "@types/jest": "^29.2.2",
57
+ "@types/testing-library__jest-dom": "^5.9.5",
58
+ "@teambit/harmony.envs.core-aspect-env": "0.0.13"
63
59
  },
64
60
  "peerDependencies": {
65
61
  "@apollo/client": "^3.6.0",
66
- "@teambit/legacy": "1.0.624",
67
- "react": "^16.8.0 || ^17.0.0",
68
- "react-dom": "^16.8.0 || ^17.0.0"
62
+ "react": "^17.0.0 || ^18.0.0",
63
+ "@types/react": "^18.2.12",
64
+ "@teambit/legacy": "1.0.624"
69
65
  },
70
66
  "license": "Apache-2.0",
71
67
  "optionalDependencies": {},
@@ -79,7 +75,7 @@
79
75
  },
80
76
  "private": false,
81
77
  "engines": {
82
- "node": ">=12.22.0"
78
+ "node": ">=16.0.0"
83
79
  },
84
80
  "repository": {
85
81
  "type": "git",
@@ -88,12 +84,9 @@
88
84
  "keywords": [
89
85
  "bit",
90
86
  "bit-aspect",
87
+ "bit-core-aspect",
91
88
  "components",
92
89
  "collaboration",
93
- "web",
94
- "react",
95
- "react-components",
96
- "angular",
97
- "angular-components"
90
+ "web"
98
91
  ]
99
92
  }
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }