@deenruv/reviews-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +58 -0
- package/dist/plugin-server/api/admin-api.resolver.d.ts +67 -0
- package/dist/plugin-server/api/admin-api.resolver.js +127 -0
- package/dist/plugin-server/api/review-asset.resolver.d.ts +11 -0
- package/dist/plugin-server/api/review-asset.resolver.js +37 -0
- package/dist/plugin-server/api/review-customer.resolver.d.ts +15 -0
- package/dist/plugin-server/api/review-customer.resolver.js +52 -0
- package/dist/plugin-server/api/review-order.resolver.d.ts +8 -0
- package/dist/plugin-server/api/review-order.resolver.js +47 -0
- package/dist/plugin-server/api/review-product.resolver.d.ts +15 -0
- package/dist/plugin-server/api/review-product.resolver.js +50 -0
- package/dist/plugin-server/api/shop-api.resolver.d.ts +28 -0
- package/dist/plugin-server/api/shop-api.resolver.js +57 -0
- package/dist/plugin-server/constants.d.ts +6 -0
- package/dist/plugin-server/constants.js +7 -0
- package/dist/plugin-server/entities/review-translation.entity.d.ts +9 -0
- package/dist/plugin-server/entities/review-translation.entity.js +37 -0
- package/dist/plugin-server/entities/review.entity.d.ts +24 -0
- package/dist/plugin-server/entities/review.entity.js +89 -0
- package/dist/plugin-server/events.d.ts +10 -0
- package/dist/plugin-server/events.js +11 -0
- package/dist/plugin-server/extensions/admin-api.extension.d.ts +2 -0
- package/dist/plugin-server/extensions/admin-api.extension.js +70 -0
- package/dist/plugin-server/extensions/shared.extension.d.ts +2 -0
- package/dist/plugin-server/extensions/shared.extension.js +87 -0
- package/dist/plugin-server/extensions/shop-api.extension.d.ts +2 -0
- package/dist/plugin-server/extensions/shop-api.extension.js +60 -0
- package/dist/plugin-server/index.d.ts +15 -0
- package/dist/plugin-server/index.js +86 -0
- package/dist/plugin-server/services/reviews.service.d.ts +85 -0
- package/dist/plugin-server/services/reviews.service.js +366 -0
- package/dist/plugin-server/state/reviews.state.d.ts +16 -0
- package/dist/plugin-server/state/reviews.state.js +63 -0
- package/dist/plugin-server/types.d.ts +33 -0
- package/dist/plugin-server/types.js +1 -0
- package/dist/plugin-server/zeus/const.d.ts +6 -0
- package/dist/plugin-server/zeus/const.js +4027 -0
- package/dist/plugin-server/zeus/index.d.ts +20410 -0
- package/dist/plugin-server/zeus/index.js +443 -0
- package/dist/plugin-ui/components/OrderInfo.d.ts +5 -0
- package/dist/plugin-ui/components/OrderInfo.js +42 -0
- package/dist/plugin-ui/components/ProductInfo.d.ts +5 -0
- package/dist/plugin-ui/components/ProductInfo.js +36 -0
- package/dist/plugin-ui/components/ReviewCustomer.d.ts +2 -0
- package/dist/plugin-ui/components/ReviewCustomer.js +166 -0
- package/dist/plugin-ui/components/ReviewOrder.d.ts +2 -0
- package/dist/plugin-ui/components/ReviewOrder.js +57 -0
- package/dist/plugin-ui/components/ReviewProductSidebar.d.ts +2 -0
- package/dist/plugin-ui/components/ReviewProductSidebar.js +29 -0
- package/dist/plugin-ui/components/ReviewStateChange.d.ts +5 -0
- package/dist/plugin-ui/components/ReviewStateChange.js +35 -0
- package/dist/plugin-ui/components/UniversalSelectDialog.d.ts +16 -0
- package/dist/plugin-ui/components/UniversalSelectDialog.js +35 -0
- package/dist/plugin-ui/components/index.d.ts +2 -0
- package/dist/plugin-ui/components/index.js +2 -0
- package/dist/plugin-ui/constants.d.ts +1 -0
- package/dist/plugin-ui/constants.js +1 -0
- package/dist/plugin-ui/graphql/index.d.ts +3 -0
- package/dist/plugin-ui/graphql/index.js +3 -0
- package/dist/plugin-ui/graphql/mutations.d.ts +35 -0
- package/dist/plugin-ui/graphql/mutations.js +28 -0
- package/dist/plugin-ui/graphql/queries.d.ts +293 -0
- package/dist/plugin-ui/graphql/queries.js +34 -0
- package/dist/plugin-ui/graphql/scalars.d.ts +16 -0
- package/dist/plugin-ui/graphql/scalars.js +14 -0
- package/dist/plugin-ui/graphql/selectors.d.ts +58 -0
- package/dist/plugin-ui/graphql/selectors.js +39 -0
- package/dist/plugin-ui/index.d.ts +7 -0
- package/dist/plugin-ui/index.js +69 -0
- package/dist/plugin-ui/locales/en/index.d.ts +108 -0
- package/dist/plugin-ui/locales/en/index.js +2 -0
- package/dist/plugin-ui/locales/en/reviews.json +107 -0
- package/dist/plugin-ui/locales/pl/index.d.ts +108 -0
- package/dist/plugin-ui/locales/pl/index.js +2 -0
- package/dist/plugin-ui/locales/pl/reviews.json +107 -0
- package/dist/plugin-ui/pages/Review.d.ts +2 -0
- package/dist/plugin-ui/pages/Review.js +263 -0
- package/dist/plugin-ui/pages/Reviews.d.ts +2 -0
- package/dist/plugin-ui/pages/Reviews.js +174 -0
- package/dist/plugin-ui/tsconfig.json +18 -0
- package/dist/plugin-ui/zeus/const.d.ts +6 -0
- package/dist/plugin-ui/zeus/const.js +4027 -0
- package/dist/plugin-ui/zeus/index.d.ts +20410 -0
- package/dist/plugin-ui/zeus/index.js +459 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
- package/package.json +61 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { DeenruvEntity, LanguageCode, } from "@deenruv/core";
|
|
11
|
+
import { Column, Entity, Index, ManyToOne } from "typeorm";
|
|
12
|
+
import { ReviewEntity } from "./review.entity.js";
|
|
13
|
+
let ReviewEntityTranslation = class ReviewEntityTranslation extends DeenruvEntity {
|
|
14
|
+
constructor(input) {
|
|
15
|
+
super(input);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
__decorate([
|
|
19
|
+
Column("varchar"),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], ReviewEntityTranslation.prototype, "languageCode", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
Column("text"),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], ReviewEntityTranslation.prototype, "body", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
Index(),
|
|
28
|
+
ManyToOne(() => ReviewEntity, (base) => base.translations, {
|
|
29
|
+
onDelete: "CASCADE",
|
|
30
|
+
}),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], ReviewEntityTranslation.prototype, "base", void 0);
|
|
33
|
+
ReviewEntityTranslation = __decorate([
|
|
34
|
+
Entity(),
|
|
35
|
+
__metadata("design:paramtypes", [Object])
|
|
36
|
+
], ReviewEntityTranslation);
|
|
37
|
+
export { ReviewEntityTranslation };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Relation } from "typeorm";
|
|
2
|
+
import type { DeepPartial, LocaleString, Translatable, Translation } from "@deenruv/core";
|
|
3
|
+
import { Customer, DeenruvEntity, Order, Product, ProductVariant, User } from "@deenruv/core";
|
|
4
|
+
import { ReviewState } from "../constants.js";
|
|
5
|
+
import { ReviewEntityTranslation } from "./review-translation.entity.js";
|
|
6
|
+
export declare class ReviewEntity extends DeenruvEntity implements Translatable {
|
|
7
|
+
constructor(input?: DeepPartial<ReviewEntity>);
|
|
8
|
+
keepAnonymous: boolean;
|
|
9
|
+
assetKeys?: string[];
|
|
10
|
+
state: ReviewState;
|
|
11
|
+
response?: string;
|
|
12
|
+
responseCreatedAt?: Date;
|
|
13
|
+
responseAuthor?: User;
|
|
14
|
+
product?: Relation<Product>;
|
|
15
|
+
productVariant?: Relation<ProductVariant>;
|
|
16
|
+
order?: Relation<Order>;
|
|
17
|
+
body: LocaleString;
|
|
18
|
+
translations: Relation<Array<Translation<ReviewEntityTranslation>>>;
|
|
19
|
+
rating: number;
|
|
20
|
+
author?: Relation<Customer>;
|
|
21
|
+
authorName: string;
|
|
22
|
+
authorEmailAddress: string;
|
|
23
|
+
authorLocation?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Column, Entity, ManyToOne, OneToMany } from "typeorm";
|
|
11
|
+
import { Customer, DeenruvEntity, Order, Product, ProductVariant, User, } from "@deenruv/core";
|
|
12
|
+
import { ReviewState } from "../constants.js";
|
|
13
|
+
import { ReviewEntityTranslation } from "./review-translation.entity.js";
|
|
14
|
+
let ReviewEntity = class ReviewEntity extends DeenruvEntity {
|
|
15
|
+
constructor(input) {
|
|
16
|
+
super(input);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
__decorate([
|
|
20
|
+
Column({ default: false }),
|
|
21
|
+
__metadata("design:type", Boolean)
|
|
22
|
+
], ReviewEntity.prototype, "keepAnonymous", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
Column({ nullable: true, type: "simple-json" }),
|
|
25
|
+
__metadata("design:type", Array)
|
|
26
|
+
], ReviewEntity.prototype, "assetKeys", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
Column({
|
|
29
|
+
type: "enum",
|
|
30
|
+
enum: ReviewState,
|
|
31
|
+
default: ReviewState.PENDING,
|
|
32
|
+
}),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ReviewEntity.prototype, "state", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Column("text", { nullable: true, default: null }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], ReviewEntity.prototype, "response", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Column({ nullable: true, default: null }),
|
|
41
|
+
__metadata("design:type", Date)
|
|
42
|
+
], ReviewEntity.prototype, "responseCreatedAt", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
ManyToOne(() => User, { nullable: true }),
|
|
45
|
+
__metadata("design:type", User)
|
|
46
|
+
], ReviewEntity.prototype, "responseAuthor", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
ManyToOne(() => Product, { nullable: true }),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], ReviewEntity.prototype, "product", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
ManyToOne(() => ProductVariant, { nullable: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], ReviewEntity.prototype, "productVariant", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
ManyToOne(() => Order, { nullable: true }),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], ReviewEntity.prototype, "order", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
OneToMany(() => ReviewEntityTranslation, (translation) => translation.base, {
|
|
61
|
+
eager: true,
|
|
62
|
+
}),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], ReviewEntity.prototype, "translations", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
Column(),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], ReviewEntity.prototype, "rating", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
ManyToOne(() => Customer, { nullable: true }),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], ReviewEntity.prototype, "author", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
Column(),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], ReviewEntity.prototype, "authorName", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
Column(),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], ReviewEntity.prototype, "authorEmailAddress", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
Column({ nullable: true }),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], ReviewEntity.prototype, "authorLocation", void 0);
|
|
85
|
+
ReviewEntity = __decorate([
|
|
86
|
+
Entity(),
|
|
87
|
+
__metadata("design:paramtypes", [Object])
|
|
88
|
+
], ReviewEntity);
|
|
89
|
+
export { ReviewEntity };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequestContext, DeenruvEvent } from "@deenruv/core";
|
|
2
|
+
import { ReviewEntity } from "./entities/review.entity.js";
|
|
3
|
+
export default class ReviewChangeStateEvent extends DeenruvEvent {
|
|
4
|
+
ctx: RequestContext;
|
|
5
|
+
review: ReviewEntity;
|
|
6
|
+
fromState: string;
|
|
7
|
+
toState: string;
|
|
8
|
+
message?: string | undefined;
|
|
9
|
+
constructor(ctx: RequestContext, review: ReviewEntity, fromState: string, toState: string, message?: string | undefined);
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DeenruvEvent } from "@deenruv/core";
|
|
2
|
+
export default class ReviewChangeStateEvent extends DeenruvEvent {
|
|
3
|
+
constructor(ctx, review, fromState, toState, message) {
|
|
4
|
+
super();
|
|
5
|
+
this.ctx = ctx;
|
|
6
|
+
this.review = review;
|
|
7
|
+
this.fromState = fromState;
|
|
8
|
+
this.toState = toState;
|
|
9
|
+
this.message = message;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
import { SharedAPIExtension } from "./shared.extension.js";
|
|
3
|
+
export const AdminAPIExtension = gql `
|
|
4
|
+
${SharedAPIExtension}
|
|
5
|
+
|
|
6
|
+
type ReviewsConfig {
|
|
7
|
+
reviewsLanguages: [LanguageCode!]!
|
|
8
|
+
canTranslate: Boolean!
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
input TranslateReviewsInput {
|
|
12
|
+
id: ID!
|
|
13
|
+
languages: [LanguageCode!]!
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type GeneratedReviewTranslation {
|
|
17
|
+
languageCode: LanguageCode!
|
|
18
|
+
body: String!
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ReviewInfoForProduct {
|
|
22
|
+
averageRating: Float!
|
|
23
|
+
totalReviews: Int!
|
|
24
|
+
totalRatings: Int!
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
extend type Query {
|
|
28
|
+
translateReviews(
|
|
29
|
+
input: TranslateReviewsInput!
|
|
30
|
+
): [GeneratedReviewTranslation!]!
|
|
31
|
+
getReviewsConfig: ReviewsConfig!
|
|
32
|
+
listReviews(
|
|
33
|
+
options: ReviewListOptions!
|
|
34
|
+
productId: ID
|
|
35
|
+
orderId: ID
|
|
36
|
+
): ReviewList!
|
|
37
|
+
getReview(id: ID!): Review
|
|
38
|
+
getReviewInfoForProduct(productId: ID!): ReviewInfoForProduct
|
|
39
|
+
getReviewForOrder(orderId: ID!): Review
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
input ChangeReviewStateInput {
|
|
43
|
+
id: ID!
|
|
44
|
+
state: ReviewState!
|
|
45
|
+
message: String
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
input ReviewEntityTranslation {
|
|
49
|
+
languageCode: LanguageCode!
|
|
50
|
+
body: String!
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
input UpdateTranslationsReviewInput {
|
|
54
|
+
id: ID!
|
|
55
|
+
translations: [ReviewEntityTranslation!]!
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type ChangeReviewStateResult {
|
|
59
|
+
id: ID!
|
|
60
|
+
success: Boolean!
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
extend type Mutation {
|
|
64
|
+
changeReviewState(input: ChangeReviewStateInput!): ChangeReviewStateResult!
|
|
65
|
+
changeReviewsState(
|
|
66
|
+
input: [ChangeReviewStateInput!]!
|
|
67
|
+
): [ChangeReviewStateResult!]!
|
|
68
|
+
updateTranslationsReview(input: UpdateTranslationsReviewInput!): Review!
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
export const SharedAPIExtension = gql `
|
|
3
|
+
enum ReviewState {
|
|
4
|
+
PENDING
|
|
5
|
+
ACCEPTED
|
|
6
|
+
DECLINED
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type ReviewTranslation {
|
|
10
|
+
id: ID!
|
|
11
|
+
createdAt: DateTime!
|
|
12
|
+
updatedAt: DateTime!
|
|
13
|
+
languageCode: String!
|
|
14
|
+
body: String
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ReviewAsset {
|
|
18
|
+
key: String!
|
|
19
|
+
url: String!
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Review implements Node {
|
|
23
|
+
id: ID!
|
|
24
|
+
createdAt: DateTime!
|
|
25
|
+
updatedAt: DateTime!
|
|
26
|
+
assets: [ReviewAsset!]!
|
|
27
|
+
state: ReviewState!
|
|
28
|
+
response: String
|
|
29
|
+
responseCreatedAt: DateTime
|
|
30
|
+
rating: Float!
|
|
31
|
+
authorName: String!
|
|
32
|
+
authorLocation: String
|
|
33
|
+
authorEmailAddress: String!
|
|
34
|
+
body: String
|
|
35
|
+
translations: [ReviewTranslation!]!
|
|
36
|
+
product: Product
|
|
37
|
+
productVariant: ProductVariant
|
|
38
|
+
order: Order
|
|
39
|
+
author: Customer
|
|
40
|
+
keepAnonymous: Boolean!
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type ReviewList implements PaginatedList {
|
|
44
|
+
items: [Review!]!
|
|
45
|
+
totalItems: Int!
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
input ReviewFilterParameter {
|
|
49
|
+
id: IDOperators
|
|
50
|
+
createdAt: DateOperators
|
|
51
|
+
updatedAt: DateOperators
|
|
52
|
+
state: StringOperators
|
|
53
|
+
response: StringOperators
|
|
54
|
+
responseCreatedAt: DateOperators
|
|
55
|
+
rating: NumberOperators
|
|
56
|
+
authorName: StringOperators
|
|
57
|
+
authorLocation: StringOperators
|
|
58
|
+
authorEmailAddress: StringOperators
|
|
59
|
+
body: StringOperators
|
|
60
|
+
productId: IDOperators
|
|
61
|
+
orderId: IDOperators
|
|
62
|
+
customerId: IDOperators
|
|
63
|
+
_and: [ReviewFilterParameter!]
|
|
64
|
+
_or: [ReviewFilterParameter!]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
input ReviewSortParameter {
|
|
68
|
+
id: SortOrder
|
|
69
|
+
createdAt: SortOrder
|
|
70
|
+
updatedAt: SortOrder
|
|
71
|
+
response: SortOrder
|
|
72
|
+
responseCreatedAt: SortOrder
|
|
73
|
+
rating: SortOrder
|
|
74
|
+
authorName: SortOrder
|
|
75
|
+
authorLocation: SortOrder
|
|
76
|
+
authorEmailAddress: SortOrder
|
|
77
|
+
body: SortOrder
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
input ReviewListOptions {
|
|
81
|
+
skip: Int
|
|
82
|
+
take: Int
|
|
83
|
+
sort: ReviewSortParameter
|
|
84
|
+
filter: ReviewFilterParameter
|
|
85
|
+
filterOperator: LogicalOperator
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
import { SharedAPIExtension } from "./shared.extension.js";
|
|
3
|
+
export const ShopAPIExtension = gql `
|
|
4
|
+
${SharedAPIExtension}
|
|
5
|
+
|
|
6
|
+
input CreateReviewInput {
|
|
7
|
+
rating: Float!
|
|
8
|
+
body: String!
|
|
9
|
+
authorName: String
|
|
10
|
+
authorLocation: String
|
|
11
|
+
authorEmailAddress: String
|
|
12
|
+
uploadedAssets: [String!]
|
|
13
|
+
orderId: ID
|
|
14
|
+
productVariantId: ID
|
|
15
|
+
keepAnonymous: Boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
input ReviewsStorageOptions {
|
|
19
|
+
filename: String!
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type ReviewsStorage {
|
|
23
|
+
url: String!
|
|
24
|
+
key: String!
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
extend type Mutation {
|
|
28
|
+
createReview(input: CreateReviewInput!): Review!
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type AverageRating {
|
|
32
|
+
total: Int!
|
|
33
|
+
count: Int!
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type AverageRatings {
|
|
37
|
+
shopAverageRating: AverageRating!
|
|
38
|
+
productsAverageRating: AverageRating!
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
extend type Query {
|
|
42
|
+
getAverageRatings: AverageRatings!
|
|
43
|
+
getReviewsStorage(input: [ReviewsStorageOptions!]!): [ReviewsStorage!]!
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
extend type Product {
|
|
47
|
+
averageRating: Float!
|
|
48
|
+
reviews(options: ReviewListOptions): ReviewList!
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
extend type Order {
|
|
52
|
+
reviewed: Boolean!
|
|
53
|
+
review: Review
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
extend type Customer {
|
|
57
|
+
reviews(options: ReviewListOptions): ReviewList!
|
|
58
|
+
shopReviewCreated: Boolean!
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReviewsPluginOptions } from "./types.js";
|
|
2
|
+
import { OnApplicationBootstrap } from "@nestjs/common";
|
|
3
|
+
import { ModuleRef } from "@nestjs/core";
|
|
4
|
+
declare class ReviewsPlugin implements OnApplicationBootstrap {
|
|
5
|
+
private moduleRef;
|
|
6
|
+
static options: ReviewsPluginOptions;
|
|
7
|
+
constructor(moduleRef: ModuleRef);
|
|
8
|
+
static init(options: ReviewsPluginOptions): typeof ReviewsPlugin;
|
|
9
|
+
onApplicationBootstrap(): Promise<void>;
|
|
10
|
+
onApplicationShutdown(): Promise<void>;
|
|
11
|
+
private initTranslationStrategy;
|
|
12
|
+
private destroyTranslationStrategy;
|
|
13
|
+
}
|
|
14
|
+
export { TranslateReviewStrategy } from "./types.js";
|
|
15
|
+
export { ReviewsPlugin };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { PluginCommonModule, DeenruvPlugin, Injector } from "@deenruv/core";
|
|
11
|
+
import { AdminAPIExtension } from "./extensions/admin-api.extension.js";
|
|
12
|
+
import { ShopAPIExtension } from "./extensions/shop-api.extension.js";
|
|
13
|
+
import { REVIEWS_PLUGIN_OPTIONS } from "./constants.js";
|
|
14
|
+
import { ReviewEntity } from "./entities/review.entity.js";
|
|
15
|
+
import { ReviewsShopAPIResolver } from "./api/shop-api.resolver.js";
|
|
16
|
+
import { ReviewsAdminAPIResolver } from "./api/admin-api.resolver.js";
|
|
17
|
+
import { ReviewEntityTranslation } from "./entities/review-translation.entity.js";
|
|
18
|
+
import { ReviewsService } from "./services/reviews.service.js";
|
|
19
|
+
import { ReviewStateMachine } from "./state/reviews.state.js";
|
|
20
|
+
import { ModuleRef } from "@nestjs/core";
|
|
21
|
+
import { ReviewAssetResolver } from "./api/review-asset.resolver.js";
|
|
22
|
+
import { ReviewProductResolver } from "./api/review-product.resolver.js";
|
|
23
|
+
import { ReviewOrderResolver } from "./api/review-order.resolver.js";
|
|
24
|
+
import { ReviewCustomerResolver } from "./api/review-customer.resolver.js";
|
|
25
|
+
let ReviewsPlugin = class ReviewsPlugin {
|
|
26
|
+
constructor(moduleRef) {
|
|
27
|
+
this.moduleRef = moduleRef;
|
|
28
|
+
}
|
|
29
|
+
static init(options) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
async onApplicationBootstrap() {
|
|
34
|
+
await this.initTranslationStrategy();
|
|
35
|
+
}
|
|
36
|
+
async onApplicationShutdown() {
|
|
37
|
+
await this.destroyTranslationStrategy();
|
|
38
|
+
}
|
|
39
|
+
async initTranslationStrategy() {
|
|
40
|
+
const injector = new Injector(this.moduleRef);
|
|
41
|
+
const service = injector.get(ReviewsService);
|
|
42
|
+
if (service.translateStrategy &&
|
|
43
|
+
typeof service.translateStrategy.init === "function") {
|
|
44
|
+
await service.translateStrategy.init(injector);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async destroyTranslationStrategy() {
|
|
48
|
+
const injector = new Injector(this.moduleRef);
|
|
49
|
+
const service = injector.get(ReviewsService);
|
|
50
|
+
if (service.translateStrategy &&
|
|
51
|
+
typeof service.translateStrategy.destroy === "function") {
|
|
52
|
+
await service.translateStrategy.destroy();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
ReviewsPlugin = __decorate([
|
|
57
|
+
DeenruvPlugin({
|
|
58
|
+
compatibility: "0.0.1",
|
|
59
|
+
imports: [PluginCommonModule],
|
|
60
|
+
entities: [ReviewEntity, ReviewEntityTranslation],
|
|
61
|
+
adminApiExtensions: {
|
|
62
|
+
schema: AdminAPIExtension,
|
|
63
|
+
resolvers: [ReviewsAdminAPIResolver, ReviewAssetResolver],
|
|
64
|
+
},
|
|
65
|
+
shopApiExtensions: {
|
|
66
|
+
schema: ShopAPIExtension,
|
|
67
|
+
resolvers: [
|
|
68
|
+
ReviewsShopAPIResolver,
|
|
69
|
+
ReviewAssetResolver,
|
|
70
|
+
ReviewProductResolver,
|
|
71
|
+
ReviewOrderResolver,
|
|
72
|
+
ReviewCustomerResolver,
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
providers: [
|
|
76
|
+
{
|
|
77
|
+
provide: REVIEWS_PLUGIN_OPTIONS,
|
|
78
|
+
useFactory: () => ReviewsPlugin.options,
|
|
79
|
+
},
|
|
80
|
+
ReviewsService,
|
|
81
|
+
ReviewStateMachine,
|
|
82
|
+
],
|
|
83
|
+
}),
|
|
84
|
+
__metadata("design:paramtypes", [ModuleRef])
|
|
85
|
+
], ReviewsPlugin);
|
|
86
|
+
export { ReviewsPlugin };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Customer, CustomerService, EntityHydrator, EventBus, ID, ListQueryBuilder, OrderService, Product, ProductVariantService, RelationPaths, RequestContext, TransactionalConnection, TranslatableSaver, TranslatorService } from "@deenruv/core";
|
|
2
|
+
import { ReviewStateMachine } from "../state/reviews.state.js";
|
|
3
|
+
import { ReviewEntity } from "../entities/review.entity.js";
|
|
4
|
+
import { ReviewState } from "../constants.js";
|
|
5
|
+
import { CreateReviewInput, ReviewsPluginOptions } from "../types.js";
|
|
6
|
+
import { ModelTypes } from "../zeus/index.js";
|
|
7
|
+
export declare class ReviewsService {
|
|
8
|
+
private readonly options;
|
|
9
|
+
private readonly connection;
|
|
10
|
+
private readonly reviewStateMachine;
|
|
11
|
+
private readonly productVariantService;
|
|
12
|
+
private readonly orderService;
|
|
13
|
+
private readonly translatableSaver;
|
|
14
|
+
private readonly translatorService;
|
|
15
|
+
private readonly customerServicer;
|
|
16
|
+
private readonly listQueryBuilder;
|
|
17
|
+
private readonly eventBus;
|
|
18
|
+
private readonly entityHydrator;
|
|
19
|
+
private readonly logger;
|
|
20
|
+
private readonly error;
|
|
21
|
+
private readonly log;
|
|
22
|
+
translateStrategy: ReviewsPluginOptions["translateStrategy"];
|
|
23
|
+
canTranslate: boolean;
|
|
24
|
+
constructor(options: ReviewsPluginOptions, connection: TransactionalConnection, reviewStateMachine: ReviewStateMachine, productVariantService: ProductVariantService, orderService: OrderService, translatableSaver: TranslatableSaver, translatorService: TranslatorService, customerServicer: CustomerService, listQueryBuilder: ListQueryBuilder, eventBus: EventBus, entityHydrator: EntityHydrator);
|
|
25
|
+
hasShopReviewCreated(ctx: RequestContext, customer: Customer): Promise<boolean>;
|
|
26
|
+
getAverageRatings(ctx: RequestContext): Promise<{
|
|
27
|
+
shopAverageRating: {
|
|
28
|
+
total: number;
|
|
29
|
+
count: number;
|
|
30
|
+
};
|
|
31
|
+
productsAverageRating: {
|
|
32
|
+
total: number;
|
|
33
|
+
count: number;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
getOrderReview(ctx: RequestContext, order: {
|
|
37
|
+
id: ID;
|
|
38
|
+
}, relations?: RelationPaths<ReviewEntity>): Promise<import("@deenruv/core").Translated<ReviewEntity> | null>;
|
|
39
|
+
isOrderReviewed(ctx: RequestContext, order: {
|
|
40
|
+
id: ID;
|
|
41
|
+
}): Promise<boolean>;
|
|
42
|
+
getAverageRating(ctx: RequestContext, product: Product): Promise<number>;
|
|
43
|
+
translateReviews(ctx: RequestContext, input: ModelTypes["TranslateReviewsInput"]): Promise<{
|
|
44
|
+
languageCode: import("../zeus/index.js").LanguageCode;
|
|
45
|
+
body: string;
|
|
46
|
+
summary: string;
|
|
47
|
+
}[]>;
|
|
48
|
+
updateTranslationsReview(ctx: RequestContext, input: ModelTypes["UpdateTranslationsReviewInput"]): Promise<ReviewEntity | undefined>;
|
|
49
|
+
getReviewInfoForProduct(ctx: RequestContext, productId: ID): Promise<{
|
|
50
|
+
averageRating: number;
|
|
51
|
+
totalReviews: number;
|
|
52
|
+
totalRatings: number;
|
|
53
|
+
}>;
|
|
54
|
+
getReviewsConfig(ctx: RequestContext): Promise<{
|
|
55
|
+
canTranslate: boolean;
|
|
56
|
+
reviewsLanguages: string[];
|
|
57
|
+
}>;
|
|
58
|
+
getReview(ctx: RequestContext, id: ID, relations: RelationPaths<ReviewEntity>): Promise<import("@deenruv/core").Translated<ReviewEntity>>;
|
|
59
|
+
changeReviewState(ctx: RequestContext, input: Array<{
|
|
60
|
+
id: ID;
|
|
61
|
+
state: ReviewState;
|
|
62
|
+
message?: string;
|
|
63
|
+
}>): Promise<{
|
|
64
|
+
id: ID;
|
|
65
|
+
success: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
id: ID;
|
|
68
|
+
success: boolean;
|
|
69
|
+
}[]>;
|
|
70
|
+
listReviews(ctx: RequestContext, _options: ModelTypes["ReviewListOptions"], relations?: RelationPaths<ReviewEntity>, showAll?: boolean): Promise<{
|
|
71
|
+
items: import("@deenruv/core").Translated<ReviewEntity>[];
|
|
72
|
+
totalItems: number;
|
|
73
|
+
}>;
|
|
74
|
+
createReview(ctx: RequestContext, input: CreateReviewInput): Promise<ReviewEntity>;
|
|
75
|
+
getReviewsStorage(ctx: RequestContext, input: Array<{
|
|
76
|
+
filename: string;
|
|
77
|
+
}>): Promise<{
|
|
78
|
+
key: string;
|
|
79
|
+
url: string;
|
|
80
|
+
}[]>;
|
|
81
|
+
getReviewAssets(ctx: RequestContext, review: ReviewEntity): Promise<{
|
|
82
|
+
key: string;
|
|
83
|
+
url: string;
|
|
84
|
+
}[]>;
|
|
85
|
+
}
|