@vendure/ui-devkit 2.2.0-next.2 → 2.2.0-next.4
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/client/devkit-client-api.d.ts +109 -109
- package/client/index.d.ts +1 -1
- package/compiler/compile.d.ts +9 -9
- package/compiler/compile.js +261 -261
- package/compiler/constants.d.ts +6 -6
- package/compiler/constants.js +9 -9
- package/compiler/helpers.d.ts +25 -25
- package/compiler/helpers.js +49 -49
- package/compiler/index.d.ts +3 -3
- package/compiler/index.js +19 -19
- package/compiler/scaffold.d.ts +4 -4
- package/compiler/scaffold.js +237 -237
- package/compiler/translations.d.ts +12 -12
- package/compiler/translations.js +136 -136
- package/compiler/types.d.ts +419 -419
- package/compiler/types.js +2 -2
- package/compiler/utils.d.ts +34 -34
- package/compiler/utils.js +137 -137
- package/package.json +6 -6
package/compiler/types.d.ts
CHANGED
|
@@ -1,419 +1,419 @@
|
|
|
1
|
-
import { LanguageCode } from '@vendure/common/lib/generated-types';
|
|
2
|
-
export type Extension = AdminUiExtension | TranslationExtension | StaticAssetExtension | GlobalStylesExtension | SassVariableOverridesExtension;
|
|
3
|
-
/**
|
|
4
|
-
* @description
|
|
5
|
-
* Defines extensions to the Admin UI translations. Can be used as a stand-alone extension definition which only adds translations
|
|
6
|
-
* without adding new UI functionality, or as part of a full {@link AdminUiExtension}.
|
|
7
|
-
*
|
|
8
|
-
* @docsCategory UiDevkit
|
|
9
|
-
* @docsPage AdminUiExtension
|
|
10
|
-
*/
|
|
11
|
-
export interface TranslationExtension {
|
|
12
|
-
/**
|
|
13
|
-
* @description
|
|
14
|
-
* Optional object defining any translation files for the Admin UI. The value should be an object with
|
|
15
|
-
* the key as a 2-character [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes),
|
|
16
|
-
* and the value being a [glob](https://github.com/isaacs/node-glob) for any relevant
|
|
17
|
-
* translation files in JSON format.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* translations: {
|
|
22
|
-
* en: path.join(__dirname, 'translations/*.en.json'),
|
|
23
|
-
* de: path.join(__dirname, 'translations/*.de.json'),
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
translations: {
|
|
28
|
-
[languageCode in LanguageCode]?: string;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @description
|
|
33
|
-
* Defines extensions which copy static assets to the custom Admin UI application source asset directory.
|
|
34
|
-
*
|
|
35
|
-
* @docsCategory UiDevkit
|
|
36
|
-
* @docsPage AdminUiExtension
|
|
37
|
-
*/
|
|
38
|
-
export interface StaticAssetExtension {
|
|
39
|
-
/**
|
|
40
|
-
* @description
|
|
41
|
-
* Optional array of paths to static assets which will be copied over to the Admin UI app's `/static`
|
|
42
|
-
* directory.
|
|
43
|
-
*/
|
|
44
|
-
staticAssets: StaticAssetDefinition[];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @description
|
|
48
|
-
* Defines extensions which add global styles to the custom Admin UI application.
|
|
49
|
-
*
|
|
50
|
-
* @docsCategory UiDevkit
|
|
51
|
-
* @docsPage AdminUiExtension
|
|
52
|
-
*/
|
|
53
|
-
export interface GlobalStylesExtension {
|
|
54
|
-
/**
|
|
55
|
-
* @description
|
|
56
|
-
* Specifies a path (or array of paths) to global style files (css or Sass) which will be
|
|
57
|
-
* incorporated into the Admin UI app global stylesheet.
|
|
58
|
-
*/
|
|
59
|
-
globalStyles: string[] | string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @description
|
|
63
|
-
* Defines an extension which allows overriding Clarity Design System's Sass variables used in styles on the Admin UI.
|
|
64
|
-
*
|
|
65
|
-
* @docsCategory UiDevkit
|
|
66
|
-
* @docsPage AdminUiExtension
|
|
67
|
-
*/
|
|
68
|
-
export interface SassVariableOverridesExtension {
|
|
69
|
-
/**
|
|
70
|
-
* @description
|
|
71
|
-
* Specifies a path to a Sass style file containing variable declarations, which will take precedence over
|
|
72
|
-
* default values defined in Clarity.
|
|
73
|
-
*/
|
|
74
|
-
sassVariableOverrides: string;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @description
|
|
78
|
-
* Defines extensions to the Admin UI application by specifying additional
|
|
79
|
-
* Angular [NgModules](https://angular.io/guide/ngmodules) which are compiled
|
|
80
|
-
* into the application.
|
|
81
|
-
*
|
|
82
|
-
* See [Extending the Admin UI](/guides/extending-the-admin-ui/getting-started/) for
|
|
83
|
-
* detailed instructions.
|
|
84
|
-
*
|
|
85
|
-
* @docsCategory UiDevkit
|
|
86
|
-
* @docsPage AdminUiExtension
|
|
87
|
-
* @docsWeight 0
|
|
88
|
-
*/
|
|
89
|
-
export interface AdminUiExtension extends Partial<TranslationExtension>, Partial<StaticAssetExtension>, Partial<GlobalStylesExtension> {
|
|
90
|
-
/**
|
|
91
|
-
* @description
|
|
92
|
-
* An optional ID for the extension module. Only used internally for generating
|
|
93
|
-
* import paths to your module. If not specified, a unique hash will be used as the id.
|
|
94
|
-
*/
|
|
95
|
-
id?: string;
|
|
96
|
-
/**
|
|
97
|
-
* @description
|
|
98
|
-
* The path to the directory containing the extension module(s). The entire contents of this directory
|
|
99
|
-
* will be copied into the Admin UI app, including all TypeScript source files, html templates,
|
|
100
|
-
* scss style sheets etc.
|
|
101
|
-
*/
|
|
102
|
-
extensionPath: string;
|
|
103
|
-
/**
|
|
104
|
-
* @description
|
|
105
|
-
* One or more Angular modules which extend the default Admin UI.
|
|
106
|
-
*
|
|
107
|
-
* @deprecated use `routes` instead of lazy modules, and `providers` instead of shared modules in combination
|
|
108
|
-
* with Angular standalone components.
|
|
109
|
-
*/
|
|
110
|
-
ngModules?: Array<AdminUiExtensionSharedModule | AdminUiExtensionLazyModule>;
|
|
111
|
-
/**
|
|
112
|
-
* @description
|
|
113
|
-
* Defines the paths to a file that exports an array of shared providers such as nav menu items, custom form inputs,
|
|
114
|
-
* custom detail components, action bar items, custom history entry components.
|
|
115
|
-
*/
|
|
116
|
-
providers?: string[];
|
|
117
|
-
/**
|
|
118
|
-
* @description
|
|
119
|
-
* Defines routes that will be lazy-loaded at the `/extensions/` route. The filePath should point to a file
|
|
120
|
-
* relative to the `extensionPath` which exports an array of Angular route definitions.
|
|
121
|
-
*/
|
|
122
|
-
routes?: Array<{
|
|
123
|
-
route: string;
|
|
124
|
-
filePath: string;
|
|
125
|
-
}>;
|
|
126
|
-
/**
|
|
127
|
-
* @description
|
|
128
|
-
* An optional alias for the module so it can be referenced by other UI extension modules.
|
|
129
|
-
*
|
|
130
|
-
* By default, Angular modules declared in an AdminUiExtension do not have access to code outside the directory
|
|
131
|
-
* defined by the `extensionPath`. A scenario in which that can be useful though is in a monorepo codebase where
|
|
132
|
-
* a common NgModule is shared across different plugins, each defined in its own package. An example can be found
|
|
133
|
-
* below - note that the main `tsconfig.json` also maps the target module but using a path relative to the project's
|
|
134
|
-
* root folder. The UI module is not part of the main TypeScript build task as explained in
|
|
135
|
-
* [Extending the Admin UI](https://www.vendure.io/docs/plugins/extending-the-admin-ui/) but having `paths`
|
|
136
|
-
* properly configured helps with usual IDE code editing features such as code completion and quick navigation, as
|
|
137
|
-
* well as linting.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts title="packages/common-ui-module/src/ui/ui-shared.module.ts"
|
|
141
|
-
* import { NgModule } from '\@angular/core';
|
|
142
|
-
* import { SharedModule } from '\@vendure/admin-ui/core';
|
|
143
|
-
* import { CommonUiComponent } from './components/common-ui/common-ui.component';
|
|
144
|
-
*
|
|
145
|
-
* export { CommonUiComponent };
|
|
146
|
-
*
|
|
147
|
-
* \@NgModule({
|
|
148
|
-
* imports: [SharedModule],
|
|
149
|
-
* exports: [CommonUiComponent],
|
|
150
|
-
* declarations: [CommonUiComponent],
|
|
151
|
-
* })
|
|
152
|
-
* export class CommonSharedUiModule {}
|
|
153
|
-
* ```
|
|
154
|
-
*
|
|
155
|
-
* ```ts title="packages/common-ui-module/src/index.ts"
|
|
156
|
-
* import path from 'path';
|
|
157
|
-
*
|
|
158
|
-
* import { AdminUiExtension } from '\@vendure/ui-devkit/compiler';
|
|
159
|
-
*
|
|
160
|
-
* export const uiExtensions: AdminUiExtension = {
|
|
161
|
-
* // highlight-next-line
|
|
162
|
-
* pathAlias: '\@common-ui-module', // this is the important part
|
|
163
|
-
* extensionPath: path.join(__dirname, 'ui'),
|
|
164
|
-
* ngModules: [
|
|
165
|
-
* {
|
|
166
|
-
* type: 'shared' as const,
|
|
167
|
-
* ngModuleFileName: 'ui-shared.module.ts',
|
|
168
|
-
* ngModuleName: 'CommonSharedUiModule',
|
|
169
|
-
* },
|
|
170
|
-
* ],
|
|
171
|
-
* };
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* ```json title="tsconfig.json"
|
|
175
|
-
* {
|
|
176
|
-
* "compilerOptions": {
|
|
177
|
-
* "baseUrl": ".",
|
|
178
|
-
* "paths": {
|
|
179
|
-
* // highlight-next-line
|
|
180
|
-
* "\@common-ui-module/*": ["packages/common-ui-module/src/ui/*"]
|
|
181
|
-
* }
|
|
182
|
-
* }
|
|
183
|
-
* }
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* ```ts title="packages/sample-plugin/src/ui/ui-extension.module.ts"
|
|
187
|
-
* import { NgModule } from '\@angular/core';
|
|
188
|
-
* import { SharedModule } from '\@vendure/admin-ui/core';
|
|
189
|
-
* // highlight-start
|
|
190
|
-
* // the import below works both in the context of the custom Admin UI app as well as the main project
|
|
191
|
-
* // '\@common-ui-module' is the value of "pathAlias" and 'ui-shared.module' is the file we want to reference inside "extensionPath"
|
|
192
|
-
* import { CommonSharedUiModule, CommonUiComponent } from '\@common-ui-module/ui-shared.module';
|
|
193
|
-
* // highlight-end
|
|
194
|
-
*
|
|
195
|
-
* \@NgModule({
|
|
196
|
-
* imports: [
|
|
197
|
-
* SharedModule,
|
|
198
|
-
* CommonSharedUiModule,
|
|
199
|
-
* RouterModule.forChild([
|
|
200
|
-
* {
|
|
201
|
-
* path: '',
|
|
202
|
-
* pathMatch: 'full',
|
|
203
|
-
* component: CommonUiComponent,
|
|
204
|
-
* },
|
|
205
|
-
* ]),
|
|
206
|
-
* ],
|
|
207
|
-
* })
|
|
208
|
-
* export class SampleUiExtensionModule {}
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
pathAlias?: string;
|
|
212
|
-
/**
|
|
213
|
-
* @description
|
|
214
|
-
* Optional array specifying filenames or [glob](https://github.com/isaacs/node-glob) patterns that should
|
|
215
|
-
* be skipped when copying the directory defined by `extensionPath`.
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```ts
|
|
219
|
-
* exclude: ['**\/*.spec.ts']
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
exclude?: string[];
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* @description
|
|
226
|
-
* A static asset can be provided as a path to the asset, or as an object containing a path and a new
|
|
227
|
-
* name, which will cause the compiler to copy and then rename the asset.
|
|
228
|
-
*
|
|
229
|
-
* @docsCategory UiDevkit
|
|
230
|
-
* @docsPage AdminUiExtension
|
|
231
|
-
*/
|
|
232
|
-
export type StaticAssetDefinition = string | {
|
|
233
|
-
path: string;
|
|
234
|
-
rename: string;
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* @description
|
|
238
|
-
* Configuration defining a single NgModule with which to extend the Admin UI.
|
|
239
|
-
*
|
|
240
|
-
* @docsCategory UiDevkit
|
|
241
|
-
* @docsPage AdminUiExtension
|
|
242
|
-
*/
|
|
243
|
-
export interface AdminUiExtensionSharedModule {
|
|
244
|
-
/**
|
|
245
|
-
* @description
|
|
246
|
-
* Shared modules are directly imported into the main AppModule of the Admin UI
|
|
247
|
-
* and should be used to declare custom form components and define custom
|
|
248
|
-
* navigation items.
|
|
249
|
-
*/
|
|
250
|
-
type: 'shared';
|
|
251
|
-
/**
|
|
252
|
-
* @description
|
|
253
|
-
* The name of the file containing the extension module class.
|
|
254
|
-
*/
|
|
255
|
-
ngModuleFileName: string;
|
|
256
|
-
/**
|
|
257
|
-
* @description
|
|
258
|
-
* The name of the extension module class.
|
|
259
|
-
*/
|
|
260
|
-
ngModuleName: string;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* @description
|
|
264
|
-
* Configuration defining a single NgModule with which to extend the Admin UI.
|
|
265
|
-
*
|
|
266
|
-
* @docsCategory UiDevkit
|
|
267
|
-
* @docsPage AdminUiExtension
|
|
268
|
-
*/
|
|
269
|
-
export interface AdminUiExtensionLazyModule {
|
|
270
|
-
/**
|
|
271
|
-
* @description
|
|
272
|
-
* Lazy modules are lazy-loaded at the `/extensions/` route and should be used for
|
|
273
|
-
* modules which define new views for the Admin UI.
|
|
274
|
-
*/
|
|
275
|
-
type: 'lazy';
|
|
276
|
-
/**
|
|
277
|
-
* @description
|
|
278
|
-
* The route specifies the route at which the module will be lazy-loaded. E.g. a value
|
|
279
|
-
* of `'foo'` will cause the module to lazy-load when the `/extensions/foo` route
|
|
280
|
-
* is activated.
|
|
281
|
-
*/
|
|
282
|
-
route: string;
|
|
283
|
-
/**
|
|
284
|
-
* @description
|
|
285
|
-
* The name of the file containing the extension module class.
|
|
286
|
-
*/
|
|
287
|
-
ngModuleFileName: string;
|
|
288
|
-
/**
|
|
289
|
-
* @description
|
|
290
|
-
* The name of the extension module class.
|
|
291
|
-
*/
|
|
292
|
-
ngModuleName: string;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* @description
|
|
296
|
-
* Argument to configure process (watch or compile)
|
|
297
|
-
*
|
|
298
|
-
* @docsCategory UiDevkit
|
|
299
|
-
*/
|
|
300
|
-
export type UiExtensionCompilerProcessArgument = string | [string, any];
|
|
301
|
-
/**
|
|
302
|
-
* @description
|
|
303
|
-
* Options to configure how the Admin UI should be compiled.
|
|
304
|
-
*
|
|
305
|
-
* @docsCategory UiDevkit
|
|
306
|
-
*/
|
|
307
|
-
export interface UiExtensionCompilerOptions {
|
|
308
|
-
/**
|
|
309
|
-
* @description
|
|
310
|
-
* The directory into which the sources for the extended Admin UI will be copied.
|
|
311
|
-
*/
|
|
312
|
-
outputPath: string;
|
|
313
|
-
/**
|
|
314
|
-
* @description
|
|
315
|
-
* An array of objects which configure Angular modules and/or
|
|
316
|
-
* translations with which to extend the Admin UI.
|
|
317
|
-
*/
|
|
318
|
-
extensions: Extension[];
|
|
319
|
-
/**
|
|
320
|
-
* @description
|
|
321
|
-
* Allows you to manually specify the path to the Angular CLI compiler script. This can be useful in scenarios
|
|
322
|
-
* where for some reason the built-in start/build scripts are unable to locate the `ng` command.
|
|
323
|
-
*
|
|
324
|
-
* This option should not usually be required.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```ts
|
|
328
|
-
* compileUiExtensions({
|
|
329
|
-
* ngCompilerPath: path.join(__dirname, '../../node_modules/@angular/cli/bin/ng.js'),
|
|
330
|
-
* outputPath: path.join(__dirname, '../admin-ui'),
|
|
331
|
-
* extensions: [
|
|
332
|
-
* // ...
|
|
333
|
-
* ],
|
|
334
|
-
* })
|
|
335
|
-
* ```
|
|
336
|
-
*
|
|
337
|
-
* @since 2.1.0
|
|
338
|
-
*/
|
|
339
|
-
ngCompilerPath?: string | undefined;
|
|
340
|
-
/**
|
|
341
|
-
* @description
|
|
342
|
-
* Set to `true` in order to compile the Admin UI in development mode (using the Angular CLI
|
|
343
|
-
* [ng serve](https://angular.io/cli/serve) command). When in dev mode, any changes to
|
|
344
|
-
* UI extension files will be watched and trigger a rebuild of the Admin UI with live
|
|
345
|
-
* reloading.
|
|
346
|
-
*
|
|
347
|
-
* @default false
|
|
348
|
-
*/
|
|
349
|
-
devMode?: boolean;
|
|
350
|
-
/**
|
|
351
|
-
* @description
|
|
352
|
-
* Allows the baseHref of the compiled Admin UI app to be set. This determines the prefix
|
|
353
|
-
* of the app, for example with the default value of `'/admin/'`, the Admin UI app
|
|
354
|
-
* will be configured to be served from `http://<host>/admin/`.
|
|
355
|
-
*
|
|
356
|
-
* Note: if you are using this in conjunction with the {@link AdminUiPlugin} then you should
|
|
357
|
-
* also set the `route` option to match this value.
|
|
358
|
-
*
|
|
359
|
-
* @example
|
|
360
|
-
* ```ts
|
|
361
|
-
* AdminUiPlugin.init({
|
|
362
|
-
* route: 'my-route',
|
|
363
|
-
* port: 5001,
|
|
364
|
-
* app: compileUiExtensions({
|
|
365
|
-
* baseHref: '/my-route/',
|
|
366
|
-
* outputPath: path.join(__dirname, './custom-admin-ui'),
|
|
367
|
-
* extensions: [],
|
|
368
|
-
* devMode: true,
|
|
369
|
-
* }),
|
|
370
|
-
* }),
|
|
371
|
-
* ```
|
|
372
|
-
*
|
|
373
|
-
* @default '/admin/'
|
|
374
|
-
*/
|
|
375
|
-
baseHref?: string;
|
|
376
|
-
/**
|
|
377
|
-
* @description
|
|
378
|
-
* In watch mode, allows the port of the dev server to be specified. Defaults to the Angular CLI default
|
|
379
|
-
* of `4200`.
|
|
380
|
-
*
|
|
381
|
-
* @default 4200 | undefined
|
|
382
|
-
*/
|
|
383
|
-
watchPort?: number;
|
|
384
|
-
/**
|
|
385
|
-
* @description
|
|
386
|
-
* Internally, the Angular CLI will be invoked as an npm script. By default, the compiler will use Yarn
|
|
387
|
-
* to run the script if it is detected, otherwise it will use npm. This setting allows you to explicitly
|
|
388
|
-
* set which command to use, rather than relying on the default behavior.
|
|
389
|
-
*
|
|
390
|
-
* @since 1.5.0
|
|
391
|
-
*/
|
|
392
|
-
command?: 'yarn' | 'npm';
|
|
393
|
-
/**
|
|
394
|
-
* @description
|
|
395
|
-
* Additional command-line arguments which will get passed to the [ng build](https://angular.io/cli/build)
|
|
396
|
-
* command (or [ng serve](https://angular.io/cli/serve) if `devMode = true`).
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* ['--disable-host-check'] // to disable host check
|
|
400
|
-
*
|
|
401
|
-
* @default undefined
|
|
402
|
-
*
|
|
403
|
-
* @since 1.5.0
|
|
404
|
-
*/
|
|
405
|
-
additionalProcessArguments?: UiExtensionCompilerProcessArgument[];
|
|
406
|
-
}
|
|
407
|
-
export type Translations = {
|
|
408
|
-
[section: string]: {
|
|
409
|
-
[token: string]: string;
|
|
410
|
-
};
|
|
411
|
-
};
|
|
412
|
-
export interface BrandingOptions {
|
|
413
|
-
smallLogoPath?: string;
|
|
414
|
-
largeLogoPath?: string;
|
|
415
|
-
faviconPath?: string;
|
|
416
|
-
}
|
|
417
|
-
export interface AdminUiExtensionWithId extends AdminUiExtension {
|
|
418
|
-
id: string;
|
|
419
|
-
}
|
|
1
|
+
import { LanguageCode } from '@vendure/common/lib/generated-types';
|
|
2
|
+
export type Extension = AdminUiExtension | TranslationExtension | StaticAssetExtension | GlobalStylesExtension | SassVariableOverridesExtension;
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* Defines extensions to the Admin UI translations. Can be used as a stand-alone extension definition which only adds translations
|
|
6
|
+
* without adding new UI functionality, or as part of a full {@link AdminUiExtension}.
|
|
7
|
+
*
|
|
8
|
+
* @docsCategory UiDevkit
|
|
9
|
+
* @docsPage AdminUiExtension
|
|
10
|
+
*/
|
|
11
|
+
export interface TranslationExtension {
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* Optional object defining any translation files for the Admin UI. The value should be an object with
|
|
15
|
+
* the key as a 2-character [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes),
|
|
16
|
+
* and the value being a [glob](https://github.com/isaacs/node-glob) for any relevant
|
|
17
|
+
* translation files in JSON format.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* translations: {
|
|
22
|
+
* en: path.join(__dirname, 'translations/*.en.json'),
|
|
23
|
+
* de: path.join(__dirname, 'translations/*.de.json'),
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
translations: {
|
|
28
|
+
[languageCode in LanguageCode]?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @description
|
|
33
|
+
* Defines extensions which copy static assets to the custom Admin UI application source asset directory.
|
|
34
|
+
*
|
|
35
|
+
* @docsCategory UiDevkit
|
|
36
|
+
* @docsPage AdminUiExtension
|
|
37
|
+
*/
|
|
38
|
+
export interface StaticAssetExtension {
|
|
39
|
+
/**
|
|
40
|
+
* @description
|
|
41
|
+
* Optional array of paths to static assets which will be copied over to the Admin UI app's `/static`
|
|
42
|
+
* directory.
|
|
43
|
+
*/
|
|
44
|
+
staticAssets: StaticAssetDefinition[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @description
|
|
48
|
+
* Defines extensions which add global styles to the custom Admin UI application.
|
|
49
|
+
*
|
|
50
|
+
* @docsCategory UiDevkit
|
|
51
|
+
* @docsPage AdminUiExtension
|
|
52
|
+
*/
|
|
53
|
+
export interface GlobalStylesExtension {
|
|
54
|
+
/**
|
|
55
|
+
* @description
|
|
56
|
+
* Specifies a path (or array of paths) to global style files (css or Sass) which will be
|
|
57
|
+
* incorporated into the Admin UI app global stylesheet.
|
|
58
|
+
*/
|
|
59
|
+
globalStyles: string[] | string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @description
|
|
63
|
+
* Defines an extension which allows overriding Clarity Design System's Sass variables used in styles on the Admin UI.
|
|
64
|
+
*
|
|
65
|
+
* @docsCategory UiDevkit
|
|
66
|
+
* @docsPage AdminUiExtension
|
|
67
|
+
*/
|
|
68
|
+
export interface SassVariableOverridesExtension {
|
|
69
|
+
/**
|
|
70
|
+
* @description
|
|
71
|
+
* Specifies a path to a Sass style file containing variable declarations, which will take precedence over
|
|
72
|
+
* default values defined in Clarity.
|
|
73
|
+
*/
|
|
74
|
+
sassVariableOverrides: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @description
|
|
78
|
+
* Defines extensions to the Admin UI application by specifying additional
|
|
79
|
+
* Angular [NgModules](https://angular.io/guide/ngmodules) which are compiled
|
|
80
|
+
* into the application.
|
|
81
|
+
*
|
|
82
|
+
* See [Extending the Admin UI](/guides/extending-the-admin-ui/getting-started/) for
|
|
83
|
+
* detailed instructions.
|
|
84
|
+
*
|
|
85
|
+
* @docsCategory UiDevkit
|
|
86
|
+
* @docsPage AdminUiExtension
|
|
87
|
+
* @docsWeight 0
|
|
88
|
+
*/
|
|
89
|
+
export interface AdminUiExtension extends Partial<TranslationExtension>, Partial<StaticAssetExtension>, Partial<GlobalStylesExtension> {
|
|
90
|
+
/**
|
|
91
|
+
* @description
|
|
92
|
+
* An optional ID for the extension module. Only used internally for generating
|
|
93
|
+
* import paths to your module. If not specified, a unique hash will be used as the id.
|
|
94
|
+
*/
|
|
95
|
+
id?: string;
|
|
96
|
+
/**
|
|
97
|
+
* @description
|
|
98
|
+
* The path to the directory containing the extension module(s). The entire contents of this directory
|
|
99
|
+
* will be copied into the Admin UI app, including all TypeScript source files, html templates,
|
|
100
|
+
* scss style sheets etc.
|
|
101
|
+
*/
|
|
102
|
+
extensionPath: string;
|
|
103
|
+
/**
|
|
104
|
+
* @description
|
|
105
|
+
* One or more Angular modules which extend the default Admin UI.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated use `routes` instead of lazy modules, and `providers` instead of shared modules in combination
|
|
108
|
+
* with Angular standalone components.
|
|
109
|
+
*/
|
|
110
|
+
ngModules?: Array<AdminUiExtensionSharedModule | AdminUiExtensionLazyModule>;
|
|
111
|
+
/**
|
|
112
|
+
* @description
|
|
113
|
+
* Defines the paths to a file that exports an array of shared providers such as nav menu items, custom form inputs,
|
|
114
|
+
* custom detail components, action bar items, custom history entry components.
|
|
115
|
+
*/
|
|
116
|
+
providers?: string[];
|
|
117
|
+
/**
|
|
118
|
+
* @description
|
|
119
|
+
* Defines routes that will be lazy-loaded at the `/extensions/` route. The filePath should point to a file
|
|
120
|
+
* relative to the `extensionPath` which exports an array of Angular route definitions.
|
|
121
|
+
*/
|
|
122
|
+
routes?: Array<{
|
|
123
|
+
route: string;
|
|
124
|
+
filePath: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* @description
|
|
128
|
+
* An optional alias for the module so it can be referenced by other UI extension modules.
|
|
129
|
+
*
|
|
130
|
+
* By default, Angular modules declared in an AdminUiExtension do not have access to code outside the directory
|
|
131
|
+
* defined by the `extensionPath`. A scenario in which that can be useful though is in a monorepo codebase where
|
|
132
|
+
* a common NgModule is shared across different plugins, each defined in its own package. An example can be found
|
|
133
|
+
* below - note that the main `tsconfig.json` also maps the target module but using a path relative to the project's
|
|
134
|
+
* root folder. The UI module is not part of the main TypeScript build task as explained in
|
|
135
|
+
* [Extending the Admin UI](https://www.vendure.io/docs/plugins/extending-the-admin-ui/) but having `paths`
|
|
136
|
+
* properly configured helps with usual IDE code editing features such as code completion and quick navigation, as
|
|
137
|
+
* well as linting.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts title="packages/common-ui-module/src/ui/ui-shared.module.ts"
|
|
141
|
+
* import { NgModule } from '\@angular/core';
|
|
142
|
+
* import { SharedModule } from '\@vendure/admin-ui/core';
|
|
143
|
+
* import { CommonUiComponent } from './components/common-ui/common-ui.component';
|
|
144
|
+
*
|
|
145
|
+
* export { CommonUiComponent };
|
|
146
|
+
*
|
|
147
|
+
* \@NgModule({
|
|
148
|
+
* imports: [SharedModule],
|
|
149
|
+
* exports: [CommonUiComponent],
|
|
150
|
+
* declarations: [CommonUiComponent],
|
|
151
|
+
* })
|
|
152
|
+
* export class CommonSharedUiModule {}
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* ```ts title="packages/common-ui-module/src/index.ts"
|
|
156
|
+
* import path from 'path';
|
|
157
|
+
*
|
|
158
|
+
* import { AdminUiExtension } from '\@vendure/ui-devkit/compiler';
|
|
159
|
+
*
|
|
160
|
+
* export const uiExtensions: AdminUiExtension = {
|
|
161
|
+
* // highlight-next-line
|
|
162
|
+
* pathAlias: '\@common-ui-module', // this is the important part
|
|
163
|
+
* extensionPath: path.join(__dirname, 'ui'),
|
|
164
|
+
* ngModules: [
|
|
165
|
+
* {
|
|
166
|
+
* type: 'shared' as const,
|
|
167
|
+
* ngModuleFileName: 'ui-shared.module.ts',
|
|
168
|
+
* ngModuleName: 'CommonSharedUiModule',
|
|
169
|
+
* },
|
|
170
|
+
* ],
|
|
171
|
+
* };
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* ```json title="tsconfig.json"
|
|
175
|
+
* {
|
|
176
|
+
* "compilerOptions": {
|
|
177
|
+
* "baseUrl": ".",
|
|
178
|
+
* "paths": {
|
|
179
|
+
* // highlight-next-line
|
|
180
|
+
* "\@common-ui-module/*": ["packages/common-ui-module/src/ui/*"]
|
|
181
|
+
* }
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* ```ts title="packages/sample-plugin/src/ui/ui-extension.module.ts"
|
|
187
|
+
* import { NgModule } from '\@angular/core';
|
|
188
|
+
* import { SharedModule } from '\@vendure/admin-ui/core';
|
|
189
|
+
* // highlight-start
|
|
190
|
+
* // the import below works both in the context of the custom Admin UI app as well as the main project
|
|
191
|
+
* // '\@common-ui-module' is the value of "pathAlias" and 'ui-shared.module' is the file we want to reference inside "extensionPath"
|
|
192
|
+
* import { CommonSharedUiModule, CommonUiComponent } from '\@common-ui-module/ui-shared.module';
|
|
193
|
+
* // highlight-end
|
|
194
|
+
*
|
|
195
|
+
* \@NgModule({
|
|
196
|
+
* imports: [
|
|
197
|
+
* SharedModule,
|
|
198
|
+
* CommonSharedUiModule,
|
|
199
|
+
* RouterModule.forChild([
|
|
200
|
+
* {
|
|
201
|
+
* path: '',
|
|
202
|
+
* pathMatch: 'full',
|
|
203
|
+
* component: CommonUiComponent,
|
|
204
|
+
* },
|
|
205
|
+
* ]),
|
|
206
|
+
* ],
|
|
207
|
+
* })
|
|
208
|
+
* export class SampleUiExtensionModule {}
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
pathAlias?: string;
|
|
212
|
+
/**
|
|
213
|
+
* @description
|
|
214
|
+
* Optional array specifying filenames or [glob](https://github.com/isaacs/node-glob) patterns that should
|
|
215
|
+
* be skipped when copying the directory defined by `extensionPath`.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* exclude: ['**\/*.spec.ts']
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
exclude?: string[];
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @description
|
|
226
|
+
* A static asset can be provided as a path to the asset, or as an object containing a path and a new
|
|
227
|
+
* name, which will cause the compiler to copy and then rename the asset.
|
|
228
|
+
*
|
|
229
|
+
* @docsCategory UiDevkit
|
|
230
|
+
* @docsPage AdminUiExtension
|
|
231
|
+
*/
|
|
232
|
+
export type StaticAssetDefinition = string | {
|
|
233
|
+
path: string;
|
|
234
|
+
rename: string;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* @description
|
|
238
|
+
* Configuration defining a single NgModule with which to extend the Admin UI.
|
|
239
|
+
*
|
|
240
|
+
* @docsCategory UiDevkit
|
|
241
|
+
* @docsPage AdminUiExtension
|
|
242
|
+
*/
|
|
243
|
+
export interface AdminUiExtensionSharedModule {
|
|
244
|
+
/**
|
|
245
|
+
* @description
|
|
246
|
+
* Shared modules are directly imported into the main AppModule of the Admin UI
|
|
247
|
+
* and should be used to declare custom form components and define custom
|
|
248
|
+
* navigation items.
|
|
249
|
+
*/
|
|
250
|
+
type: 'shared';
|
|
251
|
+
/**
|
|
252
|
+
* @description
|
|
253
|
+
* The name of the file containing the extension module class.
|
|
254
|
+
*/
|
|
255
|
+
ngModuleFileName: string;
|
|
256
|
+
/**
|
|
257
|
+
* @description
|
|
258
|
+
* The name of the extension module class.
|
|
259
|
+
*/
|
|
260
|
+
ngModuleName: string;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* @description
|
|
264
|
+
* Configuration defining a single NgModule with which to extend the Admin UI.
|
|
265
|
+
*
|
|
266
|
+
* @docsCategory UiDevkit
|
|
267
|
+
* @docsPage AdminUiExtension
|
|
268
|
+
*/
|
|
269
|
+
export interface AdminUiExtensionLazyModule {
|
|
270
|
+
/**
|
|
271
|
+
* @description
|
|
272
|
+
* Lazy modules are lazy-loaded at the `/extensions/` route and should be used for
|
|
273
|
+
* modules which define new views for the Admin UI.
|
|
274
|
+
*/
|
|
275
|
+
type: 'lazy';
|
|
276
|
+
/**
|
|
277
|
+
* @description
|
|
278
|
+
* The route specifies the route at which the module will be lazy-loaded. E.g. a value
|
|
279
|
+
* of `'foo'` will cause the module to lazy-load when the `/extensions/foo` route
|
|
280
|
+
* is activated.
|
|
281
|
+
*/
|
|
282
|
+
route: string;
|
|
283
|
+
/**
|
|
284
|
+
* @description
|
|
285
|
+
* The name of the file containing the extension module class.
|
|
286
|
+
*/
|
|
287
|
+
ngModuleFileName: string;
|
|
288
|
+
/**
|
|
289
|
+
* @description
|
|
290
|
+
* The name of the extension module class.
|
|
291
|
+
*/
|
|
292
|
+
ngModuleName: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @description
|
|
296
|
+
* Argument to configure process (watch or compile)
|
|
297
|
+
*
|
|
298
|
+
* @docsCategory UiDevkit
|
|
299
|
+
*/
|
|
300
|
+
export type UiExtensionCompilerProcessArgument = string | [string, any];
|
|
301
|
+
/**
|
|
302
|
+
* @description
|
|
303
|
+
* Options to configure how the Admin UI should be compiled.
|
|
304
|
+
*
|
|
305
|
+
* @docsCategory UiDevkit
|
|
306
|
+
*/
|
|
307
|
+
export interface UiExtensionCompilerOptions {
|
|
308
|
+
/**
|
|
309
|
+
* @description
|
|
310
|
+
* The directory into which the sources for the extended Admin UI will be copied.
|
|
311
|
+
*/
|
|
312
|
+
outputPath: string;
|
|
313
|
+
/**
|
|
314
|
+
* @description
|
|
315
|
+
* An array of objects which configure Angular modules and/or
|
|
316
|
+
* translations with which to extend the Admin UI.
|
|
317
|
+
*/
|
|
318
|
+
extensions: Extension[];
|
|
319
|
+
/**
|
|
320
|
+
* @description
|
|
321
|
+
* Allows you to manually specify the path to the Angular CLI compiler script. This can be useful in scenarios
|
|
322
|
+
* where for some reason the built-in start/build scripts are unable to locate the `ng` command.
|
|
323
|
+
*
|
|
324
|
+
* This option should not usually be required.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* compileUiExtensions({
|
|
329
|
+
* ngCompilerPath: path.join(__dirname, '../../node_modules/@angular/cli/bin/ng.js'),
|
|
330
|
+
* outputPath: path.join(__dirname, '../admin-ui'),
|
|
331
|
+
* extensions: [
|
|
332
|
+
* // ...
|
|
333
|
+
* ],
|
|
334
|
+
* })
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @since 2.1.0
|
|
338
|
+
*/
|
|
339
|
+
ngCompilerPath?: string | undefined;
|
|
340
|
+
/**
|
|
341
|
+
* @description
|
|
342
|
+
* Set to `true` in order to compile the Admin UI in development mode (using the Angular CLI
|
|
343
|
+
* [ng serve](https://angular.io/cli/serve) command). When in dev mode, any changes to
|
|
344
|
+
* UI extension files will be watched and trigger a rebuild of the Admin UI with live
|
|
345
|
+
* reloading.
|
|
346
|
+
*
|
|
347
|
+
* @default false
|
|
348
|
+
*/
|
|
349
|
+
devMode?: boolean;
|
|
350
|
+
/**
|
|
351
|
+
* @description
|
|
352
|
+
* Allows the baseHref of the compiled Admin UI app to be set. This determines the prefix
|
|
353
|
+
* of the app, for example with the default value of `'/admin/'`, the Admin UI app
|
|
354
|
+
* will be configured to be served from `http://<host>/admin/`.
|
|
355
|
+
*
|
|
356
|
+
* Note: if you are using this in conjunction with the {@link AdminUiPlugin} then you should
|
|
357
|
+
* also set the `route` option to match this value.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* AdminUiPlugin.init({
|
|
362
|
+
* route: 'my-route',
|
|
363
|
+
* port: 5001,
|
|
364
|
+
* app: compileUiExtensions({
|
|
365
|
+
* baseHref: '/my-route/',
|
|
366
|
+
* outputPath: path.join(__dirname, './custom-admin-ui'),
|
|
367
|
+
* extensions: [],
|
|
368
|
+
* devMode: true,
|
|
369
|
+
* }),
|
|
370
|
+
* }),
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* @default '/admin/'
|
|
374
|
+
*/
|
|
375
|
+
baseHref?: string;
|
|
376
|
+
/**
|
|
377
|
+
* @description
|
|
378
|
+
* In watch mode, allows the port of the dev server to be specified. Defaults to the Angular CLI default
|
|
379
|
+
* of `4200`.
|
|
380
|
+
*
|
|
381
|
+
* @default 4200 | undefined
|
|
382
|
+
*/
|
|
383
|
+
watchPort?: number;
|
|
384
|
+
/**
|
|
385
|
+
* @description
|
|
386
|
+
* Internally, the Angular CLI will be invoked as an npm script. By default, the compiler will use Yarn
|
|
387
|
+
* to run the script if it is detected, otherwise it will use npm. This setting allows you to explicitly
|
|
388
|
+
* set which command to use, rather than relying on the default behavior.
|
|
389
|
+
*
|
|
390
|
+
* @since 1.5.0
|
|
391
|
+
*/
|
|
392
|
+
command?: 'yarn' | 'npm';
|
|
393
|
+
/**
|
|
394
|
+
* @description
|
|
395
|
+
* Additional command-line arguments which will get passed to the [ng build](https://angular.io/cli/build)
|
|
396
|
+
* command (or [ng serve](https://angular.io/cli/serve) if `devMode = true`).
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ['--disable-host-check'] // to disable host check
|
|
400
|
+
*
|
|
401
|
+
* @default undefined
|
|
402
|
+
*
|
|
403
|
+
* @since 1.5.0
|
|
404
|
+
*/
|
|
405
|
+
additionalProcessArguments?: UiExtensionCompilerProcessArgument[];
|
|
406
|
+
}
|
|
407
|
+
export type Translations = {
|
|
408
|
+
[section: string]: {
|
|
409
|
+
[token: string]: string;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
export interface BrandingOptions {
|
|
413
|
+
smallLogoPath?: string;
|
|
414
|
+
largeLogoPath?: string;
|
|
415
|
+
faviconPath?: string;
|
|
416
|
+
}
|
|
417
|
+
export interface AdminUiExtensionWithId extends AdminUiExtension {
|
|
418
|
+
id: string;
|
|
419
|
+
}
|