|
1
|
import { |
|
2
|
CELL_RENDERER_VIRTUAL_MODULE, |
|
3
|
DISPLAY_VIRTUAL_MODULE, |
|
4
|
FORM_VIRTUAL_MODULE, |
|
5
|
I18N_VIRTUAL_MODULE, |
|
6
|
LAYOUT_VIRTUAL_MODULE, |
|
7
|
LINK_VIRTUAL_MODULE, |
|
8
|
MENU_ITEM_VIRTUAL_MODULE, |
|
9
|
ROUTE_VIRTUAL_MODULE, |
|
10
|
SEARCH_ENTITY_VIRTUAL_MODULE, |
|
11
|
WIDGET_VIRTUAL_MODULE, |
|
12
|
} from "@medusajs/admin-shared" |
|
13
|
|
|
14
|
const RESOLVED_LINK_VIRTUAL_MODULE = `\0${LINK_VIRTUAL_MODULE}` |
|
15
|
const RESOLVED_FORM_VIRTUAL_MODULE = `\0${FORM_VIRTUAL_MODULE}` |
|
16
|
const RESOLVED_DISPLAY_VIRTUAL_MODULE = `\0${DISPLAY_VIRTUAL_MODULE}` |
|
17
|
const RESOLVED_ROUTE_VIRTUAL_MODULE = `\0${ROUTE_VIRTUAL_MODULE}` |
|
18
|
const RESOLVED_MENU_ITEM_VIRTUAL_MODULE = `\0${MENU_ITEM_VIRTUAL_MODULE}` |
|
19
|
const RESOLVED_WIDGET_VIRTUAL_MODULE = `\0${WIDGET_VIRTUAL_MODULE}` |
|
20
|
const RESOLVED_I18N_VIRTUAL_MODULE = `\0${I18N_VIRTUAL_MODULE}` |
|
21
|
const RESOLVED_CELL_RENDERER_VIRTUAL_MODULE = `\0${CELL_RENDERER_VIRTUAL_MODULE}` |
|
22
|
const RESOLVED_LAYOUT_VIRTUAL_MODULE = `\0${LAYOUT_VIRTUAL_MODULE}` |
|
23
|
const RESOLVED_SEARCH_ENTITY_VIRTUAL_MODULE = `\0${SEARCH_ENTITY_VIRTUAL_MODULE}` |
|
24
|
|
|
25
|
const VIRTUAL_MODULES = [ |
|
26
|
LINK_VIRTUAL_MODULE, |
|
27
|
FORM_VIRTUAL_MODULE, |
|
28
|
DISPLAY_VIRTUAL_MODULE, |
|
29
|
ROUTE_VIRTUAL_MODULE, |
|
30
|
MENU_ITEM_VIRTUAL_MODULE, |
|
31
|
WIDGET_VIRTUAL_MODULE, |
|
32
|
I18N_VIRTUAL_MODULE, |
|
33
|
CELL_RENDERER_VIRTUAL_MODULE, |
|
34
|
LAYOUT_VIRTUAL_MODULE, |
|
35
|
SEARCH_ENTITY_VIRTUAL_MODULE, |
|
36
|
] as const |
|
37
|
|
|
38
|
const RESOLVED_VIRTUAL_MODULES = [ |
|
39
|
RESOLVED_LINK_VIRTUAL_MODULE, |
|
40
|
RESOLVED_FORM_VIRTUAL_MODULE, |
|
41
|
RESOLVED_DISPLAY_VIRTUAL_MODULE, |
|
42
|
RESOLVED_ROUTE_VIRTUAL_MODULE, |
|
43
|
RESOLVED_MENU_ITEM_VIRTUAL_MODULE, |
|
44
|
RESOLVED_WIDGET_VIRTUAL_MODULE, |
|
45
|
RESOLVED_I18N_VIRTUAL_MODULE, |
|
46
|
RESOLVED_CELL_RENDERER_VIRTUAL_MODULE, |
|
47
|
RESOLVED_LAYOUT_VIRTUAL_MODULE, |
|
48
|
RESOLVED_SEARCH_ENTITY_VIRTUAL_MODULE, |
|
49
|
] as const |
|
50
|
|
|
51
|
export function resolveVirtualId(id: string) { |
|
52
|
return `\0${id}` |
|
53
|
} |
|
54
|
|
|
55
|
export function isVirtualModuleId(id: string): id is VirtualModule { |
|
56
|
return VIRTUAL_MODULES.includes(id as VirtualModule) |
|
57
|
} |
|
58
|
|
|
59
|
export function isResolvedVirtualModuleId( |
|
60
|
id: string |
|
61
|
): id is (typeof RESOLVED_VIRTUAL_MODULES)[number] { |
|
62
|
return RESOLVED_VIRTUAL_MODULES.includes( |
|
63
|
id as (typeof RESOLVED_VIRTUAL_MODULES)[number] |
|
64
|
) |
|
65
|
} |
|
66
|
|
|
67
|
export type VirtualModule = |
|
68
|
| typeof LINK_VIRTUAL_MODULE |
|
69
|
| typeof FORM_VIRTUAL_MODULE |
|
70
|
| typeof DISPLAY_VIRTUAL_MODULE |
|
71
|
| typeof ROUTE_VIRTUAL_MODULE |
|
72
|
| typeof MENU_ITEM_VIRTUAL_MODULE |
|
73
|
| typeof WIDGET_VIRTUAL_MODULE |
|
74
|
| typeof I18N_VIRTUAL_MODULE |
|
75
|
| typeof CELL_RENDERER_VIRTUAL_MODULE |
|
76
|
| typeof LAYOUT_VIRTUAL_MODULE |
|
77
|
| typeof SEARCH_ENTITY_VIRTUAL_MODULE |
|
78
|
|
|
79
|
const resolvedVirtualModuleIds = { |
|
80
|
link: RESOLVED_LINK_VIRTUAL_MODULE, |
|
81
|
form: RESOLVED_FORM_VIRTUAL_MODULE, |
|
82
|
display: RESOLVED_DISPLAY_VIRTUAL_MODULE, |
|
83
|
route: RESOLVED_ROUTE_VIRTUAL_MODULE, |
|
84
|
menuItem: RESOLVED_MENU_ITEM_VIRTUAL_MODULE, |
|
85
|
widget: RESOLVED_WIDGET_VIRTUAL_MODULE, |
|
86
|
i18n: RESOLVED_I18N_VIRTUAL_MODULE, |
|
87
|
cellRenderer: RESOLVED_CELL_RENDERER_VIRTUAL_MODULE, |
|
88
|
layout: RESOLVED_LAYOUT_VIRTUAL_MODULE, |
|
89
|
searchEntity: RESOLVED_SEARCH_ENTITY_VIRTUAL_MODULE, |
|
90
|
} as const |
|
91
|
|
|
92
|
const virtualModuleIds = { |
|
93
|
link: LINK_VIRTUAL_MODULE, |
|
94
|
form: FORM_VIRTUAL_MODULE, |
|
95
|
display: DISPLAY_VIRTUAL_MODULE, |
|
96
|
route: ROUTE_VIRTUAL_MODULE, |
|
97
|
menuItem: MENU_ITEM_VIRTUAL_MODULE, |
|
98
|
widget: WIDGET_VIRTUAL_MODULE, |
|
99
|
i18n: I18N_VIRTUAL_MODULE, |
|
100
|
cellRenderer: CELL_RENDERER_VIRTUAL_MODULE, |
|
101
|
layout: LAYOUT_VIRTUAL_MODULE, |
|
102
|
searchEntity: SEARCH_ENTITY_VIRTUAL_MODULE, |
|
103
|
} as const |
|
104
|
|
|
105
|
export const vmod = { |
|
106
|
resolved: resolvedVirtualModuleIds, |
|
107
|
virtual: virtualModuleIds, |
|
108
|
} |