@vendure/dashboard 3.7.0-minor-202607010310 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/chunks/{2SSKDMRQ-mFHSQL2r.js → 2SSKDMRQ-Ddh65BrY.js} +2 -2
- package/dist/bundle/chunks/{AP7HFJJL-C8jBgxkH.js → AP7HFJJL-Db7gWBRq.js} +1 -1
- package/dist/bundle/chunks/{WDYDFRGG-CV5uCOo9.js → WDYDFRGG-D-AGRv_K.js} +2 -2
- package/dist/bundle/chunks/{main-BrEvUQtC.js → main-DsM_74hl.js} +18 -18
- package/dist/bundle/main.js +1 -1
- package/package.json +3 -3
- package/src/app/derive-base-url.spec.ts +53 -0
- package/src/app/derive-base-url.ts +41 -0
- package/src/app/main.tsx +6 -26
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/dev-config.js +0 -251
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/package.json +0 -4
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/nav-modifier-plugin/nav-modifier-plugin.js +0 -23
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/api/api-extensions.js +0 -99
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/api/product-entity.resolver.js +0 -73
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/api/product-review-admin.resolver.js +0 -146
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/api/product-review-entity.resolver.js +0 -79
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/api/product-review-shop.resolver.js +0 -79
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/entities/product-review-translation.entity.js +0 -47
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/entities/product-review.entity.js +0 -90
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/generated-admin-types.js +0 -1021
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/generated-shop-types.js +0 -974
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/reviews-plugin.js +0 -46
- package/dist/vite/.vendure-dashboard-temp/compiler/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/test-plugins/reviews/types.js +0 -2
- package/dist/vite/.vendure-dashboard-temp/gql-tada/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/schema.graphql +0 -6844
- package/dist/vite/.vendure-dashboard-temp/gql-tada/4381-13d969e9-469a-43f5-bf2c-2e91858ef25e/tsconfig.json +0 -10
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/dev-config.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/package.json +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/nav-modifier-plugin/nav-modifier-plugin.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/api/api-extensions.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/api/product-entity.resolver.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/api/product-review-admin.resolver.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/api/product-review-entity.resolver.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/api/product-review-shop.resolver.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/entities/product-review-translation.entity.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/entities/product-review.entity.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/generated-admin-types.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/generated-shop-types.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/reviews-plugin.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/compiler/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/test-plugins/reviews/types.js +0 -0
- /package/dist/vite/.vendure-dashboard-temp/gql-tada/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/schema.graphql +0 -0
- /package/dist/vite/.vendure-dashboard-temp/gql-tada/{3449-17220ddc-97f6-49c6-99d8-e74b8e94d5f2 → 3390-1f9204be-301a-46ef-909f-bcf03820d62c}/tsconfig.json +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var _a, _b, _c, _d, _e, _f;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ProductEntityResolver = void 0;
|
|
17
|
-
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
-
const core_1 = require("@vendure/core");
|
|
19
|
-
const product_review_entity_1 = require("../entities/product-review.entity");
|
|
20
|
-
const generated_shop_types_1 = require("../generated-shop-types");
|
|
21
|
-
let ProductEntityResolver = class ProductEntityResolver {
|
|
22
|
-
constructor(listQueryBuilder, connection) {
|
|
23
|
-
this.listQueryBuilder = listQueryBuilder;
|
|
24
|
-
this.connection = connection;
|
|
25
|
-
}
|
|
26
|
-
reviews(apiType, product, args) {
|
|
27
|
-
return this.listQueryBuilder
|
|
28
|
-
.build(product_review_entity_1.ProductReview, args.options || undefined, {
|
|
29
|
-
where: {
|
|
30
|
-
product: { id: product.id },
|
|
31
|
-
...(apiType === 'shop' ? { state: 'approved' } : {}),
|
|
32
|
-
},
|
|
33
|
-
relations: ['product', 'product.featuredAsset'],
|
|
34
|
-
})
|
|
35
|
-
.getManyAndCount()
|
|
36
|
-
.then(([items, totalItems]) => ({
|
|
37
|
-
items,
|
|
38
|
-
totalItems,
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
reviewsHistogram(product) {
|
|
42
|
-
return this.connection.rawConnection
|
|
43
|
-
.createQueryBuilder()
|
|
44
|
-
.select('ROUND(`rating`)', 'bin')
|
|
45
|
-
.addSelect('COUNT(*)', 'frequency')
|
|
46
|
-
.from(product_review_entity_1.ProductReview, 'review')
|
|
47
|
-
.where('review.product = :productId', { productId: product.id })
|
|
48
|
-
.andWhere('review.state = :state', { state: 'approved' })
|
|
49
|
-
.groupBy('ROUND(`rating`)')
|
|
50
|
-
.getRawMany();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
exports.ProductEntityResolver = ProductEntityResolver;
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, graphql_1.ResolveField)(),
|
|
56
|
-
__param(0, (0, core_1.Api)()),
|
|
57
|
-
__param(1, (0, graphql_1.Parent)()),
|
|
58
|
-
__param(2, (0, graphql_1.Args)()),
|
|
59
|
-
__metadata("design:type", Function),
|
|
60
|
-
__metadata("design:paramtypes", [typeof (_c = typeof core_1.ApiType !== "undefined" && core_1.ApiType) === "function" ? _c : Object, typeof (_d = typeof core_1.Product !== "undefined" && core_1.Product) === "function" ? _d : Object, typeof (_e = typeof generated_shop_types_1.ProductReviewsArgs !== "undefined" && generated_shop_types_1.ProductReviewsArgs) === "function" ? _e : Object]),
|
|
61
|
-
__metadata("design:returntype", void 0)
|
|
62
|
-
], ProductEntityResolver.prototype, "reviews", null);
|
|
63
|
-
__decorate([
|
|
64
|
-
(0, graphql_1.ResolveField)(),
|
|
65
|
-
__param(0, (0, graphql_1.Parent)()),
|
|
66
|
-
__metadata("design:type", Function),
|
|
67
|
-
__metadata("design:paramtypes", [typeof (_f = typeof core_1.Product !== "undefined" && core_1.Product) === "function" ? _f : Object]),
|
|
68
|
-
__metadata("design:returntype", void 0)
|
|
69
|
-
], ProductEntityResolver.prototype, "reviewsHistogram", null);
|
|
70
|
-
exports.ProductEntityResolver = ProductEntityResolver = __decorate([
|
|
71
|
-
(0, graphql_1.Resolver)('Product'),
|
|
72
|
-
__metadata("design:paramtypes", [typeof (_a = typeof core_1.ListQueryBuilder !== "undefined" && core_1.ListQueryBuilder) === "function" ? _a : Object, typeof (_b = typeof core_1.TransactionalConnection !== "undefined" && core_1.TransactionalConnection) === "function" ? _b : Object])
|
|
73
|
-
], ProductEntityResolver);
|
|
@@ -1,146 +0,0 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ProductReviewAdminResolver = void 0;
|
|
17
|
-
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
-
const core_1 = require("@vendure/core");
|
|
19
|
-
const product_review_translation_entity_1 = require("../entities/product-review-translation.entity");
|
|
20
|
-
const product_review_entity_1 = require("../entities/product-review.entity");
|
|
21
|
-
const generated_admin_types_1 = require("../generated-admin-types");
|
|
22
|
-
let ProductReviewAdminResolver = class ProductReviewAdminResolver {
|
|
23
|
-
constructor(connection, listQueryBuilder, translatableSaver) {
|
|
24
|
-
this.connection = connection;
|
|
25
|
-
this.listQueryBuilder = listQueryBuilder;
|
|
26
|
-
this.translatableSaver = translatableSaver;
|
|
27
|
-
}
|
|
28
|
-
async productReviews(ctx, args) {
|
|
29
|
-
return this.listQueryBuilder
|
|
30
|
-
.build(product_review_entity_1.ProductReview, args.options || undefined, {
|
|
31
|
-
relations: ['product'],
|
|
32
|
-
ctx,
|
|
33
|
-
})
|
|
34
|
-
.getManyAndCount()
|
|
35
|
-
.then(([items, totalItems]) => ({
|
|
36
|
-
items,
|
|
37
|
-
totalItems,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
async productReview(ctx, args) {
|
|
41
|
-
const review = await this.connection.getRepository(ctx, product_review_entity_1.ProductReview).findOne({
|
|
42
|
-
where: { id: args.id },
|
|
43
|
-
relations: {
|
|
44
|
-
author: true,
|
|
45
|
-
product: true,
|
|
46
|
-
productVariant: true,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
if (!review) {
|
|
50
|
-
throw new core_1.EntityNotFoundError(product_review_entity_1.ProductReview.name, args.id);
|
|
51
|
-
}
|
|
52
|
-
return (0, core_1.translateDeep)(review, ctx.languageCode);
|
|
53
|
-
}
|
|
54
|
-
async updateProductReview(ctx, { input }) {
|
|
55
|
-
const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, input.id);
|
|
56
|
-
const originalResponse = review.response;
|
|
57
|
-
return this.translatableSaver.update({
|
|
58
|
-
ctx,
|
|
59
|
-
input,
|
|
60
|
-
entityType: product_review_entity_1.ProductReview,
|
|
61
|
-
translationType: product_review_translation_entity_1.ProductReviewTranslation,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async approveProductReview(ctx, { id }) {
|
|
65
|
-
const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, id, {
|
|
66
|
-
relations: ['product'],
|
|
67
|
-
});
|
|
68
|
-
if (review.state !== 'new') {
|
|
69
|
-
return review;
|
|
70
|
-
}
|
|
71
|
-
const { product } = review;
|
|
72
|
-
const newRating = this.calculateNewReviewAverage(review.rating, product);
|
|
73
|
-
product.customFields.reviewCount++;
|
|
74
|
-
product.customFields.reviewRating = newRating;
|
|
75
|
-
await this.connection.getRepository(ctx, core_1.Product).save(product);
|
|
76
|
-
review.state = 'approved';
|
|
77
|
-
return this.connection.getRepository(ctx, product_review_entity_1.ProductReview).save(review);
|
|
78
|
-
}
|
|
79
|
-
async rejectProductReview(ctx, { id }) {
|
|
80
|
-
const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, id);
|
|
81
|
-
if (review.state !== 'new') {
|
|
82
|
-
return review;
|
|
83
|
-
}
|
|
84
|
-
review.state = 'rejected';
|
|
85
|
-
return this.connection.getRepository(ctx, product_review_entity_1.ProductReview).save(review);
|
|
86
|
-
}
|
|
87
|
-
calculateNewReviewAverage(rating, product) {
|
|
88
|
-
const count = product.customFields.reviewCount;
|
|
89
|
-
const currentRating = product.customFields.reviewRating || 0;
|
|
90
|
-
const newRating = (currentRating * count + rating) / (count + 1);
|
|
91
|
-
return newRating;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
exports.ProductReviewAdminResolver = ProductReviewAdminResolver;
|
|
95
|
-
__decorate([
|
|
96
|
-
(0, graphql_1.Query)(),
|
|
97
|
-
(0, core_1.Allow)(core_1.Permission.ReadCatalog),
|
|
98
|
-
__param(0, (0, core_1.Ctx)()),
|
|
99
|
-
__param(1, (0, graphql_1.Args)()),
|
|
100
|
-
__metadata("design:type", Function),
|
|
101
|
-
__metadata("design:paramtypes", [typeof (_d = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _d : Object, typeof (_e = typeof generated_admin_types_1.QueryProductReviewsArgs !== "undefined" && generated_admin_types_1.QueryProductReviewsArgs) === "function" ? _e : Object]),
|
|
102
|
-
__metadata("design:returntype", Promise)
|
|
103
|
-
], ProductReviewAdminResolver.prototype, "productReviews", null);
|
|
104
|
-
__decorate([
|
|
105
|
-
(0, graphql_1.Query)(),
|
|
106
|
-
(0, core_1.Allow)(core_1.Permission.ReadCatalog),
|
|
107
|
-
__param(0, (0, core_1.Ctx)()),
|
|
108
|
-
__param(1, (0, graphql_1.Args)()),
|
|
109
|
-
__metadata("design:type", Function),
|
|
110
|
-
__metadata("design:paramtypes", [typeof (_f = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _f : Object, typeof (_g = typeof generated_admin_types_1.QueryProductReviewArgs !== "undefined" && generated_admin_types_1.QueryProductReviewArgs) === "function" ? _g : Object]),
|
|
111
|
-
__metadata("design:returntype", Promise)
|
|
112
|
-
], ProductReviewAdminResolver.prototype, "productReview", null);
|
|
113
|
-
__decorate([
|
|
114
|
-
(0, core_1.Transaction)(),
|
|
115
|
-
(0, graphql_1.Mutation)(),
|
|
116
|
-
(0, core_1.Allow)(core_1.Permission.UpdateCatalog),
|
|
117
|
-
__param(0, (0, core_1.Ctx)()),
|
|
118
|
-
__param(1, (0, graphql_1.Args)()),
|
|
119
|
-
__metadata("design:type", Function),
|
|
120
|
-
__metadata("design:paramtypes", [typeof (_h = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _h : Object, typeof (_j = typeof generated_admin_types_1.MutationUpdateProductReviewArgs !== "undefined" && generated_admin_types_1.MutationUpdateProductReviewArgs) === "function" ? _j : Object]),
|
|
121
|
-
__metadata("design:returntype", Promise)
|
|
122
|
-
], ProductReviewAdminResolver.prototype, "updateProductReview", null);
|
|
123
|
-
__decorate([
|
|
124
|
-
(0, core_1.Transaction)(),
|
|
125
|
-
(0, graphql_1.Mutation)(),
|
|
126
|
-
(0, core_1.Allow)(core_1.Permission.UpdateCatalog),
|
|
127
|
-
__param(0, (0, core_1.Ctx)()),
|
|
128
|
-
__param(1, (0, graphql_1.Args)()),
|
|
129
|
-
__metadata("design:type", Function),
|
|
130
|
-
__metadata("design:paramtypes", [typeof (_k = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _k : Object, typeof (_l = typeof generated_admin_types_1.MutationApproveProductReviewArgs !== "undefined" && generated_admin_types_1.MutationApproveProductReviewArgs) === "function" ? _l : Object]),
|
|
131
|
-
__metadata("design:returntype", Promise)
|
|
132
|
-
], ProductReviewAdminResolver.prototype, "approveProductReview", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
(0, core_1.Transaction)(),
|
|
135
|
-
(0, graphql_1.Mutation)(),
|
|
136
|
-
(0, core_1.Allow)(core_1.Permission.UpdateCatalog),
|
|
137
|
-
__param(0, (0, core_1.Ctx)()),
|
|
138
|
-
__param(1, (0, graphql_1.Args)()),
|
|
139
|
-
__metadata("design:type", Function),
|
|
140
|
-
__metadata("design:paramtypes", [typeof (_m = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _m : Object, typeof (_o = typeof generated_admin_types_1.MutationRejectProductReviewArgs !== "undefined" && generated_admin_types_1.MutationRejectProductReviewArgs) === "function" ? _o : Object]),
|
|
141
|
-
__metadata("design:returntype", Promise)
|
|
142
|
-
], ProductReviewAdminResolver.prototype, "rejectProductReview", null);
|
|
143
|
-
exports.ProductReviewAdminResolver = ProductReviewAdminResolver = __decorate([
|
|
144
|
-
(0, graphql_1.Resolver)(),
|
|
145
|
-
__metadata("design:paramtypes", [typeof (_a = typeof core_1.TransactionalConnection !== "undefined" && core_1.TransactionalConnection) === "function" ? _a : Object, typeof (_b = typeof core_1.ListQueryBuilder !== "undefined" && core_1.ListQueryBuilder) === "function" ? _b : Object, typeof (_c = typeof core_1.TranslatableSaver !== "undefined" && core_1.TranslatableSaver) === "function" ? _c : Object])
|
|
146
|
-
], ProductReviewAdminResolver);
|
|
@@ -1,79 +0,0 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ProductReviewEntityResolver = void 0;
|
|
17
|
-
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
-
const core_1 = require("@vendure/core");
|
|
19
|
-
const product_review_entity_1 = require("../entities/product-review.entity");
|
|
20
|
-
let ProductReviewEntityResolver = class ProductReviewEntityResolver {
|
|
21
|
-
constructor(connection) {
|
|
22
|
-
this.connection = connection;
|
|
23
|
-
}
|
|
24
|
-
async product(review, ctx) {
|
|
25
|
-
let product = review.product;
|
|
26
|
-
if (!product) {
|
|
27
|
-
const reviewWithProduct = await this.connection.getRepository(ctx, product_review_entity_1.ProductReview).findOne({
|
|
28
|
-
where: { id: review.id },
|
|
29
|
-
relations: {
|
|
30
|
-
product: true,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
if (reviewWithProduct) {
|
|
34
|
-
product = reviewWithProduct.product;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (product) {
|
|
38
|
-
return (0, core_1.translateDeep)(product, ctx.languageCode);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async productVariant(review, ctx) {
|
|
42
|
-
let productVariant = review.productVariant;
|
|
43
|
-
if (!productVariant) {
|
|
44
|
-
const reviewWithProductVariant = await this.connection.getRepository(ctx, product_review_entity_1.ProductReview).findOne({
|
|
45
|
-
where: { id: review.id },
|
|
46
|
-
relations: {
|
|
47
|
-
productVariant: true,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
if (reviewWithProductVariant) {
|
|
51
|
-
productVariant = reviewWithProductVariant.productVariant;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (productVariant) {
|
|
55
|
-
return (0, core_1.translateDeep)(productVariant, ctx.languageCode);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
exports.ProductReviewEntityResolver = ProductReviewEntityResolver;
|
|
60
|
-
__decorate([
|
|
61
|
-
(0, graphql_1.ResolveField)(),
|
|
62
|
-
__param(0, (0, graphql_1.Parent)()),
|
|
63
|
-
__param(1, (0, core_1.Ctx)()),
|
|
64
|
-
__metadata("design:type", Function),
|
|
65
|
-
__metadata("design:paramtypes", [typeof (_b = typeof product_review_entity_1.ProductReview !== "undefined" && product_review_entity_1.ProductReview) === "function" ? _b : Object, typeof (_c = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _c : Object]),
|
|
66
|
-
__metadata("design:returntype", Promise)
|
|
67
|
-
], ProductReviewEntityResolver.prototype, "product", null);
|
|
68
|
-
__decorate([
|
|
69
|
-
(0, graphql_1.ResolveField)(),
|
|
70
|
-
__param(0, (0, graphql_1.Parent)()),
|
|
71
|
-
__param(1, (0, core_1.Ctx)()),
|
|
72
|
-
__metadata("design:type", Function),
|
|
73
|
-
__metadata("design:paramtypes", [typeof (_d = typeof product_review_entity_1.ProductReview !== "undefined" && product_review_entity_1.ProductReview) === "function" ? _d : Object, typeof (_e = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _e : Object]),
|
|
74
|
-
__metadata("design:returntype", Promise)
|
|
75
|
-
], ProductReviewEntityResolver.prototype, "productVariant", null);
|
|
76
|
-
exports.ProductReviewEntityResolver = ProductReviewEntityResolver = __decorate([
|
|
77
|
-
(0, graphql_1.Resolver)('ProductReview'),
|
|
78
|
-
__metadata("design:paramtypes", [typeof (_a = typeof core_1.TransactionalConnection !== "undefined" && core_1.TransactionalConnection) === "function" ? _a : Object])
|
|
79
|
-
], ProductReviewEntityResolver);
|
|
@@ -1,79 +0,0 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var _a, _b, _c, _d, _e, _f;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ProductReviewShopResolver = void 0;
|
|
17
|
-
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
-
const core_1 = require("@vendure/core");
|
|
19
|
-
const product_review_entity_1 = require("../entities/product-review.entity");
|
|
20
|
-
const generated_shop_types_1 = require("../generated-shop-types");
|
|
21
|
-
let ProductReviewShopResolver = class ProductReviewShopResolver {
|
|
22
|
-
constructor(connection, listQueryBuilder) {
|
|
23
|
-
this.connection = connection;
|
|
24
|
-
this.listQueryBuilder = listQueryBuilder;
|
|
25
|
-
}
|
|
26
|
-
async submitProductReview(ctx, { input }) {
|
|
27
|
-
const review = new product_review_entity_1.ProductReview(input);
|
|
28
|
-
const product = await this.connection.getEntityOrThrow(ctx, core_1.Product, input.productId);
|
|
29
|
-
review.product = product;
|
|
30
|
-
review.state = 'new';
|
|
31
|
-
if (input.variantId) {
|
|
32
|
-
const variant = await this.connection.getEntityOrThrow(ctx, core_1.ProductVariant, input.variantId);
|
|
33
|
-
review.productVariant = variant;
|
|
34
|
-
}
|
|
35
|
-
if (input.customerId) {
|
|
36
|
-
const customer = await this.connection.getEntityOrThrow(ctx, core_1.Customer, input.customerId);
|
|
37
|
-
review.author = customer;
|
|
38
|
-
}
|
|
39
|
-
return this.connection.getRepository(ctx, product_review_entity_1.ProductReview).save(review);
|
|
40
|
-
}
|
|
41
|
-
async voteOnReview(ctx, { id, vote }) {
|
|
42
|
-
const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, id, {
|
|
43
|
-
relations: ['product'],
|
|
44
|
-
where: {
|
|
45
|
-
state: 'approved',
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
if (vote) {
|
|
49
|
-
review.upvotes++;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
review.downvotes++;
|
|
53
|
-
}
|
|
54
|
-
return this.connection.getRepository(ctx, product_review_entity_1.ProductReview).save(review);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
exports.ProductReviewShopResolver = ProductReviewShopResolver;
|
|
58
|
-
__decorate([
|
|
59
|
-
(0, core_1.Transaction)(),
|
|
60
|
-
(0, graphql_1.Mutation)(),
|
|
61
|
-
__param(0, (0, core_1.Ctx)()),
|
|
62
|
-
__param(1, (0, graphql_1.Args)()),
|
|
63
|
-
__metadata("design:type", Function),
|
|
64
|
-
__metadata("design:paramtypes", [typeof (_c = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _c : Object, typeof (_d = typeof generated_shop_types_1.MutationSubmitProductReviewArgs !== "undefined" && generated_shop_types_1.MutationSubmitProductReviewArgs) === "function" ? _d : Object]),
|
|
65
|
-
__metadata("design:returntype", Promise)
|
|
66
|
-
], ProductReviewShopResolver.prototype, "submitProductReview", null);
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, core_1.Transaction)(),
|
|
69
|
-
(0, graphql_1.Mutation)(),
|
|
70
|
-
__param(0, (0, core_1.Ctx)()),
|
|
71
|
-
__param(1, (0, graphql_1.Args)()),
|
|
72
|
-
__metadata("design:type", Function),
|
|
73
|
-
__metadata("design:paramtypes", [typeof (_e = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _e : Object, typeof (_f = typeof generated_shop_types_1.MutationVoteOnReviewArgs !== "undefined" && generated_shop_types_1.MutationVoteOnReviewArgs) === "function" ? _f : Object]),
|
|
74
|
-
__metadata("design:returntype", Promise)
|
|
75
|
-
], ProductReviewShopResolver.prototype, "voteOnReview", null);
|
|
76
|
-
exports.ProductReviewShopResolver = ProductReviewShopResolver = __decorate([
|
|
77
|
-
(0, graphql_1.Resolver)(),
|
|
78
|
-
__metadata("design:paramtypes", [typeof (_a = typeof core_1.TransactionalConnection !== "undefined" && core_1.TransactionalConnection) === "function" ? _a : Object, typeof (_b = typeof core_1.ListQueryBuilder !== "undefined" && core_1.ListQueryBuilder) === "function" ? _b : Object])
|
|
79
|
-
], ProductReviewShopResolver);
|
|
@@ -1,47 +0,0 @@
|
|
|
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 _a, _b, _c;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.ProductReviewTranslation = exports.CustomReviewFieldsTranslation = void 0;
|
|
14
|
-
const shared_types_1 = require("@vendure/common/lib/shared-types");
|
|
15
|
-
const core_1 = require("@vendure/core");
|
|
16
|
-
const typeorm_1 = require("typeorm");
|
|
17
|
-
const product_review_entity_1 = require("./product-review.entity");
|
|
18
|
-
class CustomReviewFieldsTranslation {
|
|
19
|
-
}
|
|
20
|
-
exports.CustomReviewFieldsTranslation = CustomReviewFieldsTranslation;
|
|
21
|
-
let ProductReviewTranslation = class ProductReviewTranslation extends core_1.VendureEntity {
|
|
22
|
-
constructor(input) {
|
|
23
|
-
super(input);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.ProductReviewTranslation = ProductReviewTranslation;
|
|
27
|
-
__decorate([
|
|
28
|
-
(0, typeorm_1.Column)('varchar'),
|
|
29
|
-
__metadata("design:type", typeof (_b = typeof core_1.LanguageCode !== "undefined" && core_1.LanguageCode) === "function" ? _b : Object)
|
|
30
|
-
], ProductReviewTranslation.prototype, "languageCode", void 0);
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, typeorm_1.Column)('varchar'),
|
|
33
|
-
__metadata("design:type", String)
|
|
34
|
-
], ProductReviewTranslation.prototype, "text", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, typeorm_1.Index)(),
|
|
37
|
-
(0, typeorm_1.ManyToOne)(() => product_review_entity_1.ProductReview, base => base.translations, { onDelete: 'CASCADE' }),
|
|
38
|
-
__metadata("design:type", typeof (_c = typeof product_review_entity_1.ProductReview !== "undefined" && product_review_entity_1.ProductReview) === "function" ? _c : Object)
|
|
39
|
-
], ProductReviewTranslation.prototype, "base", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, typeorm_1.Column)(type => CustomReviewFieldsTranslation),
|
|
42
|
-
__metadata("design:type", CustomReviewFieldsTranslation)
|
|
43
|
-
], ProductReviewTranslation.prototype, "customFields", void 0);
|
|
44
|
-
exports.ProductReviewTranslation = ProductReviewTranslation = __decorate([
|
|
45
|
-
(0, typeorm_1.Entity)(),
|
|
46
|
-
__metadata("design:paramtypes", [typeof (_a = typeof shared_types_1.DeepPartial !== "undefined" && shared_types_1.DeepPartial) === "function" ? _a : Object])
|
|
47
|
-
], ProductReviewTranslation);
|
|
@@ -1,90 +0,0 @@
|
|
|
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 _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.ProductReview = exports.CustomReviewFields = void 0;
|
|
14
|
-
const core_1 = require("@vendure/core");
|
|
15
|
-
const typeorm_1 = require("typeorm");
|
|
16
|
-
const types_1 = require("../types");
|
|
17
|
-
const product_review_translation_entity_1 = require("./product-review-translation.entity");
|
|
18
|
-
class CustomReviewFields {
|
|
19
|
-
}
|
|
20
|
-
exports.CustomReviewFields = CustomReviewFields;
|
|
21
|
-
let ProductReview = class ProductReview extends core_1.VendureEntity {
|
|
22
|
-
constructor(input) {
|
|
23
|
-
super(input);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.ProductReview = ProductReview;
|
|
27
|
-
__decorate([
|
|
28
|
-
(0, typeorm_1.ManyToOne)(type => core_1.Product),
|
|
29
|
-
__metadata("design:type", typeof (_b = typeof core_1.Product !== "undefined" && core_1.Product) === "function" ? _b : Object)
|
|
30
|
-
], ProductReview.prototype, "product", void 0);
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, typeorm_1.ManyToOne)(type => core_1.ProductVariant),
|
|
33
|
-
__metadata("design:type", typeof (_c = typeof core_1.ProductVariant !== "undefined" && core_1.ProductVariant) === "function" ? _c : Object)
|
|
34
|
-
], ProductReview.prototype, "productVariant", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, typeorm_1.Column)(),
|
|
37
|
-
__metadata("design:type", String)
|
|
38
|
-
], ProductReview.prototype, "summary", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
(0, typeorm_1.Column)('text'),
|
|
41
|
-
__metadata("design:type", String)
|
|
42
|
-
], ProductReview.prototype, "body", void 0);
|
|
43
|
-
__decorate([
|
|
44
|
-
(0, typeorm_1.Column)(),
|
|
45
|
-
__metadata("design:type", Number)
|
|
46
|
-
], ProductReview.prototype, "rating", void 0);
|
|
47
|
-
__decorate([
|
|
48
|
-
(0, typeorm_1.ManyToOne)(type => core_1.Customer),
|
|
49
|
-
__metadata("design:type", typeof (_d = typeof core_1.Customer !== "undefined" && core_1.Customer) === "function" ? _d : Object)
|
|
50
|
-
], ProductReview.prototype, "author", void 0);
|
|
51
|
-
__decorate([
|
|
52
|
-
(0, typeorm_1.Column)(),
|
|
53
|
-
__metadata("design:type", String)
|
|
54
|
-
], ProductReview.prototype, "authorName", void 0);
|
|
55
|
-
__decorate([
|
|
56
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
|
57
|
-
__metadata("design:type", String)
|
|
58
|
-
], ProductReview.prototype, "authorLocation", void 0);
|
|
59
|
-
__decorate([
|
|
60
|
-
(0, typeorm_1.Column)({ default: 0 }),
|
|
61
|
-
__metadata("design:type", Number)
|
|
62
|
-
], ProductReview.prototype, "upvotes", void 0);
|
|
63
|
-
__decorate([
|
|
64
|
-
(0, typeorm_1.Column)({ default: 0 }),
|
|
65
|
-
__metadata("design:type", Number)
|
|
66
|
-
], ProductReview.prototype, "downvotes", void 0);
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, typeorm_1.Column)('varchar'),
|
|
69
|
-
__metadata("design:type", typeof (_e = typeof types_1.ReviewState !== "undefined" && types_1.ReviewState) === "function" ? _e : Object)
|
|
70
|
-
], ProductReview.prototype, "state", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
(0, typeorm_1.Column)('text', { nullable: true, default: null }),
|
|
73
|
-
__metadata("design:type", String)
|
|
74
|
-
], ProductReview.prototype, "response", void 0);
|
|
75
|
-
__decorate([
|
|
76
|
-
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
77
|
-
__metadata("design:type", typeof (_f = typeof Date !== "undefined" && Date) === "function" ? _f : Object)
|
|
78
|
-
], ProductReview.prototype, "responseCreatedAt", void 0);
|
|
79
|
-
__decorate([
|
|
80
|
-
(0, typeorm_1.OneToMany)(() => product_review_translation_entity_1.ProductReviewTranslation, translation => translation.base, { eager: true }),
|
|
81
|
-
__metadata("design:type", typeof (_g = typeof Array !== "undefined" && Array) === "function" ? _g : Object)
|
|
82
|
-
], ProductReview.prototype, "translations", void 0);
|
|
83
|
-
__decorate([
|
|
84
|
-
(0, typeorm_1.Column)(type => CustomReviewFields),
|
|
85
|
-
__metadata("design:type", CustomReviewFields)
|
|
86
|
-
], ProductReview.prototype, "customFields", void 0);
|
|
87
|
-
exports.ProductReview = ProductReview = __decorate([
|
|
88
|
-
(0, typeorm_1.Entity)(),
|
|
89
|
-
__metadata("design:paramtypes", [typeof (_a = typeof core_1.DeepPartial !== "undefined" && core_1.DeepPartial) === "function" ? _a : Object])
|
|
90
|
-
], ProductReview);
|