@reactionary/core 0.3.12 → 0.3.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
@@ -1,5 +1,14 @@
1
1
  import { BaseProvider } from "./base.provider.js";
2
+ import {} from "../schemas/models/identifiers.model.js";
2
3
  class ProductReviewsProvider extends BaseProvider {
4
+ createEmptyProductRatingSummary(key) {
5
+ return {
6
+ identifier: key,
7
+ averageRating: 0,
8
+ totalRatings: void 0,
9
+ ratingDistribution: void 0
10
+ };
11
+ }
3
12
  getResourceName() {
4
13
  return "product-reviews";
5
14
  }
@@ -1,5 +1,5 @@
1
1
  import * as z from "zod";
2
- import { BaseModelSchema } from "./base.model.js";
2
+ import { BaseModelSchema, createPaginatedResponseSchema } from "./base.model.js";
3
3
  import { ProductIdentifierSchema, ProductRatingIdentifierSchema, ProductReviewIdentifierSchema } from "./identifiers.model.js";
4
4
  const ProductRatingSummarySchema = BaseModelSchema.extend({
5
5
  identifier: ProductRatingIdentifierSchema,
@@ -27,7 +27,9 @@ const ProductReviewSchema = BaseModelSchema.extend({
27
27
  updatedAt: z.string().optional().meta({ description: "ISO8601 timestamp when the review was last updated." }),
28
28
  verified: z.boolean().meta({ description: "Whether this is a verified purchase review." })
29
29
  });
30
+ const ProductReviewPaginatedResultSchema = createPaginatedResponseSchema(ProductReviewSchema);
30
31
  export {
31
32
  ProductRatingSummarySchema,
33
+ ProductReviewPaginatedResultSchema,
32
34
  ProductReviewSchema
33
35
  };
@@ -1,7 +1,8 @@
1
- import type { Result, ProductReview, ProductRatingSummary } from '../schemas/index.js';
1
+ import type { Result, ProductReview, ProductRatingSummary, ProductReviewPaginatedResult } from '../schemas/index.js';
2
2
  import type { ProductReviewsListQuery, ProductReviewsGetRatingSummaryQuery } from '../schemas/queries/product-reviews.query.js';
3
3
  import type { ProductReviewMutationSubmit } from '../schemas/mutations/product-reviews.mutation.js';
4
4
  import { BaseProvider } from './base.provider.js';
5
+ import { type ProductRatingIdentifier } from '../schemas/models/identifiers.model.js';
5
6
  /**
6
7
  * The product reviews provider is responsible for providing detailed product reviews from customers.
7
8
  * Reviews contain ratings along with textual feedback, author information, and verification status.
@@ -21,7 +22,7 @@ export declare abstract class ProductReviewsProvider extends BaseProvider {
21
22
  * Usecase: Display customer reviews on product detail pages with filtering and sorting options.
22
23
  * @param query The query parameters including product, pagination, sorting, and filtering options
23
24
  */
24
- abstract listReviews(query: ProductReviewsListQuery): Promise<Result<ProductReview[]>>;
25
+ abstract findReviews(query: ProductReviewsListQuery): Promise<Result<ProductReviewPaginatedResult>>;
25
26
  /**
26
27
  * Submit a review for a product.
27
28
  *
@@ -29,5 +30,6 @@ export declare abstract class ProductReviewsProvider extends BaseProvider {
29
30
  * @param mutation The review submission data including rating, title, and content
30
31
  */
31
32
  abstract submitReview(mutation: ProductReviewMutationSubmit): Promise<Result<ProductReview>>;
33
+ protected createEmptyProductRatingSummary(key: ProductRatingIdentifier): ProductRatingSummary;
32
34
  getResourceName(): string;
33
35
  }
@@ -37,5 +37,30 @@ export declare const ProductReviewSchema: z.ZodObject<{
37
37
  updatedAt: z.ZodOptional<z.ZodString>;
38
38
  verified: z.ZodBoolean;
39
39
  }, z.core.$loose>;
40
+ export declare const ProductReviewPaginatedResultSchema: z.ZodObject<{
41
+ pageNumber: z.ZodNumber;
42
+ pageSize: z.ZodNumber;
43
+ totalCount: z.ZodNumber;
44
+ totalPages: z.ZodNumber;
45
+ items: z.ZodArray<z.ZodObject<{
46
+ identifier: z.ZodObject<{
47
+ key: z.ZodString;
48
+ }, z.core.$loose>;
49
+ product: z.ZodObject<{
50
+ key: z.ZodString;
51
+ }, z.core.$loose>;
52
+ authorName: z.ZodString;
53
+ authorId: z.ZodOptional<z.ZodString>;
54
+ rating: z.ZodNumber;
55
+ title: z.ZodString;
56
+ content: z.ZodString;
57
+ reply: z.ZodOptional<z.ZodString>;
58
+ repliedAt: z.ZodOptional<z.ZodString>;
59
+ createdAt: z.ZodString;
60
+ updatedAt: z.ZodOptional<z.ZodString>;
61
+ verified: z.ZodBoolean;
62
+ }, z.core.$loose>>;
63
+ }, z.core.$strip>;
64
+ export type ProductReviewPaginatedResult = InferType<typeof ProductReviewPaginatedResultSchema>;
40
65
  export type ProductReview = InferType<typeof ProductReviewSchema>;
41
66
  export type ProductRatingSummary = InferType<typeof ProductRatingSummarySchema>;