@vendure/ui-devkit 2.2.0-next.6 → 2.2.0-next.8

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.
@@ -146,17 +146,17 @@ function generateLazyExtensionRoutes(extensions) {
146
146
  for (const extension of extensions) {
147
147
  for (const module of extension.ngModules ?? []) {
148
148
  if (module.type === 'lazy') {
149
- routes.push(` {
150
- path: 'extensions/${module.route}',
151
- loadChildren: () => import('${getModuleFilePath(extension.id, module)}').then(m => m.${module.ngModuleName}),
149
+ routes.push(` {
150
+ path: 'extensions/${module.route}',
151
+ loadChildren: () => import('${getModuleFilePath(extension.id, module)}').then(m => m.${module.ngModuleName}),
152
152
  }`);
153
153
  }
154
154
  }
155
155
  for (const route of extension.routes ?? []) {
156
156
  const prefix = route.prefix === '' ? '' : `${route.prefix ?? 'extensions'}/`;
157
- routes.push(` {
158
- path: '${prefix}${route.route}',
159
- loadChildren: () => import('./extensions/${extension.id}/${path.basename(route.filePath, '.ts')}'),
157
+ routes.push(` {
158
+ path: '${prefix}${route.route}',
159
+ loadChildren: () => import('./extensions/${extension.id}/${path.basename(route.filePath, '.ts')}'),
160
160
  }`);
161
161
  }
162
162
  }
@@ -189,16 +189,16 @@ function generateSharedExtensionModule(extensions) {
189
189
  .map((m, i) => (m.providers ?? []).map((f, j) => `...SharedProviders_${i}_${j}`).join(', '))
190
190
  .filter(val => !!val)
191
191
  .join(', ');
192
- return `import { NgModule } from '@angular/core';
193
- import { CommonModule } from '@angular/common';
194
- ${moduleImports}
195
- ${providerImports}
196
-
197
- @NgModule({
198
- imports: [CommonModule, ${modules}],
199
- providers: [${providers}],
200
- })
201
- export class SharedExtensionsModule {}
192
+ return `import { NgModule } from '@angular/core';
193
+ import { CommonModule } from '@angular/common';
194
+ ${moduleImports}
195
+ ${providerImports}
196
+
197
+ @NgModule({
198
+ imports: [CommonModule, ${modules}],
199
+ providers: [${providers}],
200
+ })
201
+ export class SharedExtensionsModule {}
202
202
  `;
203
203
  }
204
204
  function getModuleFilePath(id, module) {
@@ -73,6 +73,37 @@ export interface SassVariableOverridesExtension {
73
73
  */
74
74
  sassVariableOverrides: string;
75
75
  }
76
+ /**
77
+ * @description
78
+ * Defines a route which will be added to the Admin UI application.
79
+ *
80
+ * @docsCategory UiDevkit
81
+ * @docsPage AdminUiExtension
82
+ */
83
+ export interface UiExtensionRouteDefinition {
84
+ /**
85
+ * @description
86
+ * The name of the route. This will be used as the path in the URL.
87
+ */
88
+ route: string;
89
+ /**
90
+ * @description
91
+ * The path to the file which exports an array of Angular route definitions.
92
+ */
93
+ filePath: string;
94
+ /**
95
+ * @description
96
+ * All extensions will be mounted under the `/extensions/` route. This option allows you to specify a
97
+ * custom prefix rather than `/extensions/`. For example, setting this to `custom` would cause the extension
98
+ * to be mounted at `/custom/<route>` instead.
99
+ *
100
+ * A common use case for this is to mount the extension at the root of the Admin UI, by setting this to an empty string.
101
+ * This is useful when the extension is intended to replace the default Admin UI, rather than extend it.
102
+ *
103
+ * @since 2.2.0
104
+ */
105
+ prefix?: string;
106
+ }
76
107
  /**
77
108
  * @description
78
109
  * Defines extensions to the Admin UI application by specifying additional
@@ -119,30 +150,7 @@ export interface AdminUiExtension extends Partial<TranslationExtension>, Partial
119
150
  * Defines routes that will be lazy-loaded at the `/extensions/` route. The filePath should point to a file
120
151
  * relative to the `extensionPath` which exports an array of Angular route definitions.
121
152
  */
122
- routes?: Array<{
123
- /**
124
- * @description
125
- * The name of the route. This will be used as the path in the URL.
126
- */
127
- route: string;
128
- /**
129
- * @description
130
- * The path to the file which exports an array of Angular route definitions.
131
- */
132
- filePath: string;
133
- /**
134
- * @description
135
- * All extensions will be mounted under the `/extensions/` route. This option allows you to specify a
136
- * custom prefix rather than `/extensions/`. For example, setting this to `custom` would cause the extension
137
- * to be mounted at `/custom/<route>` instead.
138
- *
139
- * A common use case for this is to mount the extension at the root of the Admin UI, by setting this to an empty string.
140
- * This is useful when the extension is intended to replace the default Admin UI, rather than extend it.
141
- *
142
- * @since 2.2.0
143
- */
144
- prefix?: string;
145
- }>;
153
+ routes?: UiExtensionRouteDefinition[];
146
154
  /**
147
155
  * @description
148
156
  * An optional alias for the module so it can be referenced by other UI extension modules.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure/ui-devkit",
3
- "version": "2.2.0-next.6",
3
+ "version": "2.2.0-next.8",
4
4
  "description": "A library for authoring Vendure Admin UI extensions",
5
5
  "keywords": [
6
6
  "vendure",
@@ -40,8 +40,8 @@
40
40
  "@angular/cli": "^17.2.3",
41
41
  "@angular/compiler": "^17.2.4",
42
42
  "@angular/compiler-cli": "^17.2.4",
43
- "@vendure/admin-ui": "2.2.0-next.6",
44
- "@vendure/common": "2.2.0-next.6",
43
+ "@vendure/admin-ui": "2.2.0-next.8",
44
+ "@vendure/common": "2.2.0-next.8",
45
45
  "chalk": "^4.1.0",
46
46
  "chokidar": "^3.6.0",
47
47
  "fs-extra": "^11.2.0",
@@ -52,7 +52,7 @@
52
52
  "@rollup/plugin-node-resolve": "^15.2.3",
53
53
  "@rollup/plugin-terser": "^0.4.4",
54
54
  "@types/fs-extra": "^11.0.4",
55
- "@vendure/core": "2.2.0-next.6",
55
+ "@vendure/core": "2.2.0-next.8",
56
56
  "react": "^18.2.0",
57
57
  "react-dom": "^18.2.0",
58
58
  "rimraf": "^5.0.5",
@@ -61,5 +61,5 @@
61
61
  "tslib": "^2.6.2",
62
62
  "typescript": "5.3.3"
63
63
  },
64
- "gitHead": "2357477d705829080cfa912db0cf04eedadeaa6e"
64
+ "gitHead": "4a5aec3b43e4632cab8217107c23aacc3fbe5bfb"
65
65
  }
@@ -1,52 +1,52 @@
1
- import { Route } from '@angular/router';
2
- import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
3
- import { AppShellComponent, AuthGuard } from '@vendure/admin-ui/core';
4
-
5
- import { extensionRoutes } from './extension.routes';
6
-
7
- export const routes: Route[] = [
8
- { path: 'login', loadChildren: () => import('@vendure/admin-ui/login').then(m => m.LoginModule) },
9
- {
10
- path: '',
11
- canActivate: [AuthGuard],
12
- component: AppShellComponent,
13
- data: {
14
- breadcrumb: _('breadcrumb.dashboard'),
15
- },
16
- children: [
17
- // Defining the extension routes before the built-in routes allows
18
- // the extension routes to take precedence over the built-in routes, enabling
19
- // the extensions to override built-in functionality.
20
- ...extensionRoutes,
21
- {
22
- path: '',
23
- pathMatch: 'full',
24
- loadChildren: () => import('@vendure/admin-ui/dashboard').then(m => m.DashboardModule),
25
- },
26
- {
27
- path: 'catalog',
28
- loadChildren: () => import('@vendure/admin-ui/catalog').then(m => m.CatalogModule),
29
- },
30
- {
31
- path: 'customer',
32
- loadChildren: () => import('@vendure/admin-ui/customer').then(m => m.CustomerModule),
33
- },
34
- {
35
- path: 'orders',
36
- loadChildren: () => import('@vendure/admin-ui/order').then(m => m.OrderModule),
37
- },
38
- {
39
- path: 'marketing',
40
- loadChildren: () => import('@vendure/admin-ui/marketing').then(m => m.MarketingModule),
41
- },
42
- {
43
- path: 'settings',
44
- loadChildren: () => import('@vendure/admin-ui/settings').then(m => m.SettingsModule),
45
- },
46
- {
47
- path: 'system',
48
- loadChildren: () => import('@vendure/admin-ui/system').then(m => m.SystemModule),
49
- },
50
- ],
51
- },
52
- ];
1
+ import { Route } from '@angular/router';
2
+ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
3
+ import { AppShellComponent, AuthGuard } from '@vendure/admin-ui/core';
4
+
5
+ import { extensionRoutes } from './extension.routes';
6
+
7
+ export const routes: Route[] = [
8
+ { path: 'login', loadChildren: () => import('@vendure/admin-ui/login').then(m => m.LoginModule) },
9
+ {
10
+ path: '',
11
+ canActivate: [AuthGuard],
12
+ component: AppShellComponent,
13
+ data: {
14
+ breadcrumb: _('breadcrumb.dashboard'),
15
+ },
16
+ children: [
17
+ // Defining the extension routes before the built-in routes allows
18
+ // the extension routes to take precedence over the built-in routes, enabling
19
+ // the extensions to override built-in functionality.
20
+ ...extensionRoutes,
21
+ {
22
+ path: '',
23
+ pathMatch: 'full',
24
+ loadChildren: () => import('@vendure/admin-ui/dashboard').then(m => m.DashboardModule),
25
+ },
26
+ {
27
+ path: 'catalog',
28
+ loadChildren: () => import('@vendure/admin-ui/catalog').then(m => m.CatalogModule),
29
+ },
30
+ {
31
+ path: 'customer',
32
+ loadChildren: () => import('@vendure/admin-ui/customer').then(m => m.CustomerModule),
33
+ },
34
+ {
35
+ path: 'orders',
36
+ loadChildren: () => import('@vendure/admin-ui/order').then(m => m.OrderModule),
37
+ },
38
+ {
39
+ path: 'marketing',
40
+ loadChildren: () => import('@vendure/admin-ui/marketing').then(m => m.MarketingModule),
41
+ },
42
+ {
43
+ path: 'settings',
44
+ loadChildren: () => import('@vendure/admin-ui/settings').then(m => m.SettingsModule),
45
+ },
46
+ {
47
+ path: 'system',
48
+ loadChildren: () => import('@vendure/admin-ui/system').then(m => m.SystemModule),
49
+ },
50
+ ],
51
+ },
52
+ ];