@medusajs/medusa 1.1.63-adminc.21 → 1.1.63-alpha.9
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/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/index.js +2 -0
- package/dist/api/routes/admin/index.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/api/routes/admin/variants/list-variants.js +24 -8
- package/dist/api/routes/admin/variants/list-variants.js.map +1 -1
- package/dist/repositories/product-variant.d.ts +12 -1
- package/dist/repositories/product-variant.js +304 -0
- package/dist/repositories/product-variant.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/product-variant.d.ts +30 -1
- package/dist/services/product-variant.js +92 -0
- package/dist/services/product-variant.js.map +1 -1
- 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
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;oBACJ,qBAAM,IAAA,qBAAS,EAAC,sBAAsB,EAAE,GAAG,CAAC,KAAK,CAAC,EAAA;;gBAApE,eAAe,GAAG,SAAkD;gBAEpE,cAAc,GAAmB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;gBAEtE,aAAa,GAAa,EAAE,CAAA;gBAChC,IAAI,eAAe,CAAC,MAAM,EAAE;oBAC1B,aAAa,GAAG,eAAe,CAAC,MAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;iBACnD;gBAEG,YAAY,GAAa,EAAE,CAAA;gBAC/B,IAAI,eAAe,CAAC,MAAM,EAAE;oBAC1B,YAAY,GAAG,eAAe,CAAC,MAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;iBAClD;gBAEK,UAAU,GAAwB;oBACtC,MAA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,IAAA,4BAAU,GAAE;;iEACW;IAIxB;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;wDACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;yDACC;IAId;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;+DACO;IAIpB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;0DACE;IAKf;QAHC,IAAA,2BAAS,GAAE;QACX,IAAA,4BAAU,GAAE;QACZ,IAAA,wBAAI,EAAC,cAAM,OAAA,OAAO,EAAP,CAAO,CAAC;;+DACA;IAIpB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;wDACA;IAIb;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;yDACC;IAKd;QAHC,IAAA,4BAAU,GAAE;QACZ,IAAA,gCAAc,GAAE;QAChB,IAAA,wBAAI,EAAC,cAAM,OAAA,+BAAsB,EAAtB,CAAsB,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"}
|
|
@@ -44,6 +44,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
44
44
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
+
if (!m) return o;
|
|
50
|
+
var i = m.call(o), r, ar = [], e;
|
|
51
|
+
try {
|
|
52
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) { e = { error: error }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e) throw e.error; }
|
|
60
|
+
}
|
|
61
|
+
return ar;
|
|
62
|
+
};
|
|
47
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
64
|
exports.AdminGetVariantsParams = void 0;
|
|
49
65
|
var _1 = require("./");
|
|
@@ -75,17 +91,17 @@ var class_validator_1 = require("class-validator");
|
|
|
75
91
|
* $ref: "#/components/schemas/product_variant"
|
|
76
92
|
*/
|
|
77
93
|
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var variantService, _a, offset, limit, q, selector, listConfig, variants;
|
|
79
|
-
return __generator(this, function (
|
|
80
|
-
switch (
|
|
94
|
+
var variantService, _a, offset, limit, q, selector, listConfig, _b, variants, count;
|
|
95
|
+
return __generator(this, function (_c) {
|
|
96
|
+
switch (_c.label) {
|
|
81
97
|
case 0:
|
|
82
98
|
variantService = req.scope.resolve("productVariantService");
|
|
83
99
|
return [4 /*yield*/, (0, validator_1.validator)(AdminGetVariantsParams, req.query)];
|
|
84
100
|
case 1:
|
|
85
|
-
_a =
|
|
101
|
+
_a = _c.sent(), offset = _a.offset, limit = _a.limit, q = _a.q;
|
|
86
102
|
selector = {};
|
|
87
103
|
if ("q" in req.query) {
|
|
88
|
-
selector.q =
|
|
104
|
+
selector.q = q;
|
|
89
105
|
}
|
|
90
106
|
listConfig = {
|
|
91
107
|
select: _1.defaultAdminVariantFields,
|
|
@@ -93,10 +109,10 @@ exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0
|
|
|
93
109
|
skip: offset,
|
|
94
110
|
take: limit,
|
|
95
111
|
};
|
|
96
|
-
return [4 /*yield*/, variantService.
|
|
112
|
+
return [4 /*yield*/, variantService.listAndCount(selector, listConfig)];
|
|
97
113
|
case 2:
|
|
98
|
-
|
|
99
|
-
res.json({ variants: variants, count:
|
|
114
|
+
_b = __read.apply(void 0, [_c.sent(), 2]), variants = _b[0], count = _b[1];
|
|
115
|
+
res.json({ variants: variants, count: count, offset: offset, limit: limit });
|
|
100
116
|
return [2 /*return*/];
|
|
101
117
|
}
|
|
102
118
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-variants.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/variants/list-variants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-variants.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/variants/list-variants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAA4E;AAM5E,yDAAuD;AACvD,uDAAwC;AACxC,mDAA6D;AAC7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;gBACtB,cAAc,GAA0B,GAAG,CAAC,KAAK,CAAC,OAAO,CAC7D,uBAAuB,CACxB,CAAA;gBAE4B,qBAAM,IAAA,qBAAS,EAC1C,sBAAsB,EACtB,GAAG,CAAC,KAAK,CACV,EAAA;;gBAHK,KAAuB,SAG5B,EAHO,MAAM,YAAA,EAAE,KAAK,WAAA,EAAE,CAAC,OAAA;gBAKlB,QAAQ,GAAkC,EAAE,CAAA;gBAElD,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE;oBACpB,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAA;iBACf;gBAEK,UAAU,GAA+B;oBAC7C,MAAM,EAAE,4BAAyB;oBACjC,SAAS,EAAE,+BAA4B;oBACvC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,KAAK;iBACZ,CAAA;gBAEyB,qBAAM,cAAc,CAAC,YAAY,CACzD,QAAQ,EACR,UAAU,CACX,EAAA;;gBAHK,KAAA,sBAAoB,SAGzB,KAAA,EAHM,QAAQ,QAAA,EAAE,KAAK,QAAA;gBAKtB,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,UAAA,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,KAAK,OAAA,EAAE,CAAC,CAAA;;;;KAC7C,EAAA;AAED;IAAA;QAQE,UAAK,GAAY,EAAE,CAAA;QAKnB,WAAM,GAAY,CAAC,CAAA;IACrB,CAAC;IAXC;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;qDACH;IAKV;QAHC,IAAA,uBAAK,GAAE;QACP,IAAA,4BAAU,GAAE;QACZ,IAAA,wBAAI,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC;;yDACA;IAKnB;QAHC,IAAA,uBAAK,GAAE;QACP,IAAA,4BAAU,GAAE;QACZ,IAAA,wBAAI,EAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC;;0DACA;IACrB,6BAAC;CAAA,AAdD,IAcC;AAdY,wDAAsB"}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import { Repository } from "typeorm";
|
|
1
|
+
import { FindManyOptions, OrderByCondition, Repository } from "typeorm";
|
|
2
2
|
import { ProductVariant } from "../models/product-variant";
|
|
3
|
+
export declare type FindWithRelationsOptions = FindManyOptions<ProductVariant> & {
|
|
4
|
+
order?: OrderByCondition;
|
|
5
|
+
withDeleted?: boolean;
|
|
6
|
+
};
|
|
3
7
|
export declare class ProductVariantRepository extends Repository<ProductVariant> {
|
|
8
|
+
private mergeEntitiesWithRelations;
|
|
9
|
+
private queryProductsVariants;
|
|
10
|
+
private getGroupedRelations;
|
|
11
|
+
private queryProductVariantsWithIds;
|
|
12
|
+
findWithRelationsAndCount(relations?: string[], idsOrOptionsWithoutRelations?: FindWithRelationsOptions | string[], withDeleted?: boolean): Promise<[ProductVariant[], number]>;
|
|
13
|
+
findWithRelations(relations?: string[], idsOrOptionsWithoutRelations?: FindWithRelationsOptions | string[], withDeleted?: boolean): Promise<ProductVariant[]>;
|
|
14
|
+
findOneWithRelations(relations?: Array<keyof ProductVariant>, optionsWithoutRelations?: FindWithRelationsOptions): Promise<ProductVariant>;
|
|
4
15
|
}
|
|
@@ -20,15 +20,319 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
20
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
21
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
22
|
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (_) try {
|
|
39
|
+
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;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
60
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
61
|
+
if (!m) return o;
|
|
62
|
+
var i = m.call(o), r, ar = [], e;
|
|
63
|
+
try {
|
|
64
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
65
|
+
}
|
|
66
|
+
catch (error) { e = { error: error }; }
|
|
67
|
+
finally {
|
|
68
|
+
try {
|
|
69
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
70
|
+
}
|
|
71
|
+
finally { if (e) throw e.error; }
|
|
72
|
+
}
|
|
73
|
+
return ar;
|
|
74
|
+
};
|
|
75
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
76
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
77
|
+
if (ar || !(i in from)) {
|
|
78
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
79
|
+
ar[i] = from[i];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
83
|
+
};
|
|
84
|
+
var __values = (this && this.__values) || function(o) {
|
|
85
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
86
|
+
if (m) return m.call(o);
|
|
87
|
+
if (o && typeof o.length === "number") return {
|
|
88
|
+
next: function () {
|
|
89
|
+
if (o && i >= o.length) o = void 0;
|
|
90
|
+
return { value: o && o[i++], done: !o };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
94
|
+
};
|
|
23
95
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
96
|
exports.ProductVariantRepository = void 0;
|
|
25
97
|
var typeorm_1 = require("typeorm");
|
|
98
|
+
var lodash_1 = require("lodash");
|
|
26
99
|
var product_variant_1 = require("../models/product-variant");
|
|
27
100
|
var ProductVariantRepository = /** @class */ (function (_super) {
|
|
28
101
|
__extends(ProductVariantRepository, _super);
|
|
29
102
|
function ProductVariantRepository() {
|
|
30
103
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
31
104
|
}
|
|
105
|
+
ProductVariantRepository.prototype.mergeEntitiesWithRelations = function (entitiesAndRelations) {
|
|
106
|
+
var entitiesAndRelationsById = (0, lodash_1.groupBy)(entitiesAndRelations, "id");
|
|
107
|
+
return (0, lodash_1.map)(entitiesAndRelationsById, function (entityAndRelations) {
|
|
108
|
+
return lodash_1.merge.apply(void 0, __spreadArray([{}], __read(entityAndRelations), false));
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
ProductVariantRepository.prototype.queryProductsVariants = function (optionsWithoutRelations, shouldCount) {
|
|
112
|
+
if (shouldCount === void 0) { shouldCount = false; }
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var qb, entities, count, result;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
qb = this.createQueryBuilder("pv")
|
|
119
|
+
.select(["pv.id"])
|
|
120
|
+
.skip(optionsWithoutRelations.skip)
|
|
121
|
+
.take(optionsWithoutRelations.take);
|
|
122
|
+
qb = optionsWithoutRelations.where
|
|
123
|
+
? qb.where(optionsWithoutRelations.where)
|
|
124
|
+
: qb;
|
|
125
|
+
qb = optionsWithoutRelations.order
|
|
126
|
+
? qb.orderBy(optionsWithoutRelations.order)
|
|
127
|
+
: qb;
|
|
128
|
+
if (optionsWithoutRelations.withDeleted) {
|
|
129
|
+
qb = qb.withDeleted();
|
|
130
|
+
}
|
|
131
|
+
count = 0;
|
|
132
|
+
if (!shouldCount) return [3 /*break*/, 2];
|
|
133
|
+
return [4 /*yield*/, qb.getManyAndCount()];
|
|
134
|
+
case 1:
|
|
135
|
+
result = _a.sent();
|
|
136
|
+
entities = result[0];
|
|
137
|
+
count = result[1];
|
|
138
|
+
return [3 /*break*/, 4];
|
|
139
|
+
case 2: return [4 /*yield*/, qb.getMany()];
|
|
140
|
+
case 3:
|
|
141
|
+
entities = _a.sent();
|
|
142
|
+
_a.label = 4;
|
|
143
|
+
case 4: return [2 /*return*/, [entities, count]];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
ProductVariantRepository.prototype.getGroupedRelations = function (relations) {
|
|
149
|
+
var e_1, _a;
|
|
150
|
+
var groupedRelations = {};
|
|
151
|
+
try {
|
|
152
|
+
for (var relations_1 = __values(relations), relations_1_1 = relations_1.next(); !relations_1_1.done; relations_1_1 = relations_1.next()) {
|
|
153
|
+
var rel = relations_1_1.value;
|
|
154
|
+
var _b = __read(rel.split("."), 1), topLevel = _b[0];
|
|
155
|
+
if (groupedRelations[topLevel]) {
|
|
156
|
+
groupedRelations[topLevel].push(rel);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
groupedRelations[topLevel] = [rel];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
164
|
+
finally {
|
|
165
|
+
try {
|
|
166
|
+
if (relations_1_1 && !relations_1_1.done && (_a = relations_1.return)) _a.call(relations_1);
|
|
167
|
+
}
|
|
168
|
+
finally { if (e_1) throw e_1.error; }
|
|
169
|
+
}
|
|
170
|
+
return groupedRelations;
|
|
171
|
+
};
|
|
172
|
+
ProductVariantRepository.prototype.queryProductVariantsWithIds = function (entityIds, groupedRelations, withDeleted) {
|
|
173
|
+
if (withDeleted === void 0) { withDeleted = false; }
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var entitiesIdsWithRelations;
|
|
176
|
+
var _this = this;
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
switch (_a.label) {
|
|
179
|
+
case 0: return [4 /*yield*/, Promise.all(Object.entries(groupedRelations).map(function (_a) {
|
|
180
|
+
var e_2, _b;
|
|
181
|
+
var _c = __read(_a, 2), toplevel = _c[0], rels = _c[1];
|
|
182
|
+
var querybuilder = _this.createQueryBuilder("pv");
|
|
183
|
+
querybuilder = querybuilder.leftJoinAndSelect("pv.".concat(toplevel), toplevel);
|
|
184
|
+
try {
|
|
185
|
+
for (var rels_1 = __values(rels), rels_1_1 = rels_1.next(); !rels_1_1.done; rels_1_1 = rels_1.next()) {
|
|
186
|
+
var rel = rels_1_1.value;
|
|
187
|
+
var _d = __read(rel.split("."), 2), _1 = _d[0], rest = _d[1];
|
|
188
|
+
if (!rest) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
// Regex matches all '.' except the rightmost
|
|
192
|
+
querybuilder = querybuilder.leftJoinAndSelect(rel.replace(/\.(?=[^.]*\.)/g, "__"), rel.replace(".", "__"));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
196
|
+
finally {
|
|
197
|
+
try {
|
|
198
|
+
if (rels_1_1 && !rels_1_1.done && (_b = rels_1.return)) _b.call(rels_1);
|
|
199
|
+
}
|
|
200
|
+
finally { if (e_2) throw e_2.error; }
|
|
201
|
+
}
|
|
202
|
+
if (withDeleted) {
|
|
203
|
+
querybuilder = querybuilder
|
|
204
|
+
.where("pv.id IN (:...entitiesIds)", {
|
|
205
|
+
entitiesIds: entityIds,
|
|
206
|
+
})
|
|
207
|
+
.withDeleted();
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
querybuilder = querybuilder.where("pv.deleted_at IS NULL AND pv.id IN (:...entitiesIds)", {
|
|
211
|
+
entitiesIds: entityIds,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return querybuilder.getMany();
|
|
215
|
+
})).then(lodash_1.flatten)];
|
|
216
|
+
case 1:
|
|
217
|
+
entitiesIdsWithRelations = _a.sent();
|
|
218
|
+
return [2 /*return*/, entitiesIdsWithRelations];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
ProductVariantRepository.prototype.findWithRelationsAndCount = function (relations, idsOrOptionsWithoutRelations, withDeleted) {
|
|
224
|
+
if (relations === void 0) { relations = []; }
|
|
225
|
+
if (idsOrOptionsWithoutRelations === void 0) { idsOrOptionsWithoutRelations = {
|
|
226
|
+
where: {},
|
|
227
|
+
}; }
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var count, entities, result, entitiesIds, toReturn, groupedRelations, entitiesIdsWithRelations, entitiesAndRelations, entitiesToReturn;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
if (!Array.isArray(idsOrOptionsWithoutRelations)) return [3 /*break*/, 2];
|
|
234
|
+
return [4 /*yield*/, this.findByIds(idsOrOptionsWithoutRelations, {
|
|
235
|
+
withDeleted: withDeleted !== null && withDeleted !== void 0 ? withDeleted : false,
|
|
236
|
+
})];
|
|
237
|
+
case 1:
|
|
238
|
+
entities = _a.sent();
|
|
239
|
+
count = entities.length;
|
|
240
|
+
return [3 /*break*/, 4];
|
|
241
|
+
case 2: return [4 /*yield*/, this.queryProductsVariants(idsOrOptionsWithoutRelations, true)];
|
|
242
|
+
case 3:
|
|
243
|
+
result = _a.sent();
|
|
244
|
+
entities = result[0];
|
|
245
|
+
count = result[1];
|
|
246
|
+
_a.label = 4;
|
|
247
|
+
case 4:
|
|
248
|
+
entitiesIds = entities.map(function (_a) {
|
|
249
|
+
var id = _a.id;
|
|
250
|
+
return id;
|
|
251
|
+
});
|
|
252
|
+
if (entitiesIds.length === 0) {
|
|
253
|
+
// no need to continue
|
|
254
|
+
return [2 /*return*/, [[], count]];
|
|
255
|
+
}
|
|
256
|
+
if (!(relations.length === 0)) return [3 /*break*/, 6];
|
|
257
|
+
return [4 /*yield*/, this.findByIds(entitiesIds, idsOrOptionsWithoutRelations)];
|
|
258
|
+
case 5:
|
|
259
|
+
toReturn = _a.sent();
|
|
260
|
+
return [2 /*return*/, [toReturn, toReturn.length]];
|
|
261
|
+
case 6:
|
|
262
|
+
groupedRelations = this.getGroupedRelations(relations);
|
|
263
|
+
return [4 /*yield*/, this.queryProductVariantsWithIds(entitiesIds, groupedRelations, withDeleted)];
|
|
264
|
+
case 7:
|
|
265
|
+
entitiesIdsWithRelations = _a.sent();
|
|
266
|
+
entitiesAndRelations = entitiesIdsWithRelations.concat(entities);
|
|
267
|
+
entitiesToReturn = this.mergeEntitiesWithRelations(entitiesAndRelations);
|
|
268
|
+
return [2 /*return*/, [entitiesToReturn, count]];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
ProductVariantRepository.prototype.findWithRelations = function (relations, idsOrOptionsWithoutRelations, withDeleted) {
|
|
274
|
+
if (relations === void 0) { relations = []; }
|
|
275
|
+
if (idsOrOptionsWithoutRelations === void 0) { idsOrOptionsWithoutRelations = {}; }
|
|
276
|
+
if (withDeleted === void 0) { withDeleted = false; }
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
var entities, result, entitiesIds, groupedRelations, entitiesIdsWithRelations, entitiesAndRelations, entitiesToReturn;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
if (!Array.isArray(idsOrOptionsWithoutRelations)) return [3 /*break*/, 2];
|
|
283
|
+
return [4 /*yield*/, this.findByIds(idsOrOptionsWithoutRelations, {
|
|
284
|
+
withDeleted: withDeleted,
|
|
285
|
+
})];
|
|
286
|
+
case 1:
|
|
287
|
+
entities = _a.sent();
|
|
288
|
+
return [3 /*break*/, 4];
|
|
289
|
+
case 2: return [4 /*yield*/, this.queryProductsVariants(idsOrOptionsWithoutRelations, false)];
|
|
290
|
+
case 3:
|
|
291
|
+
result = _a.sent();
|
|
292
|
+
entities = result[0];
|
|
293
|
+
_a.label = 4;
|
|
294
|
+
case 4:
|
|
295
|
+
entitiesIds = entities.map(function (_a) {
|
|
296
|
+
var id = _a.id;
|
|
297
|
+
return id;
|
|
298
|
+
});
|
|
299
|
+
if (entitiesIds.length === 0) {
|
|
300
|
+
// no need to continue
|
|
301
|
+
return [2 /*return*/, []];
|
|
302
|
+
}
|
|
303
|
+
if (!(relations.length === 0)) return [3 /*break*/, 6];
|
|
304
|
+
return [4 /*yield*/, this.findByIds(entitiesIds, idsOrOptionsWithoutRelations)];
|
|
305
|
+
case 5: return [2 /*return*/, _a.sent()];
|
|
306
|
+
case 6:
|
|
307
|
+
groupedRelations = this.getGroupedRelations(relations);
|
|
308
|
+
return [4 /*yield*/, this.queryProductVariantsWithIds(entitiesIds, groupedRelations, withDeleted)];
|
|
309
|
+
case 7:
|
|
310
|
+
entitiesIdsWithRelations = _a.sent();
|
|
311
|
+
entitiesAndRelations = entitiesIdsWithRelations.concat(entities);
|
|
312
|
+
entitiesToReturn = this.mergeEntitiesWithRelations(entitiesAndRelations);
|
|
313
|
+
return [2 /*return*/, entitiesToReturn];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
ProductVariantRepository.prototype.findOneWithRelations = function (relations, optionsWithoutRelations) {
|
|
319
|
+
if (relations === void 0) { relations = []; }
|
|
320
|
+
if (optionsWithoutRelations === void 0) { optionsWithoutRelations = { where: {} }; }
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var result;
|
|
323
|
+
return __generator(this, function (_a) {
|
|
324
|
+
switch (_a.label) {
|
|
325
|
+
case 0:
|
|
326
|
+
// Limit 1
|
|
327
|
+
optionsWithoutRelations.take = 1;
|
|
328
|
+
return [4 /*yield*/, this.findWithRelations(relations, optionsWithoutRelations)];
|
|
329
|
+
case 1:
|
|
330
|
+
result = _a.sent();
|
|
331
|
+
return [2 /*return*/, result[0]];
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
};
|
|
32
336
|
ProductVariantRepository = __decorate([
|
|
33
337
|
(0, typeorm_1.EntityRepository)(product_variant_1.ProductVariant)
|
|
34
338
|
], ProductVariantRepository);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-variant.js","sourceRoot":"","sources":["../../src/repositories/product-variant.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"product-variant.js","sourceRoot":"","sources":["../../src/repositories/product-variant.ts"],"names":[],"mappings":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;wBAEjE,UAAU;wBACV,uBAAuB,CAAC,IAAI,GAAG,CAAC,CAAA;wBAEjB,qBAAM,IAAI,CAAC,iBAAiB,CACzC,SAAS,EACT,uBAAuB,CACxB,EAAA;;wBAHK,MAAM,GAAG,SAGd;wBACD,sBAAO,MAAM,CAAC,CAAC,CAAC,EAAA;;;;KACjB;IA3NU,wBAAwB;QADpC,IAAA,0BAAgB,EAAC,gCAAc,CAAC;OACpB,wBAAwB,CA4NpC;IAAD,+BAAC;CAAA,AA5ND,CAA8C,oBAAU,GA4NvD;AA5NY,4DAAwB"}
|
|
@@ -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;
|