@pinelab/vendure-plugin-sendcloud 1.2.0 → 1.2.1
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/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Vendure SendCloud plugin
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
### Visit [pinelab-plugins.com](https://pinelab-plugins.com/plugin/vendure-plugin-sendcloud) for more documentation and examples.
|
|
3
|
+
### [Official documentation here](https://pinelab-plugins.com/plugin/vendure-plugin-sendcloud)
|
|
6
4
|
|
|
7
5
|
This plugin syncs orders to the SendCloud fulfillment platform.
|
|
8
6
|
|
|
@@ -8,12 +8,14 @@ export declare function fulfillAll(ctx: RequestContext, orderService: OrderServi
|
|
|
8
8
|
/**
|
|
9
9
|
* Fulfills all items to shipped using transitionFulfillmentToState
|
|
10
10
|
*/
|
|
11
|
-
export declare function transitionToShipped(orderService: OrderService, ctx: RequestContext, order: Order, handler: ConfigurableOperationInput): Promise<Fulfillment>;
|
|
11
|
+
export declare function transitionToShipped(orderService: OrderService, ctx: RequestContext, order: Order, handler: ConfigurableOperationInput): Promise<Fulfillment | FulfillmentStateTransitionError>;
|
|
12
12
|
/**
|
|
13
13
|
* Fulfills all items to shipped, then to delivered using transitionFulfillmentToState
|
|
14
14
|
*/
|
|
15
|
-
export declare function transitionToDelivered(orderService: OrderService, ctx: RequestContext, order: Order, handler: ConfigurableOperationInput): Promise<Fulfillment>;
|
|
15
|
+
export declare function transitionToDelivered(orderService: OrderService, ctx: RequestContext, order: Order, handler: ConfigurableOperationInput): Promise<(Fulfillment | FulfillmentStateTransitionError)[]>;
|
|
16
16
|
/**
|
|
17
17
|
* Throws the error result if the transition failed
|
|
18
|
+
* Ignores transition errors where from and to state are the same,
|
|
19
|
+
* because that still results in the situation we want
|
|
18
20
|
*/
|
|
19
21
|
export declare function throwIfTransitionFailed(result: FulfillmentStateTransitionError | Fulfillment | AddFulfillmentToOrderResult): void;
|
|
@@ -36,14 +36,28 @@ exports.transitionToShipped = transitionToShipped;
|
|
|
36
36
|
* Fulfills all items to shipped, then to delivered using transitionFulfillmentToState
|
|
37
37
|
*/
|
|
38
38
|
async function transitionToDelivered(orderService, ctx, order, handler) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const shippedResult = await transitionToShipped(orderService, ctx, order, handler);
|
|
40
|
+
let fulfillments = [];
|
|
41
|
+
if (shippedResult.errorCode) {
|
|
42
|
+
fulfillments = await orderService.getOrderFulfillments(ctx, order);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// if not an error, shippedResult is the only fulfillment
|
|
46
|
+
fulfillments.push(shippedResult);
|
|
47
|
+
}
|
|
48
|
+
const results = [];
|
|
49
|
+
for (const fulfillment of fulfillments) {
|
|
50
|
+
const result = await orderService.transitionFulfillmentToState(ctx, fulfillment.id, 'Delivered');
|
|
51
|
+
throwIfTransitionFailed(result);
|
|
52
|
+
results.push(result);
|
|
53
|
+
}
|
|
54
|
+
return results;
|
|
43
55
|
}
|
|
44
56
|
exports.transitionToDelivered = transitionToDelivered;
|
|
45
57
|
/**
|
|
46
58
|
* Throws the error result if the transition failed
|
|
59
|
+
* Ignores transition errors where from and to state are the same,
|
|
60
|
+
* because that still results in the situation we want
|
|
47
61
|
*/
|
|
48
62
|
function throwIfTransitionFailed(result) {
|
|
49
63
|
const stateError = result;
|
|
@@ -110,7 +110,7 @@ let SendcloudService = class SendcloudService {
|
|
|
110
110
|
}
|
|
111
111
|
if (sendcloudStatus.orderState === 'Shipped') {
|
|
112
112
|
await this.shipAll(ctx, order);
|
|
113
|
-
return core_2.Logger.info(`Successfully
|
|
113
|
+
return core_2.Logger.info(`Successfully updated order ${orderCode} to Shipped`, constants_1.loggerCtx);
|
|
114
114
|
}
|
|
115
115
|
order = await this.connection
|
|
116
116
|
.getRepository(ctx, core_2.Order)
|
|
@@ -120,7 +120,7 @@ let SendcloudService = class SendcloudService {
|
|
|
120
120
|
code: sendcloud_handler_1.sendcloudHandler.code,
|
|
121
121
|
arguments: [],
|
|
122
122
|
});
|
|
123
|
-
return core_2.Logger.info(`Successfully
|
|
123
|
+
return core_2.Logger.info(`Successfully updated order ${orderCode} to Delivered`, constants_1.loggerCtx);
|
|
124
124
|
}
|
|
125
125
|
// Fall through, means unhandled state
|
|
126
126
|
core_2.Logger.info(`Not handling state ${sendcloudStatus.orderState}`, constants_1.loggerCtx);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinelab/vendure-plugin-sendcloud",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Vendure plugin for syncing orders with SendCloud",
|
|
5
|
+
"icon": "truck",
|
|
5
6
|
"author": "Martijn van de Brug <martijn@pinelab.studio>",
|
|
6
7
|
"homepage": "https://pinelab-plugins.com/",
|
|
7
8
|
"repository": "https://github.com/Pinelab-studio/pinelab-vendure-plugins",
|
|
@@ -22,5 +23,5 @@
|
|
|
22
23
|
"test": "vitest run",
|
|
23
24
|
"start": "yarn ts-node test/dev-server.ts"
|
|
24
25
|
},
|
|
25
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "f2584b3c12624d023dcf9a10383e1c074e35b5d5"
|
|
26
27
|
}
|