@deenruv/inpost-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 +46 -0
- package/dist/plugin-server/api/inpost-admin.resolver.d.ts +20 -0
- package/dist/plugin-server/api/inpost-admin.resolver.js +64 -0
- package/dist/plugin-server/api/inpost-shop.resolver.d.ts +7 -0
- package/dist/plugin-server/api/inpost-shop.resolver.js +38 -0
- package/dist/plugin-server/constants.d.ts +2 -0
- package/dist/plugin-server/constants.js +5 -0
- package/dist/plugin-server/controllers/inpost.controller.d.ts +9 -0
- package/dist/plugin-server/controllers/inpost.controller.js +54 -0
- package/dist/plugin-server/entities/inpost-config-entity.d.ts +12 -0
- package/dist/plugin-server/entities/inpost-config-entity.js +49 -0
- package/dist/plugin-server/entities/inpost-ref-entity.d.ts +9 -0
- package/dist/plugin-server/entities/inpost-ref-entity.js +39 -0
- package/dist/plugin-server/extensions/inpost.extension.d.ts +1 -0
- package/dist/plugin-server/extensions/inpost.extension.js +53 -0
- package/dist/plugin-server/extensions/inpost.shop.extenstion.d.ts +1 -0
- package/dist/plugin-server/extensions/inpost.shop.extenstion.js +12 -0
- package/dist/plugin-server/guards/inpost-webhook.guard.d.ts +22 -0
- package/dist/plugin-server/guards/inpost-webhook.guard.js +96 -0
- package/dist/plugin-server/handlers/inpost.fulfillment.d.ts +20 -0
- package/dist/plugin-server/handlers/inpost.fulfillment.js +95 -0
- package/dist/plugin-server/index.d.ts +6 -0
- package/dist/plugin-server/index.js +78 -0
- package/dist/plugin-server/services/inpost.service.d.ts +46 -0
- package/dist/plugin-server/services/inpost.service.js +365 -0
- package/dist/plugin-server/types.d.ts +29 -0
- package/dist/plugin-server/types.js +2 -0
- package/dist/plugin-server/ui/Inpost.tsx +273 -0
- package/dist/plugin-server/ui/graphql/mutations.ts +14 -0
- package/dist/plugin-server/ui/graphql/queries.ts +7 -0
- package/dist/plugin-server/ui/graphql/scalars.ts +15 -0
- package/dist/plugin-server/ui/graphql/selectors.ts +0 -0
- package/dist/plugin-server/ui/providers.ts +9 -0
- package/dist/plugin-server/ui/routes.ts +1 -0
- package/dist/plugin-server/ui/styles/overwrite.css +0 -0
- package/dist/plugin-server/ui/translations/en.json +31 -0
- package/dist/plugin-server/ui/translations/pl.json +33 -0
- package/dist/plugin-server/ui/zeus/const.ts +4767 -0
- package/dist/plugin-server/ui/zeus/index.ts +21694 -0
- package/dist/plugin-server/ui/zeus/typedDocumentNode.ts +27 -0
- package/dist/plugin-server/ui.d.ts +2 -0
- package/dist/plugin-server/ui.js +17 -0
- package/dist/plugin-server/zeus/const.d.ts +6 -0
- package/dist/plugin-server/zeus/const.js +3654 -0
- package/dist/plugin-server/zeus/index.d.ts +18623 -0
- package/dist/plugin-server/zeus/index.js +1094 -0
- package/dist/plugin-server/zeus/typedDocumentNode.d.ts +3 -0
- package/dist/plugin-server/zeus/typedDocumentNode.js +13 -0
- package/dist/plugin-ui/components/Inpost.d.ts +2 -0
- package/dist/plugin-ui/components/Inpost.js +126 -0
- package/dist/plugin-ui/graphql/mutations.d.ts +12 -0
- package/dist/plugin-ui/graphql/mutations.js +10 -0
- package/dist/plugin-ui/graphql/queries.d.ts +23 -0
- package/dist/plugin-ui/graphql/queries.js +19 -0
- package/dist/plugin-ui/graphql/scalars.d.ts +16 -0
- package/dist/plugin-ui/graphql/scalars.js +14 -0
- package/dist/plugin-ui/graphql/selectors.d.ts +15 -0
- package/dist/plugin-ui/graphql/selectors.js +13 -0
- package/dist/plugin-ui/index.d.ts +1 -0
- package/dist/plugin-ui/index.js +11 -0
- package/dist/plugin-ui/locales/en/index.d.ts +35 -0
- package/dist/plugin-ui/locales/en/index.js +2 -0
- package/dist/plugin-ui/locales/en/inpost.json +34 -0
- package/dist/plugin-ui/locales/pl/index.d.ts +36 -0
- package/dist/plugin-ui/locales/pl/index.js +2 -0
- package/dist/plugin-ui/locales/pl/inpost.json +35 -0
- package/dist/plugin-ui/translation-ns.d.ts +1 -0
- package/dist/plugin-ui/translation-ns.js +1 -0
- package/dist/plugin-ui/tsconfig.json +18 -0
- package/dist/plugin-ui/zeus/const.d.ts +6 -0
- package/dist/plugin-ui/zeus/const.js +3651 -0
- package/dist/plugin-ui/zeus/index.d.ts +18623 -0
- package/dist/plugin-ui/zeus/index.js +1086 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
- package/package.json +55 -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,46 @@
|
|
|
1
|
+
# @deenruv/inpost-plugin
|
|
2
|
+
|
|
3
|
+
Integration plugin for the InPost parcel locker shipping service. It provides a custom fulfillment handler, shipment management, label generation, webhook handling, and a geowidget for pickup point selection on the storefront.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @deenruv/inpost-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { InpostPlugin } from '@deenruv/inpost-plugin';
|
|
15
|
+
|
|
16
|
+
// In your Deenruv server config:
|
|
17
|
+
plugins: [
|
|
18
|
+
InpostPlugin.init({}),
|
|
19
|
+
]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- Custom InPost fulfillment handler for shipping method integration
|
|
25
|
+
- InPost API configuration per shipping method (host, API key, organization, service type)
|
|
26
|
+
- Shipment label generation and storage as Fulfillment assets
|
|
27
|
+
- Webhook controller for InPost shipment status events (confirmed, delivered, cancelled, etc.)
|
|
28
|
+
- Pickup point ID custom field on orders
|
|
29
|
+
- Geowidget key exposed to the storefront for pickup point selection
|
|
30
|
+
- Organization listing for admin configuration
|
|
31
|
+
|
|
32
|
+
## Admin UI
|
|
33
|
+
|
|
34
|
+
This plugin extends the admin UI with an InPost configuration panel where administrators can set up API credentials, select InPost organizations and services, and manage shipping method integration settings.
|
|
35
|
+
|
|
36
|
+
## API Extensions
|
|
37
|
+
|
|
38
|
+
### Admin API
|
|
39
|
+
|
|
40
|
+
- **Query** `getInpostConfig: InpostConfig` — Returns the current InPost configuration
|
|
41
|
+
- **Query** `getInpostOrganizations(input: GetInpostOrganizationsInput): InpostOrganizationResponse!` — Lists available InPost organizations for given credentials
|
|
42
|
+
- **Mutation** `setInpostShippingMethodConfig(input: SetInpostShippingMethodConfigInput!): Boolean!` — Saves InPost configuration for a shipping method
|
|
43
|
+
|
|
44
|
+
### Shop API
|
|
45
|
+
|
|
46
|
+
- **Query** `inPostGeowidgetKey: String` — Returns the geowidget key for the storefront pickup point selector
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RequestContext } from "@deenruv/core";
|
|
2
|
+
import { InpostService } from "../services/inpost.service.js";
|
|
3
|
+
import { SetInpostShippingMethodConfigInput } from "../types.js";
|
|
4
|
+
export declare class InpostAdminResolver {
|
|
5
|
+
private inpostService;
|
|
6
|
+
constructor(inpostService: InpostService);
|
|
7
|
+
getInpostConfig(ctx: RequestContext): Promise<import("../entities/inpost-config-entity.js").InpostConfigEntity | undefined>;
|
|
8
|
+
getInpostOrganizations(ctx: RequestContext, input: {
|
|
9
|
+
host: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
inpostOrganization: number;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
items: {
|
|
14
|
+
id: number;
|
|
15
|
+
name: string;
|
|
16
|
+
services: import("@deenruv/inpost").Service[];
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
setInpostShippingMethodConfig(ctx: RequestContext, input: SetInpostShippingMethodConfigInput): Promise<boolean>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.InpostAdminResolver = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const core_1 = require("@deenruv/core");
|
|
18
|
+
const inpost_service_js_1 = require("../services/inpost.service.js");
|
|
19
|
+
let InpostAdminResolver = class InpostAdminResolver {
|
|
20
|
+
constructor(inpostService) {
|
|
21
|
+
this.inpostService = inpostService;
|
|
22
|
+
}
|
|
23
|
+
async getInpostConfig(ctx) {
|
|
24
|
+
return this.inpostService.getInpostConfig(ctx);
|
|
25
|
+
}
|
|
26
|
+
async getInpostOrganizations(ctx, input) {
|
|
27
|
+
return this.inpostService.getInpostOrganizations(ctx, input);
|
|
28
|
+
}
|
|
29
|
+
async setInpostShippingMethodConfig(ctx, input) {
|
|
30
|
+
await this.inpostService.setInpostConfig(ctx, input);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.InpostAdminResolver = InpostAdminResolver;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, graphql_1.Query)(),
|
|
37
|
+
(0, core_1.Allow)(core_1.Permission.Owner),
|
|
38
|
+
__param(0, (0, core_1.Ctx)()),
|
|
39
|
+
__metadata("design:type", Function),
|
|
40
|
+
__metadata("design:paramtypes", [core_1.RequestContext]),
|
|
41
|
+
__metadata("design:returntype", Promise)
|
|
42
|
+
], InpostAdminResolver.prototype, "getInpostConfig", null);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, graphql_1.Query)(),
|
|
45
|
+
(0, core_1.Allow)(core_1.Permission.Owner),
|
|
46
|
+
__param(0, (0, core_1.Ctx)()),
|
|
47
|
+
__param(1, (0, graphql_1.Args)("input")),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
50
|
+
__metadata("design:returntype", Promise)
|
|
51
|
+
], InpostAdminResolver.prototype, "getInpostOrganizations", null);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, graphql_1.Mutation)(),
|
|
54
|
+
(0, core_1.Allow)(core_1.Permission.Owner),
|
|
55
|
+
__param(0, (0, core_1.Ctx)()),
|
|
56
|
+
__param(1, (0, graphql_1.Args)("input")),
|
|
57
|
+
__metadata("design:type", Function),
|
|
58
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
59
|
+
__metadata("design:returntype", Promise)
|
|
60
|
+
], InpostAdminResolver.prototype, "setInpostShippingMethodConfig", null);
|
|
61
|
+
exports.InpostAdminResolver = InpostAdminResolver = __decorate([
|
|
62
|
+
(0, graphql_1.Resolver)(),
|
|
63
|
+
__metadata("design:paramtypes", [inpost_service_js_1.InpostService])
|
|
64
|
+
], InpostAdminResolver);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestContext } from "@deenruv/core";
|
|
2
|
+
import { InpostService } from "../services/inpost.service.js";
|
|
3
|
+
export declare class InpostShopResolver {
|
|
4
|
+
private inpostService;
|
|
5
|
+
constructor(inpostService: InpostService);
|
|
6
|
+
inPostGeowidgetKey(ctx: RequestContext): Promise<string | null>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.InpostShopResolver = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const core_1 = require("@deenruv/core");
|
|
18
|
+
const inpost_service_js_1 = require("../services/inpost.service.js");
|
|
19
|
+
let InpostShopResolver = class InpostShopResolver {
|
|
20
|
+
constructor(inpostService) {
|
|
21
|
+
this.inpostService = inpostService;
|
|
22
|
+
}
|
|
23
|
+
async inPostGeowidgetKey(ctx) {
|
|
24
|
+
return this.inpostService.getGeowidgetKey(ctx);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.InpostShopResolver = InpostShopResolver;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, graphql_1.Query)(),
|
|
30
|
+
__param(0, (0, core_1.Ctx)()),
|
|
31
|
+
__metadata("design:type", Function),
|
|
32
|
+
__metadata("design:paramtypes", [core_1.RequestContext]),
|
|
33
|
+
__metadata("design:returntype", Promise)
|
|
34
|
+
], InpostShopResolver.prototype, "inPostGeowidgetKey", null);
|
|
35
|
+
exports.InpostShopResolver = InpostShopResolver = __decorate([
|
|
36
|
+
(0, graphql_1.Resolver)(),
|
|
37
|
+
__metadata("design:paramtypes", [inpost_service_js_1.InpostService])
|
|
38
|
+
], InpostShopResolver);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestContext } from "@deenruv/core";
|
|
2
|
+
import { Response, Request } from "express";
|
|
3
|
+
import { InpostService } from "../services/inpost.service.js";
|
|
4
|
+
export declare class InpostController {
|
|
5
|
+
private inpostService;
|
|
6
|
+
constructor(inpostService: InpostService);
|
|
7
|
+
health(response: Response): void;
|
|
8
|
+
status(ctx: RequestContext, request: Request, response: Response): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.InpostController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@deenruv/core");
|
|
18
|
+
const inpost_service_js_1 = require("../services/inpost.service.js");
|
|
19
|
+
const inpost_webhook_guard_js_1 = require("../guards/inpost-webhook.guard.js");
|
|
20
|
+
let InpostController = class InpostController {
|
|
21
|
+
constructor(inpostService) {
|
|
22
|
+
this.inpostService = inpostService;
|
|
23
|
+
}
|
|
24
|
+
health(response) {
|
|
25
|
+
response.sendStatus(200);
|
|
26
|
+
}
|
|
27
|
+
async status(ctx, request, response) {
|
|
28
|
+
await this.inpostService.handleUpdateEvent(ctx, request.body);
|
|
29
|
+
response.sendStatus(200);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.InpostController = InpostController;
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, common_1.UseGuards)(inpost_webhook_guard_js_1.InPostWebhookGuard),
|
|
35
|
+
(0, common_1.Get)("status"),
|
|
36
|
+
__param(0, (0, common_1.Res)()),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", [Object]),
|
|
39
|
+
__metadata("design:returntype", void 0)
|
|
40
|
+
], InpostController.prototype, "health", null);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, common_1.UseGuards)(inpost_webhook_guard_js_1.InPostWebhookGuard),
|
|
43
|
+
(0, common_1.Post)("status"),
|
|
44
|
+
__param(0, (0, core_1.Ctx)()),
|
|
45
|
+
__param(1, (0, common_1.Req)()),
|
|
46
|
+
__param(2, (0, common_1.Res)()),
|
|
47
|
+
__metadata("design:type", Function),
|
|
48
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, Object]),
|
|
49
|
+
__metadata("design:returntype", Promise)
|
|
50
|
+
], InpostController.prototype, "status", null);
|
|
51
|
+
exports.InpostController = InpostController = __decorate([
|
|
52
|
+
(0, common_1.Controller)("inpost"),
|
|
53
|
+
__metadata("design:paramtypes", [inpost_service_js_1.InpostService])
|
|
54
|
+
], InpostController);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeenruvEntity, DeepPartial, ShippingMethod } from "@deenruv/core";
|
|
2
|
+
import { Relation } from "typeorm";
|
|
3
|
+
import { Service } from "@deenruv/inpost";
|
|
4
|
+
export declare class InpostConfigEntity extends DeenruvEntity {
|
|
5
|
+
constructor(data: DeepPartial<InpostConfigEntity>);
|
|
6
|
+
shippingMethod: Relation<ShippingMethod>;
|
|
7
|
+
host: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
geowidgetKey: string;
|
|
10
|
+
inpostOrganization: number;
|
|
11
|
+
service: Service;
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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.InpostConfigEntity = void 0;
|
|
13
|
+
const core_1 = require("@deenruv/core");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let InpostConfigEntity = class InpostConfigEntity extends core_1.DeenruvEntity {
|
|
16
|
+
constructor(data) {
|
|
17
|
+
super(data);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.InpostConfigEntity = InpostConfigEntity;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.OneToOne)(() => core_1.ShippingMethod),
|
|
23
|
+
(0, typeorm_1.JoinColumn)(),
|
|
24
|
+
__metadata("design:type", Object)
|
|
25
|
+
], InpostConfigEntity.prototype, "shippingMethod", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)("text"),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], InpostConfigEntity.prototype, "host", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)("text"),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], InpostConfigEntity.prototype, "apiKey", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)("text", { nullable: true }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], InpostConfigEntity.prototype, "geowidgetKey", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)("bigint"),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], InpostConfigEntity.prototype, "inpostOrganization", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)("text"),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], InpostConfigEntity.prototype, "service", void 0);
|
|
46
|
+
exports.InpostConfigEntity = InpostConfigEntity = __decorate([
|
|
47
|
+
(0, typeorm_1.Entity)(),
|
|
48
|
+
__metadata("design:paramtypes", [Object])
|
|
49
|
+
], InpostConfigEntity);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeenruvEntity, DeepPartial, OrderLine } from "@deenruv/core";
|
|
2
|
+
import { Relation } from "typeorm";
|
|
3
|
+
import { InpostConfigEntity } from "./inpost-config-entity";
|
|
4
|
+
export declare class InpostRefEntity extends DeenruvEntity {
|
|
5
|
+
constructor(data: DeepPartial<InpostRefEntity>);
|
|
6
|
+
inpostConfig: Relation<InpostConfigEntity>;
|
|
7
|
+
inpostShipmentId?: number;
|
|
8
|
+
orderLines: Relation<OrderLine[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.InpostRefEntity = void 0;
|
|
13
|
+
const core_1 = require("@deenruv/core");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const inpost_config_entity_1 = require("./inpost-config-entity");
|
|
16
|
+
let InpostRefEntity = class InpostRefEntity extends core_1.DeenruvEntity {
|
|
17
|
+
constructor(data) {
|
|
18
|
+
super(data);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.InpostRefEntity = InpostRefEntity;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.ManyToOne)(() => inpost_config_entity_1.InpostConfigEntity),
|
|
24
|
+
__metadata("design:type", Object)
|
|
25
|
+
], InpostRefEntity.prototype, "inpostConfig", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Index)({ unique: true, sparse: true }),
|
|
28
|
+
(0, typeorm_1.Column)("bigint", { nullable: true }),
|
|
29
|
+
__metadata("design:type", Number)
|
|
30
|
+
], InpostRefEntity.prototype, "inpostShipmentId", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.ManyToMany)(() => core_1.OrderLine),
|
|
33
|
+
(0, typeorm_1.JoinTable)(),
|
|
34
|
+
__metadata("design:type", Object)
|
|
35
|
+
], InpostRefEntity.prototype, "orderLines", void 0);
|
|
36
|
+
exports.InpostRefEntity = InpostRefEntity = __decorate([
|
|
37
|
+
(0, typeorm_1.Entity)(),
|
|
38
|
+
__metadata("design:paramtypes", [Object])
|
|
39
|
+
], InpostRefEntity);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AdminExtension: import("graphql").DocumentNode;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
exports.AdminExtension = (0, graphql_tag_1.default) `
|
|
9
|
+
input SetInpostShippingMethodConfigInput {
|
|
10
|
+
shippingMethodId: ID!
|
|
11
|
+
host: String!
|
|
12
|
+
apiKey: String!
|
|
13
|
+
geowidgetKey: String
|
|
14
|
+
inpostOrganization: Int!
|
|
15
|
+
service: String!
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type InpostConfig {
|
|
19
|
+
shippingMethodId: ID!
|
|
20
|
+
host: String!
|
|
21
|
+
apiKey: String!
|
|
22
|
+
geowidgetKey: String
|
|
23
|
+
inpostOrganization: Int!
|
|
24
|
+
service: String!
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type InpostOrganization {
|
|
28
|
+
id: Int!
|
|
29
|
+
name: String!
|
|
30
|
+
services: [String!]!
|
|
31
|
+
}
|
|
32
|
+
type InpostOrganizationResponse {
|
|
33
|
+
items: [InpostOrganization!]!
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
input GetInpostOrganizationsInput {
|
|
37
|
+
host: String!
|
|
38
|
+
apiKey: String!
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
extend type Query {
|
|
42
|
+
getInpostConfig: InpostConfig
|
|
43
|
+
getInpostOrganizations(
|
|
44
|
+
input: GetInpostOrganizationsInput
|
|
45
|
+
): InpostOrganizationResponse!
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
extend type Mutation {
|
|
49
|
+
setInpostShippingMethodConfig(
|
|
50
|
+
input: SetInpostShippingMethodConfigInput!
|
|
51
|
+
): Boolean!
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ShopExtension: import("graphql").DocumentNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.ShopExtension = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
exports.ShopExtension = (0, graphql_tag_1.default) `
|
|
9
|
+
extend type Query {
|
|
10
|
+
inPostGeowidgetKey: String
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CanActivate, ExecutionContext } from "@nestjs/common";
|
|
2
|
+
import { RequestContextService, TransactionalConnection } from "@deenruv/core";
|
|
3
|
+
import { InpostService } from "../services/inpost.service.js";
|
|
4
|
+
export declare class InPostAuthErrorResult extends Error {
|
|
5
|
+
readonly httpStatus: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class AuthenticationError extends InPostAuthErrorResult {
|
|
8
|
+
readonly __typename = "AuthenticationError";
|
|
9
|
+
readonly name = "authentication_error";
|
|
10
|
+
readonly httpStatus = 403;
|
|
11
|
+
readonly message = "AUTH_ERROR";
|
|
12
|
+
}
|
|
13
|
+
export declare class InPostWebhookGuard implements CanActivate {
|
|
14
|
+
private connection;
|
|
15
|
+
private requestContextService;
|
|
16
|
+
private inpostService;
|
|
17
|
+
constructor(connection: TransactionalConnection, requestContextService: RequestContextService, inpostService: InpostService);
|
|
18
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
19
|
+
validateSignature(signature: string, body: string, secret: string): boolean;
|
|
20
|
+
getHMACSecret(): Promise<string>;
|
|
21
|
+
private verifySignature;
|
|
22
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InPostWebhookGuard = exports.AuthenticationError = exports.InPostAuthErrorResult = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@deenruv/core");
|
|
18
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
19
|
+
const inpost_config_entity_js_1 = require("../entities/inpost-config-entity.js");
|
|
20
|
+
const inpost_service_js_1 = require("../services/inpost.service.js");
|
|
21
|
+
class InPostAuthErrorResult extends Error {
|
|
22
|
+
}
|
|
23
|
+
exports.InPostAuthErrorResult = InPostAuthErrorResult;
|
|
24
|
+
class AuthenticationError extends InPostAuthErrorResult {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.__typename = "AuthenticationError";
|
|
28
|
+
this.name = "authentication_error";
|
|
29
|
+
this.httpStatus = 403;
|
|
30
|
+
this.message = "AUTH_ERROR";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.AuthenticationError = AuthenticationError;
|
|
34
|
+
let InPostWebhookGuard = class InPostWebhookGuard {
|
|
35
|
+
constructor(connection, requestContextService, inpostService) {
|
|
36
|
+
this.connection = connection;
|
|
37
|
+
this.requestContextService = requestContextService;
|
|
38
|
+
this.inpostService = inpostService;
|
|
39
|
+
}
|
|
40
|
+
async canActivate(context) {
|
|
41
|
+
return this.verifySignature(context);
|
|
42
|
+
}
|
|
43
|
+
validateSignature(signature, body, secret) {
|
|
44
|
+
const computed = crypto_1.default
|
|
45
|
+
.createHmac("sha256", secret)
|
|
46
|
+
.update(body, "utf8")
|
|
47
|
+
.digest("base64");
|
|
48
|
+
return crypto_1.default.timingSafeEqual(Buffer.from(signature, "base64"), Buffer.from(computed, "base64"));
|
|
49
|
+
}
|
|
50
|
+
async getHMACSecret() {
|
|
51
|
+
const configs = await this.connection.rawConnection
|
|
52
|
+
.getRepository(inpost_config_entity_js_1.InpostConfigEntity)
|
|
53
|
+
.find({ take: 1 });
|
|
54
|
+
if (configs.length === 0) {
|
|
55
|
+
throw new Error("HMAC secret not found in database");
|
|
56
|
+
}
|
|
57
|
+
const config = configs[0];
|
|
58
|
+
return config.apiKey;
|
|
59
|
+
}
|
|
60
|
+
async verifySignature(context) {
|
|
61
|
+
const request = context.switchToHttp().getRequest();
|
|
62
|
+
const headers = request.headers;
|
|
63
|
+
console.log("INPOST HEADERS", headers, "rawBody" in request ? "rawBody" : "body", "rawBody" in request ? request.rawBody : request.body);
|
|
64
|
+
const channel = await this.connection.rawConnection
|
|
65
|
+
.getRepository(core_1.Channel)
|
|
66
|
+
.findOne({
|
|
67
|
+
where: { code: "__default_channel__" },
|
|
68
|
+
relations: ["defaultTaxZone", "defaultShippingZone"],
|
|
69
|
+
});
|
|
70
|
+
if (!channel)
|
|
71
|
+
throw new AuthenticationError();
|
|
72
|
+
const ctx = await this.requestContextService.create({
|
|
73
|
+
req: request,
|
|
74
|
+
apiType: "admin",
|
|
75
|
+
channelOrToken: channel,
|
|
76
|
+
languageCode: channel.defaultLanguageCode,
|
|
77
|
+
});
|
|
78
|
+
context.switchToHttp().getRequest()["ctx"] = ctx;
|
|
79
|
+
return true;
|
|
80
|
+
if (!ctx)
|
|
81
|
+
throw new AuthenticationError();
|
|
82
|
+
if (!headers["x-inpost-signature"])
|
|
83
|
+
throw new AuthenticationError();
|
|
84
|
+
const isValidSignature = this.validateSignature(headers["x-inpost-signature"], JSON.stringify(request.body), await this.getHMACSecret());
|
|
85
|
+
if (!isValidSignature)
|
|
86
|
+
throw new AuthenticationError();
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
exports.InPostWebhookGuard = InPostWebhookGuard;
|
|
91
|
+
exports.InPostWebhookGuard = InPostWebhookGuard = __decorate([
|
|
92
|
+
(0, common_1.Injectable)(),
|
|
93
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection,
|
|
94
|
+
core_1.RequestContextService,
|
|
95
|
+
inpost_service_js_1.InpostService])
|
|
96
|
+
], InPostWebhookGuard);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FulfillmentHandler, LanguageCode } from "@deenruv/core";
|
|
2
|
+
export declare const inpostFulfillmentHandlerCode = "inpost-fulfillment";
|
|
3
|
+
/**
|
|
4
|
+
* The handler for Inpost shipping.
|
|
5
|
+
*/
|
|
6
|
+
export declare const inpostFulfillmentHandler: () => FulfillmentHandler<{
|
|
7
|
+
dimensions: {
|
|
8
|
+
type: "string";
|
|
9
|
+
ui: {
|
|
10
|
+
component: string;
|
|
11
|
+
options: {
|
|
12
|
+
value: string;
|
|
13
|
+
label: {
|
|
14
|
+
languageCode: LanguageCode;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}>;
|