@deenruv/in-realization-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.
Files changed (64) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +51 -0
  3. package/dist/plugin-server/api/admin-order.resolver.d.ts +7 -0
  4. package/dist/plugin-server/api/admin-order.resolver.js +42 -0
  5. package/dist/plugin-server/api/admin.resolver.d.ts +28 -0
  6. package/dist/plugin-server/api/admin.resolver.js +60 -0
  7. package/dist/plugin-server/api/order.resolver.d.ts +11 -0
  8. package/dist/plugin-server/api/order.resolver.js +43 -0
  9. package/dist/plugin-server/consts.d.ts +9 -0
  10. package/dist/plugin-server/consts.js +4 -0
  11. package/dist/plugin-server/entities/order-realization.entity.d.ts +13 -0
  12. package/dist/plugin-server/entities/order-realization.entity.js +56 -0
  13. package/dist/plugin-server/extensions/realization.extension.d.ts +2 -0
  14. package/dist/plugin-server/extensions/realization.extension.js +62 -0
  15. package/dist/plugin-server/index.d.ts +5 -0
  16. package/dist/plugin-server/index.js +79 -0
  17. package/dist/plugin-server/services/order-register.service.d.ts +28 -0
  18. package/dist/plugin-server/services/order-register.service.js +89 -0
  19. package/dist/plugin-server/services/pdf.service.d.ts +17 -0
  20. package/dist/plugin-server/services/pdf.service.js +166 -0
  21. package/dist/plugin-server/services/realization.d.ts +2 -0
  22. package/dist/plugin-server/services/realization.js +130 -0
  23. package/dist/plugin-server/services/storage.service.d.ts +23 -0
  24. package/dist/plugin-server/services/storage.service.js +134 -0
  25. package/dist/plugin-server/services/types.d.ts +18 -0
  26. package/dist/plugin-server/services/types.js +2 -0
  27. package/dist/plugin-server/zeus/const.d.ts +6 -0
  28. package/dist/plugin-server/zeus/const.js +3697 -0
  29. package/dist/plugin-server/zeus/index.d.ts +18858 -0
  30. package/dist/plugin-server/zeus/index.js +1094 -0
  31. package/dist/plugin-server/zeus/typedDocumentNode.d.ts +3 -0
  32. package/dist/plugin-server/zeus/typedDocumentNode.js +16 -0
  33. package/dist/plugin-ui/components/InRealizationButton.d.ts +2 -0
  34. package/dist/plugin-ui/components/InRealizationButton.js +35 -0
  35. package/dist/plugin-ui/components/InRealizationCard.d.ts +2 -0
  36. package/dist/plugin-ui/components/InRealizationCard.js +7 -0
  37. package/dist/plugin-ui/components/InRealizationStateModal.d.ts +5 -0
  38. package/dist/plugin-ui/components/InRealizationStateModal.js +124 -0
  39. package/dist/plugin-ui/graphql/index.d.ts +1 -0
  40. package/dist/plugin-ui/graphql/index.js +1 -0
  41. package/dist/plugin-ui/graphql/mutations.d.ts +18 -0
  42. package/dist/plugin-ui/graphql/mutations.js +9 -0
  43. package/dist/plugin-ui/graphql/queries.d.ts +5 -0
  44. package/dist/plugin-ui/graphql/queries.js +6 -0
  45. package/dist/plugin-ui/graphql/selectors.d.ts +39 -0
  46. package/dist/plugin-ui/graphql/selectors.js +25 -0
  47. package/dist/plugin-ui/index.d.ts +1 -0
  48. package/dist/plugin-ui/index.js +17 -0
  49. package/dist/plugin-ui/locales/en/index.d.ts +5 -0
  50. package/dist/plugin-ui/locales/en/index.js +2 -0
  51. package/dist/plugin-ui/locales/en/realization.json +4 -0
  52. package/dist/plugin-ui/locales/pl/index.d.ts +5 -0
  53. package/dist/plugin-ui/locales/pl/index.js +2 -0
  54. package/dist/plugin-ui/locales/pl/realization.json +4 -0
  55. package/dist/plugin-ui/translation-ns.d.ts +1 -0
  56. package/dist/plugin-ui/translation-ns.js +1 -0
  57. package/dist/plugin-ui/tsconfig.json +18 -0
  58. package/dist/plugin-ui/zeus/const.d.ts +6 -0
  59. package/dist/plugin-ui/zeus/const.js +3694 -0
  60. package/dist/plugin-ui/zeus/index.d.ts +18858 -0
  61. package/dist/plugin-ui/zeus/index.js +1086 -0
  62. package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
  63. package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
  64. package/package.json +54 -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,51 @@
1
+ # @deenruv/in-realization-plugin
2
+
3
+ Plugin that adds an "InRealization" order state to the Deenruv order process, along with order realization tracking, PDF generation, and S3-based file storage. It enables administrators to register realization details (planned dates, notes, assets) and exposes realization info to the storefront.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @deenruv/in-realization-plugin
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ```typescript
14
+ import { InRealizationPlugin } from '@deenruv/in-realization-plugin';
15
+ import { S3Client } from '@aws-sdk/client-s3';
16
+
17
+ // In your Deenruv server config:
18
+ plugins: [
19
+ InRealizationPlugin.init({
20
+ s3: {
21
+ client: new S3Client({ region: 'eu-central-1' }),
22
+ bucket: 'my-realization-bucket',
23
+ expiresIn: 3600, // Pre-signed URL expiry in seconds
24
+ },
25
+ }),
26
+ ]
27
+ ```
28
+
29
+ ## Features
30
+
31
+ - Adds `InRealization` state to the order process (transition from `PaymentSettled`)
32
+ - Order realization entity for tracking planned dates, notes, colors, and associated assets
33
+ - PDF generation service for realization documents
34
+ - S3 storage integration with pre-signed URL support
35
+ - Both Admin and Shop API extensions for realization data
36
+
37
+ ## Admin UI
38
+
39
+ This plugin extends the admin UI with realization management components on the order detail page, including an "InRealization" action button, a realization card showing planned dates and notes, and a state transition modal.
40
+
41
+ ## API Extensions
42
+
43
+ ### Admin API
44
+
45
+ - **Query** `getRealizationURL(orderID: ID!): String` — Returns a pre-signed URL for the realization document
46
+ - **Mutation** `registerRealization(input: OrderRealizationInput!): OrderRealization` — Registers realization details (planned dates, notes, assets) for an order
47
+ - **Field** `Order.getRealization: OrderRealization` — Returns realization data for an order
48
+
49
+ ### Shop API
50
+
51
+ - **Field** `Order.realization: ShopOrderRealization` — Returns realization info (note, planned dates) visible to customers
@@ -0,0 +1,7 @@
1
+ import { Order, RequestContext } from "@deenruv/core";
2
+ import { OrderRegisterService } from "../services/order-register.service";
3
+ export declare class AdminOrderResolver {
4
+ private orderRegisterService;
5
+ constructor(orderRegisterService: OrderRegisterService);
6
+ getRealization(ctx: RequestContext, order: Order): Promise<import("../entities/order-realization.entity").OrderRealizationEntity | null>;
7
+ }
@@ -0,0 +1,42 @@
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.AdminOrderResolver = void 0;
16
+ const graphql_1 = require("@nestjs/graphql");
17
+ const core_1 = require("@deenruv/core");
18
+ const order_register_service_1 = require("../services/order-register.service");
19
+ let AdminOrderResolver = class AdminOrderResolver {
20
+ constructor(orderRegisterService) {
21
+ this.orderRegisterService = orderRegisterService;
22
+ }
23
+ async getRealization(ctx, order) {
24
+ const realization = await this.orderRegisterService.getRealization(ctx, order.id);
25
+ if (!realization)
26
+ return null;
27
+ return realization;
28
+ }
29
+ };
30
+ exports.AdminOrderResolver = AdminOrderResolver;
31
+ __decorate([
32
+ (0, graphql_1.ResolveField)(),
33
+ __param(0, (0, core_1.Ctx)()),
34
+ __param(1, (0, graphql_1.Parent)()),
35
+ __metadata("design:type", Function),
36
+ __metadata("design:paramtypes", [core_1.RequestContext, core_1.Order]),
37
+ __metadata("design:returntype", Promise)
38
+ ], AdminOrderResolver.prototype, "getRealization", null);
39
+ exports.AdminOrderResolver = AdminOrderResolver = __decorate([
40
+ (0, graphql_1.Resolver)("Order"),
41
+ __metadata("design:paramtypes", [order_register_service_1.OrderRegisterService])
42
+ ], AdminOrderResolver);
@@ -0,0 +1,28 @@
1
+ import { ID, RequestContext } from "@deenruv/core";
2
+ import { OrderRegisterService } from "../services/order-register.service";
3
+ import { StorageService } from "../services/storage.service";
4
+ import { ModelTypes } from "../zeus/index.js";
5
+ export declare class AdminResolver {
6
+ private orderRegisterService;
7
+ private storageService;
8
+ constructor(orderRegisterService: OrderRegisterService, storageService: StorageService);
9
+ registerRealization(ctx: RequestContext, args: {
10
+ input: ModelTypes["OrderRealizationInput"];
11
+ }): Promise<{
12
+ url: string;
13
+ orderID: string;
14
+ customerID: string;
15
+ assetID: string;
16
+ plannedAt: string;
17
+ color: string;
18
+ finalPlannedAt: string;
19
+ note: string;
20
+ key: string;
21
+ id: ID;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ }>;
25
+ getRealizationURL(ctx: RequestContext, args: {
26
+ orderID: ID;
27
+ }): Promise<string | null>;
28
+ }
@@ -0,0 +1,60 @@
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.AdminResolver = void 0;
16
+ const graphql_1 = require("@nestjs/graphql");
17
+ const core_1 = require("@deenruv/core");
18
+ const order_register_service_1 = require("../services/order-register.service");
19
+ const storage_service_1 = require("../services/storage.service");
20
+ let AdminResolver = class AdminResolver {
21
+ constructor(orderRegisterService, storageService) {
22
+ this.orderRegisterService = orderRegisterService;
23
+ this.storageService = storageService;
24
+ }
25
+ async registerRealization(ctx, args) {
26
+ return this.orderRegisterService.registerRealization(ctx, args.input);
27
+ }
28
+ async getRealizationURL(ctx, args) {
29
+ const realization = await this.orderRegisterService.getRealization(ctx, args.orderID);
30
+ if (!realization)
31
+ return null;
32
+ const url = await this.storageService.getSingedFileUrl(realization.key);
33
+ return url;
34
+ }
35
+ };
36
+ exports.AdminResolver = AdminResolver;
37
+ __decorate([
38
+ (0, core_1.Allow)(core_1.Permission.UpdateOrder),
39
+ (0, core_1.Transaction)(),
40
+ (0, graphql_1.Mutation)(),
41
+ __param(0, (0, core_1.Ctx)()),
42
+ __param(1, (0, graphql_1.Args)()),
43
+ __metadata("design:type", Function),
44
+ __metadata("design:paramtypes", [core_1.RequestContext, Object]),
45
+ __metadata("design:returntype", Promise)
46
+ ], AdminResolver.prototype, "registerRealization", null);
47
+ __decorate([
48
+ (0, core_1.Allow)(core_1.Permission.UpdateOrder),
49
+ (0, graphql_1.Query)(),
50
+ __param(0, (0, core_1.Ctx)()),
51
+ __param(1, (0, graphql_1.Args)()),
52
+ __metadata("design:type", Function),
53
+ __metadata("design:paramtypes", [core_1.RequestContext, Object]),
54
+ __metadata("design:returntype", Promise)
55
+ ], AdminResolver.prototype, "getRealizationURL", null);
56
+ exports.AdminResolver = AdminResolver = __decorate([
57
+ (0, graphql_1.Resolver)(),
58
+ __metadata("design:paramtypes", [order_register_service_1.OrderRegisterService,
59
+ storage_service_1.StorageService])
60
+ ], AdminResolver);
@@ -0,0 +1,11 @@
1
+ import { Order, RequestContext } from "@deenruv/core";
2
+ import { OrderRegisterService } from "../services/order-register.service";
3
+ export declare class OrderResolver {
4
+ private orderRegisterService;
5
+ constructor(orderRegisterService: OrderRegisterService);
6
+ realization(ctx: RequestContext, order: Order): Promise<{
7
+ note: string;
8
+ plannedAt: string;
9
+ finalPlannedAt: string;
10
+ } | null>;
11
+ }
@@ -0,0 +1,43 @@
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.OrderResolver = void 0;
16
+ const graphql_1 = require("@nestjs/graphql");
17
+ const core_1 = require("@deenruv/core");
18
+ const order_register_service_1 = require("../services/order-register.service");
19
+ let OrderResolver = class OrderResolver {
20
+ constructor(orderRegisterService) {
21
+ this.orderRegisterService = orderRegisterService;
22
+ }
23
+ async realization(ctx, order) {
24
+ const realization = await this.orderRegisterService.getRealization(ctx, order.id);
25
+ if (!realization)
26
+ return null;
27
+ const { note, plannedAt, finalPlannedAt } = realization;
28
+ return { note, plannedAt, finalPlannedAt };
29
+ }
30
+ };
31
+ exports.OrderResolver = OrderResolver;
32
+ __decorate([
33
+ (0, graphql_1.ResolveField)(),
34
+ __param(0, (0, core_1.Ctx)()),
35
+ __param(1, (0, graphql_1.Parent)()),
36
+ __metadata("design:type", Function),
37
+ __metadata("design:paramtypes", [core_1.RequestContext, core_1.Order]),
38
+ __metadata("design:returntype", Promise)
39
+ ], OrderResolver.prototype, "realization", null);
40
+ exports.OrderResolver = OrderResolver = __decorate([
41
+ (0, graphql_1.Resolver)("Order"),
42
+ __metadata("design:paramtypes", [order_register_service_1.OrderRegisterService])
43
+ ], OrderResolver);
@@ -0,0 +1,9 @@
1
+ import { S3Client } from "@aws-sdk/client-s3";
2
+ export declare const PLUGIN_INIT_OPTIONS: unique symbol;
3
+ export type InRealizationPluginOptions = {
4
+ s3: {
5
+ client: S3Client;
6
+ bucket: string;
7
+ expiresIn: number;
8
+ };
9
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_INIT_OPTIONS = void 0;
4
+ exports.PLUGIN_INIT_OPTIONS = Symbol("InRealizationPluginOptions");
@@ -0,0 +1,13 @@
1
+ import { DeepPartial } from "@deenruv/common/lib/shared-types";
2
+ import { DeenruvEntity } from "@deenruv/core";
3
+ export declare class OrderRealizationEntity extends DeenruvEntity {
4
+ constructor(input?: DeepPartial<OrderRealizationEntity>);
5
+ key: string;
6
+ customerID: string;
7
+ orderID: string;
8
+ assetID: string;
9
+ plannedAt: string;
10
+ color: string;
11
+ finalPlannedAt: string;
12
+ note: string;
13
+ }
@@ -0,0 +1,56 @@
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.OrderRealizationEntity = void 0;
13
+ const core_1 = require("@deenruv/core");
14
+ const typeorm_1 = require("typeorm");
15
+ let OrderRealizationEntity = class OrderRealizationEntity extends core_1.DeenruvEntity {
16
+ constructor(input) {
17
+ super(input);
18
+ }
19
+ };
20
+ exports.OrderRealizationEntity = OrderRealizationEntity;
21
+ __decorate([
22
+ (0, typeorm_1.Column)({ nullable: true }),
23
+ __metadata("design:type", String)
24
+ ], OrderRealizationEntity.prototype, "key", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.Column)({ nullable: true }),
27
+ __metadata("design:type", String)
28
+ ], OrderRealizationEntity.prototype, "customerID", void 0);
29
+ __decorate([
30
+ (0, typeorm_1.Column)(),
31
+ __metadata("design:type", String)
32
+ ], OrderRealizationEntity.prototype, "orderID", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.Column)(),
35
+ __metadata("design:type", String)
36
+ ], OrderRealizationEntity.prototype, "assetID", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.Column)(),
39
+ __metadata("design:type", String)
40
+ ], OrderRealizationEntity.prototype, "plannedAt", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.Column)(),
43
+ __metadata("design:type", String)
44
+ ], OrderRealizationEntity.prototype, "color", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.Column)({ nullable: true }),
47
+ __metadata("design:type", String)
48
+ ], OrderRealizationEntity.prototype, "finalPlannedAt", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.Column)({ nullable: true }),
51
+ __metadata("design:type", String)
52
+ ], OrderRealizationEntity.prototype, "note", void 0);
53
+ exports.OrderRealizationEntity = OrderRealizationEntity = __decorate([
54
+ (0, typeorm_1.Entity)(),
55
+ __metadata("design:paramtypes", [Object])
56
+ ], OrderRealizationEntity);
@@ -0,0 +1,2 @@
1
+ export declare const ShopExtension: import("graphql").DocumentNode;
2
+ export declare const AdminExtension: import("graphql").DocumentNode;
@@ -0,0 +1,62 @@
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.AdminExtension = exports.ShopExtension = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ const base = (0, graphql_tag_1.default) `
9
+ type OrderRealization {
10
+ orderID: ID!
11
+ assetID: ID!
12
+ plannedAt: String!
13
+ finalPlannedAt: String
14
+ note: String
15
+ color: String!
16
+ key: String
17
+ url: String
18
+ }
19
+
20
+ type ShopOrderRealization {
21
+ note: String
22
+ plannedAt: String
23
+ finalPlannedAt: String
24
+ }
25
+
26
+ input RealizationAssetInput {
27
+ id: String!
28
+ orderLineID: String!
29
+ preview: String!
30
+ }
31
+
32
+ input OrderRealizationInput {
33
+ orderID: String!
34
+ assets: [RealizationAssetInput!]!
35
+ plannedAt: String!
36
+ finalPlannedAt: String!
37
+ note: String!
38
+ color: String!
39
+ }
40
+ `;
41
+ exports.ShopExtension = (0, graphql_tag_1.default) `
42
+ ${base}
43
+
44
+ extend type Order {
45
+ realization: ShopOrderRealization
46
+ }
47
+ `;
48
+ exports.AdminExtension = (0, graphql_tag_1.default) `
49
+ ${base}
50
+
51
+ extend type Order {
52
+ getRealization: OrderRealization
53
+ }
54
+
55
+ extend type Query {
56
+ getRealizationURL(orderID: ID!): String
57
+ }
58
+
59
+ extend type Mutation {
60
+ registerRealization(input: OrderRealizationInput!): OrderRealization
61
+ }
62
+ `;
@@ -0,0 +1,5 @@
1
+ import { InRealizationPluginOptions } from "./consts.js";
2
+ export declare class InRealizationPlugin {
3
+ static config: InRealizationPluginOptions;
4
+ static init(config: InRealizationPluginOptions): typeof InRealizationPlugin;
5
+ }
@@ -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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.InRealizationPlugin = void 0;
10
+ const core_1 = require("@deenruv/core");
11
+ const storage_service_js_1 = require("./services/storage.service.js");
12
+ const pdf_service_js_1 = require("./services/pdf.service.js");
13
+ const order_register_service_js_1 = require("./services/order-register.service.js");
14
+ const consts_js_1 = require("./consts.js");
15
+ const order_realization_entity_js_1 = require("./entities/order-realization.entity.js");
16
+ const realization_extension_js_1 = require("./extensions/realization.extension.js");
17
+ const order_resolver_js_1 = require("./api/order.resolver.js");
18
+ const admin_resolver_js_1 = require("./api/admin.resolver.js");
19
+ const admin_order_resolver_js_1 = require("./api/admin-order.resolver.js");
20
+ const inRealizationProcess = {
21
+ transitions: {
22
+ PaymentSettled: {
23
+ to: [
24
+ "InRealization",
25
+ "Cancelled",
26
+ "Modifying",
27
+ "ArrangingAdditionalPayment",
28
+ ],
29
+ mergeStrategy: "replace",
30
+ },
31
+ InRealization: {
32
+ to: [
33
+ "PartiallyDelivered",
34
+ "Delivered",
35
+ "PartiallyShipped",
36
+ "Shipped",
37
+ "Cancelled",
38
+ "Modifying",
39
+ "ArrangingAdditionalPayment",
40
+ ],
41
+ },
42
+ },
43
+ onTransitionStart: async (from, to, { ctx, order }) => { },
44
+ };
45
+ let InRealizationPlugin = class InRealizationPlugin {
46
+ static init(config) {
47
+ this.config = config;
48
+ return this;
49
+ }
50
+ };
51
+ exports.InRealizationPlugin = InRealizationPlugin;
52
+ exports.InRealizationPlugin = InRealizationPlugin = __decorate([
53
+ (0, core_1.DeenruvPlugin)({
54
+ compatibility: "^0.0.20",
55
+ imports: [core_1.PluginCommonModule],
56
+ providers: [
57
+ order_register_service_js_1.OrderRegisterService,
58
+ pdf_service_js_1.PDFService,
59
+ storage_service_js_1.StorageService,
60
+ {
61
+ provide: consts_js_1.PLUGIN_INIT_OPTIONS,
62
+ useFactory: () => InRealizationPlugin.config,
63
+ },
64
+ ],
65
+ entities: [order_realization_entity_js_1.OrderRealizationEntity],
66
+ adminApiExtensions: {
67
+ schema: realization_extension_js_1.AdminExtension,
68
+ resolvers: [admin_resolver_js_1.AdminResolver, admin_order_resolver_js_1.AdminOrderResolver],
69
+ },
70
+ shopApiExtensions: {
71
+ schema: realization_extension_js_1.ShopExtension,
72
+ resolvers: [order_resolver_js_1.OrderResolver],
73
+ },
74
+ configuration: (config) => {
75
+ config.orderOptions.process.push(inRealizationProcess);
76
+ return config;
77
+ },
78
+ })
79
+ ], InRealizationPlugin);
@@ -0,0 +1,28 @@
1
+ import { OrderService, ProductService, TransactionalConnection, RequestContext } from "@deenruv/core";
2
+ import { PDFService } from "./pdf.service.js";
3
+ import { OrderRealizationEntity } from "../entities/order-realization.entity.js";
4
+ import { ModelTypes } from "../zeus/index.js";
5
+ export declare class OrderRegisterService {
6
+ private connection;
7
+ private pdfService;
8
+ private orderService;
9
+ private productService;
10
+ constructor(connection: TransactionalConnection, pdfService: PDFService, orderService: OrderService, productService: ProductService);
11
+ private hydrateOrderLines;
12
+ private getOrder;
13
+ getRealization(ctx: RequestContext, orderID: string): Promise<OrderRealizationEntity | null>;
14
+ registerRealization(ctx: RequestContext, options: ModelTypes["OrderRealizationInput"]): Promise<{
15
+ url: string;
16
+ orderID: string;
17
+ customerID: string;
18
+ assetID: string;
19
+ plannedAt: string;
20
+ color: string;
21
+ finalPlannedAt: string;
22
+ note: string;
23
+ key: string;
24
+ id: import("@deenruv/core").ID;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ }>;
28
+ }
@@ -0,0 +1,89 @@
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.OrderRegisterService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const core_1 = require("@deenruv/core");
15
+ const pdf_service_js_1 = require("./pdf.service.js");
16
+ const order_realization_entity_js_1 = require("../entities/order-realization.entity.js");
17
+ let OrderRegisterService = class OrderRegisterService {
18
+ constructor(connection, pdfService, orderService, productService) {
19
+ this.connection = connection;
20
+ this.pdfService = pdfService;
21
+ this.orderService = orderService;
22
+ this.productService = productService;
23
+ this.hydrateOrderLines = async (ctx, order) => {
24
+ const lines = await Promise.all(order.lines.map(async (line) => {
25
+ const product = await this.productService.findOne(ctx, line.productVariant.productId);
26
+ return Object.assign(Object.assign({}, line), { product });
27
+ }));
28
+ const payments = await this.orderService.getOrderPayments(ctx, order.id);
29
+ const shippings = await this.orderService.getEligibleShippingMethods(ctx, order.id);
30
+ const shippingMethod = shippings.find((s) => s.id === order.shippingLines[0].shippingMethodId);
31
+ return Object.assign(Object.assign({}, order), { lines, payments, shippingMethod });
32
+ };
33
+ this.getOrder = async (ctx, orderID) => {
34
+ const order = await this.orderService.findOne(ctx, orderID);
35
+ if (!order)
36
+ throw new core_1.UserInputError("Order not found");
37
+ return await this.hydrateOrderLines(ctx, order);
38
+ };
39
+ }
40
+ async getRealization(ctx, orderID) {
41
+ return await this.connection
42
+ .getRepository(ctx, order_realization_entity_js_1.OrderRealizationEntity)
43
+ .findOne({
44
+ where: { orderID },
45
+ order: { createdAt: "DESC" },
46
+ });
47
+ }
48
+ async registerRealization(ctx, options) {
49
+ var _a;
50
+ const order = (await this.getOrder(ctx, options.orderID));
51
+ const response = await this.pdfService.generateRealizationPDF(ctx, {
52
+ order,
53
+ options,
54
+ });
55
+ if (!response) {
56
+ throw new core_1.UserInputError("PDF generation failed");
57
+ }
58
+ const entity = await this.connection
59
+ .getRepository(ctx, order_realization_entity_js_1.OrderRealizationEntity)
60
+ .save({
61
+ orderID: options.orderID,
62
+ customerID: (_a = order.customer) === null || _a === void 0 ? void 0 : _a.id,
63
+ assetID: options.assets.map((a) => a.id).join(","),
64
+ plannedAt: options.plannedAt,
65
+ color: options.color,
66
+ finalPlannedAt: options.finalPlannedAt,
67
+ note: options.note,
68
+ key: response.key,
69
+ });
70
+ const firstRealization = await this.getRealization(ctx, options.orderID);
71
+ const note = firstRealization
72
+ ? `[REALIZACJA] Zmiana realizacji, planowana data: ${options.plannedAt}, finalna data: ${options.finalPlannedAt}.\nNotatka: ${options.note}, kolor kartki: ${options.color}`
73
+ : `[REALIZACJA] Realizacja zarejestrowana, planowana data: ${options.plannedAt}, finalna data: ${options.finalPlannedAt}.\nNotatka: ${options.note}, kolor kartki: ${options.color}`;
74
+ await this.orderService.addNoteToOrder(ctx, {
75
+ id: options.orderID,
76
+ note,
77
+ isPublic: false,
78
+ });
79
+ return Object.assign(Object.assign({}, entity), { url: response.url });
80
+ }
81
+ };
82
+ exports.OrderRegisterService = OrderRegisterService;
83
+ exports.OrderRegisterService = OrderRegisterService = __decorate([
84
+ (0, common_1.Injectable)(),
85
+ __metadata("design:paramtypes", [core_1.TransactionalConnection,
86
+ pdf_service_js_1.PDFService,
87
+ core_1.OrderService,
88
+ core_1.ProductService])
89
+ ], OrderRegisterService);
@@ -0,0 +1,17 @@
1
+ import { ProductOptionGroupService, TransactionalConnection, TranslatorService } from "@deenruv/core";
2
+ import { RequestContext } from "@deenruv/core";
3
+ import { StorageService } from "./storage.service.js";
4
+ import { PDFProps } from "./types.js";
5
+ export declare class PDFService {
6
+ private connection;
7
+ private storageService;
8
+ private productOptionGroupService;
9
+ private translator;
10
+ constructor(connection: TransactionalConnection, storageService: StorageService, productOptionGroupService: ProductOptionGroupService, translator: TranslatorService);
11
+ private generateRealizationDocument;
12
+ private getOptionsFromLines;
13
+ generateRealizationPDF(ctx: RequestContext, { options, order }: Omit<PDFProps, "user">): Promise<{
14
+ url: string;
15
+ key: string;
16
+ } | null>;
17
+ }