@medusajs/medusa 1.3.7 → 1.3.8-alpha.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/api/routes/admin/orders/create-swap-shipment.d.ts +1 -1
- package/dist/api/routes/admin/orders/create-swap-shipment.js +1 -1
- package/dist/api/routes/admin/orders/fulfill-swap.d.ts +1 -1
- package/dist/api/routes/admin/orders/fulfill-swap.js.map +1 -1
- package/dist/api/routes/admin/products/create-product.d.ts +1 -1
- package/dist/api/routes/admin/products/create-product.js +1 -1
- package/dist/api/routes/admin/products/update-variant.d.ts +1 -1
- package/dist/api/routes/admin/products/update-variant.js +1 -1
- package/dist/api/routes/admin/swaps/list-swaps.js +1 -1
- package/dist/api/routes/admin/swaps/list-swaps.js.map +1 -1
- package/dist/api/routes/store/swaps/index.d.ts +2 -1
- package/dist/api/routes/store/swaps/index.js.map +1 -1
- package/dist/loaders/strategies.js +9 -1
- package/dist/loaders/strategies.js.map +1 -1
- package/dist/migrations/1661863940645-swap_fulfillment_status_requires_action.d.ts +6 -0
- package/dist/migrations/1661863940645-swap_fulfillment_status_requires_action.js +89 -0
- package/dist/migrations/1661863940645-swap_fulfillment_status_requires_action.js.map +1 -0
- package/dist/models/swap.d.ts +2 -1
- package/dist/models/swap.js +2 -1
- package/dist/models/swap.js.map +1 -1
- package/dist/repositories/sales-channel.d.ts +3 -1
- package/dist/repositories/sales-channel.js +123 -0
- package/dist/repositories/sales-channel.js.map +1 -1
- package/dist/services/batch-job.js.map +1 -1
- package/dist/services/cart.d.ts +0 -7
- package/dist/services/cart.js +10 -58
- package/dist/services/cart.js.map +1 -1
- package/dist/services/csv-parser.d.ts +1 -3
- package/dist/services/csv-parser.js +4 -4
- package/dist/services/csv-parser.js.map +1 -1
- package/dist/services/event-bus.d.ts +4 -4
- package/dist/services/line-item.d.ts +8 -0
- package/dist/services/line-item.js +9 -0
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/product-variant.d.ts +2 -2
- package/dist/services/product-variant.js +43 -35
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +9 -1
- package/dist/services/product.js +36 -15
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.d.ts +7 -0
- package/dist/services/region.js +22 -0
- package/dist/services/region.js.map +1 -1
- package/dist/services/sales-channel.d.ts +19 -1
- package/dist/services/sales-channel.js +64 -14
- package/dist/services/sales-channel.js.map +1 -1
- package/dist/services/swap.d.ts +152 -168
- package/dist/services/swap.js +898 -878
- package/dist/services/swap.js.map +1 -1
- package/dist/services/tax-provider.d.ts +1 -1
- package/dist/services/user.d.ts +1 -7
- package/dist/services/user.js +3 -15
- package/dist/services/user.js.map +1 -1
- package/dist/strategies/batch-jobs/product/import.d.ts +140 -0
- package/dist/strategies/batch-jobs/product/import.js +1162 -0
- package/dist/strategies/batch-jobs/product/import.js.map +1 -0
- package/dist/strategies/batch-jobs/product/types.d.ts +47 -0
- package/dist/strategies/batch-jobs/product/types.js +14 -0
- package/dist/strategies/batch-jobs/product/types.js.map +1 -0
- package/dist/strategies/batch-jobs/product/utils.d.ts +15 -0
- package/dist/strategies/batch-jobs/product/utils.js +44 -0
- package/dist/strategies/batch-jobs/product/utils.js.map +1 -0
- package/dist/subscribers/batch-job.js +28 -8
- package/dist/subscribers/batch-job.js.map +1 -1
- package/dist/types/fulfillment.d.ts +4 -2
- package/dist/utils/is-email.d.ts +6 -0
- package/dist/utils/is-email.js +19 -0
- package/dist/utils/is-email.js.map +1 -0
- package/package.json +3 -5
|
@@ -61,6 +61,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
61
61
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
65
|
+
var t = {};
|
|
66
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67
|
+
t[p] = s[p];
|
|
68
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
69
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
71
|
+
t[p[i]] = s[p[i]];
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
74
|
+
};
|
|
64
75
|
var __values = (this && this.__values) || function(o) {
|
|
65
76
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
77
|
if (m) return m.call(o);
|
|
@@ -95,35 +106,74 @@ var SalesChannelService = /** @class */ (function (_super) {
|
|
|
95
106
|
return _this;
|
|
96
107
|
}
|
|
97
108
|
/**
|
|
98
|
-
*
|
|
109
|
+
* A generic retrieve used to find a sales channel by different attributes.
|
|
99
110
|
*
|
|
100
|
-
* @
|
|
101
|
-
*
|
|
102
|
-
* @returns a
|
|
111
|
+
* @param selector - SC selector
|
|
112
|
+
* @param config - find config
|
|
113
|
+
* @returns a single SC matching the query or throws
|
|
103
114
|
*/
|
|
104
|
-
SalesChannelService.prototype.
|
|
115
|
+
SalesChannelService.prototype.retrieve_ = function (selector, config) {
|
|
105
116
|
if (config === void 0) { config = {}; }
|
|
106
117
|
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var manager, salesChannelRepo, query, salesChannel;
|
|
108
|
-
return __generator(this, function (
|
|
109
|
-
switch (
|
|
118
|
+
var manager, salesChannelRepo, _a, relations, query, salesChannel, selectorConstraints;
|
|
119
|
+
return __generator(this, function (_b) {
|
|
120
|
+
switch (_b.label) {
|
|
110
121
|
case 0:
|
|
111
122
|
manager = this.manager_;
|
|
112
123
|
salesChannelRepo = manager.getCustomRepository(this.salesChannelRepository_);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}, config);
|
|
116
|
-
return [4 /*yield*/, salesChannelRepo.findOne(query)];
|
|
124
|
+
_a = (0, utils_1.buildQuery)(selector, config), relations = _a.relations, query = __rest(_a, ["relations"]);
|
|
125
|
+
return [4 /*yield*/, salesChannelRepo.findOneWithRelations(relations, query)];
|
|
117
126
|
case 1:
|
|
118
|
-
salesChannel =
|
|
127
|
+
salesChannel = _b.sent();
|
|
119
128
|
if (!salesChannel) {
|
|
120
|
-
|
|
129
|
+
selectorConstraints = Object.entries(selector)
|
|
130
|
+
.map(function (key, value) { return "".concat(key, ": ").concat(value); })
|
|
131
|
+
.join(", ");
|
|
132
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Sales channel with ".concat(selectorConstraints, " was not found"));
|
|
121
133
|
}
|
|
122
134
|
return [2 /*return*/, salesChannel];
|
|
123
135
|
}
|
|
124
136
|
});
|
|
125
137
|
});
|
|
126
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Retrieve a SalesChannel by id
|
|
141
|
+
*
|
|
142
|
+
* @param salesChannelId - id of the channel to retrieve
|
|
143
|
+
* @param config - SC config
|
|
144
|
+
* @experimental This feature is under development and may change in the future.
|
|
145
|
+
* To use this feature please enable the corresponding feature flag in your medusa backend project.
|
|
146
|
+
* @returns a sales channel
|
|
147
|
+
*/
|
|
148
|
+
SalesChannelService.prototype.retrieve = function (salesChannelId, config) {
|
|
149
|
+
if (config === void 0) { config = {}; }
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0: return [4 /*yield*/, this.retrieve_({ id: salesChannelId }, config)];
|
|
154
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Find a sales channel by name.
|
|
161
|
+
*
|
|
162
|
+
* @param name of the sales channel
|
|
163
|
+
* @param config - find config
|
|
164
|
+
* @return a sales channel with matching name
|
|
165
|
+
*/
|
|
166
|
+
SalesChannelService.prototype.retrieveByName = function (name, config) {
|
|
167
|
+
if (config === void 0) { config = {}; }
|
|
168
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0: return [4 /*yield*/, this.retrieve_({ name: name }, config)];
|
|
172
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
};
|
|
127
177
|
/**
|
|
128
178
|
* Lists sales channels based on the provided parameters and includes the count of
|
|
129
179
|
* sales channels that match the query.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sales-channel.js","sourceRoot":"","sources":["../../src/services/sales-channel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sales-channel.js","sourceRoot":"","sources":["../../src/services/sales-channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,uDAA+C;AAI/C,4CAAsD;AACtD,kCAAqC;AASrC;IAAkC,uCAAsB;IActD,6BAAY,EAKW;YAJrB,sBAAsB,4BAAA,EACtB,eAAe,qBAAA,EACf,OAAO,aAAA,EACP,YAAY,kBAAA;QAJd;QAME,8CAA8C;QAC9C,kBAAM;YACJ,sBAAsB,wBAAA;YACtB,eAAe,iBAAA;YACf,OAAO,SAAA;YACP,YAAY,cAAA;SACb,CAAC,SAMH;QAJC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,KAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAA;QACrD,KAAI,CAAC,gBAAgB,GAAG,eAAe,CAAA;QACvC,KAAI,CAAC,aAAa,GAAG,YAAY,CAAA;;IACnC,CAAC;IAED;;;;;;OAMG;IACa,uCAAS,GAAz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0BAAM,GAAG;QACd,OAAO,EAAE,uBAAuB;QAChC,OAAO,EAAE,uBAAuB;QAChC,OAAO,EAAE,uBAAuB;KACjC,CAAA;IAwSH,0BAAC;CAAA,AA7SD,CAAkC,mCAAsB,GA6SvD;AAED,kBAAe,mBAAmB,CAAA"}
|
package/dist/services/swap.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { EntityManager } from "typeorm";
|
|
2
|
+
import { TransactionBaseService } from "../interfaces";
|
|
3
|
+
import LineItemAdjustmentService from "./line-item-adjustment";
|
|
4
|
+
import { FindConfig, Selector } from "../types/common";
|
|
5
|
+
import { SwapRepository } from "../repositories/swap";
|
|
6
|
+
import CartService from "./cart";
|
|
7
|
+
import { CustomShippingOptionService, EventBusService, FulfillmentService, InventoryService, LineItemService, OrderService, PaymentProviderService, ReturnService, ShippingOptionService, TotalsService } from "./index";
|
|
8
|
+
import { Cart, LineItem, Order, ReturnItem, Swap } from "../models";
|
|
9
|
+
import { CreateShipmentConfig } from "../types/fulfillment";
|
|
10
|
+
declare type InjectedProps = {
|
|
11
|
+
manager: EntityManager;
|
|
12
|
+
swapRepository: typeof SwapRepository;
|
|
13
|
+
cartService: CartService;
|
|
14
|
+
eventBus: EventBusService;
|
|
15
|
+
orderService: OrderService;
|
|
16
|
+
returnService: ReturnService;
|
|
17
|
+
totalsService: TotalsService;
|
|
18
|
+
eventBusService: EventBusService;
|
|
19
|
+
lineItemService: LineItemService;
|
|
20
|
+
inventoryService: InventoryService;
|
|
21
|
+
fulfillmentService: FulfillmentService;
|
|
22
|
+
shippingOptionService: ShippingOptionService;
|
|
23
|
+
paymentProviderService: PaymentProviderService;
|
|
24
|
+
lineItemAdjustmentService: LineItemAdjustmentService;
|
|
25
|
+
customShippingOptionService: CustomShippingOptionService;
|
|
26
|
+
};
|
|
3
27
|
/**
|
|
4
28
|
* Handles swaps
|
|
5
|
-
* @extends BaseService
|
|
6
29
|
*/
|
|
7
|
-
declare class SwapService extends
|
|
8
|
-
[x: string]: any;
|
|
30
|
+
declare class SwapService extends TransactionBaseService {
|
|
9
31
|
static Events: {
|
|
10
32
|
CREATED: string;
|
|
11
33
|
RECEIVED: string;
|
|
@@ -17,209 +39,171 @@ declare class SwapService extends SwapService_base {
|
|
|
17
39
|
REFUND_PROCESSED: string;
|
|
18
40
|
FULFILLMENT_CREATED: string;
|
|
19
41
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
private cartService_;
|
|
51
|
-
/** @private @const {FulfillmentService} */
|
|
52
|
-
private fulfillmentService_;
|
|
53
|
-
/** @private @const {OrderService} */
|
|
54
|
-
private orderService_;
|
|
55
|
-
/** @private @const {ShippingOptionService} */
|
|
56
|
-
private shippingOptionService_;
|
|
57
|
-
/** @private @const {InventoryService} */
|
|
58
|
-
private inventoryService_;
|
|
59
|
-
/** @private @const {EventBusService} */
|
|
60
|
-
private eventBus_;
|
|
61
|
-
/** @private @const {typeof ShippingMethodTaxLineRepository} */
|
|
62
|
-
private shippingTaxLineRepo_;
|
|
63
|
-
/** @private @const {CustomShippingOptionService} */
|
|
64
|
-
private customShippingOptionService_;
|
|
65
|
-
/** @private @const {LineItemAdjustmentService} */
|
|
66
|
-
private lineItemAdjustmentService_;
|
|
67
|
-
withTransaction(transactionManager: any): SwapService;
|
|
68
|
-
transformQueryForCart_(config: any): any;
|
|
42
|
+
protected manager_: EntityManager;
|
|
43
|
+
protected transactionManager_: EntityManager | undefined;
|
|
44
|
+
protected readonly swapRepository_: typeof SwapRepository;
|
|
45
|
+
protected readonly cartService_: CartService;
|
|
46
|
+
protected readonly eventBus_: EventBusService;
|
|
47
|
+
protected readonly orderService_: OrderService;
|
|
48
|
+
protected readonly returnService_: ReturnService;
|
|
49
|
+
protected readonly totalsService_: TotalsService;
|
|
50
|
+
protected readonly lineItemService_: LineItemService;
|
|
51
|
+
protected readonly inventoryService_: InventoryService;
|
|
52
|
+
protected readonly fulfillmentService_: FulfillmentService;
|
|
53
|
+
protected readonly shippingOptionService_: ShippingOptionService;
|
|
54
|
+
protected readonly paymentProviderService_: PaymentProviderService;
|
|
55
|
+
protected readonly lineItemAdjustmentService_: LineItemAdjustmentService;
|
|
56
|
+
protected readonly customShippingOptionService_: CustomShippingOptionService;
|
|
57
|
+
constructor({ manager, swapRepository, eventBusService, cartService, totalsService, returnService, lineItemService, paymentProviderService, shippingOptionService, fulfillmentService, orderService, inventoryService, customShippingOptionService, lineItemAdjustmentService, }: InjectedProps);
|
|
58
|
+
/**
|
|
59
|
+
* Transform find config object for retrieval.
|
|
60
|
+
*
|
|
61
|
+
* @param config parsed swap find config
|
|
62
|
+
* @return transformed find swap config
|
|
63
|
+
*/
|
|
64
|
+
protected transformQueryForCart(config: Omit<FindConfig<Swap>, "select"> & {
|
|
65
|
+
select?: string[];
|
|
66
|
+
}): Omit<FindConfig<Swap>, "select"> & {
|
|
67
|
+
select?: string[];
|
|
68
|
+
} & {
|
|
69
|
+
cartSelects: FindConfig<Cart>["select"];
|
|
70
|
+
cartRelations: FindConfig<Cart>["relations"];
|
|
71
|
+
};
|
|
69
72
|
/**
|
|
70
73
|
* Retrieves a swap with the given id.
|
|
71
|
-
*
|
|
72
|
-
* @param
|
|
73
|
-
* @
|
|
74
|
+
*
|
|
75
|
+
* @param id - the id of the swap to retrieve
|
|
76
|
+
* @param config - the configuration to retrieve the swap
|
|
77
|
+
* @return the swap
|
|
74
78
|
*/
|
|
75
|
-
retrieve(id: string, config?:
|
|
79
|
+
retrieve(id: string, config?: Omit<FindConfig<Swap>, "select"> & {
|
|
80
|
+
select?: string[];
|
|
81
|
+
}): Promise<Swap | never>;
|
|
76
82
|
/**
|
|
77
83
|
* Retrieves a swap based on its associated cart id
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
80
|
-
* @
|
|
81
|
-
|
|
82
|
-
retrieveByCartId(cartId: string, relations?: string[]): Promise<Swap>;
|
|
83
|
-
/**
|
|
84
|
-
* @param {Object} selector - the query object for find
|
|
85
|
-
* @param {Object} config - the configuration used to find the objects. contains relations, skip, and take.
|
|
86
|
-
* @return {Promise} the result of the find operation
|
|
84
|
+
*
|
|
85
|
+
* @param cartId - the cart id that the swap's cart has
|
|
86
|
+
* @param relations - the relations to retrieve swap
|
|
87
|
+
* @return the swap
|
|
87
88
|
*/
|
|
88
|
-
|
|
89
|
+
retrieveByCartId(cartId: string, relations?: FindConfig<Swap>["relations"]): Promise<Swap | never>;
|
|
89
90
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* @
|
|
95
|
-
* @property {string} item_id - the id of the item in the order to return from.
|
|
96
|
-
* @property {number} quantity - the amount of the item to return.
|
|
97
|
-
*/
|
|
98
|
-
/**
|
|
99
|
-
* Goes through a list of return items to ensure that they exist on the
|
|
100
|
-
* original order. If the item exists it is verified that the quantity to
|
|
101
|
-
* return is not higher than the original quantity ordered.
|
|
102
|
-
* @param {OrderLike} order - the order to return from
|
|
103
|
-
* @param {Array<ReturnItem>} returnItems - the items to return
|
|
104
|
-
* @return {Array<ReturnItems>} the validated returnItems
|
|
105
|
-
*/
|
|
106
|
-
validateReturnItems_(order: {
|
|
107
|
-
/**
|
|
108
|
-
* - the items on the order
|
|
109
|
-
*/
|
|
110
|
-
items: Array<LineItem>;
|
|
111
|
-
}, returnItems: {
|
|
112
|
-
/**
|
|
113
|
-
* - the id of the item in the order to return from.
|
|
114
|
-
*/
|
|
115
|
-
item_id: string;
|
|
116
|
-
/**
|
|
117
|
-
* - the amount of the item to return.
|
|
118
|
-
*/
|
|
119
|
-
quantity: number;
|
|
120
|
-
}[]): Array<ReturnItems>;
|
|
121
|
-
/**
|
|
122
|
-
* @typedef PreliminaryLineItem
|
|
123
|
-
* @property {string} variant_id - the id of the variant to create an item from
|
|
124
|
-
* @property {number} quantity - the amount of the variant to add to the line item
|
|
91
|
+
* List swaps.
|
|
92
|
+
*
|
|
93
|
+
* @param selector - the query object for find
|
|
94
|
+
* @param config - the configuration used to find the objects. contains relations, skip, and take.
|
|
95
|
+
* @return the result of the find operation
|
|
125
96
|
*/
|
|
97
|
+
list(selector: Selector<Swap>, config?: FindConfig<Swap>): Promise<Swap[]>;
|
|
126
98
|
/**
|
|
127
99
|
* Creates a swap from an order, with given return items, additional items
|
|
128
100
|
* and an optional return shipping method.
|
|
129
|
-
*
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
*
|
|
133
|
-
* @param
|
|
134
|
-
*
|
|
135
|
-
* @param {Object} custom - contains relevant custom information. This object may
|
|
101
|
+
*
|
|
102
|
+
* @param order - the order to base the swap off
|
|
103
|
+
* @param returnItems - the items to return in the swap
|
|
104
|
+
* @param additionalItems - the items to send to the customer
|
|
105
|
+
* @param returnShipping - an optional shipping method for returning the returnItems
|
|
106
|
+
* @param custom - contains relevant custom information. This object may
|
|
136
107
|
* include no_notification which will disable sending notification when creating
|
|
137
|
-
* swap. If set, it overrules the attribute inherited from the order
|
|
138
|
-
* @return
|
|
139
|
-
*/
|
|
140
|
-
create(order: Order, returnItems: {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
108
|
+
* swap. If set, it overrules the attribute inherited from the order
|
|
109
|
+
* @return the newly created swap
|
|
110
|
+
*/
|
|
111
|
+
create(order: Order, returnItems: Partial<ReturnItem>[], additionalItems?: Pick<LineItem, "variant_id" | "quantity">[], returnShipping?: {
|
|
112
|
+
option_id: string;
|
|
113
|
+
price?: number;
|
|
114
|
+
}, custom?: {
|
|
115
|
+
no_notification?: boolean;
|
|
116
|
+
idempotency_key?: string;
|
|
117
|
+
allow_backorder?: boolean;
|
|
118
|
+
}): Promise<Swap | never>;
|
|
119
|
+
/**
|
|
120
|
+
* Process difference for the requested swap.
|
|
121
|
+
*
|
|
122
|
+
* @param swapId id of a swap being processed
|
|
123
|
+
* @return processed swap
|
|
124
|
+
*/
|
|
125
|
+
processDifference(swapId: string): Promise<Swap | never>;
|
|
126
|
+
/**
|
|
127
|
+
* Update the swap record.
|
|
128
|
+
*
|
|
129
|
+
* @param swapId id of a swap to update
|
|
130
|
+
* @param update new data
|
|
131
|
+
* @return updated swap record
|
|
132
|
+
*/
|
|
133
|
+
update(swapId: string, update: Partial<Swap>): Promise<Swap>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a cart from the given swap. The cart can be used to pay
|
|
163
136
|
* for differences associated with the swap. The swap represented by the
|
|
164
137
|
* swapId must belong to the order. Fails if there is already a cart on the
|
|
165
138
|
* swap.
|
|
166
|
-
*
|
|
167
|
-
* @param
|
|
168
|
-
* @param
|
|
169
|
-
* @return
|
|
170
|
-
* the new cart.
|
|
139
|
+
*
|
|
140
|
+
* @param swapId - the id of the swap to create the cart from
|
|
141
|
+
* @param customShippingOptions - the shipping options
|
|
142
|
+
* @return the swap with its cart_id prop set to the id of the new cart.
|
|
171
143
|
*/
|
|
172
|
-
createCart(swapId: string, customShippingOptions?:
|
|
144
|
+
createCart(swapId: string, customShippingOptions?: {
|
|
145
|
+
option_id: string;
|
|
146
|
+
price: number;
|
|
147
|
+
}[]): Promise<Swap | never>;
|
|
173
148
|
/**
|
|
174
|
-
|
|
149
|
+
* Register a cart completion
|
|
150
|
+
*
|
|
151
|
+
* @param swapId - The id of the swap
|
|
152
|
+
* @return swap related to the cart
|
|
175
153
|
*/
|
|
176
|
-
registerCartCompletion(swapId: string): Promise<
|
|
154
|
+
registerCartCompletion(swapId: string): Promise<Swap | never>;
|
|
177
155
|
/**
|
|
178
156
|
* Cancels a given swap if possible. A swap can only be canceled if all
|
|
179
157
|
* related returns, fulfillments, and payments have been canceled. If a swap
|
|
180
158
|
* is associated with a refund, it cannot be canceled.
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
159
|
+
*
|
|
160
|
+
* @param swapId - the id of the swap to cancel.
|
|
161
|
+
* @return the canceled swap.
|
|
183
162
|
*/
|
|
184
|
-
cancel(swapId: string): Promise<Swap>;
|
|
163
|
+
cancel(swapId: string): Promise<Swap | never>;
|
|
185
164
|
/**
|
|
186
|
-
* Fulfills the
|
|
165
|
+
* Fulfills the additional items associated with the swap. Will call the
|
|
187
166
|
* fulfillment providers associated with the shipping methods.
|
|
167
|
+
*
|
|
188
168
|
* @param {string} swapId - the id of the swap to fulfill,
|
|
189
169
|
* @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a no_notification flag.
|
|
190
170
|
* @return {Promise<Swap>} the updated swap with new status and fulfillments.
|
|
191
171
|
*/
|
|
192
|
-
createFulfillment(swapId: string, config?:
|
|
172
|
+
createFulfillment(swapId: string, config?: CreateShipmentConfig): Promise<Swap | never>;
|
|
193
173
|
/**
|
|
194
174
|
* Cancels a fulfillment (if related to a swap)
|
|
195
|
-
*
|
|
196
|
-
* @
|
|
175
|
+
*
|
|
176
|
+
* @param fulfillmentId - the ID of the fulfillment to cancel
|
|
177
|
+
* @return updated swap
|
|
197
178
|
*/
|
|
198
|
-
cancelFulfillment(fulfillmentId: string): Swap
|
|
179
|
+
cancelFulfillment(fulfillmentId: string): Promise<Swap | never>;
|
|
199
180
|
/**
|
|
200
181
|
* Marks a fulfillment as shipped and attaches tracking numbers.
|
|
201
|
-
*
|
|
202
|
-
* @param
|
|
203
|
-
*
|
|
204
|
-
* @param
|
|
205
|
-
*
|
|
206
|
-
* @
|
|
207
|
-
* @return {Promise<Swap>} the updated swap with new fulfillments and status.
|
|
182
|
+
*
|
|
183
|
+
* @param swapId - the id of the swap that has been shipped.
|
|
184
|
+
* @param fulfillmentId - the id of the specific fulfillment that has been shipped
|
|
185
|
+
* @param trackingLinks - the tracking numbers associated with the shipment
|
|
186
|
+
* @param config - optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag.
|
|
187
|
+
* @return the updated swap with new fulfillments and status.
|
|
208
188
|
*/
|
|
209
|
-
createShipment(swapId: string, fulfillmentId: string, trackingLinks
|
|
189
|
+
createShipment(swapId: string, fulfillmentId: string, trackingLinks?: {
|
|
190
|
+
tracking_number: string;
|
|
191
|
+
}[], config?: CreateShipmentConfig): Promise<Swap | never>;
|
|
210
192
|
/**
|
|
211
193
|
* Dedicated method to delete metadata for a swap.
|
|
212
|
-
*
|
|
213
|
-
* @param
|
|
214
|
-
* @
|
|
194
|
+
*
|
|
195
|
+
* @param swapId - the order to delete metadata from.
|
|
196
|
+
* @param key - key for metadata field
|
|
197
|
+
* @return resolves to the updated result.
|
|
215
198
|
*/
|
|
216
|
-
deleteMetadata(swapId: string, key: string): Promise<
|
|
199
|
+
deleteMetadata(swapId: string, key: string): Promise<Swap | never>;
|
|
217
200
|
/**
|
|
218
201
|
* Registers the swap return items as received so that they cannot be used
|
|
219
202
|
* as a part of other swaps/returns.
|
|
220
|
-
*
|
|
221
|
-
* @param
|
|
222
|
-
* @return
|
|
203
|
+
*
|
|
204
|
+
* @param id - the id of the order with the swap.
|
|
205
|
+
* @return the resulting order
|
|
223
206
|
*/
|
|
224
|
-
registerReceived(id:
|
|
207
|
+
registerReceived(id: any): Promise<Swap | never>;
|
|
225
208
|
}
|
|
209
|
+
export default SwapService;
|