@medusajs/medusa 1.1.63-adminc.7 → 1.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -25
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/routes/admin/collections/get-collection.js +6 -2
- package/dist/api/routes/admin/collections/get-collection.js.map +1 -1
- package/dist/api/routes/admin/collections/index.d.ts +1 -1
- package/dist/api/routes/admin/collections/index.js +2 -2
- package/dist/api/routes/admin/collections/index.js.map +1 -1
- package/dist/api/routes/admin/collections/list-collections.d.ts +1 -0
- package/dist/api/routes/admin/collections/list-collections.js +5 -0
- package/dist/api/routes/admin/collections/list-collections.js.map +1 -1
- package/dist/api/routes/admin/index.js +2 -0
- package/dist/api/routes/admin/index.js.map +1 -1
- package/dist/api/routes/admin/orders/create-swap.d.ts +2 -0
- package/dist/api/routes/admin/orders/create-swap.js +11 -0
- package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
- package/dist/api/routes/admin/product-tags/create-collection.d.ts +41 -0
- package/dist/api/routes/admin/product-tags/create-collection.js +125 -0
- package/dist/api/routes/admin/product-tags/create-collection.js.map +1 -0
- package/dist/api/routes/admin/product-tags/delete-collection.d.ts +28 -0
- package/dist/api/routes/admin/product-tags/delete-collection.js +84 -0
- package/dist/api/routes/admin/product-tags/delete-collection.js.map +1 -0
- package/dist/api/routes/admin/product-tags/get-collection.d.ts +22 -0
- package/dist/api/routes/admin/product-tags/get-collection.js +74 -0
- package/dist/api/routes/admin/product-tags/get-collection.js.map +1 -0
- package/dist/api/routes/admin/product-tags/index.d.ts +15 -0
- package/dist/api/routes/admin/product-tags/index.js +40 -0
- package/dist/api/routes/admin/product-tags/index.js.map +1 -0
- package/dist/api/routes/admin/product-tags/list-collections.d.ts +40 -0
- package/dist/api/routes/admin/product-tags/list-collections.js +215 -0
- package/dist/api/routes/admin/product-tags/list-collections.js.map +1 -0
- package/dist/api/routes/admin/product-tags/list-product-tags.d.ts +39 -0
- package/dist/api/routes/admin/product-tags/list-product-tags.js +211 -0
- package/dist/api/routes/admin/product-tags/list-product-tags.js.map +1 -0
- package/dist/api/routes/admin/product-tags/update-collection.d.ts +41 -0
- package/dist/api/routes/admin/product-tags/update-collection.js +127 -0
- package/dist/api/routes/admin/product-tags/update-collection.js.map +1 -0
- package/dist/api/routes/admin/products/list-products.js +27 -28
- package/dist/api/routes/admin/products/list-products.js.map +1 -1
- package/dist/services/product-collection.js +22 -2
- package/dist/services/product-collection.js.map +1 -1
- package/dist/services/product-tag.d.ts +48 -0
- package/dist/services/product-tag.js +180 -0
- package/dist/services/product-tag.js.map +1 -0
- package/dist/services/store.js +28 -16
- package/dist/services/store.js.map +1 -1
- package/dist/types/common.d.ts +3 -1
- package/dist/types/product.d.ts +7 -0
- package/dist/types/product.js +37 -1
- package/dist/types/product.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* @oas [post] /collections/{id}
|
|
4
|
+
* operationId: "PostCollectionsCollection"
|
|
5
|
+
* summary: "Update a Product Collection"
|
|
6
|
+
* description: "Updates a Product Collection."
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* parameters:
|
|
9
|
+
* - (path) id=* {string} The id of the Collection.
|
|
10
|
+
* requestBody:
|
|
11
|
+
* content:
|
|
12
|
+
* application/json:
|
|
13
|
+
* schema:
|
|
14
|
+
* properties:
|
|
15
|
+
* title:
|
|
16
|
+
* type: string
|
|
17
|
+
* description: The title to identify the Collection by.
|
|
18
|
+
* handle:
|
|
19
|
+
* type: string
|
|
20
|
+
* description: An optional handle to be used in slugs, if none is provided we will kebab-case the title.
|
|
21
|
+
* metadata:
|
|
22
|
+
* description: An optional set of key-value pairs to hold additional information.
|
|
23
|
+
* type: object
|
|
24
|
+
* tags:
|
|
25
|
+
* - Collection
|
|
26
|
+
* responses:
|
|
27
|
+
* "200":
|
|
28
|
+
* description: OK
|
|
29
|
+
* content:
|
|
30
|
+
* application/json:
|
|
31
|
+
* schema:
|
|
32
|
+
* properties:
|
|
33
|
+
* collection:
|
|
34
|
+
* $ref: "#/components/schemas/product_collection"
|
|
35
|
+
*/
|
|
36
|
+
export default _default;
|
|
37
|
+
export declare class AdminPostCollectionsCollectionReq {
|
|
38
|
+
title?: string;
|
|
39
|
+
handle?: string;
|
|
40
|
+
metadata?: object;
|
|
41
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
+
function step(op) {
|
|
25
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
+
while (_) try {
|
|
27
|
+
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;
|
|
28
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
+
switch (op[0]) {
|
|
30
|
+
case 0: case 1: t = op; break;
|
|
31
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
+
default:
|
|
35
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
+
if (t[2]) _.ops.pop();
|
|
40
|
+
_.trys.pop(); continue;
|
|
41
|
+
}
|
|
42
|
+
op = body.call(thisArg, _);
|
|
43
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AdminPostCollectionsCollectionReq = void 0;
|
|
49
|
+
var class_validator_1 = require("class-validator");
|
|
50
|
+
var validator_1 = require("../../../../utils/validator");
|
|
51
|
+
/**
|
|
52
|
+
* @oas [post] /collections/{id}
|
|
53
|
+
* operationId: "PostCollectionsCollection"
|
|
54
|
+
* summary: "Update a Product Collection"
|
|
55
|
+
* description: "Updates a Product Collection."
|
|
56
|
+
* x-authenticated: true
|
|
57
|
+
* parameters:
|
|
58
|
+
* - (path) id=* {string} The id of the Collection.
|
|
59
|
+
* requestBody:
|
|
60
|
+
* content:
|
|
61
|
+
* application/json:
|
|
62
|
+
* schema:
|
|
63
|
+
* properties:
|
|
64
|
+
* title:
|
|
65
|
+
* type: string
|
|
66
|
+
* description: The title to identify the Collection by.
|
|
67
|
+
* handle:
|
|
68
|
+
* type: string
|
|
69
|
+
* description: An optional handle to be used in slugs, if none is provided we will kebab-case the title.
|
|
70
|
+
* metadata:
|
|
71
|
+
* description: An optional set of key-value pairs to hold additional information.
|
|
72
|
+
* type: object
|
|
73
|
+
* tags:
|
|
74
|
+
* - Collection
|
|
75
|
+
* responses:
|
|
76
|
+
* "200":
|
|
77
|
+
* description: OK
|
|
78
|
+
* content:
|
|
79
|
+
* application/json:
|
|
80
|
+
* schema:
|
|
81
|
+
* properties:
|
|
82
|
+
* collection:
|
|
83
|
+
* $ref: "#/components/schemas/product_collection"
|
|
84
|
+
*/
|
|
85
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
var id, validated, productCollectionService, updated, collection;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
id = req.params.id;
|
|
91
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminPostCollectionsCollectionReq, req.body)];
|
|
92
|
+
case 1:
|
|
93
|
+
validated = _a.sent();
|
|
94
|
+
productCollectionService = req.scope.resolve("productCollectionService");
|
|
95
|
+
return [4 /*yield*/, productCollectionService.update(id, validated)];
|
|
96
|
+
case 2:
|
|
97
|
+
updated = _a.sent();
|
|
98
|
+
return [4 /*yield*/, productCollectionService.retrieve(updated.id)];
|
|
99
|
+
case 3:
|
|
100
|
+
collection = _a.sent();
|
|
101
|
+
res.status(200).json({ collection: collection });
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); });
|
|
106
|
+
var AdminPostCollectionsCollectionReq = /** @class */ (function () {
|
|
107
|
+
function AdminPostCollectionsCollectionReq() {
|
|
108
|
+
}
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, class_validator_1.IsString)(),
|
|
111
|
+
(0, class_validator_1.IsOptional)(),
|
|
112
|
+
__metadata("design:type", String)
|
|
113
|
+
], AdminPostCollectionsCollectionReq.prototype, "title", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, class_validator_1.IsString)(),
|
|
116
|
+
(0, class_validator_1.IsOptional)(),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], AdminPostCollectionsCollectionReq.prototype, "handle", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, class_validator_1.IsObject)(),
|
|
121
|
+
(0, class_validator_1.IsOptional)(),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], AdminPostCollectionsCollectionReq.prototype, "metadata", void 0);
|
|
124
|
+
return AdminPostCollectionsCollectionReq;
|
|
125
|
+
}());
|
|
126
|
+
exports.AdminPostCollectionsCollectionReq = AdminPostCollectionsCollectionReq;
|
|
127
|
+
//# sourceMappingURL=update-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-collection.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/product-tags/update-collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAgE;AAEhE,yDAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;gBACpB,EAAE,GAAK,GAAG,CAAC,MAAM,GAAf,CAAe;gBAEP,qBAAM,IAAA,qBAAS,EAAC,iCAAiC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAA;;gBAAxE,SAAS,GAAG,SAA4D;gBACxE,wBAAwB,GAA6B,GAAG,CAAC,KAAK,CAAC,OAAO,CAC1E,0BAA0B,CAC3B,CAAA;gBAEe,qBAAM,wBAAwB,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,EAAA;;gBAA9D,OAAO,GAAG,SAAoD;gBACjD,qBAAM,wBAAwB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAA;;gBAAhE,UAAU,GAAG,SAAmD;gBAEtE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,UAAU,YAAA,EAAE,CAAC,CAAA;;;;KACrC,EAAA;AAED;IAAA;IAYA,CAAC;IATC;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;oEACC;IAId;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;qEACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;uEACI;IACnB,wCAAC;CAAA,AAZD,IAYC;AAZY,8EAAiC"}
|
|
@@ -14,31 +14,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
17
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
30
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31
19
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
32
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;
|
|
33
21
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
34
22
|
};
|
|
35
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
36
|
-
if (mod && mod.__esModule) return mod;
|
|
37
|
-
var result = {};
|
|
38
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
39
|
-
__setModuleDefault(result, mod);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
23
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
43
24
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
44
25
|
};
|
|
@@ -98,7 +79,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
98
79
|
exports.AdminGetProductsParams = exports.AdminGetProductsPaginationParams = exports.ProductStatus = void 0;
|
|
99
80
|
var class_transformer_1 = require("class-transformer");
|
|
100
81
|
var class_validator_1 = require("class-validator");
|
|
101
|
-
var
|
|
82
|
+
var lodash_1 = require("lodash");
|
|
83
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
102
84
|
var _1 = require(".");
|
|
103
85
|
var common_1 = require("../../../../types/common");
|
|
104
86
|
var validator_1 = require("../../../../utils/validator");
|
|
@@ -151,12 +133,13 @@ var validator_1 = require("../../../../utils/validator");
|
|
|
151
133
|
* $ref: "#/components/schemas/product"
|
|
152
134
|
*/
|
|
153
135
|
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
154
|
-
var validatedParams, productService, includeFields, expandFields, listConfig,
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
var validatedParams, productService, includeFields, expandFields, listConfig, orderField, _a, field, filterableFields, _b, products, count;
|
|
137
|
+
var _c, _d;
|
|
138
|
+
return __generator(this, function (_e) {
|
|
139
|
+
switch (_e.label) {
|
|
157
140
|
case 0: return [4 /*yield*/, (0, validator_1.validator)(AdminGetProductsParams, req.query)];
|
|
158
141
|
case 1:
|
|
159
|
-
validatedParams =
|
|
142
|
+
validatedParams = _e.sent();
|
|
160
143
|
productService = req.scope.resolve("productService");
|
|
161
144
|
includeFields = [];
|
|
162
145
|
if (validatedParams.fields) {
|
|
@@ -167,23 +150,39 @@ exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0
|
|
|
167
150
|
expandFields = validatedParams.expand.split(",");
|
|
168
151
|
}
|
|
169
152
|
listConfig = {
|
|
170
|
-
select: includeFields.length
|
|
153
|
+
select: (includeFields.length
|
|
154
|
+
? includeFields
|
|
155
|
+
: _1.defaultAdminProductFields),
|
|
171
156
|
relations: expandFields.length
|
|
172
157
|
? expandFields
|
|
173
158
|
: _1.defaultAdminProductRelations,
|
|
174
159
|
skip: validatedParams.offset,
|
|
175
160
|
take: validatedParams.limit,
|
|
176
161
|
};
|
|
177
|
-
|
|
162
|
+
if (typeof validatedParams.order !== "undefined") {
|
|
163
|
+
orderField = validatedParams.order;
|
|
164
|
+
if (validatedParams.order.startsWith("-")) {
|
|
165
|
+
_a = __read(validatedParams.order.split("-"), 2), field = _a[1];
|
|
166
|
+
orderField = field;
|
|
167
|
+
listConfig.order = (_c = {}, _c[field] = "DESC", _c);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
listConfig.order = (_d = {}, _d[validatedParams.order] = "ASC", _d);
|
|
171
|
+
}
|
|
172
|
+
if (!_1.allowedAdminProductFields.includes(orderField)) {
|
|
173
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "Order field must be a valid product field");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
filterableFields = (0, lodash_1.omit)(validatedParams, [
|
|
178
177
|
"limit",
|
|
179
178
|
"offset",
|
|
180
179
|
"expand",
|
|
181
180
|
"fields",
|
|
182
181
|
"order",
|
|
183
182
|
]);
|
|
184
|
-
return [4 /*yield*/, productService.listAndCount(
|
|
183
|
+
return [4 /*yield*/, productService.listAndCount((0, lodash_1.pickBy)(filterableFields, function (val) { return typeof val !== "undefined"; }), listConfig)];
|
|
185
184
|
case 2:
|
|
186
|
-
|
|
185
|
+
_b = __read.apply(void 0, [_e.sent(), 2]), products = _b[0], count = _b[1];
|
|
187
186
|
res.json({
|
|
188
187
|
products: products,
|
|
189
188
|
count: count,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-products.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/products/list-products.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-products.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/products/list-products.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAwC;AACxC,mDAQwB;AACxB,iCAAqC;AACrC,uDAA+C;AAE/C,sBAIU;AAEV,mDAA6E;AAC7E,yDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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sB,CAAC;kCACtB,+BAAsB;8DAAA;IAKnC;QAHC,IAAA,4BAAU,GAAE;QACZ,IAAA,gCAAc,GAAE;QAChB,IAAA,wBAAI,EAAC,cAAM,OAAA,+BAAsB,EAAtB,CAAsB,CAAC;kCACtB,+BAAsB;8DAAA;IAKnC;QAHC,IAAA,gCAAc,GAAE;QAChB,IAAA,4BAAU,GAAE;QACZ,IAAA,wBAAI,EAAC,cAAM,OAAA,+BAAsB,EAAtB,CAAsB,CAAC;kCACtB,+BAAsB;8DAAA;IACrC,6BAAC;CAAA,AA5DD,CAA4C,gCAAgC,GA4D3E;AA5DY,wDAAsB"}
|
|
@@ -89,8 +89,9 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
89
89
|
return ar;
|
|
90
90
|
};
|
|
91
91
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
-
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
93
92
|
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
93
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
94
|
+
var typeorm_1 = require("typeorm");
|
|
94
95
|
/**
|
|
95
96
|
* Provides layer to manipulate product collections.
|
|
96
97
|
* @extends BaseService
|
|
@@ -303,12 +304,31 @@ var ProductCollectionService = /** @class */ (function (_super) {
|
|
|
303
304
|
if (selector === void 0) { selector = {}; }
|
|
304
305
|
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
305
306
|
return __awaiter(this, void 0, void 0, function () {
|
|
306
|
-
var productCollectionRepo, query;
|
|
307
|
+
var productCollectionRepo, q, query, where_1;
|
|
307
308
|
return __generator(this, function (_a) {
|
|
308
309
|
switch (_a.label) {
|
|
309
310
|
case 0:
|
|
310
311
|
productCollectionRepo = this.manager_.getCustomRepository(this.productCollectionRepository_);
|
|
312
|
+
if ("q" in selector) {
|
|
313
|
+
q = selector.q;
|
|
314
|
+
delete selector.q;
|
|
315
|
+
}
|
|
311
316
|
query = this.buildQuery_(selector, config);
|
|
317
|
+
if (q) {
|
|
318
|
+
where_1 = query.where;
|
|
319
|
+
delete where_1.title;
|
|
320
|
+
delete where_1.handle;
|
|
321
|
+
delete where_1.created_at;
|
|
322
|
+
delete where_1.updated_at;
|
|
323
|
+
query.where = function (qb) {
|
|
324
|
+
qb.where(where_1);
|
|
325
|
+
qb.andWhere(new typeorm_1.Brackets(function (qb) {
|
|
326
|
+
qb.where({ title: (0, typeorm_1.ILike)("%".concat(q, "%")) }).orWhere({
|
|
327
|
+
handle: (0, typeorm_1.ILike)("%".concat(q, "%")),
|
|
328
|
+
});
|
|
329
|
+
}));
|
|
330
|
+
};
|
|
331
|
+
}
|
|
312
332
|
return [4 /*yield*/, productCollectionRepo.findAndCount(query)];
|
|
313
333
|
case 1: return [2 /*return*/, _a.sent()];
|
|
314
334
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-collection.js","sourceRoot":"","sources":["../../src/services/product-collection.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;
|
|
1
|
+
{"version":3,"file":"product-collection.js","sourceRoot":"","sources":["../../src/services/product-collection.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;AAC/C,mCAAyC;AAEzC;;;GAGG;AACH;IAAuC,4CAAW;IAChD,kCAAY,EAKX;YAJC,OAAO,aAAA,EACP,2BAA2B,iCAAA,EAC3B,iBAAiB,uBAAA,EACjB,eAAe,qBAAA;QAJjB,YAME,iBAAO,SAaR;QAXC,sCAAsC;QACtC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QAEvB,oDAAoD;QACpD,KAAI,CAAC,4BAA4B,G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SAA+C,EAAA;;;;KACvD;IACH,+BAAC;AAAD,CAAC,AArND,CAAuC,+BAAW,GAqNjD;AAED,kBAAe,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EntityManager } from "typeorm";
|
|
2
|
+
import { BaseService } from "medusa-interfaces";
|
|
3
|
+
import { ProductTagRepository } from "../repositories/product-tag";
|
|
4
|
+
import { ProductTag } from "../models/product-tag";
|
|
5
|
+
import { FindConfig } from "../types/common";
|
|
6
|
+
import { FilterableProductTagProps } from "../types/product";
|
|
7
|
+
declare type ProductTagConstructorProps = {
|
|
8
|
+
manager: EntityManager;
|
|
9
|
+
productTagRepository: typeof ProductTagRepository;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Provides layer to manipulate product tags.
|
|
13
|
+
* @extends BaseService
|
|
14
|
+
*/
|
|
15
|
+
declare class ProductTagService extends BaseService {
|
|
16
|
+
private manager_;
|
|
17
|
+
private tagRepo_;
|
|
18
|
+
constructor({ manager, productTagRepository }: ProductTagConstructorProps);
|
|
19
|
+
withTransaction(transactionManager: EntityManager): ProductTagService;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves a product tag by id.
|
|
22
|
+
* @param {string} tagId - the id of the product tag to retrieve
|
|
23
|
+
* @param {Object} config - the config to retrieve the tag by
|
|
24
|
+
* @return {Promise<ProductTag>} the collection.
|
|
25
|
+
*/
|
|
26
|
+
retrieve(tagId: string, config?: FindConfig<ProductTag>): Promise<ProductTag>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a product tag
|
|
29
|
+
* @param {object} tag - the product tag to create
|
|
30
|
+
* @return {Promise<ProductTag>} created product tag
|
|
31
|
+
*/
|
|
32
|
+
create(tag: Partial<ProductTag>): Promise<ProductTag>;
|
|
33
|
+
/**
|
|
34
|
+
* Lists product tags
|
|
35
|
+
* @param {Object} selector - the query object for find
|
|
36
|
+
* @param {Object} config - the config to be used for find
|
|
37
|
+
* @return {Promise} the result of the find operation
|
|
38
|
+
*/
|
|
39
|
+
list(selector?: FilterableProductTagProps, config?: FindConfig<ProductTag>): Promise<ProductTag[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Lists product tags and adds count.
|
|
42
|
+
* @param {Object} selector - the query object for find
|
|
43
|
+
* @param {Object} config - the config to be used for find
|
|
44
|
+
* @return {Promise} the result of the find operation
|
|
45
|
+
*/
|
|
46
|
+
listAndCount(selector?: FilterableProductTagProps, config?: FindConfig<ProductTag>): Promise<[ProductTag[], number]>;
|
|
47
|
+
}
|
|
48
|
+
export default ProductTagService;
|
|
@@ -0,0 +1,180 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
55
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
56
|
+
/**
|
|
57
|
+
* Provides layer to manipulate product tags.
|
|
58
|
+
* @extends BaseService
|
|
59
|
+
*/
|
|
60
|
+
var ProductTagService = /** @class */ (function (_super) {
|
|
61
|
+
__extends(ProductTagService, _super);
|
|
62
|
+
function ProductTagService(_a) {
|
|
63
|
+
var manager = _a.manager, productTagRepository = _a.productTagRepository;
|
|
64
|
+
var _this = _super.call(this) || this;
|
|
65
|
+
_this.manager_ = manager;
|
|
66
|
+
_this.tagRepo_ = productTagRepository;
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
ProductTagService.prototype.withTransaction = function (transactionManager) {
|
|
70
|
+
if (!transactionManager) {
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
var cloned = new ProductTagService({
|
|
74
|
+
manager: transactionManager,
|
|
75
|
+
productTagRepository: this.tagRepo_,
|
|
76
|
+
});
|
|
77
|
+
cloned.transactionManager_ = transactionManager;
|
|
78
|
+
return cloned;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves a product tag by id.
|
|
82
|
+
* @param {string} tagId - the id of the product tag to retrieve
|
|
83
|
+
* @param {Object} config - the config to retrieve the tag by
|
|
84
|
+
* @return {Promise<ProductTag>} the collection.
|
|
85
|
+
*/
|
|
86
|
+
ProductTagService.prototype.retrieve = function (tagId, config) {
|
|
87
|
+
if (config === void 0) { config = {}; }
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var tagRepo, query, tag;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0:
|
|
93
|
+
tagRepo = this.manager_.getCustomRepository(this.tagRepo_);
|
|
94
|
+
query = this.buildQuery_({ id: tagId }, config);
|
|
95
|
+
return [4 /*yield*/, tagRepo.findOne(query)];
|
|
96
|
+
case 1:
|
|
97
|
+
tag = _a.sent();
|
|
98
|
+
if (!tag) {
|
|
99
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Product tag with id: ".concat(tagId, " was not found"));
|
|
100
|
+
}
|
|
101
|
+
return [2 /*return*/, tag];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Creates a product tag
|
|
108
|
+
* @param {object} tag - the product tag to create
|
|
109
|
+
* @return {Promise<ProductTag>} created product tag
|
|
110
|
+
*/
|
|
111
|
+
ProductTagService.prototype.create = function (tag) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var _this = this;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
117
|
+
var tagRepo, productTag;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
tagRepo = manager.getCustomRepository(this.tagRepo_);
|
|
122
|
+
productTag = tagRepo.create(tag);
|
|
123
|
+
return [4 /*yield*/, tagRepo.save(productTag)];
|
|
124
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}); })];
|
|
128
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Lists product tags
|
|
135
|
+
* @param {Object} selector - the query object for find
|
|
136
|
+
* @param {Object} config - the config to be used for find
|
|
137
|
+
* @return {Promise} the result of the find operation
|
|
138
|
+
*/
|
|
139
|
+
ProductTagService.prototype.list = function (selector, config) {
|
|
140
|
+
if (selector === void 0) { selector = {}; }
|
|
141
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
142
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
+
var tagRepo, query;
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
tagRepo = this.manager_.getCustomRepository(this.tagRepo_);
|
|
148
|
+
query = this.buildQuery_(selector, config);
|
|
149
|
+
return [4 /*yield*/, tagRepo.find(query)];
|
|
150
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Lists product tags and adds count.
|
|
157
|
+
* @param {Object} selector - the query object for find
|
|
158
|
+
* @param {Object} config - the config to be used for find
|
|
159
|
+
* @return {Promise} the result of the find operation
|
|
160
|
+
*/
|
|
161
|
+
ProductTagService.prototype.listAndCount = function (selector, config) {
|
|
162
|
+
if (selector === void 0) { selector = {}; }
|
|
163
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
164
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
+
var tagRepo, query;
|
|
166
|
+
return __generator(this, function (_a) {
|
|
167
|
+
switch (_a.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
tagRepo = this.manager_.getCustomRepository(this.tagRepo_);
|
|
170
|
+
query = this.buildQuery_(selector, config);
|
|
171
|
+
return [4 /*yield*/, tagRepo.findAndCount(query)];
|
|
172
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
return ProductTagService;
|
|
178
|
+
}(medusa_interfaces_1.BaseService));
|
|
179
|
+
exports.default = ProductTagService;
|
|
180
|
+
//# sourceMappingURL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