@medusajs/inventory 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/dist/config.d.ts +1 -0
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/connection.d.ts +5 -0
- package/dist/loaders/connection.js +64 -0
- package/dist/loaders/connection.js.map +1 -0
- package/dist/migrations/schema-migrations/1665748086258-inventory_setup.d.ts +13 -0
- package/dist/migrations/schema-migrations/1665748086258-inventory_setup.js +131 -0
- package/dist/migrations/schema-migrations/1665748086258-inventory_setup.js.map +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +20 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/inventory-item.d.ts +15 -0
- package/dist/models/inventory-item.js +95 -0
- package/dist/models/inventory-item.js.map +1 -0
- package/dist/models/inventory-level.d.ts +10 -0
- package/dist/models/inventory-level.js +77 -0
- package/dist/models/inventory-level.js.map +1 -0
- package/dist/models/reservation-item.d.ts +9 -0
- package/dist/models/reservation-item.js +73 -0
- package/dist/models/reservation-item.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +15 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/inventory-item.d.ts +53 -0
- package/dist/services/inventory-item.js +289 -0
- package/dist/services/inventory-item.js.map +1 -0
- package/dist/services/inventory-level.d.ts +89 -0
- package/dist/services/inventory-level.js +411 -0
- package/dist/services/inventory-level.js.map +1 -0
- package/dist/services/inventory.d.ts +150 -0
- package/dist/services/inventory.js +496 -0
- package/dist/services/inventory.js.map +1 -0
- package/dist/services/reservation-item.d.ts +68 -0
- package/dist/services/reservation-item.js +385 -0
- package/dist/services/reservation-item.js.map +1 -0
- package/jest.config.js +13 -0
- package/package.json +37 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
54
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
55
|
+
if (!m) return o;
|
|
56
|
+
var i = m.call(o), r, ar = [], e;
|
|
57
|
+
try {
|
|
58
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
59
|
+
}
|
|
60
|
+
catch (error) { e = { error: error }; }
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
64
|
+
}
|
|
65
|
+
finally { if (e) throw e.error; }
|
|
66
|
+
}
|
|
67
|
+
return ar;
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
var typeorm_1 = require("typeorm");
|
|
71
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
72
|
+
var medusa_1 = require("@medusajs/medusa");
|
|
73
|
+
var models_1 = require("../models");
|
|
74
|
+
var config_1 = require("../config");
|
|
75
|
+
var InventoryLevelService = /** @class */ (function (_super) {
|
|
76
|
+
__extends(InventoryLevelService, _super);
|
|
77
|
+
function InventoryLevelService(_a) {
|
|
78
|
+
var eventBusService = _a.eventBusService;
|
|
79
|
+
var _this = _super.call(this, arguments[0]) || this;
|
|
80
|
+
_this.eventBusService_ = eventBusService;
|
|
81
|
+
_this.manager_ = _this.getManager();
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
InventoryLevelService.prototype.getManager = function () {
|
|
85
|
+
var _a;
|
|
86
|
+
if (this.manager_) {
|
|
87
|
+
return (_a = this.transactionManager_) !== null && _a !== void 0 ? _a : this.manager_;
|
|
88
|
+
}
|
|
89
|
+
var connection = (0, typeorm_1.getConnection)(config_1.CONNECTION_NAME);
|
|
90
|
+
return connection.manager;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves a list of inventory levels based on the provided selector and configuration.
|
|
94
|
+
* @param selector - An object containing filterable properties for inventory levels.
|
|
95
|
+
* @param config - An object containing configuration options for the query.
|
|
96
|
+
* @return Array of inventory levels.
|
|
97
|
+
*/
|
|
98
|
+
InventoryLevelService.prototype.list = function (selector, config) {
|
|
99
|
+
if (selector === void 0) { selector = {}; }
|
|
100
|
+
if (config === void 0) { config = { relations: [], skip: 0, take: 10 }; }
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var manager, levelRepository, query;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
manager = this.getManager();
|
|
107
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
108
|
+
query = (0, medusa_1.buildQuery)(selector, config);
|
|
109
|
+
return [4 /*yield*/, levelRepository.find(query)];
|
|
110
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Retrieves a list of inventory levels and a count based on the provided selector and configuration.
|
|
117
|
+
* @param selector - An object containing filterable properties for inventory levels.
|
|
118
|
+
* @param config - An object containing configuration options for the query.
|
|
119
|
+
* @return An array of inventory levels and a count.
|
|
120
|
+
*/
|
|
121
|
+
InventoryLevelService.prototype.listAndCount = function (selector, config) {
|
|
122
|
+
if (selector === void 0) { selector = {}; }
|
|
123
|
+
if (config === void 0) { config = { relations: [], skip: 0, take: 10 }; }
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var manager, levelRepository, query;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
manager = this.getManager();
|
|
130
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
131
|
+
query = (0, medusa_1.buildQuery)(selector, config);
|
|
132
|
+
return [4 /*yield*/, levelRepository.findAndCount(query)];
|
|
133
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves a single inventory level by its ID.
|
|
140
|
+
* @param inventoryLevelId - The ID of the inventory level to retrieve.
|
|
141
|
+
* @param config - An object containing configuration options for the query.
|
|
142
|
+
* @return A inventory level.
|
|
143
|
+
* @throws If the inventory level ID is not defined or the given ID was not found.
|
|
144
|
+
*/
|
|
145
|
+
InventoryLevelService.prototype.retrieve = function (inventoryLevelId, config) {
|
|
146
|
+
if (config === void 0) { config = {}; }
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
var manager, levelRepository, query, _a, inventoryLevel;
|
|
149
|
+
return __generator(this, function (_b) {
|
|
150
|
+
switch (_b.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
if (!(0, medusa_core_utils_1.isDefined)(inventoryLevelId)) {
|
|
153
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "\"inventoryLevelId\" must be defined");
|
|
154
|
+
}
|
|
155
|
+
manager = this.getManager();
|
|
156
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
157
|
+
query = (0, medusa_1.buildQuery)({ id: inventoryLevelId }, config);
|
|
158
|
+
return [4 /*yield*/, levelRepository.find(query)];
|
|
159
|
+
case 1:
|
|
160
|
+
_a = __read.apply(void 0, [_b.sent(), 1]), inventoryLevel = _a[0];
|
|
161
|
+
if (!inventoryLevel) {
|
|
162
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "InventoryLevel with id ".concat(inventoryLevelId, " was not found"));
|
|
163
|
+
}
|
|
164
|
+
return [2 /*return*/, inventoryLevel];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Creates a new inventory level.
|
|
171
|
+
* @param data - An object containing the properties for the new inventory level.
|
|
172
|
+
* @return The created inventory level.
|
|
173
|
+
*/
|
|
174
|
+
InventoryLevelService.prototype.create = function (data) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var result;
|
|
177
|
+
var _this = this;
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
switch (_a.label) {
|
|
180
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
181
|
+
var levelRepository, inventoryLevel;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
switch (_a.label) {
|
|
184
|
+
case 0:
|
|
185
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
186
|
+
inventoryLevel = levelRepository.create({
|
|
187
|
+
location_id: data.location_id,
|
|
188
|
+
inventory_item_id: data.inventory_item_id,
|
|
189
|
+
stocked_quantity: data.stocked_quantity,
|
|
190
|
+
reserved_quantity: data.reserved_quantity,
|
|
191
|
+
incoming_quantity: data.incoming_quantity,
|
|
192
|
+
});
|
|
193
|
+
return [4 /*yield*/, levelRepository.save(inventoryLevel)];
|
|
194
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); })];
|
|
198
|
+
case 1:
|
|
199
|
+
result = _a.sent();
|
|
200
|
+
return [4 /*yield*/, this.eventBusService_.emit(InventoryLevelService.Events.CREATED, {
|
|
201
|
+
id: result.id,
|
|
202
|
+
})];
|
|
203
|
+
case 2:
|
|
204
|
+
_a.sent();
|
|
205
|
+
return [2 /*return*/, result];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Updates an existing inventory level.
|
|
212
|
+
* @param inventoryLevelId - The ID of the inventory level to update.
|
|
213
|
+
* @param data - An object containing the properties to update on the inventory level.
|
|
214
|
+
* @param autoSave - A flag indicating whether to save the changes automatically.
|
|
215
|
+
* @return The updated inventory level.
|
|
216
|
+
* @throws If the inventory level ID is not defined or the given ID was not found.
|
|
217
|
+
*/
|
|
218
|
+
InventoryLevelService.prototype.update = function (inventoryLevelId, data) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
var _this = this;
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
switch (_a.label) {
|
|
223
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
224
|
+
var levelRepository, item, shouldUpdate;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
229
|
+
return [4 /*yield*/, this.retrieve(inventoryLevelId)];
|
|
230
|
+
case 1:
|
|
231
|
+
item = _a.sent();
|
|
232
|
+
shouldUpdate = Object.keys(data).some(function (key) {
|
|
233
|
+
return item[key] !== data[key];
|
|
234
|
+
});
|
|
235
|
+
if (!shouldUpdate) return [3 /*break*/, 4];
|
|
236
|
+
levelRepository.merge(item, data);
|
|
237
|
+
return [4 /*yield*/, levelRepository.save(item)];
|
|
238
|
+
case 2:
|
|
239
|
+
_a.sent();
|
|
240
|
+
return [4 /*yield*/, this.eventBusService_.emit(InventoryLevelService.Events.UPDATED, {
|
|
241
|
+
id: item.id,
|
|
242
|
+
})];
|
|
243
|
+
case 3:
|
|
244
|
+
_a.sent();
|
|
245
|
+
_a.label = 4;
|
|
246
|
+
case 4: return [2 /*return*/, item];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}); })];
|
|
250
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Adjust the reserved quantity for an inventory item at a specific location.
|
|
257
|
+
* @param inventoryItemId - The ID of the inventory item.
|
|
258
|
+
* @param locationId - The ID of the location.
|
|
259
|
+
* @param quantity - The quantity to adjust from the reserved quantity.
|
|
260
|
+
*/
|
|
261
|
+
InventoryLevelService.prototype.adjustReservedQuantity = function (inventoryItemId, locationId, quantity) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
+
var _this = this;
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
switch (_a.label) {
|
|
266
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
267
|
+
return __generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0: return [4 /*yield*/, manager
|
|
270
|
+
.createQueryBuilder()
|
|
271
|
+
.update(models_1.InventoryLevel)
|
|
272
|
+
.set({ reserved_quantity: function () { return "reserved_quantity + ".concat(quantity); } })
|
|
273
|
+
.where("inventory_item_id = :inventoryItemId AND location_id = :locationId", { inventoryItemId: inventoryItemId, locationId: locationId })
|
|
274
|
+
.execute()];
|
|
275
|
+
case 1:
|
|
276
|
+
_a.sent();
|
|
277
|
+
return [2 /*return*/];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}); })];
|
|
281
|
+
case 1:
|
|
282
|
+
_a.sent();
|
|
283
|
+
return [2 /*return*/];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Deletes an inventory level by ID.
|
|
290
|
+
* @param inventoryLevelId - The ID of the inventory level to delete.
|
|
291
|
+
*/
|
|
292
|
+
InventoryLevelService.prototype.delete = function (inventoryLevelId) {
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
var _this = this;
|
|
295
|
+
return __generator(this, function (_a) {
|
|
296
|
+
switch (_a.label) {
|
|
297
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
298
|
+
var levelRepository;
|
|
299
|
+
return __generator(this, function (_a) {
|
|
300
|
+
switch (_a.label) {
|
|
301
|
+
case 0:
|
|
302
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
303
|
+
return [4 /*yield*/, levelRepository.delete({ id: inventoryLevelId })];
|
|
304
|
+
case 1:
|
|
305
|
+
_a.sent();
|
|
306
|
+
return [2 /*return*/];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}); })];
|
|
310
|
+
case 1:
|
|
311
|
+
_a.sent();
|
|
312
|
+
return [4 /*yield*/, this.eventBusService_.emit(InventoryLevelService.Events.DELETED, {
|
|
313
|
+
id: inventoryLevelId,
|
|
314
|
+
})];
|
|
315
|
+
case 2:
|
|
316
|
+
_a.sent();
|
|
317
|
+
return [2 /*return*/];
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Gets the total stocked quantity for a specific inventory item at multiple locations.
|
|
324
|
+
* @param inventoryItemId - The ID of the inventory item.
|
|
325
|
+
* @param locationIds - The IDs of the locations.
|
|
326
|
+
* @return The total stocked quantity.
|
|
327
|
+
*/
|
|
328
|
+
InventoryLevelService.prototype.getStockedQuantity = function (inventoryItemId, locationIds) {
|
|
329
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
330
|
+
var manager, levelRepository, result;
|
|
331
|
+
return __generator(this, function (_a) {
|
|
332
|
+
switch (_a.label) {
|
|
333
|
+
case 0:
|
|
334
|
+
manager = this.getManager();
|
|
335
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
336
|
+
return [4 /*yield*/, levelRepository
|
|
337
|
+
.createQueryBuilder()
|
|
338
|
+
.select("SUM(stocked_quantity)", "quantity")
|
|
339
|
+
.where("inventory_item_id = :inventoryItemId", { inventoryItemId: inventoryItemId })
|
|
340
|
+
.andWhere("location_id IN (:...locationIds)", { locationIds: locationIds })
|
|
341
|
+
.getRawOne()];
|
|
342
|
+
case 1:
|
|
343
|
+
result = _a.sent();
|
|
344
|
+
return [2 /*return*/, result.quantity];
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Gets the total available quantity for a specific inventory item at multiple locations.
|
|
351
|
+
* @param inventoryItemId - The ID of the inventory item.
|
|
352
|
+
* @param locationIds - The IDs of the locations.
|
|
353
|
+
* @return The total available quantity.
|
|
354
|
+
*/
|
|
355
|
+
InventoryLevelService.prototype.getAvailableQuantity = function (inventoryItemId, locationIds) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
357
|
+
var manager, levelRepository, result;
|
|
358
|
+
return __generator(this, function (_a) {
|
|
359
|
+
switch (_a.label) {
|
|
360
|
+
case 0:
|
|
361
|
+
manager = this.getManager();
|
|
362
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
363
|
+
return [4 /*yield*/, levelRepository
|
|
364
|
+
.createQueryBuilder()
|
|
365
|
+
.select("SUM(stocked_quantity - reserved_quantity)", "quantity")
|
|
366
|
+
.where("inventory_item_id = :inventoryItemId", { inventoryItemId: inventoryItemId })
|
|
367
|
+
.andWhere("location_id IN (:...locationIds)", { locationIds: locationIds })
|
|
368
|
+
.getRawOne()];
|
|
369
|
+
case 1:
|
|
370
|
+
result = _a.sent();
|
|
371
|
+
return [2 /*return*/, result.quantity];
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Gets the total reserved quantity for a specific inventory item at multiple locations.
|
|
378
|
+
* @param inventoryItemId - The ID of the inventory item.
|
|
379
|
+
* @param locationIds - The IDs of the locations.
|
|
380
|
+
* @return The total reserved quantity.
|
|
381
|
+
*/
|
|
382
|
+
InventoryLevelService.prototype.getReservedQuantity = function (inventoryItemId, locationIds) {
|
|
383
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
+
var manager, levelRepository, result;
|
|
385
|
+
return __generator(this, function (_a) {
|
|
386
|
+
switch (_a.label) {
|
|
387
|
+
case 0:
|
|
388
|
+
manager = this.getManager();
|
|
389
|
+
levelRepository = manager.getRepository(models_1.InventoryLevel);
|
|
390
|
+
return [4 /*yield*/, levelRepository
|
|
391
|
+
.createQueryBuilder()
|
|
392
|
+
.select("SUM(reserved_quantity)", "quantity")
|
|
393
|
+
.where("inventory_item_id = :inventoryItemId", { inventoryItemId: inventoryItemId })
|
|
394
|
+
.andWhere("location_id IN (:...locationIds)", { locationIds: locationIds })
|
|
395
|
+
.getRawOne()];
|
|
396
|
+
case 1:
|
|
397
|
+
result = _a.sent();
|
|
398
|
+
return [2 /*return*/, result.quantity];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
InventoryLevelService.Events = {
|
|
404
|
+
CREATED: "inventory-level.created",
|
|
405
|
+
UPDATED: "inventory-level.updated",
|
|
406
|
+
DELETED: "inventory-level.deleted",
|
|
407
|
+
};
|
|
408
|
+
return InventoryLevelService;
|
|
409
|
+
}(medusa_1.TransactionBaseService));
|
|
410
|
+
exports.default = InventoryLevelService;
|
|
411
|
+
//# sourceMappingURL=inventory-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory-level.js","sourceRoot":"","sources":["../../src/services/inventory-level.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAmE;AACnE,uDAA0D;AAC1D,2CAOyB;AAEzB,oCAA0C;AAC1C,oCAA2C;AAM3C;IAAmD,yCAAsB;IAYvE,+BAAY,EAAyC;YAAvC,eAAe,qBAAA;QAA7B,YACE,kBAAM,SAAS,CAAC,CAAC,CAAC,CAAC,SAIpB;QAFC,KAAI,CAAC,gBAAgB,GAAG,eAAe,CAAA;QACvC,KAAI,CAAC,QAAQ,GAAG,KAAI,CAAC,UAAU,EAAE,CAAA;;IACnC,CAAC;IAEO,0CAAU,GAAlB;;QACE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,MAAA,IAAI,CAAC,mBAAmB,mCAAI,IAAI,CAAC,QAAQ,CAAA;SACjD;QAED,IAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,wBAAe,CAAC,CAAA;QACjD,OAAO,UAAU,CAAC,OAAO,CAAA;IAC3B,CAAC;IAED;;;;;OAKG;IACG,oCAAI,GAAV,UACE,QAA4C,EAC5C,MAAyE;QADzE,yBAAA,EAAA,aAA4C;QAC5C,uBAAA,EAAA,WA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,qBAAM,eAAe;iCACjC,kBAAkB,EAAE;iCACpB,MAAM,CAAC,2CAA2C,EAAE,UAAU,CAAC;iCAC/D,KAAK,CAAC,sCAAsC,EAAE,EAAE,eAAe,iBAAA,EAAE,CAAC;iCAClE,QAAQ,CAAC,kCAAkC,EAAE,EAAE,WAAW,aAAA,EAAE,CAAC;iCAC7D,SAAS,EAAE,EAAA;;wBALR,MAAM,GAAG,SAKD;wBAEd,sBAAO,MAAM,CAAC,QAAQ,EAAA;;;;KACvB;IAED;;;;;OAKG;IACG,mDAAmB,GAAzB,UACE,eAAuB,EACvB,WAAqB;;;;;;wBAEf,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;wBAC3B,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,uBAAc,CAAC,CAAA;wBAE9C,qBAAM,eAAe;iCACjC,kBAAkB,EAAE;iCACpB,MAAM,CAAC,wBAAwB,EAAE,UAAU,CAAC;iCAC5C,KAAK,CAAC,sCAAsC,EAAE,EAAE,eAAe,iBAAA,EAAE,CAAC;iCAClE,QAAQ,CAAC,kCAAkC,EAAE,EAAE,WAAW,aAAA,EAAE,CAAC;iCAC7D,SAAS,EAAE,EAAA;;wBALR,MAAM,GAAG,SAKD;wBAEd,sBAAO,MAAM,CAAC,QAAQ,EAAA;;;;KACvB;IA1QM,4BAAM,GAAG;QACd,OAAO,EAAE,yBAAyB;QAClC,OAAO,EAAE,yBAAyB;QAClC,OAAO,EAAE,yBAAyB;KACnC,CAAA;IAuQH,4BAAC;CAAA,AA5QD,CAAmD,+BAAsB,GA4QxE;kBA5QoB,qBAAqB"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { FindConfig, IInventoryService, FilterableInventoryItemProps, FilterableReservationItemProps, CreateInventoryItemInput, CreateReservationItemInput, FilterableInventoryLevelProps, CreateInventoryLevelInput, UpdateInventoryLevelInput, UpdateReservationItemInput, IEventBusService, InventoryItemDTO, ReservationItemDTO, InventoryLevelDTO } from "@medusajs/medusa";
|
|
2
|
+
import { InventoryItemService, ReservationItemService, InventoryLevelService } from "./";
|
|
3
|
+
declare type InjectedDependencies = {
|
|
4
|
+
eventBusService: IEventBusService;
|
|
5
|
+
};
|
|
6
|
+
export default class InventoryService implements IInventoryService {
|
|
7
|
+
protected readonly eventBusService_: IEventBusService;
|
|
8
|
+
protected readonly inventoryItemService_: InventoryItemService;
|
|
9
|
+
protected readonly reservationItemService_: ReservationItemService;
|
|
10
|
+
protected readonly inventoryLevelService_: InventoryLevelService;
|
|
11
|
+
constructor({ eventBusService }: InjectedDependencies);
|
|
12
|
+
/**
|
|
13
|
+
* Lists inventory items that match the given selector
|
|
14
|
+
* @param selector - the selector to filter inventory items by
|
|
15
|
+
* @param config - the find configuration to use
|
|
16
|
+
* @return A tuple of inventory items and their total count
|
|
17
|
+
*/
|
|
18
|
+
listInventoryItems(selector: FilterableInventoryItemProps, config?: FindConfig<InventoryItemDTO>): Promise<[InventoryItemDTO[], number]>;
|
|
19
|
+
/**
|
|
20
|
+
* Lists inventory levels that match the given selector
|
|
21
|
+
* @param selector - the selector to filter inventory levels by
|
|
22
|
+
* @param config - the find configuration to use
|
|
23
|
+
* @return A tuple of inventory levels and their total count
|
|
24
|
+
*/
|
|
25
|
+
listInventoryLevels(selector: FilterableInventoryLevelProps, config?: FindConfig<InventoryLevelDTO>): Promise<[InventoryLevelDTO[], number]>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists reservation items that match the given selector
|
|
28
|
+
* @param selector - the selector to filter reservation items by
|
|
29
|
+
* @param config - the find configuration to use
|
|
30
|
+
* @return A tuple of reservation items and their total count
|
|
31
|
+
*/
|
|
32
|
+
listReservationItems(selector: FilterableReservationItemProps, config?: FindConfig<ReservationItemDTO>): Promise<[ReservationItemDTO[], number]>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves an inventory item with the given id
|
|
35
|
+
* @param inventoryItemId - the id of the inventory item to retrieve
|
|
36
|
+
* @param config - the find configuration to use
|
|
37
|
+
* @return The retrieved inventory item
|
|
38
|
+
*/
|
|
39
|
+
retrieveInventoryItem(inventoryItemId: string, config?: FindConfig<InventoryItemDTO>): Promise<InventoryItemDTO>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves an inventory level for a given inventory item and location
|
|
42
|
+
* @param inventoryItemId - the id of the inventory item
|
|
43
|
+
* @param locationId - the id of the location
|
|
44
|
+
* @return the retrieved inventory level
|
|
45
|
+
*/
|
|
46
|
+
retrieveInventoryLevel(inventoryItemId: string, locationId: string): Promise<InventoryLevelDTO>;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a reservation item
|
|
49
|
+
* @param input - the input object
|
|
50
|
+
* @return The created reservation item
|
|
51
|
+
*/
|
|
52
|
+
createReservationItem(input: CreateReservationItemInput): Promise<ReservationItemDTO>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an inventory item
|
|
55
|
+
* @param input - the input object
|
|
56
|
+
* @return The created inventory item
|
|
57
|
+
*/
|
|
58
|
+
createInventoryItem(input: CreateInventoryItemInput): Promise<InventoryItemDTO>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates an inventory item
|
|
61
|
+
* @param input - the input object
|
|
62
|
+
* @return The created inventory level
|
|
63
|
+
*/
|
|
64
|
+
createInventoryLevel(input: CreateInventoryLevelInput): Promise<InventoryLevelDTO>;
|
|
65
|
+
/**
|
|
66
|
+
* Updates an inventory item
|
|
67
|
+
* @param inventoryItemId - the id of the inventory item to update
|
|
68
|
+
* @param input - the input object
|
|
69
|
+
* @return The updated inventory item
|
|
70
|
+
*/
|
|
71
|
+
updateInventoryItem(inventoryItemId: string, input: Partial<CreateInventoryItemInput>): Promise<InventoryItemDTO>;
|
|
72
|
+
/**
|
|
73
|
+
* Deletes an inventory item
|
|
74
|
+
* @param inventoryItemId - the id of the inventory item to delete
|
|
75
|
+
*/
|
|
76
|
+
deleteInventoryItem(inventoryItemId: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Deletes an inventory level
|
|
79
|
+
* @param inventoryItemId - the id of the inventory item associated with the level
|
|
80
|
+
* @param locationId - the id of the location associated with the level
|
|
81
|
+
*/
|
|
82
|
+
deleteInventoryLevel(inventoryItemId: string, locationId: string): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Updates an inventory level
|
|
85
|
+
* @param inventoryItemId - the id of the inventory item associated with the level
|
|
86
|
+
* @param locationId - the id of the location associated with the level
|
|
87
|
+
* @param input - the input object
|
|
88
|
+
* @return The updated inventory level
|
|
89
|
+
*/
|
|
90
|
+
updateInventoryLevel(inventoryItemId: string, locationId: string, input: UpdateInventoryLevelInput): Promise<InventoryLevelDTO>;
|
|
91
|
+
/**
|
|
92
|
+
* Updates a reservation item
|
|
93
|
+
* @param inventoryItemId - the id of the inventory item associated with the level
|
|
94
|
+
* @param input - the input object
|
|
95
|
+
* @return The updated inventory level
|
|
96
|
+
*/
|
|
97
|
+
updateReservationItem(reservationItemId: string, input: UpdateReservationItemInput): Promise<ReservationItemDTO>;
|
|
98
|
+
/**
|
|
99
|
+
* Deletes reservation items by line item
|
|
100
|
+
* @param lineItemId - the id of the line item associated with the reservation item
|
|
101
|
+
*/
|
|
102
|
+
deleteReservationItemsByLineItem(lineItemId: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Deletes a reservation item
|
|
105
|
+
* @param reservationItemId - the id of the reservation item to delete
|
|
106
|
+
*/
|
|
107
|
+
deleteReservationItem(reservationItemId: string): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Adjusts the inventory level for a given inventory item and location.
|
|
110
|
+
* @param inventoryItemId - the id of the inventory item
|
|
111
|
+
* @param locationId - the id of the location
|
|
112
|
+
* @param adjustment - the number to adjust the inventory by (can be positive or negative)
|
|
113
|
+
* @return The updated inventory level
|
|
114
|
+
* @throws when the inventory level is not found
|
|
115
|
+
*/
|
|
116
|
+
adjustInventory(inventoryItemId: string, locationId: string, adjustment: number): Promise<InventoryLevelDTO>;
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves the available quantity of a given inventory item in a given location.
|
|
119
|
+
* @param inventoryItemId - the id of the inventory item
|
|
120
|
+
* @param locationIds - the ids of the locations to check
|
|
121
|
+
* @return The available quantity
|
|
122
|
+
* @throws when the inventory item is not found
|
|
123
|
+
*/
|
|
124
|
+
retrieveAvailableQuantity(inventoryItemId: string, locationIds: string[]): Promise<number>;
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves the stocked quantity of a given inventory item in a given location.
|
|
127
|
+
* @param inventoryItemId - the id of the inventory item
|
|
128
|
+
* @param locationIds - the ids of the locations to check
|
|
129
|
+
* @return The stocked quantity
|
|
130
|
+
* @throws when the inventory item is not found
|
|
131
|
+
*/
|
|
132
|
+
retrieveStockedQuantity(inventoryItemId: string, locationIds: string[]): Promise<number>;
|
|
133
|
+
/**
|
|
134
|
+
* Retrieves the reserved quantity of a given inventory item in a given location.
|
|
135
|
+
* @param inventoryItemId - the id of the inventory item
|
|
136
|
+
* @param locationIds - the ids of the locations to check
|
|
137
|
+
* @return The reserved quantity
|
|
138
|
+
* @throws when the inventory item is not found
|
|
139
|
+
*/
|
|
140
|
+
retrieveReservedQuantity(inventoryItemId: string, locationIds: string[]): Promise<number>;
|
|
141
|
+
/**
|
|
142
|
+
* Confirms whether there is sufficient inventory for a given quantity of a given inventory item in a given location.
|
|
143
|
+
* @param inventoryItemId - the id of the inventory item
|
|
144
|
+
* @param locationIds - the ids of the locations to check
|
|
145
|
+
* @param quantity - the quantity to check
|
|
146
|
+
* @return Whether there is sufficient inventory
|
|
147
|
+
*/
|
|
148
|
+
confirmInventory(inventoryItemId: string, locationIds: string[], quantity: number): Promise<boolean>;
|
|
149
|
+
}
|
|
150
|
+
export {};
|