@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.
Files changed (41) hide show
  1. package/dist/config.d.ts +1 -0
  2. package/dist/config.js +5 -0
  3. package/dist/config.js.map +1 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +36 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/loaders/connection.d.ts +5 -0
  8. package/dist/loaders/connection.js +64 -0
  9. package/dist/loaders/connection.js.map +1 -0
  10. package/dist/migrations/schema-migrations/1665748086258-inventory_setup.d.ts +13 -0
  11. package/dist/migrations/schema-migrations/1665748086258-inventory_setup.js +131 -0
  12. package/dist/migrations/schema-migrations/1665748086258-inventory_setup.js.map +1 -0
  13. package/dist/models/index.d.ts +3 -0
  14. package/dist/models/index.js +20 -0
  15. package/dist/models/index.js.map +1 -0
  16. package/dist/models/inventory-item.d.ts +15 -0
  17. package/dist/models/inventory-item.js +95 -0
  18. package/dist/models/inventory-item.js.map +1 -0
  19. package/dist/models/inventory-level.d.ts +10 -0
  20. package/dist/models/inventory-level.js +77 -0
  21. package/dist/models/inventory-level.js.map +1 -0
  22. package/dist/models/reservation-item.d.ts +9 -0
  23. package/dist/models/reservation-item.js +73 -0
  24. package/dist/models/reservation-item.js.map +1 -0
  25. package/dist/services/index.d.ts +4 -0
  26. package/dist/services/index.js +15 -0
  27. package/dist/services/index.js.map +1 -0
  28. package/dist/services/inventory-item.d.ts +53 -0
  29. package/dist/services/inventory-item.js +289 -0
  30. package/dist/services/inventory-item.js.map +1 -0
  31. package/dist/services/inventory-level.d.ts +89 -0
  32. package/dist/services/inventory-level.js +411 -0
  33. package/dist/services/inventory-level.js.map +1 -0
  34. package/dist/services/inventory.d.ts +150 -0
  35. package/dist/services/inventory.js +496 -0
  36. package/dist/services/inventory.js.map +1 -0
  37. package/dist/services/reservation-item.d.ts +68 -0
  38. package/dist/services/reservation-item.js +385 -0
  39. package/dist/services/reservation-item.js.map +1 -0
  40. package/jest.config.js +13 -0
  41. package/package.json +37 -0
@@ -0,0 +1,385 @@
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
+ var __values = (this && this.__values) || function(o) {
70
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
71
+ if (m) return m.call(o);
72
+ if (o && typeof o.length === "number") return {
73
+ next: function () {
74
+ if (o && i >= o.length) o = void 0;
75
+ return { value: o && o[i++], done: !o };
76
+ }
77
+ };
78
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
79
+ };
80
+ Object.defineProperty(exports, "__esModule", { value: true });
81
+ var typeorm_1 = require("typeorm");
82
+ var medusa_core_utils_1 = require("medusa-core-utils");
83
+ var medusa_1 = require("@medusajs/medusa");
84
+ var models_1 = require("../models");
85
+ var config_1 = require("../config");
86
+ var ReservationItemService = /** @class */ (function (_super) {
87
+ __extends(ReservationItemService, _super);
88
+ function ReservationItemService(_a) {
89
+ var eventBusService = _a.eventBusService, inventoryLevelService = _a.inventoryLevelService;
90
+ var _this = _super.call(this, arguments[0]) || this;
91
+ _this.manager_ = _this.getManager();
92
+ _this.eventBusService_ = eventBusService;
93
+ _this.inventoryLevelService_ = inventoryLevelService;
94
+ return _this;
95
+ }
96
+ ReservationItemService.prototype.getManager = function () {
97
+ var _a;
98
+ if (this.manager_) {
99
+ return (_a = this.transactionManager_) !== null && _a !== void 0 ? _a : this.manager_;
100
+ }
101
+ var connection = (0, typeorm_1.getConnection)(config_1.CONNECTION_NAME);
102
+ return connection.manager;
103
+ };
104
+ /**
105
+ * Lists reservation items that match the provided filter.
106
+ * @param selector - Filters to apply to the reservation items.
107
+ * @param config - Configuration for the query.
108
+ * @return Array of reservation items that match the selector.
109
+ */
110
+ ReservationItemService.prototype.list = function (selector, config) {
111
+ if (selector === void 0) { selector = {}; }
112
+ if (config === void 0) { config = { relations: [], skip: 0, take: 10 }; }
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var manager, itemRepository, query;
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0:
118
+ manager = this.getManager();
119
+ itemRepository = manager.getRepository(models_1.ReservationItem);
120
+ query = (0, medusa_1.buildQuery)(selector, config);
121
+ return [4 /*yield*/, itemRepository.find(query)];
122
+ case 1: return [2 /*return*/, _a.sent()];
123
+ }
124
+ });
125
+ });
126
+ };
127
+ /**
128
+ * Lists reservation items that match the provided filter and returns the total count.
129
+ * @param selector - Filters to apply to the reservation items.
130
+ * @param config - Configuration for the query.
131
+ * @return Array of reservation items that match the selector and the total count.
132
+ */
133
+ ReservationItemService.prototype.listAndCount = function (selector, config) {
134
+ if (selector === void 0) { selector = {}; }
135
+ if (config === void 0) { config = { relations: [], skip: 0, take: 10 }; }
136
+ return __awaiter(this, void 0, void 0, function () {
137
+ var manager, itemRepository, query;
138
+ return __generator(this, function (_a) {
139
+ switch (_a.label) {
140
+ case 0:
141
+ manager = this.getManager();
142
+ itemRepository = manager.getRepository(models_1.ReservationItem);
143
+ query = (0, medusa_1.buildQuery)(selector, config);
144
+ return [4 /*yield*/, itemRepository.findAndCount(query)];
145
+ case 1: return [2 /*return*/, _a.sent()];
146
+ }
147
+ });
148
+ });
149
+ };
150
+ /**
151
+ * Retrieves a reservation item by its id.
152
+ * @param reservationItemId - The id of the reservation item to retrieve.
153
+ * @param config - Configuration for the query.
154
+ * @return The reservation item with the provided id.
155
+ * @throws If reservationItemId is not defined or if the reservation item was not found.
156
+ */
157
+ ReservationItemService.prototype.retrieve = function (reservationItemId, config) {
158
+ if (config === void 0) { config = {}; }
159
+ return __awaiter(this, void 0, void 0, function () {
160
+ var manager, reservationItemRepository, query, _a, reservationItem;
161
+ return __generator(this, function (_b) {
162
+ switch (_b.label) {
163
+ case 0:
164
+ if (!(0, medusa_core_utils_1.isDefined)(reservationItemId)) {
165
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "\"reservationItemId\" must be defined");
166
+ }
167
+ manager = this.getManager();
168
+ reservationItemRepository = manager.getRepository(models_1.ReservationItem);
169
+ query = (0, medusa_1.buildQuery)({ id: reservationItemId }, config);
170
+ return [4 /*yield*/, reservationItemRepository.find(query)];
171
+ case 1:
172
+ _a = __read.apply(void 0, [_b.sent(), 1]), reservationItem = _a[0];
173
+ if (!reservationItem) {
174
+ throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "ReservationItem with id ".concat(reservationItemId, " was not found"));
175
+ }
176
+ return [2 /*return*/, reservationItem];
177
+ }
178
+ });
179
+ });
180
+ };
181
+ /**
182
+ * Create a new reservation item.
183
+ * @param data - The reservation item data.
184
+ * @return The created reservation item.
185
+ */
186
+ ReservationItemService.prototype.create = function (data) {
187
+ return __awaiter(this, void 0, void 0, function () {
188
+ var result;
189
+ var _this = this;
190
+ return __generator(this, function (_a) {
191
+ switch (_a.label) {
192
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
193
+ var itemRepository, inventoryItem, _a, newInventoryItem;
194
+ return __generator(this, function (_b) {
195
+ switch (_b.label) {
196
+ case 0:
197
+ itemRepository = manager.getRepository(models_1.ReservationItem);
198
+ inventoryItem = itemRepository.create({
199
+ inventory_item_id: data.inventory_item_id,
200
+ line_item_id: data.line_item_id,
201
+ location_id: data.location_id,
202
+ quantity: data.quantity,
203
+ metadata: data.metadata,
204
+ });
205
+ return [4 /*yield*/, Promise.all([
206
+ itemRepository.save(inventoryItem),
207
+ this.inventoryLevelService_
208
+ .withTransaction(manager)
209
+ .adjustReservedQuantity(data.inventory_item_id, data.location_id, data.quantity),
210
+ ])];
211
+ case 1:
212
+ _a = __read.apply(void 0, [_b.sent(), 1]), newInventoryItem = _a[0];
213
+ return [2 /*return*/, newInventoryItem];
214
+ }
215
+ });
216
+ }); })];
217
+ case 1:
218
+ result = _a.sent();
219
+ return [4 /*yield*/, this.eventBusService_.emit(ReservationItemService.Events.CREATED, {
220
+ id: result.id,
221
+ })];
222
+ case 2:
223
+ _a.sent();
224
+ return [2 /*return*/, result];
225
+ }
226
+ });
227
+ });
228
+ };
229
+ /**
230
+ * Update a reservation item.
231
+ * @param reservationItemId - The reservation item's id.
232
+ * @param data - The reservation item data to update.
233
+ * @return The updated reservation item.
234
+ */
235
+ ReservationItemService.prototype.update = function (reservationItemId, data) {
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var updatedItem;
238
+ var _this = this;
239
+ return __generator(this, function (_a) {
240
+ switch (_a.label) {
241
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
242
+ var itemRepository, item, shouldUpdateQuantity, ops, quantityDiff, mergedItem;
243
+ return __generator(this, function (_a) {
244
+ switch (_a.label) {
245
+ case 0:
246
+ itemRepository = manager.getRepository(models_1.ReservationItem);
247
+ return [4 /*yield*/, this.retrieve(reservationItemId)];
248
+ case 1:
249
+ item = _a.sent();
250
+ shouldUpdateQuantity = (0, medusa_core_utils_1.isDefined)(data.quantity) && data.quantity !== item.quantity;
251
+ ops = [];
252
+ if (shouldUpdateQuantity) {
253
+ quantityDiff = data.quantity - item.quantity;
254
+ ops.push(this.inventoryLevelService_
255
+ .withTransaction(manager)
256
+ .adjustReservedQuantity(item.inventory_item_id, item.location_id, quantityDiff));
257
+ }
258
+ mergedItem = itemRepository.merge(item, data);
259
+ ops.push(itemRepository.save(item));
260
+ return [4 /*yield*/, Promise.all(ops)];
261
+ case 2:
262
+ _a.sent();
263
+ return [2 /*return*/, mergedItem];
264
+ }
265
+ });
266
+ }); })];
267
+ case 1:
268
+ updatedItem = _a.sent();
269
+ return [4 /*yield*/, this.eventBusService_.emit(ReservationItemService.Events.UPDATED, {
270
+ id: updatedItem.id,
271
+ })];
272
+ case 2:
273
+ _a.sent();
274
+ return [2 /*return*/, updatedItem];
275
+ }
276
+ });
277
+ });
278
+ };
279
+ /**
280
+ * Deletes a reservation item by line item id.
281
+ * @param lineItemId - the id of the line item to delete.
282
+ */
283
+ ReservationItemService.prototype.deleteByLineItem = function (lineItemId) {
284
+ return __awaiter(this, void 0, void 0, function () {
285
+ var _this = this;
286
+ return __generator(this, function (_a) {
287
+ switch (_a.label) {
288
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
289
+ var itemRepository, items, ops, items_1, items_1_1, item;
290
+ var e_1, _a;
291
+ return __generator(this, function (_b) {
292
+ switch (_b.label) {
293
+ case 0:
294
+ itemRepository = manager.getRepository(models_1.ReservationItem);
295
+ return [4 /*yield*/, this.list({ line_item_id: lineItemId })];
296
+ case 1:
297
+ items = _b.sent();
298
+ ops = [];
299
+ try {
300
+ for (items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
301
+ item = items_1_1.value;
302
+ ops.push(itemRepository.softRemove({ line_item_id: lineItemId }));
303
+ ops.push(this.inventoryLevelService_
304
+ .withTransaction(manager)
305
+ .adjustReservedQuantity(item.inventory_item_id, item.location_id, item.quantity * -1));
306
+ }
307
+ }
308
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
309
+ finally {
310
+ try {
311
+ if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
312
+ }
313
+ finally { if (e_1) throw e_1.error; }
314
+ }
315
+ return [4 /*yield*/, Promise.all(ops)];
316
+ case 2:
317
+ _b.sent();
318
+ return [2 /*return*/];
319
+ }
320
+ });
321
+ }); })];
322
+ case 1:
323
+ _a.sent();
324
+ return [4 /*yield*/, this.eventBusService_.emit(ReservationItemService.Events.DELETED_BY_LINE_ITEM, {
325
+ line_item_id: lineItemId,
326
+ })];
327
+ case 2:
328
+ _a.sent();
329
+ return [2 /*return*/];
330
+ }
331
+ });
332
+ });
333
+ };
334
+ /**
335
+ * Deletes a reservation item by id.
336
+ * @param reservationItemId - the id of the reservation item to delete.
337
+ */
338
+ ReservationItemService.prototype.delete = function (reservationItemId) {
339
+ return __awaiter(this, void 0, void 0, function () {
340
+ var _this = this;
341
+ return __generator(this, function (_a) {
342
+ switch (_a.label) {
343
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
344
+ var itemRepository, item;
345
+ return __generator(this, function (_a) {
346
+ switch (_a.label) {
347
+ case 0:
348
+ itemRepository = manager.getRepository(models_1.ReservationItem);
349
+ return [4 /*yield*/, this.retrieve(reservationItemId)];
350
+ case 1:
351
+ item = _a.sent();
352
+ return [4 /*yield*/, Promise.all([
353
+ itemRepository.softRemove({ id: reservationItemId }),
354
+ this.inventoryLevelService_
355
+ .withTransaction(manager)
356
+ .adjustReservedQuantity(item.inventory_item_id, item.location_id, item.quantity * -1),
357
+ ])];
358
+ case 2:
359
+ _a.sent();
360
+ return [2 /*return*/];
361
+ }
362
+ });
363
+ }); })];
364
+ case 1:
365
+ _a.sent();
366
+ return [4 /*yield*/, this.eventBusService_.emit(ReservationItemService.Events.DELETED, {
367
+ id: reservationItemId,
368
+ })];
369
+ case 2:
370
+ _a.sent();
371
+ return [2 /*return*/];
372
+ }
373
+ });
374
+ });
375
+ };
376
+ ReservationItemService.Events = {
377
+ CREATED: "reservation-item.created",
378
+ UPDATED: "reservation-item.updated",
379
+ DELETED: "reservation-item.deleted",
380
+ DELETED_BY_LINE_ITEM: "reservation-item.deleted-by-line-item",
381
+ };
382
+ return ReservationItemService;
383
+ }(medusa_1.TransactionBaseService));
384
+ exports.default = ReservationItemService;
385
+ //# sourceMappingURL=reservation-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reservation-item.js","sourceRoot":"","sources":["../../src/services/reservation-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAmE;AACnE,uDAA0D;AAC1D,2CAQyB;AAEzB,oCAA2C;AAC3C,oCAA2C;AAQ3C;IAAoD,0CAAsB;IAaxE,gCAAY,EAGW;YAFrB,eAAe,qBAAA,EACf,qBAAqB,2BAAA;QAFvB,YAIE,kBAAM,SAAS,CAAC,CAAC,CAAC,CAAC,SAKpB;QAHC,KAAI,CAAC,QAAQ,GAAG,KAAI,CAAC,UAAU,EAAE,CAAA;QACjC,KAAI,CAAC,gBAAgB,GAAG,eAAe,CAAA;QACvC,KAAI,CAAC,sBAAsB,GAAG,qBAAqB,CAAA;;IACrD,CAAC;IAEO,2CAAU,GAAlB;;QACE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,MAAA,IAAI,CAAC,mBAAmB,mCAAI,IAAI,CAAC,Q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+ "ts-jest": {
4
+ tsConfig: "tsconfig.json",
5
+ isolatedModules: false,
6
+ },
7
+ },
8
+ transform: {
9
+ "^.+\\.[jt]s?$": "ts-jest",
10
+ },
11
+ testEnvironment: `node`,
12
+ moduleFileExtensions: [`js`, `ts`],
13
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@medusajs/inventory",
3
+ "version": "1.0.0",
4
+ "description": "Inventory Module for Medusa",
5
+ "main": "dist/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/medusajs/medusa",
9
+ "directory": "packages/inventory"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "author": "Medusa",
15
+ "license": "MIT",
16
+ "devDependencies": {
17
+ "@medusajs/medusa": "*",
18
+ "cross-env": "^5.2.1",
19
+ "jest": "^25.5.2",
20
+ "ts-jest": "^25.5.1",
21
+ "typescript": "^4.4.4"
22
+ },
23
+ "scripts": {
24
+ "watch": "tsc --build --watch",
25
+ "prepare": "cross-env NODE_ENV=production yarn run build",
26
+ "build": "tsc --build",
27
+ "test": "jest --passWithNoTests",
28
+ "test:unit": "jest --passWithNoTests"
29
+ },
30
+ "peerDependencies": {
31
+ "@medusajs/medusa": "1.x.x",
32
+ "medusa-interfaces": "1.x.x"
33
+ },
34
+ "dependencies": {
35
+ "typeorm": "^0.2.31"
36
+ }
37
+ }