@leandrosk/dashboard 3.5.5 → 3.5.6

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 (71) hide show
  1. package/dist/plugin/api/api-extensions.d.ts +1 -0
  2. package/dist/plugin/api/api-extensions.js +35 -0
  3. package/dist/plugin/api/metrics.resolver.d.ts +8 -0
  4. package/dist/plugin/api/metrics.resolver.js +40 -0
  5. package/dist/plugin/config/metrics-strategies.d.ts +39 -0
  6. package/dist/plugin/config/metrics-strategies.js +74 -0
  7. package/dist/plugin/constants.d.ts +8 -0
  8. package/dist/plugin/constants.js +33 -0
  9. package/dist/plugin/dashboard.plugin.d.ts +115 -0
  10. package/dist/plugin/dashboard.plugin.js +339 -0
  11. package/dist/plugin/default-page.html +193 -0
  12. package/dist/plugin/index.d.ts +2 -0
  13. package/dist/plugin/index.js +18 -0
  14. package/dist/plugin/package.json +3 -0
  15. package/dist/plugin/service/metrics.service.d.ts +15 -0
  16. package/dist/plugin/service/metrics.service.js +129 -0
  17. package/dist/plugin/types.d.ts +20 -0
  18. package/dist/plugin/types.js +9 -0
  19. package/dist/vite/constants.d.ts +5 -0
  20. package/dist/vite/constants.js +279 -0
  21. package/dist/vite/index.d.ts +1 -0
  22. package/dist/vite/index.js +1 -0
  23. package/dist/vite/types.d.ts +79 -0
  24. package/dist/vite/types.js +1 -0
  25. package/dist/vite/utils/ast-utils.d.ts +5 -0
  26. package/dist/vite/utils/ast-utils.js +29 -0
  27. package/dist/vite/utils/ast-utils.spec.d.ts +1 -0
  28. package/dist/vite/utils/ast-utils.spec.js +45 -0
  29. package/dist/vite/utils/compiler.d.ts +23 -0
  30. package/dist/vite/utils/compiler.js +191 -0
  31. package/dist/vite/utils/get-dashboard-paths.d.ts +5 -0
  32. package/dist/vite/utils/get-dashboard-paths.js +20 -0
  33. package/dist/vite/utils/logger.d.ts +3 -0
  34. package/dist/vite/utils/logger.js +39 -0
  35. package/dist/vite/utils/path-transformer.d.ts +20 -0
  36. package/dist/vite/utils/path-transformer.js +116 -0
  37. package/dist/vite/utils/plugin-discovery.d.ts +27 -0
  38. package/dist/vite/utils/plugin-discovery.js +399 -0
  39. package/dist/vite/utils/schema-generator.d.ts +10 -0
  40. package/dist/vite/utils/schema-generator.js +35 -0
  41. package/dist/vite/utils/tsconfig-utils.d.ts +9 -0
  42. package/dist/vite/utils/tsconfig-utils.js +51 -0
  43. package/dist/vite/utils/ui-config.d.ts +3 -0
  44. package/dist/vite/utils/ui-config.js +44 -0
  45. package/dist/vite/vite-plugin-admin-api-schema.d.ts +24 -0
  46. package/dist/vite/vite-plugin-admin-api-schema.js +82 -0
  47. package/dist/vite/vite-plugin-config-loader.d.ts +16 -0
  48. package/dist/vite/vite-plugin-config-loader.js +70 -0
  49. package/dist/vite/vite-plugin-config.d.ts +4 -0
  50. package/dist/vite/vite-plugin-config.js +60 -0
  51. package/dist/vite/vite-plugin-dashboard-metadata.d.ts +7 -0
  52. package/dist/vite/vite-plugin-dashboard-metadata.js +61 -0
  53. package/dist/vite/vite-plugin-gql-tada.d.ts +6 -0
  54. package/dist/vite/vite-plugin-gql-tada.js +51 -0
  55. package/dist/vite/vite-plugin-hmr.d.ts +8 -0
  56. package/dist/vite/vite-plugin-hmr.js +34 -0
  57. package/dist/vite/vite-plugin-lingui-babel.d.ts +40 -0
  58. package/dist/vite/vite-plugin-lingui-babel.js +168 -0
  59. package/dist/vite/vite-plugin-tailwind-source.d.ts +7 -0
  60. package/dist/vite/vite-plugin-tailwind-source.js +48 -0
  61. package/dist/vite/vite-plugin-theme.d.ts +55 -0
  62. package/dist/vite/vite-plugin-theme.js +130 -0
  63. package/dist/vite/vite-plugin-transform-index.d.ts +11 -0
  64. package/dist/vite/vite-plugin-transform-index.js +40 -0
  65. package/dist/vite/vite-plugin-translations.d.ts +31 -0
  66. package/dist/vite/vite-plugin-translations.js +177 -0
  67. package/dist/vite/vite-plugin-ui-config.d.ts +181 -0
  68. package/dist/vite/vite-plugin-ui-config.js +36 -0
  69. package/dist/vite/vite-plugin-vendure-dashboard.d.ts +142 -0
  70. package/dist/vite/vite-plugin-vendure-dashboard.js +170 -0
  71. package/package.json +5 -4
@@ -0,0 +1 @@
1
+ export declare const adminApiExtensions: import("graphql").DocumentNode;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.adminApiExtensions = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.adminApiExtensions = (0, graphql_tag_1.default) `
9
+ type DashboardMetricSummary {
10
+ type: DashboardMetricType!
11
+ title: String!
12
+ entries: [DashboardMetricSummaryEntry!]!
13
+ }
14
+ enum DashboardMetricType {
15
+ OrderCount
16
+ OrderTotal
17
+ AverageOrderValue
18
+ }
19
+ type DashboardMetricSummaryEntry {
20
+ label: String!
21
+ value: Float!
22
+ }
23
+ input DashboardMetricSummaryInput {
24
+ types: [DashboardMetricType!]!
25
+ refresh: Boolean
26
+ startDate: DateTime!
27
+ endDate: DateTime!
28
+ }
29
+ extend type Query {
30
+ """
31
+ Get metrics for the given date range and metric types.
32
+ """
33
+ dashboardMetricSummary(input: DashboardMetricSummaryInput): [DashboardMetricSummary!]!
34
+ }
35
+ `;
@@ -0,0 +1,8 @@
1
+ import { RequestContext } from '@vendure/core';
2
+ import { MetricsService } from '../service/metrics.service.js';
3
+ import { DashboardMetricSummary, DashboardMetricSummaryInput } from '../types.js';
4
+ export declare class MetricsResolver {
5
+ private service;
6
+ constructor(service: MetricsService);
7
+ dashboardMetricSummary(ctx: RequestContext, input: DashboardMetricSummaryInput): Promise<DashboardMetricSummary[]>;
8
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MetricsResolver = void 0;
16
+ const graphql_1 = require("@nestjs/graphql");
17
+ const core_1 = require("@vendure/core");
18
+ const metrics_service_js_1 = require("../service/metrics.service.js");
19
+ let MetricsResolver = class MetricsResolver {
20
+ constructor(service) {
21
+ this.service = service;
22
+ }
23
+ async dashboardMetricSummary(ctx, input) {
24
+ return this.service.getMetrics(ctx, input);
25
+ }
26
+ };
27
+ exports.MetricsResolver = MetricsResolver;
28
+ __decorate([
29
+ (0, graphql_1.Query)(),
30
+ (0, core_1.Allow)(core_1.Permission.ReadOrder),
31
+ __param(0, (0, core_1.Ctx)()),
32
+ __param(1, (0, graphql_1.Args)('input')),
33
+ __metadata("design:type", Function),
34
+ __metadata("design:paramtypes", [core_1.RequestContext, Object]),
35
+ __metadata("design:returntype", Promise)
36
+ ], MetricsResolver.prototype, "dashboardMetricSummary", null);
37
+ exports.MetricsResolver = MetricsResolver = __decorate([
38
+ (0, graphql_1.Resolver)(),
39
+ __metadata("design:paramtypes", [metrics_service_js_1.MetricsService])
40
+ ], MetricsResolver);
@@ -0,0 +1,39 @@
1
+ import { RequestContext } from '@vendure/core';
2
+ import { MetricData } from '../service/metrics.service.js';
3
+ import { DashboardMetricSummaryEntry, DashboardMetricType } from '../types.js';
4
+ /**
5
+ * Calculate your metric data based on the given input.
6
+ * Be careful with heavy queries and calculations,
7
+ * as this function is executed everytime a user views its dashboard
8
+ *
9
+ */
10
+ export interface MetricCalculation {
11
+ type: DashboardMetricType;
12
+ getTitle(ctx: RequestContext): string;
13
+ calculateEntry(ctx: RequestContext, data: MetricData): DashboardMetricSummaryEntry;
14
+ }
15
+ export declare function getMonthName(monthNr: number): string;
16
+ /**
17
+ * Calculates the average order value per month/week
18
+ */
19
+ export declare class AverageOrderValueMetric implements MetricCalculation {
20
+ readonly type = DashboardMetricType.AverageOrderValue;
21
+ getTitle(ctx: RequestContext): string;
22
+ calculateEntry(ctx: RequestContext, data: MetricData): DashboardMetricSummaryEntry;
23
+ }
24
+ /**
25
+ * Calculates number of orders
26
+ */
27
+ export declare class OrderCountMetric implements MetricCalculation {
28
+ readonly type = DashboardMetricType.OrderCount;
29
+ getTitle(ctx: RequestContext): string;
30
+ calculateEntry(ctx: RequestContext, data: MetricData): DashboardMetricSummaryEntry;
31
+ }
32
+ /**
33
+ * Calculates order total
34
+ */
35
+ export declare class OrderTotalMetric implements MetricCalculation {
36
+ readonly type = DashboardMetricType.OrderTotal;
37
+ getTitle(ctx: RequestContext): string;
38
+ calculateEntry(ctx: RequestContext, data: MetricData): DashboardMetricSummaryEntry;
39
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderTotalMetric = exports.OrderCountMetric = exports.AverageOrderValueMetric = void 0;
4
+ exports.getMonthName = getMonthName;
5
+ const types_js_1 = require("../types.js");
6
+ function getMonthName(monthNr) {
7
+ const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
8
+ return monthNames[monthNr];
9
+ }
10
+ /**
11
+ * Calculates the average order value per month/week
12
+ */
13
+ class AverageOrderValueMetric {
14
+ constructor() {
15
+ this.type = types_js_1.DashboardMetricType.AverageOrderValue;
16
+ }
17
+ getTitle(ctx) {
18
+ return 'average-order-value';
19
+ }
20
+ calculateEntry(ctx, data) {
21
+ const label = data.date.toISOString();
22
+ if (!data.orders.length) {
23
+ return {
24
+ label,
25
+ value: 0,
26
+ };
27
+ }
28
+ const total = data.orders.map(o => o.totalWithTax).reduce((_total, current) => _total + current, 0);
29
+ const average = Math.round(total / data.orders.length);
30
+ return {
31
+ label,
32
+ value: average,
33
+ };
34
+ }
35
+ }
36
+ exports.AverageOrderValueMetric = AverageOrderValueMetric;
37
+ /**
38
+ * Calculates number of orders
39
+ */
40
+ class OrderCountMetric {
41
+ constructor() {
42
+ this.type = types_js_1.DashboardMetricType.OrderCount;
43
+ }
44
+ getTitle(ctx) {
45
+ return 'order-count';
46
+ }
47
+ calculateEntry(ctx, data) {
48
+ const label = data.date.toISOString();
49
+ return {
50
+ label,
51
+ value: data.orders.length,
52
+ };
53
+ }
54
+ }
55
+ exports.OrderCountMetric = OrderCountMetric;
56
+ /**
57
+ * Calculates order total
58
+ */
59
+ class OrderTotalMetric {
60
+ constructor() {
61
+ this.type = types_js_1.DashboardMetricType.OrderTotal;
62
+ }
63
+ getTitle(ctx) {
64
+ return 'order-totals';
65
+ }
66
+ calculateEntry(ctx, data) {
67
+ const label = data.date.toISOString();
68
+ return {
69
+ label,
70
+ value: data.orders.map(o => o.totalWithTax).reduce((_total, current) => _total + current, 0),
71
+ };
72
+ }
73
+ }
74
+ exports.OrderTotalMetric = OrderTotalMetric;
@@ -0,0 +1,8 @@
1
+ import { RwPermissionDefinition } from '@vendure/core';
2
+ export declare const DEFAULT_APP_PATH: string;
3
+ export declare const loggerCtx = "DashboardPlugin";
4
+ export declare const defaultLanguage = "en";
5
+ export declare const defaultLocale: undefined;
6
+ export declare const defaultAvailableLanguages: string[];
7
+ export declare const defaultAvailableLocales: string[];
8
+ export declare const manageDashboardGlobalViews: RwPermissionDefinition;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.manageDashboardGlobalViews = exports.defaultAvailableLocales = exports.defaultAvailableLanguages = exports.defaultLocale = exports.defaultLanguage = exports.loggerCtx = exports.DEFAULT_APP_PATH = void 0;
4
+ const core_1 = require("@vendure/core");
5
+ const path_1 = require("path");
6
+ exports.DEFAULT_APP_PATH = (0, path_1.join)(__dirname, 'dist');
7
+ exports.loggerCtx = 'DashboardPlugin';
8
+ exports.defaultLanguage = 'en';
9
+ exports.defaultLocale = undefined;
10
+ exports.defaultAvailableLanguages = [
11
+ 'en',
12
+ 'de',
13
+ 'es',
14
+ 'cs',
15
+ 'zh_Hans',
16
+ 'pt_BR',
17
+ 'pt_PT',
18
+ 'zh_Hant',
19
+ 'bg',
20
+ 'nl',
21
+ ];
22
+ exports.defaultAvailableLocales = [
23
+ 'en-US',
24
+ 'de-DE',
25
+ 'es-ES',
26
+ 'zh-CN',
27
+ 'zh-TW',
28
+ 'pt-BR',
29
+ 'pt-PT',
30
+ 'bg_BG',
31
+ 'nl-NL',
32
+ ];
33
+ exports.manageDashboardGlobalViews = new core_1.RwPermissionDefinition('DashboardGlobalViews');
@@ -0,0 +1,115 @@
1
+ import { MiddlewareConsumer, NestModule } from '@nestjs/common';
2
+ import { Type } from '@vendure/common/lib/shared-types';
3
+ import { ProcessContext } from '@vendure/core';
4
+ /**
5
+ * @description
6
+ * Configuration options for the {@link DashboardPlugin}.
7
+ *
8
+ * @docsCategory core plugins/DashboardPlugin
9
+ */
10
+ export interface DashboardPluginOptions {
11
+ /**
12
+ * @description
13
+ * The route to the Dashboard UI.
14
+ *
15
+ * @default 'dashboard'
16
+ */
17
+ route: string;
18
+ /**
19
+ * @description
20
+ * The path to the dashboard UI app dist directory.
21
+ */
22
+ appDir: string;
23
+ /**
24
+ * @description
25
+ * The port on which to check for a running Vite dev server.
26
+ * If a Vite dev server is detected on this port, requests will be proxied to it
27
+ * instead of serving static files from appDir.
28
+ *
29
+ * @default 5173
30
+ */
31
+ viteDevServerPort?: number;
32
+ }
33
+ /**
34
+ * @description
35
+ * This plugin serves the static files of the Vendure Dashboard and provides the
36
+ * GraphQL extensions needed for the order metrics on the dashboard index page.
37
+ *
38
+ * ## Installation
39
+ *
40
+ * `npm install \@vendure/dashboard`
41
+ *
42
+ * ## Usage
43
+ *
44
+ * First you need to set up compilation of the Dashboard, using the Vite configuration
45
+ * described in the [Dashboard Getting Started Guide](/extending-the-dashboard/getting-started/)
46
+ *
47
+ * ## Development vs Production
48
+ *
49
+ * When developing, you can run `npx vite` (or `npm run dev`) to start the Vite development server.
50
+ * The plugin will automatically detect if Vite is running on the default port (5173) and proxy
51
+ * requests to it instead of serving static files. This enables hot module replacement and faster
52
+ * development iterations.
53
+ *
54
+ * For production, run `npx vite build` to build the dashboard app. The built app files will be
55
+ * output to the location specified by `build.outDir` in your Vite config file. This should then
56
+ * be passed to the `appDir` init option, as in the example below:
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import { DashboardPlugin } from '\@vendure/dashboard/plugin';
61
+ *
62
+ * const config: VendureConfig = {
63
+ * // Add an instance of the plugin to the plugins array
64
+ * plugins: [
65
+ * DashboardPlugin.init({
66
+ * route: 'dashboard',
67
+ * appDir: './dist/dashboard',
68
+ * // Optional: customize Vite dev server port (defaults to 5173)
69
+ * viteDevServerPort: 3000,
70
+ * }),
71
+ * ],
72
+ * };
73
+ * ```
74
+ *
75
+ * ## Metrics
76
+ *
77
+ * This plugin defines a `metricSummary` query which is used by the Dashboard UI to
78
+ * display the order metrics on the dashboard.
79
+ *
80
+ * If you are building a stand-alone version of the Dashboard UI app, and therefore
81
+ * don't need this plugin to serve the Dashboard UI, you can still use the
82
+ * `metricSummary` query by adding the `DashboardPlugin` to the `plugins` array,
83
+ * but without calling the `init()` method:
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { DashboardPlugin } from '\@vendure/dashboard-plugin';
88
+ *
89
+ * const config: VendureConfig = {
90
+ * plugins: [
91
+ * DashboardPlugin, // <-- no call to .init()
92
+ * ],
93
+ * // ...
94
+ * };
95
+ * ```
96
+ *
97
+ * @docsCategory core plugins/DashboardPlugin
98
+ */
99
+ export declare class DashboardPlugin implements NestModule {
100
+ private readonly processContext;
101
+ private static options;
102
+ private readonly rateLimitRequests;
103
+ constructor(processContext: ProcessContext);
104
+ /**
105
+ * @description
106
+ * Set the plugin options
107
+ */
108
+ static init(options: DashboardPluginOptions): Type<DashboardPlugin>;
109
+ configure(consumer: MiddlewareConsumer): void;
110
+ private createStaticServer;
111
+ private checkViteDevServer;
112
+ private checkBuiltFiles;
113
+ private createDefaultPage;
114
+ private createDynamicHandler;
115
+ }