@atlaskit/forge-react-types 0.59.0 → 0.60.0
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/CHANGELOG.md +9 -0
- package/README.md +10 -0
- package/dist/cjs/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.js +1 -0
- package/dist/cjs/components/global/__generated__/GlobalLinkMenuItemProps.codegen.js +1 -0
- package/dist/cjs/components/global/__generated__/GlobalSidebarProps.codegen.js +1 -0
- package/dist/cjs/components/global/__generated__/index.js +1 -0
- package/dist/es2019/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.js +0 -0
- package/dist/es2019/components/global/__generated__/GlobalLinkMenuItemProps.codegen.js +0 -0
- package/dist/es2019/components/global/__generated__/GlobalSidebarProps.codegen.js +0 -0
- package/dist/es2019/components/global/__generated__/index.js +0 -0
- package/dist/esm/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.js +0 -0
- package/dist/esm/components/global/__generated__/GlobalLinkMenuItemProps.codegen.js +0 -0
- package/dist/esm/components/global/__generated__/GlobalSidebarProps.codegen.js +0 -0
- package/dist/esm/components/global/__generated__/index.js +0 -0
- package/dist/types/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.d.ts +17 -0
- package/dist/types/components/global/__generated__/GlobalLinkMenuItemProps.codegen.d.ts +21 -0
- package/dist/types/components/global/__generated__/GlobalSidebarProps.codegen.d.ts +18 -0
- package/dist/types/components/global/__generated__/index.d.ts +12 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types-ts4.5/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.d.ts +17 -0
- package/dist/types-ts4.5/components/global/__generated__/GlobalLinkMenuItemProps.codegen.d.ts +21 -0
- package/dist/types-ts4.5/components/global/__generated__/GlobalSidebarProps.codegen.d.ts +18 -0
- package/dist/types-ts4.5/components/global/__generated__/index.d.ts +12 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/package.json +5 -4
- package/scripts/codegen/globalComponentPropTypes.ts +313 -0
- package/scripts/codegen-global-runner.ts +18 -0
- package/src/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.tsx +20 -0
- package/src/components/global/__generated__/GlobalLinkMenuItemProps.codegen.tsx +24 -0
- package/src/components/global/__generated__/GlobalSidebarProps.codegen.tsx +21 -0
- package/src/components/global/__generated__/index.ts +14 -0
- package/src/index.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/forge-react-types
|
|
2
2
|
|
|
3
|
+
## 0.60.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`cc1ec16a6b6f3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cc1ec16a6b6f3) -
|
|
8
|
+
Add type codegen support for global components
|
|
9
|
+
- [`cc1ec16a6b6f3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cc1ec16a6b6f3) -
|
|
10
|
+
Export Global component prop types
|
|
11
|
+
|
|
3
12
|
## 0.59.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -33,3 +33,13 @@ yarn workspace @atlaskit/forge-react-types codegen Button
|
|
|
33
33
|
|
|
34
34
|
NOTE: Make sure any new component prop types are being exported from
|
|
35
35
|
`packages/forge/forge-react-types/src/components/__generated__/index.ts`
|
|
36
|
+
|
|
37
|
+
### Generating global component types
|
|
38
|
+
|
|
39
|
+
To generate global component types, run the following command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn workspace @atlaskit/forge-react-types codegen-global
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This will generate the global component types found in `forge-common-app-gateway` package into `/src/components/global/__generated__/index.ts`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalExpandableMenuItem
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::5cc168904578780ba265e1ad2fc3cfec>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-ExpandableMenuItem.tsx <<SignedSource::79df02babb605094ae73bdd0c00c7156>>
|
|
10
|
+
*/
|
|
11
|
+
export type GlobalExpandableMenuItemProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The display label for the expandable menu item.
|
|
14
|
+
*/
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
export type TGlobalExpandableMenuItem<T> = (props: GlobalExpandableMenuItemProps) => T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalLinkMenuItem
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::1c930740db9038f51b3e7b99771b253c>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-LinkMenuItem.tsx <<SignedSource::e70effe0d4e0620246252b35abddb112>>
|
|
10
|
+
*/
|
|
11
|
+
export type GlobalLinkMenuItemProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The display label for the menu item.
|
|
14
|
+
*/
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL path to navigate to when clicked.
|
|
18
|
+
*/
|
|
19
|
+
href: string;
|
|
20
|
+
};
|
|
21
|
+
export type TGlobalLinkMenuItem<T> = (props: GlobalLinkMenuItemProps) => T;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalSidebar
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::2e9345246b57199aa34c90c2d697b45c>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-Sidebar.tsx <<SignedSource::79c613be77297a86b70005750a4b0220>>
|
|
10
|
+
*/
|
|
11
|
+
export type GlobalSidebarProps = {
|
|
12
|
+
/**
|
|
13
|
+
* URL path for the "For You" section in the sidebar.
|
|
14
|
+
* When provided, enables the "For You" navigation item.
|
|
15
|
+
*/
|
|
16
|
+
forYouUrl?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type TGlobalSidebar<T> = (props: GlobalSidebarProps) => T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Index file for generated Global component prop types
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::94d4d04a65ea9019214cd455fcb4c585>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
*/
|
|
10
|
+
export type { GlobalSidebarProps, TGlobalSidebar } from './GlobalSidebarProps.codegen';
|
|
11
|
+
export type { GlobalLinkMenuItemProps, TGlobalLinkMenuItem } from './GlobalLinkMenuItemProps.codegen';
|
|
12
|
+
export type { GlobalExpandableMenuItemProps, TGlobalExpandableMenuItem } from './GlobalExpandableMenuItemProps.codegen';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export type { BarChartProps, StackBarChartProps, HorizontalStackBarChartProps, H
|
|
|
3
3
|
export type { ChromelessEditorProps, CommentEditorProps, TChromelessEditor, TCommentEditor, } from './components/editor';
|
|
4
4
|
export type { ChartColorTokens } from './types';
|
|
5
5
|
export type { FrameProps } from './components/frame';
|
|
6
|
+
export type { GlobalSidebarProps, TGlobalSidebar, GlobalLinkMenuItemProps, TGlobalLinkMenuItem, GlobalExpandableMenuItemProps, TGlobalExpandableMenuItem, } from './components/global/__generated__';
|
package/dist/types-ts4.5/components/global/__generated__/GlobalExpandableMenuItemProps.codegen.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalExpandableMenuItem
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::5cc168904578780ba265e1ad2fc3cfec>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-ExpandableMenuItem.tsx <<SignedSource::79df02babb605094ae73bdd0c00c7156>>
|
|
10
|
+
*/
|
|
11
|
+
export type GlobalExpandableMenuItemProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The display label for the expandable menu item.
|
|
14
|
+
*/
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
export type TGlobalExpandableMenuItem<T> = (props: GlobalExpandableMenuItemProps) => T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalLinkMenuItem
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::1c930740db9038f51b3e7b99771b253c>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-LinkMenuItem.tsx <<SignedSource::e70effe0d4e0620246252b35abddb112>>
|
|
10
|
+
*/
|
|
11
|
+
export type GlobalLinkMenuItemProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The display label for the menu item.
|
|
14
|
+
*/
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* The URL path to navigate to when clicked.
|
|
18
|
+
*/
|
|
19
|
+
href: string;
|
|
20
|
+
};
|
|
21
|
+
export type TGlobalLinkMenuItem<T> = (props: GlobalLinkMenuItemProps) => T;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalSidebar
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::2e9345246b57199aa34c90c2d697b45c>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-Sidebar.tsx <<SignedSource::79c613be77297a86b70005750a4b0220>>
|
|
10
|
+
*/
|
|
11
|
+
export type GlobalSidebarProps = {
|
|
12
|
+
/**
|
|
13
|
+
* URL path for the "For You" section in the sidebar.
|
|
14
|
+
* When provided, enables the "For You" navigation item.
|
|
15
|
+
*/
|
|
16
|
+
forYouUrl?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type TGlobalSidebar<T> = (props: GlobalSidebarProps) => T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Index file for generated Global component prop types
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::94d4d04a65ea9019214cd455fcb4c585>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
*/
|
|
10
|
+
export type { GlobalSidebarProps, TGlobalSidebar } from './GlobalSidebarProps.codegen';
|
|
11
|
+
export type { GlobalLinkMenuItemProps, TGlobalLinkMenuItem } from './GlobalLinkMenuItemProps.codegen';
|
|
12
|
+
export type { GlobalExpandableMenuItemProps, TGlobalExpandableMenuItem } from './GlobalExpandableMenuItemProps.codegen';
|
|
@@ -3,3 +3,4 @@ export type { BarChartProps, StackBarChartProps, HorizontalStackBarChartProps, H
|
|
|
3
3
|
export type { ChromelessEditorProps, CommentEditorProps, TChromelessEditor, TCommentEditor, } from './components/editor';
|
|
4
4
|
export type { ChartColorTokens } from './types';
|
|
5
5
|
export type { FrameProps } from './components/frame';
|
|
6
|
+
export type { GlobalSidebarProps, TGlobalSidebar, GlobalLinkMenuItemProps, TGlobalLinkMenuItem, GlobalExpandableMenuItemProps, TGlobalExpandableMenuItem, } from './components/global/__generated__';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/forge-react-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.0",
|
|
4
4
|
"description": "Component types for Forge UI Kit React components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/button": "^23.9.0",
|
|
25
25
|
"@atlaskit/comment": "^13.2.0",
|
|
26
|
-
"@atlaskit/datetime-picker": "^17.
|
|
26
|
+
"@atlaskit/datetime-picker": "^17.5.0",
|
|
27
27
|
"@atlaskit/dynamic-table": "^18.3.0",
|
|
28
28
|
"@atlaskit/form": "^15.3.0",
|
|
29
29
|
"@atlaskit/inline-edit": "^15.6.0",
|
|
30
30
|
"@atlaskit/modal-dialog": "^14.10.0",
|
|
31
|
-
"@atlaskit/navigation-system": "^5.
|
|
31
|
+
"@atlaskit/navigation-system": "^5.33.0",
|
|
32
32
|
"@atlaskit/object": "^1.0.0",
|
|
33
33
|
"@atlaskit/popup": "^4.13.0",
|
|
34
34
|
"@atlaskit/primitives": "^18.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/select": "^21.7.0",
|
|
40
40
|
"@atlaskit/spinner": "^19.0.0",
|
|
41
41
|
"@atlaskit/tabs": "^18.3.0",
|
|
42
|
-
"@atlaskit/tag": "^14.
|
|
42
|
+
"@atlaskit/tag": "^14.4.0",
|
|
43
43
|
"@atlaskit/tag-group": "^12.0.0",
|
|
44
44
|
"@atlaskit/textarea": "^8.2.0",
|
|
45
45
|
"@atlaskit/textfield": "^8.2.0",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"codegen": "ts-node ./scripts/codegen-runner.ts",
|
|
68
|
+
"codegen-global": "ts-node ./scripts/codegen-global-runner.ts",
|
|
68
69
|
"check-types": "ts-node --type-check ./scripts/typechecker.ts"
|
|
69
70
|
},
|
|
70
71
|
"sideEffects": [
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// This file was generated by AI. It is an internal script used only for generating types and is not used in any production code. Use AI to update as needed and check the generated types are correct before committing.
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
|
+
import { createSignedArtifact } from '@atlassian/codegen';
|
|
5
|
+
import { Project } from 'ts-morph';
|
|
6
|
+
import type { Symbol, InterfaceDeclaration, PropertySignature, SourceFile } from 'ts-morph';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
|
|
10
|
+
// Path to the global component props source file (re-exports)
|
|
11
|
+
const GLOBAL_PROPS_SOURCE_PATH = resolve(
|
|
12
|
+
__dirname,
|
|
13
|
+
'../../../../..',
|
|
14
|
+
'services/forge-common-app-gateway/src/types/global-component-props.ts',
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// Output directory for generated files
|
|
18
|
+
const GLOBAL_OUTPUT_DIR = resolve(
|
|
19
|
+
__dirname,
|
|
20
|
+
'..',
|
|
21
|
+
'..',
|
|
22
|
+
'src',
|
|
23
|
+
'components',
|
|
24
|
+
'global',
|
|
25
|
+
'__generated__',
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extracts the JSDoc comment from a node and formats it properly.
|
|
30
|
+
* Only extracts JSDoc that is directly attached to the node (not file-level comments).
|
|
31
|
+
*/
|
|
32
|
+
const getJSDocComment = (node: InterfaceDeclaration | PropertySignature): string | null => {
|
|
33
|
+
const jsDocs = node.getJsDocs();
|
|
34
|
+
if (jsDocs.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Get only the last JSDoc (the one directly attached to the declaration)
|
|
39
|
+
const lastJsDoc = jsDocs[jsDocs.length - 1];
|
|
40
|
+
const comment = lastJsDoc.getInnerText();
|
|
41
|
+
|
|
42
|
+
if (!comment || comment.length === 0) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const commentBody = comment
|
|
47
|
+
.split('\n')
|
|
48
|
+
.map((line: string) => line.trimEnd())
|
|
49
|
+
.map((line: string) => (line.length === 0 ? ' *' : ` * ${line}`))
|
|
50
|
+
.join('\n');
|
|
51
|
+
|
|
52
|
+
return `/**\n${commentBody}\n */`;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resolves a TypeScript type to its primitive representation.
|
|
57
|
+
* For now, we only support simple primitive types.
|
|
58
|
+
*/
|
|
59
|
+
const resolveToPrimitive = (typeText: string): string => {
|
|
60
|
+
// Already primitive types
|
|
61
|
+
const primitives = [
|
|
62
|
+
'string',
|
|
63
|
+
'number',
|
|
64
|
+
'boolean',
|
|
65
|
+
'null',
|
|
66
|
+
'undefined',
|
|
67
|
+
'void',
|
|
68
|
+
'never',
|
|
69
|
+
'unknown',
|
|
70
|
+
'any',
|
|
71
|
+
];
|
|
72
|
+
if (primitives.includes(typeText)) {
|
|
73
|
+
return typeText;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Handle optional types (e.g., "string | undefined")
|
|
77
|
+
if (typeText.includes('|')) {
|
|
78
|
+
const parts = typeText.split('|').map((p) => p.trim());
|
|
79
|
+
const resolvedParts = parts.map((part) => resolveToPrimitive(part));
|
|
80
|
+
return resolvedParts.join(' | ');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// For any other type, return as-is (it should already be primitive based on our props)
|
|
84
|
+
return typeText;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Resolves a symbol to its original interface declaration.
|
|
89
|
+
* Handles re-exported types by following the export declarations.
|
|
90
|
+
*/
|
|
91
|
+
const resolveToInterfaceDeclaration = (
|
|
92
|
+
symbol: Symbol,
|
|
93
|
+
sourceFile: SourceFile,
|
|
94
|
+
project: Project,
|
|
95
|
+
): { interfaceDecl: InterfaceDeclaration; sourceFilePath: string } | null => {
|
|
96
|
+
const symbolName = symbol.getName();
|
|
97
|
+
|
|
98
|
+
// Find the export declaration for this symbol
|
|
99
|
+
const exportDeclarations = sourceFile.getExportDeclarations();
|
|
100
|
+
|
|
101
|
+
for (const exportDecl of exportDeclarations) {
|
|
102
|
+
const namedExports = exportDecl.getNamedExports();
|
|
103
|
+
const matchingExport = namedExports.find(
|
|
104
|
+
(ne) => ne.getName() === symbolName || ne.getAliasNode()?.getText() === symbolName,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
if (matchingExport) {
|
|
108
|
+
// Get the module specifier (the path being exported from)
|
|
109
|
+
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
110
|
+
if (!moduleSpecifier) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Resolve the module path
|
|
115
|
+
const moduleSourceFile = exportDecl.getModuleSpecifierSourceFile();
|
|
116
|
+
if (!moduleSourceFile) {
|
|
117
|
+
// Try to manually resolve and add the source file
|
|
118
|
+
const resolvedPath = resolve(sourceFile.getDirectoryPath(), moduleSpecifier + '.tsx');
|
|
119
|
+
|
|
120
|
+
if (fs.existsSync(resolvedPath)) {
|
|
121
|
+
const addedSourceFile = project.addSourceFileAtPath(resolvedPath);
|
|
122
|
+
const interfaceDecl = addedSourceFile.getInterface(symbolName);
|
|
123
|
+
if (interfaceDecl) {
|
|
124
|
+
return {
|
|
125
|
+
interfaceDecl,
|
|
126
|
+
sourceFilePath: resolvedPath,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Find the interface in the module source file
|
|
134
|
+
const interfaceDecl = moduleSourceFile.getInterface(symbolName);
|
|
135
|
+
if (interfaceDecl) {
|
|
136
|
+
return {
|
|
137
|
+
interfaceDecl,
|
|
138
|
+
sourceFilePath: moduleSourceFile.getFilePath(),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Generates the source code for a single component's prop types.
|
|
149
|
+
*/
|
|
150
|
+
const generateComponentPropTypeCode = (interfaceDecl: InterfaceDeclaration): string => {
|
|
151
|
+
const interfaceName = interfaceDecl.getName();
|
|
152
|
+
const componentName = interfaceName.replace('Props', '');
|
|
153
|
+
|
|
154
|
+
const lines: string[] = [];
|
|
155
|
+
|
|
156
|
+
// Add eslint directive
|
|
157
|
+
lines.push('/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */');
|
|
158
|
+
lines.push('');
|
|
159
|
+
|
|
160
|
+
// Get interface JSDoc
|
|
161
|
+
const interfaceJSDoc = getJSDocComment(interfaceDecl);
|
|
162
|
+
if (interfaceJSDoc) {
|
|
163
|
+
lines.push(interfaceJSDoc);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Generate the props type
|
|
167
|
+
const properties = interfaceDecl.getProperties();
|
|
168
|
+
|
|
169
|
+
if (properties.length === 0) {
|
|
170
|
+
// Empty props interface
|
|
171
|
+
lines.push(`export type ${interfaceName} = Record<string, never>;`);
|
|
172
|
+
} else {
|
|
173
|
+
lines.push(`export type ${interfaceName} = {`);
|
|
174
|
+
|
|
175
|
+
properties.forEach((prop: PropertySignature) => {
|
|
176
|
+
const propName = prop.getName();
|
|
177
|
+
const propType = prop.getType().getText();
|
|
178
|
+
const isOptional = prop.hasQuestionToken();
|
|
179
|
+
const resolvedType = resolveToPrimitive(propType);
|
|
180
|
+
|
|
181
|
+
// Get property JSDoc
|
|
182
|
+
const propJSDoc = getJSDocComment(prop);
|
|
183
|
+
if (propJSDoc) {
|
|
184
|
+
// Indent the JSDoc for property
|
|
185
|
+
const indentedJSDoc = propJSDoc
|
|
186
|
+
.split('\n')
|
|
187
|
+
.map((line: string) => `\t${line}`)
|
|
188
|
+
.join('\n');
|
|
189
|
+
lines.push(indentedJSDoc);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const optionalMarker = isOptional ? '?' : '';
|
|
193
|
+
lines.push(`\t${propName}${optionalMarker}: ${resolvedType};`);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
lines.push('};');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
lines.push('');
|
|
200
|
+
|
|
201
|
+
// Generate the T* component type
|
|
202
|
+
if (interfaceJSDoc) {
|
|
203
|
+
lines.push(interfaceJSDoc);
|
|
204
|
+
}
|
|
205
|
+
lines.push(`export type T${componentName}<T> = (props: ${interfaceName}) => T;`);
|
|
206
|
+
|
|
207
|
+
return lines.join('\n');
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Generates prop type files for all Global components.
|
|
212
|
+
*
|
|
213
|
+
* Process:
|
|
214
|
+
* 1. Load the re-export file (global-component-props.ts)
|
|
215
|
+
* 2. Get exported symbols ending with "Props"
|
|
216
|
+
* 3. Resolve each to its original interface declaration
|
|
217
|
+
* 4. Extract type info and resolve to primitives
|
|
218
|
+
* 5. Generate signed .codegen.tsx files and index.ts
|
|
219
|
+
*/
|
|
220
|
+
const generateGlobalComponentPropTypes = () => {
|
|
221
|
+
// eslint-disable-next-line no-console
|
|
222
|
+
console.log('Generating Global component prop types...');
|
|
223
|
+
|
|
224
|
+
// Ensure output directory exists
|
|
225
|
+
if (!fs.existsSync(GLOBAL_OUTPUT_DIR)) {
|
|
226
|
+
fs.mkdirSync(GLOBAL_OUTPUT_DIR, { recursive: true });
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const project = new Project({
|
|
230
|
+
compilerOptions: {
|
|
231
|
+
strict: true,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const sourceFile = project.addSourceFileAtPath(GLOBAL_PROPS_SOURCE_PATH);
|
|
236
|
+
const exportedSymbols = sourceFile.getExportSymbols();
|
|
237
|
+
const propsSymbols = exportedSymbols.filter((symbol) => symbol.getName().endsWith('Props'));
|
|
238
|
+
|
|
239
|
+
const generatedFiles: string[] = [];
|
|
240
|
+
|
|
241
|
+
propsSymbols.forEach((symbol) => {
|
|
242
|
+
const symbolName = symbol.getName();
|
|
243
|
+
const componentName = symbolName.replace('Props', '');
|
|
244
|
+
|
|
245
|
+
const resolved = resolveToInterfaceDeclaration(symbol, sourceFile, project);
|
|
246
|
+
|
|
247
|
+
if (!resolved) {
|
|
248
|
+
// eslint-disable-next-line no-console
|
|
249
|
+
console.error(` ✗ Could not resolve ${symbolName} to an interface declaration`);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const { interfaceDecl, sourceFilePath } = resolved;
|
|
254
|
+
const sourceCode = generateComponentPropTypeCode(interfaceDecl);
|
|
255
|
+
const outputPath = resolve(GLOBAL_OUTPUT_DIR, `${symbolName}.codegen.tsx`);
|
|
256
|
+
|
|
257
|
+
const signedSourceCode = createSignedArtifact(
|
|
258
|
+
sourceCode,
|
|
259
|
+
'yarn workspace @atlaskit/forge-react-types codegen-global',
|
|
260
|
+
{
|
|
261
|
+
description: `Generated prop types for Global component - ${componentName}`,
|
|
262
|
+
dependencies: [GLOBAL_PROPS_SOURCE_PATH, sourceFilePath],
|
|
263
|
+
outputFolder: GLOBAL_OUTPUT_DIR,
|
|
264
|
+
},
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
fs.writeFileSync(outputPath, signedSourceCode);
|
|
268
|
+
generatedFiles.push(symbolName);
|
|
269
|
+
|
|
270
|
+
// eslint-disable-next-line no-console
|
|
271
|
+
console.log(` ✓ Generated ${symbolName}.codegen.tsx`);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
generateIndexFile(generatedFiles);
|
|
275
|
+
|
|
276
|
+
// eslint-disable-next-line no-console
|
|
277
|
+
console.log('✓ Global component prop types generation complete!');
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Generates the index.ts file that exports all generated types.
|
|
282
|
+
*/
|
|
283
|
+
const generateIndexFile = (interfaceNames: string[]) => {
|
|
284
|
+
const lines: string[] = [];
|
|
285
|
+
|
|
286
|
+
lines.push('/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */');
|
|
287
|
+
lines.push('');
|
|
288
|
+
|
|
289
|
+
interfaceNames.forEach((interfaceName) => {
|
|
290
|
+
const componentName = interfaceName.replace('Props', '');
|
|
291
|
+
lines.push(
|
|
292
|
+
`export type { ${interfaceName}, T${componentName} } from './${interfaceName}.codegen';`,
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const sourceCode = lines.join('\n') + '\n';
|
|
297
|
+
|
|
298
|
+
const indexPath = resolve(GLOBAL_OUTPUT_DIR, 'index.ts');
|
|
299
|
+
|
|
300
|
+
const signedSourceCode = createSignedArtifact(
|
|
301
|
+
sourceCode,
|
|
302
|
+
'yarn workspace @atlaskit/forge-react-types codegen-global',
|
|
303
|
+
{
|
|
304
|
+
description: 'Index file for generated Global component prop types',
|
|
305
|
+
dependencies: [GLOBAL_PROPS_SOURCE_PATH],
|
|
306
|
+
outputFolder: GLOBAL_OUTPUT_DIR,
|
|
307
|
+
},
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
fs.writeFileSync(indexPath, signedSourceCode);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export { generateGlobalComponentPropTypes };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { generateGlobalComponentPropTypes } from './codegen/globalComponentPropTypes';
|
|
2
|
+
|
|
3
|
+
const runTypeCheck = () => {
|
|
4
|
+
// execute yarn run check-types
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
try {
|
|
7
|
+
execSync('yarn run check-types', { stdio: 'inherit' });
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.log('✅ 🚀 Type checks passed successfully for generated Global component types!');
|
|
10
|
+
} catch (error) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.error('❌ Type checks failed:', error);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
generateGlobalComponentPropTypes();
|
|
18
|
+
runTypeCheck();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalExpandableMenuItem
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::5cc168904578780ba265e1ad2fc3cfec>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-ExpandableMenuItem.tsx <<SignedSource::79df02babb605094ae73bdd0c00c7156>>
|
|
10
|
+
*/
|
|
11
|
+
/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */
|
|
12
|
+
|
|
13
|
+
export type GlobalExpandableMenuItemProps = {
|
|
14
|
+
/**
|
|
15
|
+
* The display label for the expandable menu item.
|
|
16
|
+
*/
|
|
17
|
+
label: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type TGlobalExpandableMenuItem<T> = (props: GlobalExpandableMenuItemProps) => T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalLinkMenuItem
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::1c930740db9038f51b3e7b99771b253c>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-LinkMenuItem.tsx <<SignedSource::e70effe0d4e0620246252b35abddb112>>
|
|
10
|
+
*/
|
|
11
|
+
/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */
|
|
12
|
+
|
|
13
|
+
export type GlobalLinkMenuItemProps = {
|
|
14
|
+
/**
|
|
15
|
+
* The display label for the menu item.
|
|
16
|
+
*/
|
|
17
|
+
label: string;
|
|
18
|
+
/**
|
|
19
|
+
* The URL path to navigate to when clicked.
|
|
20
|
+
*/
|
|
21
|
+
href: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TGlobalLinkMenuItem<T> = (props: GlobalLinkMenuItemProps) => T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Generated prop types for Global component - GlobalSidebar
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::2e9345246b57199aa34c90c2d697b45c>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/components/global/Global-Sidebar.tsx <<SignedSource::79c613be77297a86b70005750a4b0220>>
|
|
10
|
+
*/
|
|
11
|
+
/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */
|
|
12
|
+
|
|
13
|
+
export type GlobalSidebarProps = {
|
|
14
|
+
/**
|
|
15
|
+
* URL path for the "For You" section in the sidebar.
|
|
16
|
+
* When provided, enables the "For You" navigation item.
|
|
17
|
+
*/
|
|
18
|
+
forYouUrl?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type TGlobalSidebar<T> = (props: GlobalSidebarProps) => T;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Index file for generated Global component prop types
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::94d4d04a65ea9019214cd455fcb4c585>>
|
|
7
|
+
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen-global
|
|
8
|
+
* @codegenDependency ../../../../../../../services/forge-common-app-gateway/src/types/global-component-props.ts <<SignedSource::f24c6db68c9118776491952640ba616f>>
|
|
9
|
+
*/
|
|
10
|
+
/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */
|
|
11
|
+
|
|
12
|
+
export type { GlobalSidebarProps, TGlobalSidebar } from './GlobalSidebarProps.codegen';
|
|
13
|
+
export type { GlobalLinkMenuItemProps, TGlobalLinkMenuItem } from './GlobalLinkMenuItemProps.codegen';
|
|
14
|
+
export type { GlobalExpandableMenuItemProps, TGlobalExpandableMenuItem } from './GlobalExpandableMenuItemProps.codegen';
|
package/src/index.ts
CHANGED
|
@@ -162,3 +162,12 @@ export type {
|
|
|
162
162
|
export type { ChartColorTokens } from './types';
|
|
163
163
|
|
|
164
164
|
export type { FrameProps } from './components/frame';
|
|
165
|
+
|
|
166
|
+
export type {
|
|
167
|
+
GlobalSidebarProps,
|
|
168
|
+
TGlobalSidebar,
|
|
169
|
+
GlobalLinkMenuItemProps,
|
|
170
|
+
TGlobalLinkMenuItem,
|
|
171
|
+
GlobalExpandableMenuItemProps,
|
|
172
|
+
TGlobalExpandableMenuItem,
|
|
173
|
+
} from './components/global/__generated__';
|