@diffsome/sdk 3.0.0 → 3.2.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/dist/index.js CHANGED
@@ -153,6 +153,12 @@ var HttpClient = class {
153
153
  getApiKey() {
154
154
  return this.apiKey;
155
155
  }
156
+ /**
157
+ * Get the base URL with tenant path
158
+ */
159
+ getBaseUrl() {
160
+ return `${this.baseUrl}/api/${this.tenantId}`;
161
+ }
156
162
  /**
157
163
  * Set cart session ID (for guest cart persistence)
158
164
  */
@@ -596,7 +602,7 @@ var BlogResource = class {
596
602
  }
597
603
  /**
598
604
  * Get blog categories
599
- * @returns Array of category names (always an array)
605
+ * @returns Array of blog categories with details
600
606
  */
601
607
  async categories() {
602
608
  const response = await this.http.get("/blog/categories");
@@ -1022,6 +1028,231 @@ var ShopResource = class {
1022
1028
  async myReviews(params) {
1023
1029
  return this.http.getList("/my/reviews", params);
1024
1030
  }
1031
+ // ============================================
1032
+ // Wishlist
1033
+ // ============================================
1034
+ /**
1035
+ * Get wishlist items
1036
+ * Requires authentication
1037
+ */
1038
+ async getWishlist(params) {
1039
+ return this.http.getList("/wishlist", params);
1040
+ }
1041
+ /**
1042
+ * Add product to wishlist
1043
+ * Requires authentication
1044
+ */
1045
+ async addToWishlist(data) {
1046
+ return this.http.post("/wishlist", data);
1047
+ }
1048
+ /**
1049
+ * Remove item from wishlist
1050
+ * Requires authentication
1051
+ */
1052
+ async removeFromWishlist(wishlistId) {
1053
+ await this.http.delete(`/wishlist/${wishlistId}`);
1054
+ }
1055
+ /**
1056
+ * Toggle wishlist (add if not in wishlist, remove if in wishlist)
1057
+ * Requires authentication
1058
+ */
1059
+ async toggleWishlist(productId, variantId) {
1060
+ return this.http.post("/wishlist/toggle", {
1061
+ product_id: productId,
1062
+ variant_id: variantId
1063
+ });
1064
+ }
1065
+ /**
1066
+ * Check if product is in wishlist
1067
+ */
1068
+ async isInWishlist(productId, variantId) {
1069
+ const result = await this.http.get("/wishlist/check", {
1070
+ product_id: productId,
1071
+ variant_id: variantId
1072
+ });
1073
+ return result.in_wishlist;
1074
+ }
1075
+ /**
1076
+ * Check multiple products' wishlist status
1077
+ * Useful for product list pages
1078
+ */
1079
+ async checkWishlistBulk(productIds) {
1080
+ const result = await this.http.post("/wishlist/check-bulk", {
1081
+ product_ids: productIds
1082
+ });
1083
+ return result.items;
1084
+ }
1085
+ /**
1086
+ * Get wishlist count
1087
+ */
1088
+ async getWishlistCount() {
1089
+ const result = await this.http.get("/wishlist/count");
1090
+ return result.count;
1091
+ }
1092
+ /**
1093
+ * Move wishlist items to cart
1094
+ * @param wishlistIds - Optional array of wishlist item IDs to move. If empty, moves all items.
1095
+ */
1096
+ async moveWishlistToCart(wishlistIds) {
1097
+ return this.http.post("/wishlist/move-to-cart", {
1098
+ wishlist_ids: wishlistIds
1099
+ });
1100
+ }
1101
+ /**
1102
+ * Update wishlist item note
1103
+ */
1104
+ async updateWishlistNote(wishlistId, note) {
1105
+ return this.http.put(`/wishlist/${wishlistId}`, { note });
1106
+ }
1107
+ /**
1108
+ * Get product's wishlist count (how many users added this product)
1109
+ */
1110
+ async getProductWishlistCount(productSlug) {
1111
+ const result = await this.http.get(`/products/${productSlug}/wishlist-count`);
1112
+ return result.count;
1113
+ }
1114
+ // ============================================
1115
+ // Digital Downloads
1116
+ // ============================================
1117
+ /**
1118
+ * Get my download links
1119
+ * Requires authentication
1120
+ */
1121
+ async getMyDownloads() {
1122
+ const result = await this.http.get("/my/downloads");
1123
+ return result.downloads;
1124
+ }
1125
+ /**
1126
+ * Get download links for a specific order
1127
+ * Requires authentication
1128
+ */
1129
+ async getOrderDownloads(orderNumber) {
1130
+ const result = await this.http.get(
1131
+ `/orders/${orderNumber}/downloads`
1132
+ );
1133
+ return result.downloads;
1134
+ }
1135
+ /**
1136
+ * Get download file URL
1137
+ * Returns the direct download URL for the file
1138
+ * Requires authentication
1139
+ */
1140
+ async downloadFile(token) {
1141
+ return `${this.http.getBaseUrl()}/downloads/${token}`;
1142
+ }
1143
+ /**
1144
+ * Get download link info (without triggering download)
1145
+ * Requires authentication
1146
+ */
1147
+ async getDownloadInfo(token) {
1148
+ const result = await this.http.get(`/downloads/${token}/info`);
1149
+ return result.download;
1150
+ }
1151
+ // ============================================
1152
+ // Subscriptions
1153
+ // ============================================
1154
+ /**
1155
+ * Get my subscriptions
1156
+ * Requires authentication
1157
+ */
1158
+ async getSubscriptions() {
1159
+ const result = await this.http.get("/subscriptions");
1160
+ return result.subscriptions;
1161
+ }
1162
+ /**
1163
+ * Get subscription by ID
1164
+ * Requires authentication
1165
+ */
1166
+ async getSubscription(id) {
1167
+ const result = await this.http.get(`/subscriptions/${id}`);
1168
+ return result.subscription;
1169
+ }
1170
+ /**
1171
+ * Create a new subscription
1172
+ * Requires Stripe payment method ID
1173
+ * Requires authentication
1174
+ */
1175
+ async createSubscription(data) {
1176
+ return this.http.post("/subscriptions", data);
1177
+ }
1178
+ /**
1179
+ * Cancel subscription
1180
+ * @param immediately - If true, cancel immediately. Otherwise, cancel at end of billing period.
1181
+ * Requires authentication
1182
+ */
1183
+ async cancelSubscription(id, immediately = false) {
1184
+ const result = await this.http.post(
1185
+ `/subscriptions/${id}/cancel`,
1186
+ { immediately }
1187
+ );
1188
+ return result.subscription;
1189
+ }
1190
+ /**
1191
+ * Pause subscription
1192
+ * Requires authentication
1193
+ */
1194
+ async pauseSubscription(id) {
1195
+ const result = await this.http.post(
1196
+ `/subscriptions/${id}/pause`
1197
+ );
1198
+ return result.subscription;
1199
+ }
1200
+ /**
1201
+ * Resume paused subscription
1202
+ * Requires authentication
1203
+ */
1204
+ async resumeSubscription(id) {
1205
+ const result = await this.http.post(
1206
+ `/subscriptions/${id}/resume`
1207
+ );
1208
+ return result.subscription;
1209
+ }
1210
+ /**
1211
+ * Create Stripe Setup Intent for adding payment method
1212
+ * Use with Stripe.js to collect card details
1213
+ * Requires authentication
1214
+ */
1215
+ async createSetupIntent() {
1216
+ return this.http.post("/subscriptions/setup-intent");
1217
+ }
1218
+ // ============================================
1219
+ // Bundle Products
1220
+ // ============================================
1221
+ /**
1222
+ * Get bundle items and pricing
1223
+ * Returns all products in the bundle with calculated pricing
1224
+ */
1225
+ async getBundleItems(productSlug) {
1226
+ const result = await this.http.get(`/products/${productSlug}/bundle-items`);
1227
+ return result.bundle;
1228
+ }
1229
+ // ============================================
1230
+ // Product Type Filters
1231
+ // ============================================
1232
+ /**
1233
+ * List products with type filter
1234
+ */
1235
+ async listProductsByType(type, params) {
1236
+ return this.http.getList("/products", { ...params, type });
1237
+ }
1238
+ /**
1239
+ * Get digital products
1240
+ */
1241
+ async getDigitalProducts(params) {
1242
+ return this.listProductsByType("digital", params);
1243
+ }
1244
+ /**
1245
+ * Get subscription products
1246
+ */
1247
+ async getSubscriptionProducts(params) {
1248
+ return this.listProductsByType("subscription", params);
1249
+ }
1250
+ /**
1251
+ * Get bundle products
1252
+ */
1253
+ async getBundleProducts(params) {
1254
+ return this.listProductsByType("bundle", params);
1255
+ }
1025
1256
  };
1026
1257
 
1027
1258
  // src/resources/media.ts
@@ -1428,18 +1659,6 @@ var Diffsome = class {
1428
1659
  this.entities = new EntitiesResource(this.http);
1429
1660
  this.reservation = new ReservationResource(this.http);
1430
1661
  }
1431
- /**
1432
- * Get site theme settings
1433
- */
1434
- async getTheme() {
1435
- return this.http.get("/public/theme");
1436
- }
1437
- /**
1438
- * Get site settings
1439
- */
1440
- async getSettings() {
1441
- return this.http.get("/public/settings");
1442
- }
1443
1662
  /**
1444
1663
  * Check if user is authenticated
1445
1664
  */
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.1",
4
4
  "description": "Diffsome SDK for JavaScript/TypeScript - Different + Awesome",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",