@alphabite/medusa-wishlist 0.4.9 → 0.5.1
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/.medusa/server/src/index.js +18 -0
- package/.medusa/server/src/modules/wishlist/models/wishlist-item.js +1 -1
- package/.medusa/server/src/modules/wishlist/models/wishlist.js +1 -1
- package/.medusa/server/src/modules/wishlist/service.js +6 -5
- package/.medusa/server/src/types/index.js +18 -0
- package/.medusa/server/src/types/types.js +3 -0
- package/.medusa/types/api/store/wishlists/[id]/add-item/validators.d.ts +9 -0
- package/.medusa/types/api/store/wishlists/[id]/validators.d.ts +9 -0
- package/.medusa/types/api/store/wishlists/import/validators.d.ts +9 -0
- package/.medusa/types/api/store/wishlists/total-items-count/validators.d.ts +9 -0
- package/.medusa/types/api/store/wishlists/types.d.ts +33 -0
- package/.medusa/types/api/store/wishlists/validators.d.ts +29 -0
- package/.medusa/types/index.d.ts +1 -0
- package/.medusa/types/modules/wishlist/models/wishlist-item.d.ts +11 -0
- package/.medusa/types/modules/wishlist/models/wishlist.d.ts +11 -0
- package/.medusa/types/modules/wishlist/service.d.ts +107 -0
- package/.medusa/types/types/index.d.ts +1 -0
- package/.medusa/types/types/types.d.ts +8 -0
- package/package.json +13 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDBDQUF3QiJ9
|
|
@@ -17,4 +17,4 @@ exports.WishlistItem = utils_1.model
|
|
|
17
17
|
unique: true,
|
|
18
18
|
},
|
|
19
19
|
]);
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2lzaGxpc3QtaXRlbS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tb2R1bGVzL3dpc2hsaXN0L21vZGVscy93aXNobGlzdC1pdGVtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHFEQUFrRDtBQUNsRCx5Q0FBc0M7QUFHekIsUUFBQSxZQUFZLEdBQUcsYUFBSztLQUM5QixNQUFNLENBQUMsZUFBZSxFQUFFO0lBQ3ZCLEVBQUUsRUFBRSxhQUFLLENBQUMsRUFBRSxDQUFDLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxDQUFDLENBQUMsVUFBVSxFQUFFO0lBQzVDLGtCQUFrQixFQUFFLGFBQUssQ0FBQyxJQUFJLEVBQUU7SUFDaEMsUUFBUSxFQUFFLGFBQUssQ0FBQyxTQUFTLENBQUMsR0FBRyxFQUFFLENBQUMsbUJBQVEsRUFBRTtRQUN4QyxRQUFRLEVBQUUsT0FBTztLQUNsQixDQUFDO0NBQ0gsQ0FBQztLQUNELE9BQU8sQ0FBQztJQUNQO1FBQ0UsRUFBRSxFQUFFLENBQUMsb0JBQW9CLEVBQUUsYUFBYSxDQUFDO1FBQ3pDLE1BQU0sRUFBRSxJQUFJO0tBQ2I7Q0FDRixDQUFDLENBQUMifQ==
|
|
@@ -17,4 +17,4 @@ exports.Wishlist = utils_1.model
|
|
|
17
17
|
where: { customer_id: { $ne: null } },
|
|
18
18
|
},
|
|
19
19
|
]);
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2lzaGxpc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy93aXNobGlzdC9tb2RlbHMvd2lzaGxpc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEscURBQWtEO0FBQ2xELG1EQUErQztBQUdsQyxRQUFBLFFBQVEsR0FBRyxhQUFLO0tBQzFCLE1BQU0sQ0FBQyxVQUFVLEVBQUU7SUFDbEIsRUFBRSxFQUFFLGFBQUssQ0FBQyxFQUFFLENBQUMsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQyxVQUFVLEVBQUU7SUFDM0MsSUFBSSxFQUFFLGFBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQyxRQUFRLEVBQUU7SUFDN0IsV0FBVyxFQUFFLGFBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQyxRQUFRLEVBQUU7SUFDcEMsZ0JBQWdCLEVBQUUsYUFBSyxDQUFDLElBQUksRUFBRTtJQUM5QixLQUFLLEVBQUUsYUFBSyxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQyw0QkFBWSxDQUFDO0NBQ3pDLENBQUM7S0FDRCxPQUFPLENBQUM7SUFDUDtRQUNFLEVBQUUsRUFBRSxDQUFDLGFBQWEsRUFBRSxrQkFBa0IsQ0FBQztRQUN2QyxLQUFLLEVBQUUsRUFBRSxXQUFXLEVBQUUsRUFBRSxHQUFHLEVBQUUsSUFBSSxFQUFFLEVBQUU7S0FDdEM7Q0FDRixDQUFDLENBQUMifQ==
|
|
@@ -50,16 +50,17 @@ class WishlistModuleService extends (0, utils_1.MedusaService)({
|
|
|
50
50
|
.where("wi.product_id = ?", [productId])
|
|
51
51
|
.execute())?.length || 0);
|
|
52
52
|
}
|
|
53
|
-
async totalItemsCount({ customer_id, wishlist_id }, context = {}) {
|
|
53
|
+
async totalItemsCount({ customer_id, wishlist_id, }, context = {}) {
|
|
54
54
|
const wishlist_items_count = await context.manager?.count(wishlist_item_1.WishlistItem, {
|
|
55
55
|
wishlist: {
|
|
56
56
|
...(customer_id && { customer_id }),
|
|
57
|
-
...(wishlist_id &&
|
|
57
|
+
...(wishlist_id &&
|
|
58
|
+
!customer_id && { id: wishlist_id, customer_id: null }),
|
|
58
59
|
},
|
|
59
60
|
});
|
|
60
61
|
return Number(wishlist_items_count || 0);
|
|
61
62
|
}
|
|
62
|
-
async createShareToken({ wishlist_id }) {
|
|
63
|
+
async createShareToken({ wishlist_id, }) {
|
|
63
64
|
const shareToken = jsonwebtoken_1.default.sign({ wishlist_id }, this._options.shareTokenSecret, { expiresIn: "7d" });
|
|
64
65
|
return shareToken;
|
|
65
66
|
}
|
|
@@ -67,7 +68,7 @@ class WishlistModuleService extends (0, utils_1.MedusaService)({
|
|
|
67
68
|
const decoded = jsonwebtoken_1.default.verify(shareToken, this._options.shareTokenSecret);
|
|
68
69
|
return decoded;
|
|
69
70
|
}
|
|
70
|
-
async importWishlist({ id, customer_id }) {
|
|
71
|
+
async importWishlist({ id, customer_id, }) {
|
|
71
72
|
const wishlist = await this.retrieveWishlist(id, { relations: ["items"] });
|
|
72
73
|
if (!wishlist) {
|
|
73
74
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Wishlist with ID ${id} not found`);
|
|
@@ -104,4 +105,4 @@ __decorate([
|
|
|
104
105
|
__metadata("design:paramtypes", [Object, Object]),
|
|
105
106
|
__metadata("design:returntype", Promise)
|
|
106
107
|
], WishlistModuleService.prototype, "totalItemsCount", null);
|
|
107
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
108
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tb2R1bGVzL3dpc2hsaXN0L3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxxREFJbUM7QUFDbkMsZ0RBQTZDO0FBQzdDLDBEQUFzRDtBQUN0RCxxREFBMEQ7QUFHMUQsZ0VBQStCO0FBQy9CLDhDQUFvQjtBQTRDcEIsTUFBTSxhQUFhLEdBQUcsYUFBQyxDQUFDLE1BQU0sQ0FBQztJQUM3QixjQUFjLEVBQUUsYUFBQyxDQUFDLEtBQUssQ0FBQyxhQUFDLENBQUMsTUFBTSxFQUFFLENBQUMsQ0FBQyxRQUFRLEVBQUU7SUFDOUMsbUJBQW1CLEVBQUUsYUFBQyxDQUFDLEtBQUssQ0FBQyxhQUFDLENBQUMsTUFBTSxFQUFFLENBQUMsQ0FBQyxRQUFRLEVBQUU7SUFDbkQsb0JBQW9CLEVBQUUsYUFBQyxDQUFDLE9BQU8sRUFBRSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFDaEQsd0JBQXdCLEVBQUUsYUFBQyxDQUFDLE1BQU0sRUFBRSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7SUFDL0Msa0JBQWtCLEV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QzlCLGtCQUFrQixFQUFFLElBQUksQ0FBQyxrQkFBa0I7Z0JBQzNDLFdBQVcsRUFBRSxXQUFXLENBQUMsRUFBRTthQUM1QixDQUFDLENBQUM7UUFDTCxDQUFDLENBQUMsQ0FDSCxDQUFDO1FBRUYsT0FBTyxFQUFFLEdBQUcsV0FBVyxFQUFFLFdBQVcsRUFBRSxRQUFRLENBQUMsS0FBSyxDQUFDLE1BQU0sRUFBRSxLQUFLLEVBQUUsRUFBRSxFQUFFLENBQUM7SUFDM0UsQ0FBQztDQUNGO0FBeEhELHdDQXdIQztBQWhHTztJQURMLElBQUEscUJBQWEsR0FBRTtJQUdiLFdBQUEsSUFBQSxxQkFBYSxHQUFFLENBQUE7Ozs7dUVBV2pCO0FBR0s7SUFETCxJQUFBLHFCQUFhLEdBQUU7SUFNYixXQUFBLElBQUEscUJBQWEsR0FBRSxDQUFBOzs7OzREQVdqQiJ9
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDBDQUF3QiJ9
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdHlwZXMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AddItemToWishlistInputSchema: z.ZodObject<{
|
|
3
|
+
product_variant_id: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
product_variant_id: string;
|
|
6
|
+
}, {
|
|
7
|
+
product_variant_id: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type AddItemToWishlistInput = z.infer<typeof AddItemToWishlistInputSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const RetrieveWishlistQuerySchema: z.ZodObject<{
|
|
3
|
+
items_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
items_fields?: string[] | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
items_fields?: string[] | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
export type RetrieveWishlistQuery = z.infer<typeof RetrieveWishlistQuerySchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ImportWishlistInputSchema: z.ZodObject<{
|
|
3
|
+
share_token: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
share_token: string;
|
|
6
|
+
}, {
|
|
7
|
+
share_token: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type ImportWishlistInput = z.infer<typeof ImportWishlistInputSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TotalItemsCountInputSchema: z.ZodObject<{
|
|
3
|
+
wishlist_id: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
wishlist_id?: string | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
wishlist_id?: string | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
export type TotalItemsCountInput = z.infer<typeof TotalItemsCountInputSchema>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PriceDTO, ProductDTO, ProductVariantDTO, RemoteQueryFunctionReturnPagination } from "@medusajs/types";
|
|
2
|
+
export interface PaginatedOutputMeta extends RemoteQueryFunctionReturnPagination {
|
|
3
|
+
totalPages: number;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
nextPage: number;
|
|
6
|
+
prevPage: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PaginatedOutput<T> extends PaginatedOutputMeta {
|
|
9
|
+
data: T[];
|
|
10
|
+
}
|
|
11
|
+
export interface WishlistItem {
|
|
12
|
+
id: string;
|
|
13
|
+
product_variant_id: string;
|
|
14
|
+
wishlist_id: string;
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
deleted_at: string | null;
|
|
18
|
+
product_variant: (Omit<ProductVariantDTO, "product"> & {
|
|
19
|
+
product: Pick<ProductDTO, "id" | "thumbnail">;
|
|
20
|
+
prices: PriceDTO[];
|
|
21
|
+
}) | null;
|
|
22
|
+
}
|
|
23
|
+
export interface Wishlist {
|
|
24
|
+
id: string;
|
|
25
|
+
customer_id: string | null;
|
|
26
|
+
sales_channel_id: string;
|
|
27
|
+
created_at: Date | string;
|
|
28
|
+
updated_at: Date | string;
|
|
29
|
+
deleted_at: Date | string | null;
|
|
30
|
+
items: WishlistItem[];
|
|
31
|
+
items_count: number;
|
|
32
|
+
name: string | null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CreateWishlistInputSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodOptional<z.ZodString>;
|
|
4
|
+
sales_channel_id: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
sales_channel_id: string;
|
|
7
|
+
name?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
sales_channel_id: string;
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export type CreateWishlistInput = Zod.infer<typeof CreateWishlistInputSchema>;
|
|
13
|
+
export declare const UpdateWishlistInputSchema: z.ZodObject<Pick<{
|
|
14
|
+
name: z.ZodOptional<z.ZodString>;
|
|
15
|
+
sales_channel_id: z.ZodString;
|
|
16
|
+
}, "name">, "strip", z.ZodTypeAny, {
|
|
17
|
+
name?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type UpdateWishlistInput = Zod.infer<typeof UpdateWishlistInputSchema>;
|
|
22
|
+
export declare const ListWishlistsQuerySchema: z.ZodObject<{
|
|
23
|
+
items_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
items_fields?: string[] | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
items_fields?: string[] | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type ListWishlistsQuery = Zod.infer<typeof ListWishlistsQuerySchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const WishlistItem: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
3
|
+
product_variant_id: import("@medusajs/framework/utils").TextProperty;
|
|
4
|
+
wishlist: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
5
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
6
|
+
name: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
7
|
+
customer_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
8
|
+
sales_channel_id: import("@medusajs/framework/utils").TextProperty;
|
|
9
|
+
items: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "wishlist_item">>;
|
|
10
|
+
}>, "wishlist">, undefined>;
|
|
11
|
+
}>, "wishlist_item">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const Wishlist: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
3
|
+
name: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
4
|
+
customer_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
5
|
+
sales_channel_id: import("@medusajs/framework/utils").TextProperty;
|
|
6
|
+
items: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
7
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
8
|
+
product_variant_id: import("@medusajs/framework/utils").TextProperty;
|
|
9
|
+
wishlist: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "wishlist">, undefined>;
|
|
10
|
+
}>, "wishlist_item">>;
|
|
11
|
+
}>, "wishlist">;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Context } from "@medusajs/framework/types";
|
|
2
|
+
import { EntityManager } from "@mikro-orm/knex";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
import { Wishlist as WishlistType } from "../../api/store/wishlists/types";
|
|
5
|
+
/**
|
|
6
|
+
* Options for configuring the Alphabite Wishlist Plugin
|
|
7
|
+
*/
|
|
8
|
+
export type AlphabiteWishlistPluginOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* List of fields to retrieve when fetching a wishlist.
|
|
11
|
+
* Example: ['id', 'name', 'createdAt']
|
|
12
|
+
*/
|
|
13
|
+
wishlistFields?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* List of fields to retrieve for each wishlist item.
|
|
16
|
+
* Example: ['id', 'name', 'price']
|
|
17
|
+
*/
|
|
18
|
+
wishlistItemsFields?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Whether to include wishlist items when fetching a wishlist.
|
|
21
|
+
* Default: false
|
|
22
|
+
*/
|
|
23
|
+
includeWishlistItems?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Number of wishlist items to include when `includeWishlistItems` is true.
|
|
26
|
+
* Default: 5
|
|
27
|
+
*/
|
|
28
|
+
includeWishlistItemsTake?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Whether guests (non-logged-in users) can have a wishlist.
|
|
31
|
+
* Default: false
|
|
32
|
+
*/
|
|
33
|
+
allowGuestWishlist?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Secret used for generating share tokens for wishlists.
|
|
36
|
+
* Default: 'default_secret'
|
|
37
|
+
*/
|
|
38
|
+
shareTokenSecret?: string;
|
|
39
|
+
};
|
|
40
|
+
declare const optionsSchema: z.ZodObject<{
|
|
41
|
+
wishlistFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
+
wishlistItemsFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
43
|
+
includeWishlistItems: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
includeWishlistItemsTake: z.ZodDefault<z.ZodNumber>;
|
|
45
|
+
allowGuestWishlist: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
shareTokenSecret: z.ZodDefault<z.ZodString>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
includeWishlistItems: boolean;
|
|
49
|
+
includeWishlistItemsTake: number;
|
|
50
|
+
allowGuestWishlist: boolean;
|
|
51
|
+
shareTokenSecret: string;
|
|
52
|
+
wishlistFields?: string[] | undefined;
|
|
53
|
+
wishlistItemsFields?: string[] | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
wishlistFields?: string[] | undefined;
|
|
56
|
+
wishlistItemsFields?: string[] | undefined;
|
|
57
|
+
includeWishlistItems?: boolean | undefined;
|
|
58
|
+
includeWishlistItemsTake?: number | undefined;
|
|
59
|
+
allowGuestWishlist?: boolean | undefined;
|
|
60
|
+
shareTokenSecret?: string | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
export type AlphabiteWishlistPluginOptionsType = z.infer<typeof optionsSchema>;
|
|
63
|
+
declare const WishlistModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<import("@medusajs/framework/utils").ModelConfigurationsToConfigTemplate<{
|
|
64
|
+
readonly Wishlist: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
65
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
66
|
+
name: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
67
|
+
customer_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
68
|
+
sales_channel_id: import("@medusajs/framework/utils").TextProperty;
|
|
69
|
+
items: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
70
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
71
|
+
product_variant_id: import("@medusajs/framework/utils").TextProperty;
|
|
72
|
+
wishlist: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "wishlist">, undefined>;
|
|
73
|
+
}>, "wishlist_item">>;
|
|
74
|
+
}>, "wishlist">;
|
|
75
|
+
readonly WishlistItem: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
76
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
77
|
+
product_variant_id: import("@medusajs/framework/utils").TextProperty;
|
|
78
|
+
wishlist: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
79
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
80
|
+
name: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
81
|
+
customer_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
82
|
+
sales_channel_id: import("@medusajs/framework/utils").TextProperty;
|
|
83
|
+
items: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "wishlist_item">>;
|
|
84
|
+
}>, "wishlist">, undefined>;
|
|
85
|
+
}>, "wishlist_item">;
|
|
86
|
+
}>>;
|
|
87
|
+
export default class WishlistModuleService extends WishlistModuleService_base {
|
|
88
|
+
_options: AlphabiteWishlistPluginOptionsType;
|
|
89
|
+
static validateOptions(_options: AlphabiteWishlistPluginOptionsType): void | never;
|
|
90
|
+
constructor({}: {}, options: AlphabiteWishlistPluginOptionsType);
|
|
91
|
+
getWishlistCountsOfProduct(productId: string, context?: Context<EntityManager>): Promise<number>;
|
|
92
|
+
totalItemsCount({ customer_id, wishlist_id, }: {
|
|
93
|
+
customer_id?: string;
|
|
94
|
+
wishlist_id?: string;
|
|
95
|
+
}, context?: Context<EntityManager>): Promise<number>;
|
|
96
|
+
createShareToken({ wishlist_id, }: {
|
|
97
|
+
wishlist_id: string;
|
|
98
|
+
}): Promise<string>;
|
|
99
|
+
validateToken(shareToken: string): Promise<{
|
|
100
|
+
wishlist_id: string;
|
|
101
|
+
} | null>;
|
|
102
|
+
importWishlist({ id, customer_id, }: {
|
|
103
|
+
id: string;
|
|
104
|
+
customer_id?: string;
|
|
105
|
+
}): Promise<WishlistType>;
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AlphabiteWishlistPluginOptions } from "../modules/wishlist/service";
|
|
2
|
+
import { type Wishlist, type WishlistItem } from "../api/store/wishlists/types";
|
|
3
|
+
import { type CreateWishlistInput, type CreateWishlistInputSchema, type ListWishlistsQuery, type UpdateWishlistInput } from "../api/store/wishlists/validators";
|
|
4
|
+
import { type TotalItemsCountInput } from "../api/store/wishlists/total-items-count/validators";
|
|
5
|
+
import { type ImportWishlistInput } from "../api/store/wishlists/import/validators";
|
|
6
|
+
import { type RetrieveWishlistQuery } from "../api/store/wishlists/[id]/validators";
|
|
7
|
+
import { type AddItemToWishlistInput } from "../api/store/wishlists/[id]/add-item/validators";
|
|
8
|
+
export type { AlphabiteWishlistPluginOptions, Wishlist, WishlistItem, CreateWishlistInput, CreateWishlistInputSchema, ListWishlistsQuery, UpdateWishlistInput, TotalItemsCountInput, ImportWishlistInput, RetrieveWishlistQuery, AddItemToWishlistInput, };
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphabite/medusa-wishlist",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Alphabite's Medusa Wishlist Plugin",
|
|
5
5
|
"author": "Alphabite (https://alphabite.io)",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"main": "./.medusa/server/src/index.js",
|
|
8
|
+
"types": "./.medusa/types/index.d.ts",
|
|
7
9
|
"files": [
|
|
8
|
-
".medusa/server"
|
|
10
|
+
".medusa/server",
|
|
11
|
+
".medusa/types"
|
|
9
12
|
],
|
|
10
13
|
"bugs": {
|
|
11
14
|
"url": "https://github.com/alphabite-dev/medusa-client/issues"
|
|
@@ -16,6 +19,12 @@
|
|
|
16
19
|
"url": "git+ssh://git@github.com/alphabite-dev/medusa-wishlist.git"
|
|
17
20
|
},
|
|
18
21
|
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./.medusa/types/index.d.ts",
|
|
24
|
+
"import": "./.medusa/server/src/index.js",
|
|
25
|
+
"require": "./.medusa/server/src/index.js",
|
|
26
|
+
"default": "./.medusa/server/src/index.js"
|
|
27
|
+
},
|
|
19
28
|
"./package.json": "./package.json",
|
|
20
29
|
"./workflows": "./.medusa/server/src/workflows/index.js",
|
|
21
30
|
"./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
|
|
@@ -43,7 +52,8 @@
|
|
|
43
52
|
"medusa-wishlist"
|
|
44
53
|
],
|
|
45
54
|
"scripts": {
|
|
46
|
-
"build": "medusa plugin:build",
|
|
55
|
+
"build": "npx medusa plugin:build && npm run build:types",
|
|
56
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
47
57
|
"dev": "medusa plugin:develop",
|
|
48
58
|
"prepublishOnly": "medusa plugin:build"
|
|
49
59
|
},
|