@mohasinac/appkit 4.20.0 → 4.21.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.
@@ -13,7 +13,7 @@ export async function createReviewAction(input) {
13
13
  if (!parsed.success) {
14
14
  throw new ValidationError(parsed.error.issues[0]?.message ?? "Invalid input");
15
15
  }
16
- const { productId, storeId, rating, title, body, images } = parsed.data;
16
+ const { productId, storeId, rating, title, comment, images } = parsed.data;
17
17
  await assertNotDuplicateReview(productId, user.uid);
18
18
  const product = await productRepository.findById(productId);
19
19
  const profile = await userRepository.findById(user.uid);
@@ -27,7 +27,9 @@ export async function createReviewAction(input) {
27
27
  userAvatar: profile?.photoURL ?? "",
28
28
  rating,
29
29
  title,
30
- comment: body,
30
+ // Was `comment: body` — the schema called the field `body` and this
31
+ // line translated it. Both now use the document's own name.
32
+ comment,
31
33
  images: images ?? [],
32
34
  verified: false,
33
35
  status: "pending",
@@ -4,23 +4,23 @@ export declare const createReviewSchema: z.ZodObject<{
4
4
  storeId: z.ZodString;
5
5
  rating: z.ZodNumber;
6
6
  title: z.ZodString;
7
- body: z.ZodString;
7
+ comment: z.ZodString;
8
8
  images: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
9
9
  orderId: z.ZodOptional<z.ZodString>;
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  title: string;
12
- body: string;
13
12
  storeId: string;
14
13
  rating: number;
15
14
  images: string[];
16
15
  productId: string;
16
+ comment: string;
17
17
  orderId?: string | undefined;
18
18
  }, {
19
19
  title: string;
20
- body: string;
21
20
  storeId: string;
22
21
  rating: number;
23
22
  productId: string;
23
+ comment: string;
24
24
  orderId?: string | undefined;
25
25
  images?: string[] | undefined;
26
26
  }>;
@@ -5,7 +5,17 @@ export const createReviewSchema = z.object({
5
5
  storeId: z.string().min(1),
6
6
  rating: z.number().int().min(REVIEW_MIN_RATING).max(REVIEW_MAX_RATING),
7
7
  title: z.string().min(1).max(REVIEW_TITLE_MAX_LENGTH),
8
- body: z.string().min(REVIEW_BODY_MIN_LENGTH).max(REVIEW_BODY_MAX_LENGTH),
8
+ /*
9
+ * 🛑 This was named `body`. The field is `comment` — on `ReviewDocument`
10
+ * (schemas/firestore.ts:39), on `CreateReviewActionInput`, and in what
11
+ * `useCreateReview` actually sends. So this schema disagreed with the
12
+ * document, the action AND the client, and would have rejected every real
13
+ * submission the moment anything used it to validate one.
14
+ *
15
+ * It went unnoticed because `POST /api/reviews` passed `body as any` and
16
+ * never consulted it.
17
+ */
18
+ comment: z.string().min(REVIEW_BODY_MIN_LENGTH).max(REVIEW_BODY_MAX_LENGTH),
9
19
  images: z.array(z.string().url()).max(REVIEW_IMAGES_MAX).default([]),
10
20
  orderId: z.string().optional(),
11
21
  });
package/dist/index.d.ts CHANGED
@@ -3292,3 +3292,5 @@ export { adminOrderUpdateSchema, employeeInviteSchema, hardBanReasonSchema, feat
3292
3292
  export { changeEmailSchema } from "./features/account/schemas/index";
3293
3293
  export { adminUserUpdateSchema, whatsappSettingsSchema, lotteryPullSchema, } from "./features/admin/schemas/admin-user-form";
3294
3294
  export { siteSettingsFormSchema } from "./features/admin/schemas/site-settings-form";
3295
+ export { createReviewSchema as reviewSubmitSchema } from "./_internal/shared/features/reviews/schema";
3296
+ export { wishlistAddSchema } from "./schemas/api-routes";
package/dist/index.js CHANGED
@@ -5702,3 +5702,12 @@ export { adminOrderUpdateSchema, employeeInviteSchema, hardBanReasonSchema, feat
5702
5702
  export { changeEmailSchema } from "./features/account/schemas/index";
5703
5703
  export { adminUserUpdateSchema, whatsappSettingsSchema, lotteryPullSchema, } from "./features/admin/schemas/admin-user-form";
5704
5704
  export { siteSettingsFormSchema } from "./features/admin/schemas/site-settings-form";
5705
+ /*
5706
+ * Two schemas that existed and whose own routes did not use them.
5707
+ * `postApiWishlist` had sat in SCHEMAS.api since the registry was seeded while
5708
+ * `/api/wishlist` read its body raw; `createReviewSchema` was reachable only
5709
+ * through a server action while `POST /api/reviews` passed `body as any`.
5710
+ * Re-exported here under names that read clearly at a route call site.
5711
+ */
5712
+ export { createReviewSchema as reviewSubmitSchema } from "./_internal/shared/features/reviews/schema";
5713
+ export { wishlistAddSchema } from "./schemas/api-routes";
@@ -1,4 +1,13 @@
1
+ import { z } from "zod";
1
2
  import type { ApiRouteSchema } from "./types";
3
+ /** The body shape, named so a route can import it directly. */
4
+ export declare const wishlistAddSchema: z.ZodObject<{
5
+ productId: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ productId: string;
8
+ }, {
9
+ productId: string;
10
+ }>;
2
11
  export declare const postApiWishlist: ApiRouteSchema;
3
12
  export declare const postApiAuthSession: ApiRouteSchema;
4
13
  export declare const postApiAdminProductsIdGroup: ApiRouteSchema;
@@ -16,10 +16,12 @@
16
16
  // as the highest unknown-leakage offenders). W5–W7 will register the rest.
17
17
  import { z } from "zod";
18
18
  // ── POST /api/wishlist ────────────────────────────────────────────────────────
19
+ /** The body shape, named so a route can import it directly. */
20
+ export const wishlistAddSchema = z.object({
21
+ productId: z.string().min(1),
22
+ });
19
23
  export const postApiWishlist = {
20
- body: z.object({
21
- productId: z.string().min(1),
22
- }),
24
+ body: wishlistAddSchema,
23
25
  };
24
26
  // ── POST /api/auth/session ───────────────────────────────────────────────────
25
27
  export const postApiAuthSession = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohasinac/appkit",
3
- "version": "4.20.0",
3
+ "version": "4.21.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"