@deenruv/dashboard-widgets-plugin 1.0.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/LICENSE +23 -0
- package/README.md +58 -0
- package/dist/plugin-server/constants.d.ts +4 -0
- package/dist/plugin-server/constants.js +12 -0
- package/dist/plugin-server/controllers/admin-ui-controller.d.ts +4 -0
- package/dist/plugin-server/controllers/admin-ui-controller.js +46 -0
- package/dist/plugin-server/controllers/refresh-view-controller.d.ts +8 -0
- package/dist/plugin-server/controllers/refresh-view-controller.js +41 -0
- package/dist/plugin-server/index.d.ts +1 -0
- package/dist/plugin-server/index.js +17 -0
- package/dist/plugin-server/materialisedViewEntities/order_summary.d.ts +9 -0
- package/dist/plugin-server/materialisedViewEntities/order_summary.js +79 -0
- package/dist/plugin-server/materialisedViewEntities/orders_summary_with_state.d.ts +10 -0
- package/dist/plugin-server/materialisedViewEntities/orders_summary_with_state.js +79 -0
- package/dist/plugin-server/materialisedViewEntities/total_products.d.ts +7 -0
- package/dist/plugin-server/materialisedViewEntities/total_products.js +62 -0
- package/dist/plugin-server/materialisedViewEntities/total_products_with_state.d.ts +9 -0
- package/dist/plugin-server/materialisedViewEntities/total_products_with_state.js +62 -0
- package/dist/plugin-server/plugin.d.ts +6 -0
- package/dist/plugin-server/plugin.js +149 -0
- package/dist/plugin-server/raw-sql.d.ts +8 -0
- package/dist/plugin-server/raw-sql.js +48 -0
- package/dist/plugin-server/resolvers/admin.resolver.d.ts +47 -0
- package/dist/plugin-server/resolvers/admin.resolver.js +63 -0
- package/dist/plugin-server/services/metrics.service.d.ts +30 -0
- package/dist/plugin-server/services/metrics.service.js +272 -0
- package/dist/plugin-server/types.d.ts +20 -0
- package/dist/plugin-server/types.js +2 -0
- package/dist/plugin-server/utils.d.ts +1 -0
- package/dist/plugin-server/utils.js +12 -0
- package/dist/plugin-server/zeus/const.d.ts +6 -0
- package/dist/plugin-server/zeus/const.js +3675 -0
- package/dist/plugin-server/zeus/index.d.ts +18709 -0
- package/dist/plugin-server/zeus/index.js +1122 -0
- package/dist/plugin-server/zeus/typedDocumentNode.d.ts +3 -0
- package/dist/plugin-server/zeus/typedDocumentNode.js +16 -0
- package/dist/plugin-ui/components/CategoriesChartWidget/dashCaseToSpaces.d.ts +1 -0
- package/dist/plugin-ui/components/CategoriesChartWidget/dashCaseToSpaces.js +6 -0
- package/dist/plugin-ui/components/CategoriesChartWidget/index.d.ts +2 -0
- package/dist/plugin-ui/components/CategoriesChartWidget/index.js +100 -0
- package/dist/plugin-ui/components/LatestOrdersWidget/index.d.ts +4 -0
- package/dist/plugin-ui/components/LatestOrdersWidget/index.js +96 -0
- package/dist/plugin-ui/components/LatestOrdersWidget/paymentMethod.d.ts +6 -0
- package/dist/plugin-ui/components/LatestOrdersWidget/paymentMethod.js +7 -0
- package/dist/plugin-ui/components/OrdersWidget/CustomTooltip.d.ts +18 -0
- package/dist/plugin-ui/components/OrdersWidget/CustomTooltip.js +92 -0
- package/dist/plugin-ui/components/OrdersWidget/GroupBySelect.d.ts +8 -0
- package/dist/plugin-ui/components/OrdersWidget/GroupBySelect.js +17 -0
- package/dist/plugin-ui/components/OrdersWidget/MetricCustomDates.d.ts +9 -0
- package/dist/plugin-ui/components/OrdersWidget/MetricCustomDates.js +27 -0
- package/dist/plugin-ui/components/OrdersWidget/MetricTypeSelect.d.ts +9 -0
- package/dist/plugin-ui/components/OrdersWidget/MetricTypeSelect.js +17 -0
- package/dist/plugin-ui/components/OrdersWidget/OrdersChart.d.ts +24 -0
- package/dist/plugin-ui/components/OrdersWidget/OrdersChart.js +46 -0
- package/dist/plugin-ui/components/OrdersWidget/OrdersSummaryTile.d.ts +13 -0
- package/dist/plugin-ui/components/OrdersWidget/OrdersSummaryTile.js +115 -0
- package/dist/plugin-ui/components/OrdersWidget/ProductSelector.d.ts +17 -0
- package/dist/plugin-ui/components/OrdersWidget/ProductSelector.js +37 -0
- package/dist/plugin-ui/components/OrdersWidget/RatioBadge.d.ts +6 -0
- package/dist/plugin-ui/components/OrdersWidget/RatioBadge.js +12 -0
- package/dist/plugin-ui/components/OrdersWidget/index.d.ts +2 -0
- package/dist/plugin-ui/components/OrdersWidget/index.js +229 -0
- package/dist/plugin-ui/components/ProductsChartWidget/CustomBarChartTooltip.d.ts +9 -0
- package/dist/plugin-ui/components/ProductsChartWidget/CustomBarChartTooltip.js +14 -0
- package/dist/plugin-ui/components/ProductsChartWidget/index.d.ts +2 -0
- package/dist/plugin-ui/components/ProductsChartWidget/index.js +116 -0
- package/dist/plugin-ui/components/index.d.ts +4 -0
- package/dist/plugin-ui/components/index.js +4 -0
- package/dist/plugin-ui/components/shared/EmptyData.d.ts +6 -0
- package/dist/plugin-ui/components/shared/EmptyData.js +8 -0
- package/dist/plugin-ui/components/shared/MetricsRangeSelect.d.ts +10 -0
- package/dist/plugin-ui/components/shared/MetricsRangeSelect.js +26 -0
- package/dist/plugin-ui/components/shared/OrderStatesSelect.d.ts +8 -0
- package/dist/plugin-ui/components/shared/OrderStatesSelect.js +28 -0
- package/dist/plugin-ui/components/shared/PeriodSelect.d.ts +20 -0
- package/dist/plugin-ui/components/shared/PeriodSelect.js +56 -0
- package/dist/plugin-ui/components/shared/colors.d.ts +1 -0
- package/dist/plugin-ui/components/shared/colors.js +1 -0
- package/dist/plugin-ui/components/shared/index.d.ts +3 -0
- package/dist/plugin-ui/components/shared/index.js +3 -0
- package/dist/plugin-ui/graphql/index.d.ts +2 -0
- package/dist/plugin-ui/graphql/index.js +2 -0
- package/dist/plugin-ui/graphql/queries.d.ts +425 -0
- package/dist/plugin-ui/graphql/queries.js +182 -0
- package/dist/plugin-ui/graphql/selectors.d.ts +19 -0
- package/dist/plugin-ui/graphql/selectors.js +21 -0
- package/dist/plugin-ui/index.d.ts +9 -0
- package/dist/plugin-ui/index.js +21 -0
- package/dist/plugin-ui/locales/en/index.d.ts +72 -0
- package/dist/plugin-ui/locales/en/index.js +2 -0
- package/dist/plugin-ui/locales/en/test.json +71 -0
- package/dist/plugin-ui/locales/pl/index.d.ts +71 -0
- package/dist/plugin-ui/locales/pl/index.js +2 -0
- package/dist/plugin-ui/locales/pl/test.json +70 -0
- package/dist/plugin-ui/tsconfig.json +18 -0
- package/dist/plugin-ui/types.d.ts +64 -0
- package/dist/plugin-ui/types.js +14 -0
- package/dist/plugin-ui/utils.d.ts +70 -0
- package/dist/plugin-ui/utils.js +366 -0
- package/dist/plugin-ui/widgets.d.ts +15 -0
- package/dist/plugin-ui/widgets.js +36 -0
- package/dist/plugin-ui/zeus/const.d.ts +6 -0
- package/dist/plugin-ui/zeus/const.js +3672 -0
- package/dist/plugin-ui/zeus/index.d.ts +18709 -0
- package/dist/plugin-ui/zeus/index.js +1114 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# License 1
|
|
2
|
+
|
|
3
|
+
The MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025-present Aexol
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
12
|
+
|
|
13
|
+
# License 2
|
|
14
|
+
|
|
15
|
+
The MIT License
|
|
16
|
+
|
|
17
|
+
Copyright (c) 2018-2025 Michael Bromley
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @deenruv/dashboard-widgets-plugin
|
|
2
|
+
|
|
3
|
+
Admin dashboard plugin that provides rich order and product analytics widgets. It adds chart-based metrics, order summary tiles, category breakdowns, product charts, and a latest orders table to the admin dashboard.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @deenruv/dashboard-widgets-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { DashboardWidgetsPlugin } from '@deenruv/dashboard-widgets-plugin';
|
|
15
|
+
|
|
16
|
+
// In your Deenruv server config:
|
|
17
|
+
plugins: [
|
|
18
|
+
DashboardWidgetsPlugin.init({
|
|
19
|
+
// Optional: cache time for metrics queries in milliseconds
|
|
20
|
+
cacheTime: 60000,
|
|
21
|
+
// Optional: enable discount custom field support
|
|
22
|
+
discountByCustomField: false,
|
|
23
|
+
// Optional: additional order states to include in filters
|
|
24
|
+
additionalOrderStates: [
|
|
25
|
+
{ state: 'InRealization', selectedByDefault: true },
|
|
26
|
+
],
|
|
27
|
+
}),
|
|
28
|
+
]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- Order summary metrics (total revenue, order count, average order value, product count)
|
|
34
|
+
- Interactive time-series charts for order count, order total, average order value, and product count
|
|
35
|
+
- Configurable time ranges (today, this week, this month, this year, custom, etc.)
|
|
36
|
+
- Hourly and daily chart intervals
|
|
37
|
+
- Order state filtering for all metrics
|
|
38
|
+
- Product-specific metric filtering
|
|
39
|
+
- Categories and products breakdown chart widgets
|
|
40
|
+
- Latest orders table widget
|
|
41
|
+
- Materialized database views for fast metric aggregation
|
|
42
|
+
|
|
43
|
+
## Admin UI
|
|
44
|
+
|
|
45
|
+
This plugin extends the admin UI with a comprehensive dashboard featuring:
|
|
46
|
+
- **Orders Widget** — Time-series charts with configurable metrics, date ranges, and order state filters
|
|
47
|
+
- **Order Summary Tiles** — Quick overview cards showing total revenue, order count, average value, and product count
|
|
48
|
+
- **Categories Chart Widget** — Breakdown of orders by product categories
|
|
49
|
+
- **Products Chart Widget** — Top products bar chart with custom tooltips
|
|
50
|
+
- **Latest Orders Widget** — Recent orders table with payment method info
|
|
51
|
+
|
|
52
|
+
## API Extensions
|
|
53
|
+
|
|
54
|
+
### Admin API
|
|
55
|
+
|
|
56
|
+
- **Query** `additionalOrderStates: [AdditionalOrderState!]!` — Returns configured additional order states
|
|
57
|
+
- **Query** `chartMetric(input: ChartMetricInput!): ChartMetrics!` — Returns time-series chart data for selected metric types, date ranges, and intervals
|
|
58
|
+
- **Query** `orderSummaryMetric(input: OrderSummaryMetricInput!): OrderSummaryMetrics!` — Returns aggregated order summary data (totals, counts, averages)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OrderLineEvent, OrderStateTransitionEvent, LoginEvent, LogoutEvent } from "@deenruv/core";
|
|
2
|
+
export declare const PLUGIN_INIT_OPTIONS: unique symbol;
|
|
3
|
+
export declare const DEFAULT_CACHE_TIME = 3600;
|
|
4
|
+
export declare const events: (typeof OrderLineEvent | typeof OrderStateTransitionEvent | typeof LoginEvent | typeof LogoutEvent)[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.events = exports.DEFAULT_CACHE_TIME = exports.PLUGIN_INIT_OPTIONS = void 0;
|
|
4
|
+
const core_1 = require("@deenruv/core");
|
|
5
|
+
exports.PLUGIN_INIT_OPTIONS = Symbol("ANALYTICS_PLUGIN_OPTIONS");
|
|
6
|
+
exports.DEFAULT_CACHE_TIME = 3600;
|
|
7
|
+
exports.events = [
|
|
8
|
+
core_1.OrderLineEvent,
|
|
9
|
+
core_1.OrderStateTransitionEvent,
|
|
10
|
+
core_1.LoginEvent,
|
|
11
|
+
core_1.LogoutEvent,
|
|
12
|
+
];
|
|
@@ -0,0 +1,46 @@
|
|
|
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.AdminUIController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let AdminUIController = class AdminUIController {
|
|
18
|
+
constructor() { }
|
|
19
|
+
async page(res) {
|
|
20
|
+
res.send(`
|
|
21
|
+
<html>
|
|
22
|
+
<head>
|
|
23
|
+
<title>Deenruv - Admin UI</title>
|
|
24
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
25
|
+
<script type="module" crossorigin src="http://localhost:9000/assets/assets/index.js"></script>
|
|
26
|
+
<link rel="stylesheet" crossorigin href="http://localhost:9000/assets/assets/index.css">
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<div id="root"></div>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.AdminUIController = AdminUIController;
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, common_1.Get)(),
|
|
38
|
+
__param(0, (0, common_1.Res)()),
|
|
39
|
+
__metadata("design:type", Function),
|
|
40
|
+
__metadata("design:paramtypes", [Object]),
|
|
41
|
+
__metadata("design:returntype", Promise)
|
|
42
|
+
], AdminUIController.prototype, "page", null);
|
|
43
|
+
exports.AdminUIController = AdminUIController = __decorate([
|
|
44
|
+
(0, common_1.Controller)("admin-ui"),
|
|
45
|
+
__metadata("design:paramtypes", [])
|
|
46
|
+
], AdminUIController);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RequestContext } from "@deenruv/core";
|
|
2
|
+
import { BetterMetricsService } from "../services/metrics.service";
|
|
3
|
+
import { type Response } from "express";
|
|
4
|
+
export declare class RefreshViewController {
|
|
5
|
+
private metricsService;
|
|
6
|
+
constructor(metricsService: BetterMetricsService);
|
|
7
|
+
refreshView(ctx: RequestContext, res: Response): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.RefreshViewController = void 0;
|
|
16
|
+
const core_1 = require("@deenruv/core");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const metrics_service_1 = require("../services/metrics.service");
|
|
19
|
+
let RefreshViewController = class RefreshViewController {
|
|
20
|
+
constructor(metricsService) {
|
|
21
|
+
this.metricsService = metricsService;
|
|
22
|
+
}
|
|
23
|
+
async refreshView(ctx, res) {
|
|
24
|
+
await this.metricsService.refreshViews(ctx);
|
|
25
|
+
res.status(200).send("OK");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.RefreshViewController = RefreshViewController;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, core_1.Allow)(core_1.Permission.ReadOrder),
|
|
31
|
+
(0, common_1.Get)("/refresh-view"),
|
|
32
|
+
__param(0, (0, core_1.Ctx)()),
|
|
33
|
+
__param(1, (0, common_1.Res)()),
|
|
34
|
+
__metadata("design:type", Function),
|
|
35
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
36
|
+
__metadata("design:returntype", Promise)
|
|
37
|
+
], RefreshViewController.prototype, "refreshView", null);
|
|
38
|
+
exports.RefreshViewController = RefreshViewController = __decorate([
|
|
39
|
+
(0, common_1.Controller)("metrics"),
|
|
40
|
+
__metadata("design:paramtypes", [metrics_service_1.BetterMetricsService])
|
|
41
|
+
], RefreshViewController);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./plugin.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./plugin.js"), exports);
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrderSummaryViewEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let OrderSummaryViewEntity = class OrderSummaryViewEntity {
|
|
15
|
+
};
|
|
16
|
+
exports.OrderSummaryViewEntity = OrderSummaryViewEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.ViewColumn)(),
|
|
19
|
+
__metadata("design:type", Date)
|
|
20
|
+
], OrderSummaryViewEntity.prototype, "hour", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.ViewColumn)(),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], OrderSummaryViewEntity.prototype, "orderCount", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.ViewColumn)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], OrderSummaryViewEntity.prototype, "totalWithTax", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ViewColumn)(),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], OrderSummaryViewEntity.prototype, "total", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.ViewColumn)(),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], OrderSummaryViewEntity.prototype, "productPlacedCount", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ViewColumn)(),
|
|
39
|
+
__metadata("design:type", Number)
|
|
40
|
+
], OrderSummaryViewEntity.prototype, "productCount", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.ViewColumn)(),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], OrderSummaryViewEntity.prototype, "channelId", void 0);
|
|
45
|
+
exports.OrderSummaryViewEntity = OrderSummaryViewEntity = __decorate([
|
|
46
|
+
(0, typeorm_1.ViewEntity)({
|
|
47
|
+
materialized: true,
|
|
48
|
+
expression: `
|
|
49
|
+
WITH order_line_summary AS (
|
|
50
|
+
SELECT
|
|
51
|
+
"orderId",
|
|
52
|
+
SUM("orderPlacedQuantity") as "orderPlacedQuantity",
|
|
53
|
+
SUM(quantity) as "quantity"
|
|
54
|
+
FROM public.order_line
|
|
55
|
+
GROUP BY "orderId"
|
|
56
|
+
)
|
|
57
|
+
SELECT
|
|
58
|
+
date_trunc('hour', o."orderPlacedAt") AS hour,
|
|
59
|
+
occ."channelId" AS "channelId",
|
|
60
|
+
COUNT(*) AS "orderCount",
|
|
61
|
+
SUM(o."subTotalWithTax" + o."shippingWithTax") AS "totalWithTax",
|
|
62
|
+
SUM(o."subTotal" + o."shipping") AS "total",
|
|
63
|
+
SUM(ols."orderPlacedQuantity") as "productPlacedCount",
|
|
64
|
+
SUM(ols."quantity") as "productCount"
|
|
65
|
+
FROM "order" o
|
|
66
|
+
LEFT JOIN "order_channels_channel" occ ON occ."orderId" = o."id"
|
|
67
|
+
LEFT JOIN "order_line_summary" ols ON ols."orderId" = o.id
|
|
68
|
+
WHERE o."orderPlacedAt" >= '2020-01-01T00:00:00.000Z'
|
|
69
|
+
AND o.state IN ('PaymentSettled',
|
|
70
|
+
'PartiallyShipped',
|
|
71
|
+
'Shipped',
|
|
72
|
+
'PartiallyDelivered',
|
|
73
|
+
'Delivered')
|
|
74
|
+
GROUP BY hour,occ."channelId"
|
|
75
|
+
ORDER BY hour ASC
|
|
76
|
+
`,
|
|
77
|
+
}),
|
|
78
|
+
(0, typeorm_1.Index)(["hour", "channelId"], { unique: true })
|
|
79
|
+
], OrderSummaryViewEntity);
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrderSummaryWithStateViewEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let OrderSummaryWithStateViewEntity = class OrderSummaryWithStateViewEntity {
|
|
15
|
+
};
|
|
16
|
+
exports.OrderSummaryWithStateViewEntity = OrderSummaryWithStateViewEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.ViewColumn)(),
|
|
19
|
+
__metadata("design:type", Date)
|
|
20
|
+
], OrderSummaryWithStateViewEntity.prototype, "hour", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.ViewColumn)(),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], OrderSummaryWithStateViewEntity.prototype, "orderCount", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.ViewColumn)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], OrderSummaryWithStateViewEntity.prototype, "totalWithTax", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ViewColumn)(),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], OrderSummaryWithStateViewEntity.prototype, "total", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.ViewColumn)(),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], OrderSummaryWithStateViewEntity.prototype, "productPlacedCount", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ViewColumn)(),
|
|
39
|
+
__metadata("design:type", Number)
|
|
40
|
+
], OrderSummaryWithStateViewEntity.prototype, "productCount", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.ViewColumn)(),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], OrderSummaryWithStateViewEntity.prototype, "channelId", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.ViewColumn)(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], OrderSummaryWithStateViewEntity.prototype, "state", void 0);
|
|
49
|
+
exports.OrderSummaryWithStateViewEntity = OrderSummaryWithStateViewEntity = __decorate([
|
|
50
|
+
(0, typeorm_1.ViewEntity)({
|
|
51
|
+
materialized: true,
|
|
52
|
+
expression: `
|
|
53
|
+
WITH order_line_summary AS (
|
|
54
|
+
SELECT
|
|
55
|
+
"orderId",
|
|
56
|
+
SUM("orderPlacedQuantity") as "orderPlacedQuantity",
|
|
57
|
+
SUM(quantity) as "quantity"
|
|
58
|
+
FROM public.order_line
|
|
59
|
+
GROUP BY "orderId"
|
|
60
|
+
)
|
|
61
|
+
SELECT
|
|
62
|
+
date_trunc('hour', o."orderPlacedAt") AS hour,
|
|
63
|
+
occ."channelId" AS "channelId",
|
|
64
|
+
o.state,
|
|
65
|
+
COUNT(*) AS "orderCount",
|
|
66
|
+
SUM(o."subTotalWithTax" + o."shippingWithTax") AS "totalWithTax",
|
|
67
|
+
SUM(o."subTotal" + o."shipping") AS "total",
|
|
68
|
+
SUM(ols."orderPlacedQuantity") as "productPlacedCount",
|
|
69
|
+
SUM(ols."quantity") as "productCount"
|
|
70
|
+
FROM "order" o
|
|
71
|
+
INNER JOIN "order_channels_channel" occ ON occ."orderId" = o."id"
|
|
72
|
+
INNER JOIN "order_line_summary" ols ON ols."orderId" = o.id
|
|
73
|
+
WHERE o."orderPlacedAt" >= '2020-01-01T00:00:00.000Z'
|
|
74
|
+
GROUP BY hour, occ."channelId",o.state
|
|
75
|
+
ORDER BY hour ASC
|
|
76
|
+
`,
|
|
77
|
+
}),
|
|
78
|
+
(0, typeorm_1.Index)(["hour", "channelId", "state"], { unique: true })
|
|
79
|
+
], OrderSummaryWithStateViewEntity);
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TotalProductsViewEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let TotalProductsViewEntity = class TotalProductsViewEntity {
|
|
15
|
+
};
|
|
16
|
+
exports.TotalProductsViewEntity = TotalProductsViewEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.ViewColumn)(),
|
|
19
|
+
__metadata("design:type", Date)
|
|
20
|
+
], TotalProductsViewEntity.prototype, "hour", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.ViewColumn)(),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], TotalProductsViewEntity.prototype, "productVariantId", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.ViewColumn)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], TotalProductsViewEntity.prototype, "quantitySum", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ViewColumn)(),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], TotalProductsViewEntity.prototype, "orderPlacedQuantitySum", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.ViewColumn)(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], TotalProductsViewEntity.prototype, "channelId", void 0);
|
|
37
|
+
exports.TotalProductsViewEntity = TotalProductsViewEntity = __decorate([
|
|
38
|
+
(0, typeorm_1.ViewEntity)({
|
|
39
|
+
materialized: true,
|
|
40
|
+
expression: `
|
|
41
|
+
SELECT
|
|
42
|
+
date_trunc('hour', o."orderPlacedAt") AS hour,
|
|
43
|
+
ol."productVariantId" AS "productVariantId",
|
|
44
|
+
occ."channelId" AS "channelId",
|
|
45
|
+
SUM(ol."orderPlacedQuantity") as "orderPlacedQuantitySum",
|
|
46
|
+
SUM(ol."quantity") as "quantitySum"
|
|
47
|
+
FROM "public"."order" o
|
|
48
|
+
INNER JOIN "public"."order_channels_channel" occ ON occ."orderId" = o."id"
|
|
49
|
+
INNER JOIN "public"."order_line" ol ON ol."orderId" = o."id"
|
|
50
|
+
INNER JOIN "public"."product_variant" pv ON pv.id = ol."productVariantId"
|
|
51
|
+
WHERE o."orderPlacedAt"::timestamptz >= '2020-01-01T00:00:00.000Z'
|
|
52
|
+
AND o.state IN ('PaymentSettled',
|
|
53
|
+
'PartiallyShipped',
|
|
54
|
+
'Shipped',
|
|
55
|
+
'PartiallyDelivered',
|
|
56
|
+
'Delivered')
|
|
57
|
+
GROUP BY hour, ol."productVariantId",occ."channelId"
|
|
58
|
+
ORDER BY hour DESC;
|
|
59
|
+
`,
|
|
60
|
+
}),
|
|
61
|
+
(0, typeorm_1.Index)(["hour", "productVariantId", "channelId"], { unique: true })
|
|
62
|
+
], TotalProductsViewEntity);
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TotalProductsWithStateViewEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let TotalProductsWithStateViewEntity = class TotalProductsWithStateViewEntity {
|
|
15
|
+
};
|
|
16
|
+
exports.TotalProductsWithStateViewEntity = TotalProductsWithStateViewEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.ViewColumn)(),
|
|
19
|
+
__metadata("design:type", Date)
|
|
20
|
+
], TotalProductsWithStateViewEntity.prototype, "hour", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.ViewColumn)(),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], TotalProductsWithStateViewEntity.prototype, "productVariantId", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.ViewColumn)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], TotalProductsWithStateViewEntity.prototype, "quantitySum", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ViewColumn)(),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], TotalProductsWithStateViewEntity.prototype, "orderPlacedQuantitySum", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.ViewColumn)(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], TotalProductsWithStateViewEntity.prototype, "channelId", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ViewColumn)(),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], TotalProductsWithStateViewEntity.prototype, "state", void 0);
|
|
41
|
+
exports.TotalProductsWithStateViewEntity = TotalProductsWithStateViewEntity = __decorate([
|
|
42
|
+
(0, typeorm_1.ViewEntity)({
|
|
43
|
+
materialized: true,
|
|
44
|
+
expression: `
|
|
45
|
+
SELECT
|
|
46
|
+
date_trunc('hour', o."orderPlacedAt") AS hour,
|
|
47
|
+
o.state,
|
|
48
|
+
ol."productVariantId" AS "productVariantId",
|
|
49
|
+
occ."channelId" AS "channelId",
|
|
50
|
+
SUM(ol."orderPlacedQuantity") as "orderPlacedQuantitySum",
|
|
51
|
+
SUM(ol."quantity") as "quantitySum"
|
|
52
|
+
FROM "public"."order" o
|
|
53
|
+
INNER JOIN "public"."order_channels_channel" occ ON occ."orderId" = o."id"
|
|
54
|
+
INNER JOIN "public"."order_line" ol ON ol."orderId" = o."id"
|
|
55
|
+
INNER JOIN "public"."product_variant" pv ON pv.id = ol."productVariantId"
|
|
56
|
+
WHERE o."orderPlacedAt"::timestamptz >= '2020-01-01T00:00:00.000Z'
|
|
57
|
+
GROUP BY "hour", ol."productVariantId",occ."channelId",o.state
|
|
58
|
+
ORDER BY "hour" DESC
|
|
59
|
+
`,
|
|
60
|
+
}),
|
|
61
|
+
(0, typeorm_1.Index)(["hour", "productVariantId", "channelId", "state"], { unique: true })
|
|
62
|
+
], TotalProductsWithStateViewEntity);
|