@86d-app/reviews 0.0.22 → 0.0.23
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/admin/components/review-list.d.ts.map +1 -1
- package/dist/admin/components/review-moderation.d.ts.map +1 -1
- package/dist/service-impl.d.ts.map +1 -1
- package/dist/service.d.ts +18 -18
- package/dist/service.d.ts.map +1 -1
- package/dist/store/components/_utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/admin/components/review-list.tsx +3 -2
- package/src/admin/components/review-moderation.tsx +3 -2
- package/src/service-impl.ts +17 -26
- package/src/service.ts +18 -18
- package/src/store/components/_utils.ts +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-list.d.ts","sourceRoot":"","sources":["../../../src/admin/components/review-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"review-list.d.ts","sourceRoot":"","sources":["../../../src/admin/components/review-list.tsx"],"names":[],"mappings":"AAsGA,wBAAgB,UAAU,gCA8MzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-moderation.d.ts","sourceRoot":"","sources":["../../../src/admin/components/review-moderation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"review-moderation.d.ts","sourceRoot":"","sources":["../../../src/admin/components/review-moderation.tsx"],"names":[],"mappings":"AA+FA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,+BA4VA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-impl.d.ts","sourceRoot":"","sources":["../src/service-impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAEX,gBAAgB,EAMhB,MAAM,WAAW,CAAC;AAwBnB,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GACjC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"service-impl.d.ts","sourceRoot":"","sources":["../src/service-impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAEX,gBAAgB,EAMhB,MAAM,WAAW,CAAC;AAwBnB,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GACjC,gBAAgB,CA6WlB"}
|
package/dist/service.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type { ModuleController } from "@86d-app/core";
|
|
|
2
2
|
export type ReviewStatus = "pending" | "approved" | "rejected";
|
|
3
3
|
export type ReportStatus = "pending" | "resolved" | "dismissed";
|
|
4
4
|
export type ReviewSortBy = "recent" | "oldest" | "highest" | "lowest" | "helpful";
|
|
5
|
-
export
|
|
5
|
+
export type ReviewImage = {
|
|
6
6
|
url: string;
|
|
7
7
|
caption?: string | undefined;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
8
|
+
};
|
|
9
|
+
export type Review = {
|
|
10
10
|
id: string;
|
|
11
11
|
productId: string;
|
|
12
12
|
customerId?: string | undefined;
|
|
@@ -24,19 +24,19 @@ export interface Review {
|
|
|
24
24
|
moderationNote?: string | undefined;
|
|
25
25
|
createdAt: Date;
|
|
26
26
|
updatedAt: Date;
|
|
27
|
-
}
|
|
28
|
-
export
|
|
27
|
+
};
|
|
28
|
+
export type RatingSummary = {
|
|
29
29
|
average: number;
|
|
30
30
|
count: number;
|
|
31
31
|
distribution: Record<string, number>;
|
|
32
|
-
}
|
|
33
|
-
export
|
|
32
|
+
};
|
|
33
|
+
export type ReviewVote = {
|
|
34
34
|
id: string;
|
|
35
35
|
reviewId: string;
|
|
36
36
|
voterId: string;
|
|
37
37
|
createdAt: Date;
|
|
38
|
-
}
|
|
39
|
-
export
|
|
38
|
+
};
|
|
39
|
+
export type ReviewReport = {
|
|
40
40
|
id: string;
|
|
41
41
|
reviewId: string;
|
|
42
42
|
reporterId?: string | undefined;
|
|
@@ -44,8 +44,8 @@ export interface ReviewReport {
|
|
|
44
44
|
details?: string | undefined;
|
|
45
45
|
status: ReportStatus;
|
|
46
46
|
createdAt: Date;
|
|
47
|
-
}
|
|
48
|
-
export
|
|
47
|
+
};
|
|
48
|
+
export type ReviewController = ModuleController & {
|
|
49
49
|
createReview(params: {
|
|
50
50
|
productId: string;
|
|
51
51
|
authorName: string;
|
|
@@ -119,8 +119,8 @@ export interface ReviewController extends ModuleController {
|
|
|
119
119
|
}): Promise<ReviewReport[]>;
|
|
120
120
|
updateReportStatus(id: string, status: ReportStatus): Promise<ReviewReport | null>;
|
|
121
121
|
getReportCount(reviewId: string): Promise<number>;
|
|
122
|
-
}
|
|
123
|
-
export
|
|
122
|
+
};
|
|
123
|
+
export type ReviewAnalytics = {
|
|
124
124
|
totalReviews: number;
|
|
125
125
|
pendingCount: number;
|
|
126
126
|
approvedCount: number;
|
|
@@ -129,8 +129,8 @@ export interface ReviewAnalytics {
|
|
|
129
129
|
ratingsDistribution: Record<string, number>;
|
|
130
130
|
withMerchantResponse: number;
|
|
131
131
|
reportedCount: number;
|
|
132
|
-
}
|
|
133
|
-
export
|
|
132
|
+
};
|
|
133
|
+
export type ReviewRequest = {
|
|
134
134
|
id: string;
|
|
135
135
|
orderId: string;
|
|
136
136
|
orderNumber: string;
|
|
@@ -141,9 +141,9 @@ export interface ReviewRequest {
|
|
|
141
141
|
name: string;
|
|
142
142
|
}>;
|
|
143
143
|
sentAt: Date;
|
|
144
|
-
}
|
|
145
|
-
export
|
|
144
|
+
};
|
|
145
|
+
export type ReviewRequestStats = {
|
|
146
146
|
totalSent: number;
|
|
147
147
|
uniqueOrders: number;
|
|
148
|
-
}
|
|
148
|
+
};
|
|
149
149
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AAChE,MAAM,MAAM,YAAY,GACrB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,CAAC;AAEb,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AAChE,MAAM,MAAM,YAAY,GACrB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,CAAC;AAEb,MAAM,MAAM,WAAW,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf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,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,MAAM,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_utils.d.ts","sourceRoot":"","sources":["../../../src/store/components/_utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"_utils.d.ts","sourceRoot":"","sources":["../../../src/store/components/_utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ1E"}
|
package/package.json
CHANGED
|
@@ -41,8 +41,9 @@ function formatDate(iso: string): string {
|
|
|
41
41
|
|
|
42
42
|
function extractError(error: Error | null, fallback: string): string {
|
|
43
43
|
if (!error) return fallback;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const body = (
|
|
45
|
+
error as Error & { body?: { error?: string | { message?: string } } }
|
|
46
|
+
).body;
|
|
46
47
|
if (typeof body?.error === "string") return body.error;
|
|
47
48
|
if (typeof body?.error?.message === "string") return body.error.message;
|
|
48
49
|
return fallback;
|
|
@@ -33,8 +33,9 @@ function formatDate(iso: string): string {
|
|
|
33
33
|
|
|
34
34
|
function extractError(error: Error | null, fallback: string): string {
|
|
35
35
|
if (!error) return fallback;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const body = (
|
|
37
|
+
error as Error & { body?: { error?: string | { message?: string } } }
|
|
38
|
+
).body;
|
|
38
39
|
if (typeof body?.error === "string") return body.error;
|
|
39
40
|
if (typeof body?.error?.message === "string") return body.error.message;
|
|
40
41
|
return fallback;
|
package/src/service-impl.ts
CHANGED
|
@@ -59,8 +59,7 @@ export function createReviewController(
|
|
|
59
59
|
createdAt: now,
|
|
60
60
|
updatedAt: now,
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
await data.upsert("review", id, review as Record<string, any>);
|
|
62
|
+
await data.upsert("review", id, review as Record<string, unknown>);
|
|
64
63
|
return review;
|
|
65
64
|
},
|
|
66
65
|
|
|
@@ -71,8 +70,7 @@ export function createReviewController(
|
|
|
71
70
|
},
|
|
72
71
|
|
|
73
72
|
async listReviewsByProduct(productId, params) {
|
|
74
|
-
|
|
75
|
-
const where: Record<string, any> = { productId };
|
|
73
|
+
const where: Record<string, unknown> = { productId };
|
|
76
74
|
if (params?.approvedOnly) where.status = "approved";
|
|
77
75
|
|
|
78
76
|
const all = await data.findMany("review", {
|
|
@@ -97,8 +95,7 @@ export function createReviewController(
|
|
|
97
95
|
},
|
|
98
96
|
|
|
99
97
|
async listReviews(params) {
|
|
100
|
-
|
|
101
|
-
const where: Record<string, any> = {};
|
|
98
|
+
const where: Record<string, unknown> = {};
|
|
102
99
|
if (params?.productId) where.productId = params.productId;
|
|
103
100
|
if (params?.status) where.status = params.status;
|
|
104
101
|
|
|
@@ -120,8 +117,7 @@ export function createReviewController(
|
|
|
120
117
|
updatedAt: new Date(),
|
|
121
118
|
...(moderationNote !== undefined ? { moderationNote } : {}),
|
|
122
119
|
};
|
|
123
|
-
|
|
124
|
-
await data.upsert("review", id, updated as Record<string, any>);
|
|
120
|
+
await data.upsert("review", id, updated as Record<string, unknown>);
|
|
125
121
|
return updated;
|
|
126
122
|
},
|
|
127
123
|
|
|
@@ -142,8 +138,7 @@ export function createReviewController(
|
|
|
142
138
|
merchantResponseAt: new Date(),
|
|
143
139
|
updatedAt: new Date(),
|
|
144
140
|
};
|
|
145
|
-
|
|
146
|
-
await data.upsert("review", id, updated as Record<string, any>);
|
|
141
|
+
await data.upsert("review", id, updated as Record<string, unknown>);
|
|
147
142
|
return updated;
|
|
148
143
|
},
|
|
149
144
|
|
|
@@ -156,8 +151,7 @@ export function createReviewController(
|
|
|
156
151
|
helpfulCount: review.helpfulCount + 1,
|
|
157
152
|
updatedAt: new Date(),
|
|
158
153
|
};
|
|
159
|
-
|
|
160
|
-
await data.upsert("review", id, updated as Record<string, any>);
|
|
154
|
+
await data.upsert("review", id, updated as Record<string, unknown>);
|
|
161
155
|
return updated;
|
|
162
156
|
},
|
|
163
157
|
|
|
@@ -185,8 +179,7 @@ export function createReviewController(
|
|
|
185
179
|
voterId,
|
|
186
180
|
createdAt: new Date(),
|
|
187
181
|
};
|
|
188
|
-
|
|
189
|
-
await data.upsert("reviewVote", voteId, vote as Record<string, any>);
|
|
182
|
+
await data.upsert("reviewVote", voteId, vote as Record<string, unknown>);
|
|
190
183
|
|
|
191
184
|
// Increment helpful count
|
|
192
185
|
const updated: Review = {
|
|
@@ -194,8 +187,7 @@ export function createReviewController(
|
|
|
194
187
|
helpfulCount: review.helpfulCount + 1,
|
|
195
188
|
updatedAt: new Date(),
|
|
196
189
|
};
|
|
197
|
-
|
|
198
|
-
await data.upsert("review", reviewId, updated as Record<string, any>);
|
|
190
|
+
await data.upsert("review", reviewId, updated as Record<string, unknown>);
|
|
199
191
|
|
|
200
192
|
return { review: updated, alreadyVoted: false };
|
|
201
193
|
},
|
|
@@ -294,8 +286,11 @@ export function createReviewController(
|
|
|
294
286
|
items: params.items,
|
|
295
287
|
sentAt: new Date(),
|
|
296
288
|
};
|
|
297
|
-
|
|
298
|
-
|
|
289
|
+
await data.upsert(
|
|
290
|
+
"reviewRequest",
|
|
291
|
+
id,
|
|
292
|
+
request as Record<string, unknown>,
|
|
293
|
+
);
|
|
299
294
|
return request;
|
|
300
295
|
},
|
|
301
296
|
|
|
@@ -317,8 +312,7 @@ export function createReviewController(
|
|
|
317
312
|
},
|
|
318
313
|
|
|
319
314
|
async listReviewsByCustomer(customerId, params) {
|
|
320
|
-
|
|
321
|
-
const where: Record<string, any> = { customerId };
|
|
315
|
+
const where: Record<string, unknown> = { customerId };
|
|
322
316
|
if (params?.status) where.status = params.status;
|
|
323
317
|
|
|
324
318
|
const all = await data.findMany("review", {
|
|
@@ -358,14 +352,12 @@ export function createReviewController(
|
|
|
358
352
|
status: "pending",
|
|
359
353
|
createdAt: new Date(),
|
|
360
354
|
};
|
|
361
|
-
|
|
362
|
-
await data.upsert("reviewReport", id, report as Record<string, any>);
|
|
355
|
+
await data.upsert("reviewReport", id, report as Record<string, unknown>);
|
|
363
356
|
return report;
|
|
364
357
|
},
|
|
365
358
|
|
|
366
359
|
async listReports(params) {
|
|
367
|
-
|
|
368
|
-
const where: Record<string, any> = {};
|
|
360
|
+
const where: Record<string, unknown> = {};
|
|
369
361
|
if (params?.status) where.status = params.status;
|
|
370
362
|
if (params?.reviewId) where.reviewId = params.reviewId;
|
|
371
363
|
|
|
@@ -385,8 +377,7 @@ export function createReviewController(
|
|
|
385
377
|
...report,
|
|
386
378
|
status,
|
|
387
379
|
};
|
|
388
|
-
|
|
389
|
-
await data.upsert("reviewReport", id, updated as Record<string, any>);
|
|
380
|
+
await data.upsert("reviewReport", id, updated as Record<string, unknown>);
|
|
390
381
|
return updated;
|
|
391
382
|
},
|
|
392
383
|
|
package/src/service.ts
CHANGED
|
@@ -9,12 +9,12 @@ export type ReviewSortBy =
|
|
|
9
9
|
| "lowest"
|
|
10
10
|
| "helpful";
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type ReviewImage = {
|
|
13
13
|
url: string;
|
|
14
14
|
caption?: string | undefined;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export type Review = {
|
|
18
18
|
id: string;
|
|
19
19
|
productId: string;
|
|
20
20
|
customerId?: string | undefined;
|
|
@@ -32,22 +32,22 @@ export interface Review {
|
|
|
32
32
|
moderationNote?: string | undefined;
|
|
33
33
|
createdAt: Date;
|
|
34
34
|
updatedAt: Date;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
|
|
37
|
-
export
|
|
37
|
+
export type RatingSummary = {
|
|
38
38
|
average: number;
|
|
39
39
|
count: number;
|
|
40
40
|
distribution: Record<string, number>;
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
|
|
43
|
-
export
|
|
43
|
+
export type ReviewVote = {
|
|
44
44
|
id: string;
|
|
45
45
|
reviewId: string;
|
|
46
46
|
voterId: string;
|
|
47
47
|
createdAt: Date;
|
|
48
|
-
}
|
|
48
|
+
};
|
|
49
49
|
|
|
50
|
-
export
|
|
50
|
+
export type ReviewReport = {
|
|
51
51
|
id: string;
|
|
52
52
|
reviewId: string;
|
|
53
53
|
reporterId?: string | undefined;
|
|
@@ -55,9 +55,9 @@ export interface ReviewReport {
|
|
|
55
55
|
details?: string | undefined;
|
|
56
56
|
status: ReportStatus;
|
|
57
57
|
createdAt: Date;
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
59
|
|
|
60
|
-
export
|
|
60
|
+
export type ReviewController = ModuleController & {
|
|
61
61
|
createReview(params: {
|
|
62
62
|
productId: string;
|
|
63
63
|
authorName: string;
|
|
@@ -158,9 +158,9 @@ export interface ReviewController extends ModuleController {
|
|
|
158
158
|
): Promise<ReviewReport | null>;
|
|
159
159
|
|
|
160
160
|
getReportCount(reviewId: string): Promise<number>;
|
|
161
|
-
}
|
|
161
|
+
};
|
|
162
162
|
|
|
163
|
-
export
|
|
163
|
+
export type ReviewAnalytics = {
|
|
164
164
|
totalReviews: number;
|
|
165
165
|
pendingCount: number;
|
|
166
166
|
approvedCount: number;
|
|
@@ -169,9 +169,9 @@ export interface ReviewAnalytics {
|
|
|
169
169
|
ratingsDistribution: Record<string, number>;
|
|
170
170
|
withMerchantResponse: number;
|
|
171
171
|
reportedCount: number;
|
|
172
|
-
}
|
|
172
|
+
};
|
|
173
173
|
|
|
174
|
-
export
|
|
174
|
+
export type ReviewRequest = {
|
|
175
175
|
id: string;
|
|
176
176
|
orderId: string;
|
|
177
177
|
orderNumber: string;
|
|
@@ -179,9 +179,9 @@ export interface ReviewRequest {
|
|
|
179
179
|
customerName: string;
|
|
180
180
|
items: Array<{ productId: string; name: string }>;
|
|
181
181
|
sentAt: Date;
|
|
182
|
-
}
|
|
182
|
+
};
|
|
183
183
|
|
|
184
|
-
export
|
|
184
|
+
export type ReviewRequestStats = {
|
|
185
185
|
totalSent: number;
|
|
186
186
|
uniqueOrders: number;
|
|
187
|
-
}
|
|
187
|
+
};
|
|
@@ -8,8 +8,9 @@ export function formatDate(iso: string): string {
|
|
|
8
8
|
|
|
9
9
|
export function extractError(error: Error | null, fallback: string): string {
|
|
10
10
|
if (!error) return fallback;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const body = (
|
|
12
|
+
error as Error & { body?: { error?: string | { message?: string } } }
|
|
13
|
+
).body;
|
|
13
14
|
if (typeof body?.error === "string") return body.error;
|
|
14
15
|
if (typeof body?.error?.message === "string") return body.error.message;
|
|
15
16
|
return fallback;
|