@diffsome/sdk 3.0.0 → 3.2.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/dist/index.mjs CHANGED
@@ -123,6 +123,12 @@ var HttpClient = class {
123
123
  getApiKey() {
124
124
  return this.apiKey;
125
125
  }
126
+ /**
127
+ * Get the base URL with tenant path
128
+ */
129
+ getBaseUrl() {
130
+ return `${this.baseUrl}/api/${this.tenantId}`;
131
+ }
126
132
  /**
127
133
  * Set cart session ID (for guest cart persistence)
128
134
  */
@@ -566,7 +572,7 @@ var BlogResource = class {
566
572
  }
567
573
  /**
568
574
  * Get blog categories
569
- * @returns Array of category names (always an array)
575
+ * @returns Array of blog categories with details
570
576
  */
571
577
  async categories() {
572
578
  const response = await this.http.get("/blog/categories");
@@ -992,6 +998,231 @@ var ShopResource = class {
992
998
  async myReviews(params) {
993
999
  return this.http.getList("/my/reviews", params);
994
1000
  }
1001
+ // ============================================
1002
+ // Wishlist
1003
+ // ============================================
1004
+ /**
1005
+ * Get wishlist items
1006
+ * Requires authentication
1007
+ */
1008
+ async getWishlist(params) {
1009
+ return this.http.getList("/wishlist", params);
1010
+ }
1011
+ /**
1012
+ * Add product to wishlist
1013
+ * Requires authentication
1014
+ */
1015
+ async addToWishlist(data) {
1016
+ return this.http.post("/wishlist", data);
1017
+ }
1018
+ /**
1019
+ * Remove item from wishlist
1020
+ * Requires authentication
1021
+ */
1022
+ async removeFromWishlist(wishlistId) {
1023
+ await this.http.delete(`/wishlist/${wishlistId}`);
1024
+ }
1025
+ /**
1026
+ * Toggle wishlist (add if not in wishlist, remove if in wishlist)
1027
+ * Requires authentication
1028
+ */
1029
+ async toggleWishlist(productId, variantId) {
1030
+ return this.http.post("/wishlist/toggle", {
1031
+ product_id: productId,
1032
+ variant_id: variantId
1033
+ });
1034
+ }
1035
+ /**
1036
+ * Check if product is in wishlist
1037
+ */
1038
+ async isInWishlist(productId, variantId) {
1039
+ const result = await this.http.get("/wishlist/check", {
1040
+ product_id: productId,
1041
+ variant_id: variantId
1042
+ });
1043
+ return result.in_wishlist;
1044
+ }
1045
+ /**
1046
+ * Check multiple products' wishlist status
1047
+ * Useful for product list pages
1048
+ */
1049
+ async checkWishlistBulk(productIds) {
1050
+ const result = await this.http.post("/wishlist/check-bulk", {
1051
+ product_ids: productIds
1052
+ });
1053
+ return result.items;
1054
+ }
1055
+ /**
1056
+ * Get wishlist count
1057
+ */
1058
+ async getWishlistCount() {
1059
+ const result = await this.http.get("/wishlist/count");
1060
+ return result.count;
1061
+ }
1062
+ /**
1063
+ * Move wishlist items to cart
1064
+ * @param wishlistIds - Optional array of wishlist item IDs to move. If empty, moves all items.
1065
+ */
1066
+ async moveWishlistToCart(wishlistIds) {
1067
+ return this.http.post("/wishlist/move-to-cart", {
1068
+ wishlist_ids: wishlistIds
1069
+ });
1070
+ }
1071
+ /**
1072
+ * Update wishlist item note
1073
+ */
1074
+ async updateWishlistNote(wishlistId, note) {
1075
+ return this.http.put(`/wishlist/${wishlistId}`, { note });
1076
+ }
1077
+ /**
1078
+ * Get product's wishlist count (how many users added this product)
1079
+ */
1080
+ async getProductWishlistCount(productSlug) {
1081
+ const result = await this.http.get(`/products/${productSlug}/wishlist-count`);
1082
+ return result.count;
1083
+ }
1084
+ // ============================================
1085
+ // Digital Downloads
1086
+ // ============================================
1087
+ /**
1088
+ * Get my download links
1089
+ * Requires authentication
1090
+ */
1091
+ async getMyDownloads() {
1092
+ const result = await this.http.get("/my/downloads");
1093
+ return result.downloads;
1094
+ }
1095
+ /**
1096
+ * Get download links for a specific order
1097
+ * Requires authentication
1098
+ */
1099
+ async getOrderDownloads(orderNumber) {
1100
+ const result = await this.http.get(
1101
+ `/orders/${orderNumber}/downloads`
1102
+ );
1103
+ return result.downloads;
1104
+ }
1105
+ /**
1106
+ * Get download file URL
1107
+ * Returns the direct download URL for the file
1108
+ * Requires authentication
1109
+ */
1110
+ async downloadFile(token) {
1111
+ return `${this.http.getBaseUrl()}/downloads/${token}`;
1112
+ }
1113
+ /**
1114
+ * Get download link info (without triggering download)
1115
+ * Requires authentication
1116
+ */
1117
+ async getDownloadInfo(token) {
1118
+ const result = await this.http.get(`/downloads/${token}/info`);
1119
+ return result.download;
1120
+ }
1121
+ // ============================================
1122
+ // Subscriptions
1123
+ // ============================================
1124
+ /**
1125
+ * Get my subscriptions
1126
+ * Requires authentication
1127
+ */
1128
+ async getSubscriptions() {
1129
+ const result = await this.http.get("/subscriptions");
1130
+ return result.subscriptions;
1131
+ }
1132
+ /**
1133
+ * Get subscription by ID
1134
+ * Requires authentication
1135
+ */
1136
+ async getSubscription(id) {
1137
+ const result = await this.http.get(`/subscriptions/${id}`);
1138
+ return result.subscription;
1139
+ }
1140
+ /**
1141
+ * Create a new subscription
1142
+ * Requires Stripe payment method ID
1143
+ * Requires authentication
1144
+ */
1145
+ async createSubscription(data) {
1146
+ return this.http.post("/subscriptions", data);
1147
+ }
1148
+ /**
1149
+ * Cancel subscription
1150
+ * @param immediately - If true, cancel immediately. Otherwise, cancel at end of billing period.
1151
+ * Requires authentication
1152
+ */
1153
+ async cancelSubscription(id, immediately = false) {
1154
+ const result = await this.http.post(
1155
+ `/subscriptions/${id}/cancel`,
1156
+ { immediately }
1157
+ );
1158
+ return result.subscription;
1159
+ }
1160
+ /**
1161
+ * Pause subscription
1162
+ * Requires authentication
1163
+ */
1164
+ async pauseSubscription(id) {
1165
+ const result = await this.http.post(
1166
+ `/subscriptions/${id}/pause`
1167
+ );
1168
+ return result.subscription;
1169
+ }
1170
+ /**
1171
+ * Resume paused subscription
1172
+ * Requires authentication
1173
+ */
1174
+ async resumeSubscription(id) {
1175
+ const result = await this.http.post(
1176
+ `/subscriptions/${id}/resume`
1177
+ );
1178
+ return result.subscription;
1179
+ }
1180
+ /**
1181
+ * Create Stripe Setup Intent for adding payment method
1182
+ * Use with Stripe.js to collect card details
1183
+ * Requires authentication
1184
+ */
1185
+ async createSetupIntent() {
1186
+ return this.http.post("/subscriptions/setup-intent");
1187
+ }
1188
+ // ============================================
1189
+ // Bundle Products
1190
+ // ============================================
1191
+ /**
1192
+ * Get bundle items and pricing
1193
+ * Returns all products in the bundle with calculated pricing
1194
+ */
1195
+ async getBundleItems(productSlug) {
1196
+ const result = await this.http.get(`/products/${productSlug}/bundle-items`);
1197
+ return result.bundle;
1198
+ }
1199
+ // ============================================
1200
+ // Product Type Filters
1201
+ // ============================================
1202
+ /**
1203
+ * List products with type filter
1204
+ */
1205
+ async listProductsByType(type, params) {
1206
+ return this.http.getList("/products", { ...params, type });
1207
+ }
1208
+ /**
1209
+ * Get digital products
1210
+ */
1211
+ async getDigitalProducts(params) {
1212
+ return this.listProductsByType("digital", params);
1213
+ }
1214
+ /**
1215
+ * Get subscription products
1216
+ */
1217
+ async getSubscriptionProducts(params) {
1218
+ return this.listProductsByType("subscription", params);
1219
+ }
1220
+ /**
1221
+ * Get bundle products
1222
+ */
1223
+ async getBundleProducts(params) {
1224
+ return this.listProductsByType("bundle", params);
1225
+ }
995
1226
  };
996
1227
 
997
1228
  // src/resources/media.ts
@@ -1398,18 +1629,6 @@ var Diffsome = class {
1398
1629
  this.entities = new EntitiesResource(this.http);
1399
1630
  this.reservation = new ReservationResource(this.http);
1400
1631
  }
1401
- /**
1402
- * Get site theme settings
1403
- */
1404
- async getTheme() {
1405
- return this.http.get("/public/theme");
1406
- }
1407
- /**
1408
- * Get site settings
1409
- */
1410
- async getSettings() {
1411
- return this.http.get("/public/settings");
1412
- }
1413
1632
  /**
1414
1633
  * Check if user is authenticated
1415
1634
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffsome/sdk",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Diffsome SDK for JavaScript/TypeScript - Different + Awesome",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",