@medusajs/medusa 1.7.13 → 1.7.14
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/api/routes/admin/inventory-items/create-inventory-item.d.ts +136 -0
- package/dist/api/routes/admin/inventory-items/create-inventory-item.js +315 -0
- package/dist/api/routes/admin/inventory-items/create-inventory-item.js.map +1 -0
- package/dist/api/routes/admin/inventory-items/transaction/create-inventory-item.d.ts +25 -0
- package/dist/api/routes/admin/inventory-items/transaction/create-inventory-item.js +200 -0
- package/dist/api/routes/admin/inventory-items/transaction/create-inventory-item.js.map +1 -0
- package/dist/api/routes/admin/products/update-product.d.ts +1 -1
- package/dist/api/routes/admin/products/update-product.js +116 -143
- package/dist/api/routes/admin/products/update-product.js.map +1 -1
- package/dist/helpers/test-request.js +26 -3
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/loaders/models.d.ts +2 -1
- package/dist/loaders/models.js +2 -2
- package/dist/loaders/models.js.map +1 -1
- package/dist/loaders/repositories.d.ts +2 -1
- package/dist/loaders/repositories.js +2 -2
- package/dist/loaders/repositories.js.map +1 -1
- package/dist/repositories/image.d.ts +3 -1
- package/dist/repositories/image.js +71 -49
- package/dist/repositories/image.js.map +1 -1
- package/dist/repositories/money-amount.d.ts +8 -2
- package/dist/repositories/money-amount.js +84 -33
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/staged-job.d.ts +1 -1
- package/dist/repositories/staged-job.js +3 -3
- package/dist/repositories/staged-job.js.map +1 -1
- package/dist/services/discount.js +4 -3
- package/dist/services/discount.js.map +1 -1
- package/dist/services/product-variant.d.ts +31 -6
- package/dist/services/product-variant.js +431 -231
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.js +30 -37
- package/dist/services/product.js.map +1 -1
- package/dist/services/staged-job.d.ts +3 -1
- package/dist/services/staged-job.js +46 -0
- package/dist/services/staged-job.js.map +1 -1
- package/dist/strategies/batch-jobs/product/import.js +5 -2
- package/dist/strategies/batch-jobs/product/import.js.map +1 -1
- package/dist/types/product-variant.d.ts +22 -1
- package/dist/types/product-variant.js.map +1 -1
- package/dist/utils/has-changes.d.ts +6 -0
- package/dist/utils/has-changes.js +60 -0
- package/dist/utils/has-changes.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/product-category/index.js +1 -14
- package/dist/utils/product-category/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { FindParams } from "../../../../types/common";
|
|
2
|
+
/**
|
|
3
|
+
* @oas [post] /admin/inventory-items
|
|
4
|
+
* operationId: "PostInventoryItems"
|
|
5
|
+
* summary: "Create an Inventory Item."
|
|
6
|
+
* description: "Creates an Inventory Item."
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* parameters:
|
|
9
|
+
* - (query) expand {string} Comma separated list of relations to include in the results.
|
|
10
|
+
* - (query) fields {string} Comma separated list of fields to include in the results.
|
|
11
|
+
* requestBody:
|
|
12
|
+
* content:
|
|
13
|
+
* application/json:
|
|
14
|
+
* schema:
|
|
15
|
+
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsReq"
|
|
16
|
+
* x-codeSamples:
|
|
17
|
+
* - lang: JavaScript
|
|
18
|
+
* label: JS Client
|
|
19
|
+
* source: |
|
|
20
|
+
* import Medusa from "@medusajs/medusa-js"
|
|
21
|
+
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
22
|
+
* // must be previously logged in or use api token
|
|
23
|
+
* medusa.admin.inventoryItems.create(inventoryItemId, {
|
|
24
|
+
* variant_id: 'variant_123',
|
|
25
|
+
* sku: "sku-123",
|
|
26
|
+
* })
|
|
27
|
+
* .then(({ inventory_item }) => {
|
|
28
|
+
* console.log(inventory_item.id);
|
|
29
|
+
* });
|
|
30
|
+
* - lang: Shell
|
|
31
|
+
* label: cURL
|
|
32
|
+
* source: |
|
|
33
|
+
* curl --location --request POST 'https://medusa-url.com/admin/inventory-items' \
|
|
34
|
+
* --header 'Authorization: Bearer {api_token}' \
|
|
35
|
+
* --header 'Content-Type: application/json' \
|
|
36
|
+
* --data-raw '{
|
|
37
|
+
* "variant_id": "variant_123",
|
|
38
|
+
* "sku": "sku-123",
|
|
39
|
+
* }'
|
|
40
|
+
* security:
|
|
41
|
+
* - api_token: []
|
|
42
|
+
* - cookie_auth: []
|
|
43
|
+
* tags:
|
|
44
|
+
* - Inventory Items
|
|
45
|
+
* responses:
|
|
46
|
+
* 200:
|
|
47
|
+
* description: OK
|
|
48
|
+
* content:
|
|
49
|
+
* application/json:
|
|
50
|
+
* schema:
|
|
51
|
+
* $ref: "#/components/schemas/AdminInventoryItemsRes"
|
|
52
|
+
* "400":
|
|
53
|
+
* $ref: "#/components/responses/400_error"
|
|
54
|
+
* "401":
|
|
55
|
+
* $ref: "#/components/responses/unauthorized"
|
|
56
|
+
* "404":
|
|
57
|
+
* $ref: "#/components/responses/not_found_error"
|
|
58
|
+
* "409":
|
|
59
|
+
* $ref: "#/components/responses/invalid_state_error"
|
|
60
|
+
* "422":
|
|
61
|
+
* $ref: "#/components/responses/invalid_request_error"
|
|
62
|
+
* "500":
|
|
63
|
+
* $ref: "#/components/responses/500_error"
|
|
64
|
+
*/
|
|
65
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
66
|
+
export default _default;
|
|
67
|
+
/**
|
|
68
|
+
* @schema AdminPostInventoryItemsReq
|
|
69
|
+
* type: object
|
|
70
|
+
* properties:
|
|
71
|
+
* sku:
|
|
72
|
+
* description: The unique SKU for the Product Variant.
|
|
73
|
+
* type: string
|
|
74
|
+
* ean:
|
|
75
|
+
* description: The EAN number of the item.
|
|
76
|
+
* type: string
|
|
77
|
+
* upc:
|
|
78
|
+
* description: The UPC number of the item.
|
|
79
|
+
* type: string
|
|
80
|
+
* barcode:
|
|
81
|
+
* description: A generic GTIN field for the Product Variant.
|
|
82
|
+
* type: string
|
|
83
|
+
* hs_code:
|
|
84
|
+
* description: The Harmonized System code for the Product Variant.
|
|
85
|
+
* type: string
|
|
86
|
+
* inventory_quantity:
|
|
87
|
+
* description: The amount of stock kept for the Product Variant.
|
|
88
|
+
* type: integer
|
|
89
|
+
* default: 0
|
|
90
|
+
* allow_backorder:
|
|
91
|
+
* description: Whether the Product Variant can be purchased when out of stock.
|
|
92
|
+
* type: boolean
|
|
93
|
+
* manage_inventory:
|
|
94
|
+
* description: Whether Medusa should keep track of the inventory for this Product Variant.
|
|
95
|
+
* type: boolean
|
|
96
|
+
* default: true
|
|
97
|
+
* weight:
|
|
98
|
+
* description: The wieght of the Product Variant.
|
|
99
|
+
* type: number
|
|
100
|
+
* length:
|
|
101
|
+
* description: The length of the Product Variant.
|
|
102
|
+
* type: number
|
|
103
|
+
* height:
|
|
104
|
+
* description: The height of the Product Variant.
|
|
105
|
+
* type: number
|
|
106
|
+
* width:
|
|
107
|
+
* description: The width of the Product Variant.
|
|
108
|
+
* type: number
|
|
109
|
+
* origin_country:
|
|
110
|
+
* description: The country of origin of the Product Variant.
|
|
111
|
+
* type: string
|
|
112
|
+
* mid_code:
|
|
113
|
+
* description: The Manufacturer Identification code for the Product Variant.
|
|
114
|
+
* type: string
|
|
115
|
+
* material:
|
|
116
|
+
* description: The material composition of the Product Variant.
|
|
117
|
+
* type: string
|
|
118
|
+
* metadata:
|
|
119
|
+
* description: An optional set of key-value pairs with additional information.
|
|
120
|
+
* type: object
|
|
121
|
+
*/
|
|
122
|
+
export declare class AdminPostInventoryItemsReq {
|
|
123
|
+
variant_id: string;
|
|
124
|
+
sku?: string;
|
|
125
|
+
hs_code?: string;
|
|
126
|
+
weight?: number;
|
|
127
|
+
length?: number;
|
|
128
|
+
height?: number;
|
|
129
|
+
width?: number;
|
|
130
|
+
origin_country?: string;
|
|
131
|
+
mid_code?: string;
|
|
132
|
+
material?: string;
|
|
133
|
+
metadata?: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
export declare class AdminPostInventoryItemsParams extends FindParams {
|
|
136
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
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;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
36
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
37
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
38
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
39
|
+
function step(op) {
|
|
40
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
41
|
+
while (_) try {
|
|
42
|
+
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;
|
|
43
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
44
|
+
switch (op[0]) {
|
|
45
|
+
case 0: case 1: t = op; break;
|
|
46
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
47
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
48
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
49
|
+
default:
|
|
50
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
51
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
52
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
53
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
54
|
+
if (t[2]) _.ops.pop();
|
|
55
|
+
_.trys.pop(); continue;
|
|
56
|
+
}
|
|
57
|
+
op = body.call(thisArg, _);
|
|
58
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
59
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
63
|
+
var t = {};
|
|
64
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
65
|
+
t[p] = s[p];
|
|
66
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
67
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
68
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
69
|
+
t[p[i]] = s[p[i]];
|
|
70
|
+
}
|
|
71
|
+
return t;
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.AdminPostInventoryItemsParams = exports.AdminPostInventoryItemsReq = void 0;
|
|
75
|
+
var class_validator_1 = require("class-validator");
|
|
76
|
+
var validator_1 = require("../../../../utils/validator");
|
|
77
|
+
var create_inventory_item_1 = require("./transaction/create-inventory-item");
|
|
78
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
79
|
+
var common_1 = require("../../../../types/common");
|
|
80
|
+
/**
|
|
81
|
+
* @oas [post] /admin/inventory-items
|
|
82
|
+
* operationId: "PostInventoryItems"
|
|
83
|
+
* summary: "Create an Inventory Item."
|
|
84
|
+
* description: "Creates an Inventory Item."
|
|
85
|
+
* x-authenticated: true
|
|
86
|
+
* parameters:
|
|
87
|
+
* - (query) expand {string} Comma separated list of relations to include in the results.
|
|
88
|
+
* - (query) fields {string} Comma separated list of fields to include in the results.
|
|
89
|
+
* requestBody:
|
|
90
|
+
* content:
|
|
91
|
+
* application/json:
|
|
92
|
+
* schema:
|
|
93
|
+
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsReq"
|
|
94
|
+
* x-codeSamples:
|
|
95
|
+
* - lang: JavaScript
|
|
96
|
+
* label: JS Client
|
|
97
|
+
* source: |
|
|
98
|
+
* import Medusa from "@medusajs/medusa-js"
|
|
99
|
+
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
100
|
+
* // must be previously logged in or use api token
|
|
101
|
+
* medusa.admin.inventoryItems.create(inventoryItemId, {
|
|
102
|
+
* variant_id: 'variant_123',
|
|
103
|
+
* sku: "sku-123",
|
|
104
|
+
* })
|
|
105
|
+
* .then(({ inventory_item }) => {
|
|
106
|
+
* console.log(inventory_item.id);
|
|
107
|
+
* });
|
|
108
|
+
* - lang: Shell
|
|
109
|
+
* label: cURL
|
|
110
|
+
* source: |
|
|
111
|
+
* curl --location --request POST 'https://medusa-url.com/admin/inventory-items' \
|
|
112
|
+
* --header 'Authorization: Bearer {api_token}' \
|
|
113
|
+
* --header 'Content-Type: application/json' \
|
|
114
|
+
* --data-raw '{
|
|
115
|
+
* "variant_id": "variant_123",
|
|
116
|
+
* "sku": "sku-123",
|
|
117
|
+
* }'
|
|
118
|
+
* security:
|
|
119
|
+
* - api_token: []
|
|
120
|
+
* - cookie_auth: []
|
|
121
|
+
* tags:
|
|
122
|
+
* - Inventory Items
|
|
123
|
+
* responses:
|
|
124
|
+
* 200:
|
|
125
|
+
* description: OK
|
|
126
|
+
* content:
|
|
127
|
+
* application/json:
|
|
128
|
+
* schema:
|
|
129
|
+
* $ref: "#/components/schemas/AdminInventoryItemsRes"
|
|
130
|
+
* "400":
|
|
131
|
+
* $ref: "#/components/responses/400_error"
|
|
132
|
+
* "401":
|
|
133
|
+
* $ref: "#/components/responses/unauthorized"
|
|
134
|
+
* "404":
|
|
135
|
+
* $ref: "#/components/responses/not_found_error"
|
|
136
|
+
* "409":
|
|
137
|
+
* $ref: "#/components/responses/invalid_state_error"
|
|
138
|
+
* "422":
|
|
139
|
+
* $ref: "#/components/responses/invalid_request_error"
|
|
140
|
+
* "500":
|
|
141
|
+
* $ref: "#/components/responses/500_error"
|
|
142
|
+
*/
|
|
143
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
|
+
var validated, variant_id, input, inventoryService, productVariantInventoryService, productVariantService, inventoryItems, manager, inventoryItem;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0: return [4 /*yield*/, (0, validator_1.validator)(AdminPostInventoryItemsReq, req.body)];
|
|
148
|
+
case 1:
|
|
149
|
+
validated = _a.sent();
|
|
150
|
+
variant_id = validated.variant_id, input = __rest(validated, ["variant_id"]);
|
|
151
|
+
inventoryService = req.scope.resolve("inventoryService");
|
|
152
|
+
productVariantInventoryService = req.scope.resolve("productVariantInventoryService");
|
|
153
|
+
productVariantService = req.scope.resolve("productVariantService");
|
|
154
|
+
return [4 /*yield*/, productVariantInventoryService.listByVariant(variant_id)
|
|
155
|
+
// TODO: this is a temporary fix to prevent duplicate inventory items since we don't support this functionality yet
|
|
156
|
+
];
|
|
157
|
+
case 2:
|
|
158
|
+
inventoryItems = _a.sent();
|
|
159
|
+
// TODO: this is a temporary fix to prevent duplicate inventory items since we don't support this functionality yet
|
|
160
|
+
if (inventoryItems.length) {
|
|
161
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_ALLOWED, "Inventory Item already exists for this variant");
|
|
162
|
+
}
|
|
163
|
+
manager = req.scope.resolve("manager");
|
|
164
|
+
return [4 /*yield*/, manager.transaction(function (transactionManager) { return __awaiter(void 0, void 0, void 0, function () {
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, (0, create_inventory_item_1.createInventoryItemTransaction)({
|
|
168
|
+
manager: transactionManager,
|
|
169
|
+
inventoryService: inventoryService,
|
|
170
|
+
productVariantInventoryService: productVariantInventoryService,
|
|
171
|
+
productVariantService: productVariantService,
|
|
172
|
+
}, variant_id, input)];
|
|
173
|
+
case 1:
|
|
174
|
+
_a.sent();
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}); })];
|
|
179
|
+
case 3:
|
|
180
|
+
_a.sent();
|
|
181
|
+
return [4 /*yield*/, productVariantInventoryService.listByVariant(variant_id)];
|
|
182
|
+
case 4:
|
|
183
|
+
inventoryItems = _a.sent();
|
|
184
|
+
return [4 /*yield*/, inventoryService.retrieveInventoryItem(inventoryItems[0].inventory_item_id, req.retrieveConfig)];
|
|
185
|
+
case 5:
|
|
186
|
+
inventoryItem = _a.sent();
|
|
187
|
+
res.status(200).json({ inventory_item: inventoryItem });
|
|
188
|
+
return [2 /*return*/];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}); });
|
|
192
|
+
/**
|
|
193
|
+
* @schema AdminPostInventoryItemsReq
|
|
194
|
+
* type: object
|
|
195
|
+
* properties:
|
|
196
|
+
* sku:
|
|
197
|
+
* description: The unique SKU for the Product Variant.
|
|
198
|
+
* type: string
|
|
199
|
+
* ean:
|
|
200
|
+
* description: The EAN number of the item.
|
|
201
|
+
* type: string
|
|
202
|
+
* upc:
|
|
203
|
+
* description: The UPC number of the item.
|
|
204
|
+
* type: string
|
|
205
|
+
* barcode:
|
|
206
|
+
* description: A generic GTIN field for the Product Variant.
|
|
207
|
+
* type: string
|
|
208
|
+
* hs_code:
|
|
209
|
+
* description: The Harmonized System code for the Product Variant.
|
|
210
|
+
* type: string
|
|
211
|
+
* inventory_quantity:
|
|
212
|
+
* description: The amount of stock kept for the Product Variant.
|
|
213
|
+
* type: integer
|
|
214
|
+
* default: 0
|
|
215
|
+
* allow_backorder:
|
|
216
|
+
* description: Whether the Product Variant can be purchased when out of stock.
|
|
217
|
+
* type: boolean
|
|
218
|
+
* manage_inventory:
|
|
219
|
+
* description: Whether Medusa should keep track of the inventory for this Product Variant.
|
|
220
|
+
* type: boolean
|
|
221
|
+
* default: true
|
|
222
|
+
* weight:
|
|
223
|
+
* description: The wieght of the Product Variant.
|
|
224
|
+
* type: number
|
|
225
|
+
* length:
|
|
226
|
+
* description: The length of the Product Variant.
|
|
227
|
+
* type: number
|
|
228
|
+
* height:
|
|
229
|
+
* description: The height of the Product Variant.
|
|
230
|
+
* type: number
|
|
231
|
+
* width:
|
|
232
|
+
* description: The width of the Product Variant.
|
|
233
|
+
* type: number
|
|
234
|
+
* origin_country:
|
|
235
|
+
* description: The country of origin of the Product Variant.
|
|
236
|
+
* type: string
|
|
237
|
+
* mid_code:
|
|
238
|
+
* description: The Manufacturer Identification code for the Product Variant.
|
|
239
|
+
* type: string
|
|
240
|
+
* material:
|
|
241
|
+
* description: The material composition of the Product Variant.
|
|
242
|
+
* type: string
|
|
243
|
+
* metadata:
|
|
244
|
+
* description: An optional set of key-value pairs with additional information.
|
|
245
|
+
* type: object
|
|
246
|
+
*/
|
|
247
|
+
var AdminPostInventoryItemsReq = /** @class */ (function () {
|
|
248
|
+
function AdminPostInventoryItemsReq() {
|
|
249
|
+
}
|
|
250
|
+
__decorate([
|
|
251
|
+
(0, class_validator_1.IsString)(),
|
|
252
|
+
__metadata("design:type", String)
|
|
253
|
+
], AdminPostInventoryItemsReq.prototype, "variant_id", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
(0, class_validator_1.IsString)(),
|
|
256
|
+
(0, class_validator_1.IsOptional)(),
|
|
257
|
+
__metadata("design:type", String)
|
|
258
|
+
], AdminPostInventoryItemsReq.prototype, "sku", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
(0, class_validator_1.IsString)(),
|
|
261
|
+
(0, class_validator_1.IsOptional)(),
|
|
262
|
+
__metadata("design:type", String)
|
|
263
|
+
], AdminPostInventoryItemsReq.prototype, "hs_code", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
(0, class_validator_1.IsNumber)(),
|
|
266
|
+
(0, class_validator_1.IsOptional)(),
|
|
267
|
+
__metadata("design:type", Number)
|
|
268
|
+
], AdminPostInventoryItemsReq.prototype, "weight", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
(0, class_validator_1.IsNumber)(),
|
|
271
|
+
(0, class_validator_1.IsOptional)(),
|
|
272
|
+
__metadata("design:type", Number)
|
|
273
|
+
], AdminPostInventoryItemsReq.prototype, "length", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
(0, class_validator_1.IsNumber)(),
|
|
276
|
+
(0, class_validator_1.IsOptional)(),
|
|
277
|
+
__metadata("design:type", Number)
|
|
278
|
+
], AdminPostInventoryItemsReq.prototype, "height", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
(0, class_validator_1.IsNumber)(),
|
|
281
|
+
(0, class_validator_1.IsOptional)(),
|
|
282
|
+
__metadata("design:type", Number)
|
|
283
|
+
], AdminPostInventoryItemsReq.prototype, "width", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
(0, class_validator_1.IsString)(),
|
|
286
|
+
(0, class_validator_1.IsOptional)(),
|
|
287
|
+
__metadata("design:type", String)
|
|
288
|
+
], AdminPostInventoryItemsReq.prototype, "origin_country", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
(0, class_validator_1.IsString)(),
|
|
291
|
+
(0, class_validator_1.IsOptional)(),
|
|
292
|
+
__metadata("design:type", String)
|
|
293
|
+
], AdminPostInventoryItemsReq.prototype, "mid_code", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
(0, class_validator_1.IsString)(),
|
|
296
|
+
(0, class_validator_1.IsOptional)(),
|
|
297
|
+
__metadata("design:type", String)
|
|
298
|
+
], AdminPostInventoryItemsReq.prototype, "material", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
(0, class_validator_1.IsObject)(),
|
|
301
|
+
(0, class_validator_1.IsOptional)(),
|
|
302
|
+
__metadata("design:type", Object)
|
|
303
|
+
], AdminPostInventoryItemsReq.prototype, "metadata", void 0);
|
|
304
|
+
return AdminPostInventoryItemsReq;
|
|
305
|
+
}());
|
|
306
|
+
exports.AdminPostInventoryItemsReq = AdminPostInventoryItemsReq;
|
|
307
|
+
var AdminPostInventoryItemsParams = /** @class */ (function (_super) {
|
|
308
|
+
__extends(AdminPostInventoryItemsParams, _super);
|
|
309
|
+
function AdminPostInventoryItemsParams() {
|
|
310
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
311
|
+
}
|
|
312
|
+
return AdminPostInventoryItemsParams;
|
|
313
|
+
}(common_1.FindParams));
|
|
314
|
+
exports.AdminPostInventoryItemsParams = AdminPostInventoryItemsParams;
|
|
315
|
+
//# sourceMappingURL=create-inventory-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-inventory-item.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/inventory-items/create-inventory-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA0E;AAM1E,yDAAuD;AAIvD,6EAAoF;AACpF,uDAA+C;AAC/C,mDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;oBACV,qBAAM,IAAA,qBAAS,EAAC,0BAA0B,EAAE,GAAG,CAAC,IAAI,CAAC,EAAA;;gBAAjE,SAAS,GAAG,SAAqD;gBAC/D,UAAU,GAAe,SAAS,WAAxB,EAAK,KAAK,UAAK,SAAS,EAApC,cAAwB,CAAF,CAAc;gBAEpC,gBAAgB,GACpB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;gBACjC,8BAA8B,GAClC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAA;gBAC/C,qBAAqB,GAA0B,GAAG,CAAC,KAAK,CAAC,OAAO,CACpE,uBAAuB,CACxB,CAAA;gBAEoB,qBAAM,8BAA8B,CAAC,aAAa,CACrE,UAAU,CACX;oBAED,mHAAmH;kBAFlH;;gBAFG,cAAc,GAAG,SAEpB;gBAED,mHAAmH;gBACnH,IAAI,cAAc,CAAC,MAAM,EAAE;oBACzB,MAAM,IAAI,+BAAW,CACnB,+BAAW,CAAC,KAAK,CAAC,WAAW,EAC7B,gDAAgD,CACjD,CAAA;iBACF;gBAEK,OAAO,GAAkB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;gBAE3D,qBAAM,OAAO,CAAC,WAAW,CAAC,UAAO,kBAAkB;;;wCACjD,qBAAM,IAAA,sDAA8B,EAClC;wCACE,OAAO,EAAE,kBAAkB;wCAC3B,gBAAgB,kBAAA;wCAChB,8BAA8B,gCAAA;wCAC9B,qBAAqB,uBAAA;qCACtB,EACD,UAAU,EACV,KAAK,CACN,EAAA;;oCATD,SASC,CAAA;;;;yBACF,CAAC,EAAA;;gBAXF,SAWE,CAAA;gBAEe,qBAAM,8BAA8B,CAAC,aAAa,CACjE,UAAU,CACX,EAAA;;gBAFD,cAAc,GAAG,SAEhB,CAAA;gBAEqB,qBAAM,gBAAgB,CAAC,qBAAqB,CAChE,cAAc,CAAC,CAAC,CAAC,CAAC,iBAAiB,EACnC,GAAG,CAAC,cAAc,CACnB,EAAA;;gBAHK,aAAa,GAAG,SAGrB;gBAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC,CAAA;;;;KACxD,EAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH;IAAA;IA2CA,CAAC;IAzCC;QADC,IAAA,0BAAQ,GAAE;;kEACO;IAIlB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;2DACD;IAIZ;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;+DACG;IAIhB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;8DACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;8DACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;8DACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;6DACC;IAId;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;sEACU;IAIvB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;gEACI;IAIjB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;gEACI;IAIjB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;gEACqB;IACpC,iCAAC;CAAA,AA3CD,IA2CC;AA3CY,gEAA0B;AA6CvC;IAAmD,iDAAU;IAA7D;;IAA+D,CAAC;IAAD,oCAAC;AAAD,CAAC,AAAhE,CAAmD,mBAAU,GAAG;AAAnD,sEAA6B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DistributedTransaction } from "../../../../../utils/transaction";
|
|
2
|
+
import { EntityManager } from "typeorm";
|
|
3
|
+
import { IInventoryService } from "../../../../../interfaces";
|
|
4
|
+
import { ProductVariantInventoryService, ProductVariantService } from "../../../../../services";
|
|
5
|
+
declare type InjectedDependencies = {
|
|
6
|
+
manager: EntityManager;
|
|
7
|
+
productVariantService: ProductVariantService;
|
|
8
|
+
productVariantInventoryService: ProductVariantInventoryService;
|
|
9
|
+
inventoryService: IInventoryService;
|
|
10
|
+
};
|
|
11
|
+
declare type CreateInventoryItemInput = {
|
|
12
|
+
sku?: string;
|
|
13
|
+
hs_code?: string;
|
|
14
|
+
weight?: number;
|
|
15
|
+
length?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
width?: number;
|
|
18
|
+
origin_country?: string;
|
|
19
|
+
mid_code?: string;
|
|
20
|
+
material?: string;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
export declare const createInventoryItemTransaction: (dependencies: InjectedDependencies, variantId: string, input: CreateInventoryItemInput) => Promise<DistributedTransaction>;
|
|
24
|
+
export declare const revertVariantTransaction: (transaction: DistributedTransaction) => Promise<void>;
|
|
25
|
+
export {};
|