@alphabite/medusa-sdk 0.5.7 → 0.6.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.d.mts CHANGED
@@ -1,34 +1,73 @@
1
1
  import Medusa, { ClientHeaders } from '@medusajs/js-sdk';
2
2
  import { BaseProductVariant, BaseProduct } from '@medusajs/types/dist/http/product/common';
3
3
  import { FindParams, RemoteQueryFunctionReturnPagination, PriceDTO, StoreCartAddress, StoreCartLineItem, CustomerDTO, ProductDTO, FileDTO } from '@medusajs/types';
4
+ import { City, Quarter, Office } from '@alphabite/econt-types';
4
5
 
6
+ /**
7
+ * Standard paginated response structure for list endpoints
8
+ * @template T - Type of the data items in the response
9
+ */
5
10
  interface PaginatedOutput<T> extends PaginatedOutputMeta {
11
+ /** Array of data items for the current page */
6
12
  data: T[];
7
13
  }
14
+ /**
15
+ * Pagination metadata included in paginated responses
16
+ */
8
17
  interface PaginatedOutputMeta extends RemoteQueryFunctionReturnPagination {
18
+ /** Total number of pages available */
9
19
  totalPages: number;
20
+ /** Current page number (1-indexed) */
10
21
  currentPage: number;
22
+ /** Next page number, 0 if on last page */
11
23
  nextPage: number;
24
+ /** Previous page number, 0 if on first page */
12
25
  prevPage: number;
13
26
  }
27
+ /**
28
+ * Standard pagination parameters for list endpoints
29
+ * Extends FindParams from Medusa types for consistent querying
30
+ */
14
31
  interface PaginatedInput extends FindParams {
15
32
  }
33
+ /**
34
+ * Base image structure used across Medusa entities
35
+ */
16
36
  interface MedusaImage {
37
+ /** Unique identifier for the image */
17
38
  id: string;
39
+ /** URL where the image is accessible */
18
40
  url: string;
41
+ /** Display order/priority of the image */
19
42
  rank: number;
43
+ /** Additional metadata associated with the image */
20
44
  metadata: Record<string, unknown> | null;
45
+ /** Timestamp when the image was created */
21
46
  created_at: string;
47
+ /** Timestamp when the image was last updated */
22
48
  updated_at: string;
49
+ /** Timestamp when the image was deleted, null if active */
23
50
  deleted_at: string | null;
24
51
  }
52
+ /**
53
+ * Image associated with a product category
54
+ */
25
55
  interface ProductCategoryImage extends MedusaImage {
56
+ /** ID of the product category this image belongs to */
26
57
  product_category_id: string;
27
58
  }
59
+ /**
60
+ * Image associated with a product collection
61
+ */
28
62
  interface ProductCollectionImage extends MedusaImage {
63
+ /** ID of the product collection this image belongs to */
29
64
  product_collection_id: string;
30
65
  }
66
+ /**
67
+ * Image associated with a product variant
68
+ */
31
69
  interface ProductVariantImage extends MedusaImage {
70
+ /** ID of the product variant this image belongs to */
32
71
  product_variant_id: string;
33
72
  }
34
73
 
@@ -141,79 +180,147 @@ type WishlistEndpoints = {
141
180
  };
142
181
  declare const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints>;
143
182
 
183
+ /**
184
+ * Response containing PayPal client token for frontend integration
185
+ */
144
186
  interface CreateClientTokenOutput {
187
+ /** PayPal client token used for initializing PayPal SDK on frontend */
145
188
  client_token: string;
146
189
  }
190
+ /**
191
+ * Payment session data structure for PayPal transactions
192
+ */
147
193
  interface PaypalPaymentSessionInputData {
194
+ /** Shipping address information */
148
195
  shipping_info?: StoreCartAddress;
196
+ /** Line items in the cart */
149
197
  items?: StoreCartLineItem[];
198
+ /** Customer email address */
150
199
  email?: string;
151
200
  }
201
+ /**
202
+ * Available PayPal plugin endpoints
203
+ */
152
204
  type PaypalEndpoints = {
205
+ /** Creates a PayPal client token for frontend integration */
153
206
  createClientToken: (headers?: ClientHeaders) => Promise<CreateClientTokenOutput>;
154
207
  };
208
+ /**
209
+ * PayPal payment integration plugin
210
+ * Provides endpoints for PayPal payment processing
211
+ */
155
212
  declare const paypalPlugin: Plugin<'paypal', PaypalEndpoints>;
156
213
 
214
+ /**
215
+ * Aggregate rating statistics for products
216
+ */
157
217
  interface AggregateCounts {
218
+ /** Average rating across all reviews */
158
219
  average: number;
220
+ /** Distribution of ratings (count per rating value) */
159
221
  counts: {
160
222
  rating: number;
161
223
  count: number;
162
224
  }[];
225
+ /** Product ID for which these counts apply */
163
226
  product_id?: string;
227
+ /** Total number of reviews */
164
228
  total_count: number;
165
229
  }
230
+ /**
231
+ * Represents a product review submitted by a customer
232
+ */
166
233
  interface Review {
234
+ /** Title of the review */
167
235
  title: string;
236
+ /** Detailed content of the review */
168
237
  content: string;
238
+ /** Rating value (typically 1-5) */
169
239
  rating: number;
240
+ /** Unique identifier for the review */
170
241
  id: string;
242
+ /** Timestamp when the review was created */
171
243
  created_at: string;
244
+ /** Array of image URLs attached to the review */
172
245
  image_urls: string[];
246
+ /** Whether the reviewer purchased this product */
173
247
  is_verified_purchase: boolean;
248
+ /** ID of the reviewed product */
174
249
  product_id: string;
250
+ /** Customer information (name only) */
175
251
  customer: Pick<CustomerDTO, 'first_name' | 'last_name'>;
252
+ /** Optional product details with aggregate ratings */
176
253
  product?: Pick<ProductDTO, 'thumbnail' | 'title' | 'handle' | 'id'> & AggregateCounts;
177
254
  }
255
+ /** Input for creating a new review */
178
256
  interface CreateReviewInput {
257
+ /** Detailed content of the review */
179
258
  content: string;
259
+ /** Rating value (typically 1-5) */
180
260
  rating: number;
261
+ /** ID of the product being reviewed */
181
262
  product_id: string;
263
+ /** Array of image URLs to attach to the review */
182
264
  image_urls: string[];
265
+ /** Optional title for the review */
183
266
  title?: string;
184
267
  }
268
+ /** Response after creating a review */
185
269
  interface CreateReviewOutput extends Review {
186
270
  }
271
+ /** Input for listing reviews with filters and pagination */
187
272
  interface ListReviewsInput extends PaginatedInput {
273
+ /** Filter by specific product IDs */
188
274
  product_ids?: string[];
275
+ /** Show only reviews by the current user */
189
276
  my_reviews_only?: boolean;
277
+ /** Show only reviews from verified purchases */
190
278
  verified_purchase_only?: boolean;
279
+ /** Filter by specific rating value */
191
280
  rating?: number;
281
+ /** Include product details in the response */
192
282
  include_product?: boolean;
283
+ /** Field to sort by */
193
284
  sort_by?: 'created_at' | 'rating';
285
+ /** Sort order */
194
286
  order?: 'asc' | 'desc';
195
287
  }
288
+ /** Response containing paginated review data */
196
289
  interface ListReviewsOutput extends PaginatedOutput<Review> {
197
290
  }
291
+ /** Input for listing reviews of a specific product */
198
292
  interface ListProductReviewsInput extends Omit<ListReviewsInput, 'product_ids'> {
293
+ /** Product ID to get reviews for */
199
294
  product_id: string;
295
+ /** Include aggregate counts in the response */
200
296
  include_aggregated_counts?: boolean;
201
297
  }
298
+ /** Response containing paginated product reviews with aggregate counts */
202
299
  interface ListProductReviewsOutput extends PaginatedOutput<Omit<Review, 'product'>>, AggregateCounts {
203
300
  }
301
+ /** Input for deleting a review */
204
302
  interface DeleteReviewInput {
303
+ /** Review ID to delete */
205
304
  id: string;
206
305
  }
306
+ /** Response after deleting a review */
207
307
  interface DeleteReviewOutput {
308
+ /** ID of the deleted review */
208
309
  id: string;
209
310
  }
311
+ /** Input for getting aggregate rating counts */
210
312
  interface AggregateCountsInput {
313
+ /** Product ID to get aggregate counts for */
211
314
  product_id: string;
315
+ /** Only count reviews from verified purchases */
212
316
  verified_purchase_only?: boolean;
213
317
  }
318
+ /** Response containing aggregate rating statistics */
214
319
  interface AggregateCountsOutput extends AggregateCounts {
215
320
  }
321
+ /** Input for uploading review image files */
216
322
  interface UploadImageFilesInput {
323
+ /** FormData containing the image files to upload */
217
324
  formData: FormData;
218
325
  }
219
326
  type ReviewsEndpoints = {
@@ -226,22 +333,183 @@ type ReviewsEndpoints = {
226
333
  };
227
334
  declare const reviewsPlugin: Plugin<'reviews', ReviewsEndpoints>;
228
335
 
336
+ /**
337
+ * Supported country codes for Econt delivery service
338
+ * Currently supports Bulgaria, can be extended with additional countries
339
+ */
340
+ type CountryCode = 'BGR';
341
+ /**
342
+ * Input for listing cities in a country
343
+ */
344
+ interface ListCitiesInput {
345
+ /**
346
+ * ISO 3166-1 alpha-3 country code
347
+ * @default "BGR"
348
+ */
349
+ countryCode?: CountryCode;
350
+ }
351
+ /**
352
+ * Response containing list of cities
353
+ */
354
+ interface ListCitiesOutput {
355
+ /**
356
+ * Array of cities with full details from Econt
357
+ * Includes: id, name, nameEn, postCode, region, etc.
358
+ */
359
+ cities: City[];
360
+ }
361
+ /**
362
+ * Input for listing quarters (neighborhoods) in a city
363
+ */
364
+ interface ListQuartersInput {
365
+ /**
366
+ * ISO 3166-1 alpha-3 country code
367
+ * @default "BGR"
368
+ */
369
+ countryCode?: CountryCode;
370
+ /**
371
+ * ID of the city to get quarters for
372
+ * Required parameter
373
+ */
374
+ cityId: string;
375
+ }
376
+ /**
377
+ * Response containing list of quarters
378
+ */
379
+ interface ListQuartersOutput {
380
+ /**
381
+ * Array of quarters with details from Econt
382
+ * Includes: id, cityID, name, nameEn
383
+ */
384
+ quarters: Quarter[];
385
+ }
386
+ /**
387
+ * Input for listing Econt offices with optional filtering
388
+ */
389
+ interface ListOfficesInput {
390
+ /**
391
+ * ISO 3166-1 alpha-3 country code
392
+ * @default "BGR"
393
+ */
394
+ countryCode?: CountryCode;
395
+ /**
396
+ * ID of the city to filter offices by
397
+ * At least cityId or officeCode should be provided
398
+ */
399
+ cityId?: string;
400
+ /**
401
+ * Quarter name to filter offices by
402
+ * Only works when cityId is also provided
403
+ */
404
+ quarter?: string;
405
+ /**
406
+ * Specific office code to retrieve
407
+ * Can be used alone or with cityId for faster filtering
408
+ */
409
+ officeCode?: string;
410
+ }
411
+ /**
412
+ * Response containing list of Econt offices
413
+ */
414
+ interface ListOfficesOutput {
415
+ /**
416
+ * Array of offices with full details from Econt
417
+ * Includes: code, name, address, phones, workingHours, etc.
418
+ */
419
+ offices: Office[];
420
+ }
421
+ /**
422
+ * Available Econt plugin endpoints
423
+ */
424
+ type EcontEndpoints = {
425
+ /**
426
+ * Lists cities for a given country
427
+ * Cities are cached and returned from Redis for fast responses
428
+ */
429
+ listCities: (input: ListCitiesInput, headers?: ClientHeaders) => Promise<ListCitiesOutput>;
430
+ /**
431
+ * Lists quarters (neighborhoods) for a specific city
432
+ * Quarters are cached per city for fast responses
433
+ */
434
+ listQuarters: (input: ListQuartersInput, headers?: ClientHeaders) => Promise<ListQuartersOutput>;
435
+ /**
436
+ * Lists Econt offices with optional filtering
437
+ * Supports filtering by city, quarter, or specific office code
438
+ * All data is served from hierarchical cache for instant responses
439
+ */
440
+ listOffices: (input: ListOfficesInput, headers?: ClientHeaders) => Promise<ListOfficesOutput>;
441
+ };
442
+ /**
443
+ * Econt fulfillment provider plugin
444
+ * Provides endpoints for fetching Econt delivery locations (cities, offices, quarters)
445
+ * to enable customers to select pickup locations in the storefront
446
+ */
447
+ declare const econtPlugin: Plugin<'econt', EcontEndpoints>;
448
+
449
+ /**
450
+ * Configuration options for Alphabite client functionality
451
+ */
229
452
  type AlphabiteClientOptions = {
453
+ /** Function to retrieve authentication headers (sync or async) */
230
454
  getAuthHeader?: () => Promise<Record<string, string>> | Record<string, string>;
231
455
  };
456
+ /**
457
+ * Medusa configuration type extracted from the Medusa SDK constructor
458
+ */
232
459
  type AlphabiteMedusaConfig = ConstructorParameters<typeof Medusa>[0];
460
+ /**
461
+ * Plugin definition structure for extending the SDK with custom endpoints
462
+ * @template Name - Unique string identifier for the plugin
463
+ * @template Endpoints - Type definition for the plugin's endpoint methods
464
+ */
233
465
  type Plugin<Name extends string, Endpoints> = {
466
+ /** Unique identifier for the plugin namespace */
234
467
  name: Name;
468
+ /** Function that returns the plugin's endpoint implementations */
235
469
  endpoints: (client: any, options?: AlphabiteClientOptions, medusaConfig?: AlphabiteMedusaConfig) => Endpoints;
236
470
  };
471
+ /**
472
+ * Transforms an array of plugins into a typed object with plugin names as keys
473
+ * @template T - Array of plugin definitions
474
+ */
237
475
  type PluginsToAlphabite<T extends readonly Plugin<any, any>[]> = {
238
476
  [K in T[number] as K['name']]: ReturnType<K['endpoints']>;
239
477
  };
478
+ /**
479
+ * Extended Medusa SDK with support for custom plugin endpoints
480
+ * Provides a modular way to add plugin-specific API methods while maintaining
481
+ * full compatibility with the base Medusa SDK functionality
482
+ *
483
+ * @template TPlugins - Array of plugin definitions to integrate
484
+ * @template TOptions - Client options configuration type
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * const sdk = new AlphabiteMedusaSdk(
489
+ * { baseUrl: 'https://api.example.com', publishableKey: 'pk_...' },
490
+ * [wishlistPlugin, reviewsPlugin, paypalPlugin],
491
+ * { getAuthHeader: async () => ({ Authorization: 'Bearer token' }) }
492
+ * )
493
+ *
494
+ * // Access plugin endpoints
495
+ * const wishlist = await sdk.alphabite.wishlist.create({ sales_channel_id: 'sc_123' })
496
+ * const reviews = await sdk.alphabite.reviews.list({ product_ids: ['prod_123'] })
497
+ * ```
498
+ */
240
499
  declare class AlphabiteMedusaSdk<TPlugins extends readonly Plugin<any, any>[], TOptions extends AlphabiteClientOptions = AlphabiteClientOptions> extends Medusa {
500
+ /** Object containing all plugin endpoints, keyed by plugin name */
241
501
  alphabite: PluginsToAlphabite<TPlugins>;
502
+ /** Client configuration options */
242
503
  protected options?: TOptions;
504
+ /** Medusa configuration passed to the constructor */
243
505
  medusaConfig: AlphabiteMedusaConfig;
506
+ /**
507
+ * Creates a new instance of the Alphabite Medusa SDK
508
+ * @param medusaOptions - Configuration for the base Medusa SDK
509
+ * @param plugins - Array of plugin definitions to integrate
510
+ * @param options - Optional client configuration (e.g., auth headers)
511
+ */
244
512
  constructor(medusaOptions: AlphabiteMedusaConfig, plugins: TPlugins, options?: TOptions);
245
513
  }
246
514
 
247
- export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, type AlphabiteMedusaConfig, AlphabiteMedusaSdk, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ImportWishlistInput, type ImportWishlistOutput, type ListItemsInput, type ListItemsOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type PaypalPaymentSessionInputData, type Plugin, type PluginsToAlphabite, type ProductCategoryImage, type ProductCollectionImage, type ProductVariantImage, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type ShareWishlistInput, type ShareWishlistOutput, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type UploadImageFilesInput, type Wishlist, type WishlistItem, paypalPlugin, reviewsPlugin, wishlistPlugin };
515
+ export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, type AlphabiteMedusaConfig, AlphabiteMedusaSdk, type CountryCode, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ImportWishlistInput, type ImportWishlistOutput, type ListCitiesInput, type ListCitiesOutput, type ListItemsInput, type ListItemsOutput, type ListOfficesInput, type ListOfficesOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListQuartersInput, type ListQuartersOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type PaypalPaymentSessionInputData, type Plugin, type PluginsToAlphabite, type ProductCategoryImage, type ProductCollectionImage, type ProductVariantImage, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type ShareWishlistInput, type ShareWishlistOutput, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type UploadImageFilesInput, type Wishlist, type WishlistItem, econtPlugin, paypalPlugin, reviewsPlugin, wishlistPlugin };
package/dist/index.d.ts CHANGED
@@ -1,34 +1,73 @@
1
1
  import Medusa, { ClientHeaders } from '@medusajs/js-sdk';
2
2
  import { BaseProductVariant, BaseProduct } from '@medusajs/types/dist/http/product/common';
3
3
  import { FindParams, RemoteQueryFunctionReturnPagination, PriceDTO, StoreCartAddress, StoreCartLineItem, CustomerDTO, ProductDTO, FileDTO } from '@medusajs/types';
4
+ import { City, Quarter, Office } from '@alphabite/econt-types';
4
5
 
6
+ /**
7
+ * Standard paginated response structure for list endpoints
8
+ * @template T - Type of the data items in the response
9
+ */
5
10
  interface PaginatedOutput<T> extends PaginatedOutputMeta {
11
+ /** Array of data items for the current page */
6
12
  data: T[];
7
13
  }
14
+ /**
15
+ * Pagination metadata included in paginated responses
16
+ */
8
17
  interface PaginatedOutputMeta extends RemoteQueryFunctionReturnPagination {
18
+ /** Total number of pages available */
9
19
  totalPages: number;
20
+ /** Current page number (1-indexed) */
10
21
  currentPage: number;
22
+ /** Next page number, 0 if on last page */
11
23
  nextPage: number;
24
+ /** Previous page number, 0 if on first page */
12
25
  prevPage: number;
13
26
  }
27
+ /**
28
+ * Standard pagination parameters for list endpoints
29
+ * Extends FindParams from Medusa types for consistent querying
30
+ */
14
31
  interface PaginatedInput extends FindParams {
15
32
  }
33
+ /**
34
+ * Base image structure used across Medusa entities
35
+ */
16
36
  interface MedusaImage {
37
+ /** Unique identifier for the image */
17
38
  id: string;
39
+ /** URL where the image is accessible */
18
40
  url: string;
41
+ /** Display order/priority of the image */
19
42
  rank: number;
43
+ /** Additional metadata associated with the image */
20
44
  metadata: Record<string, unknown> | null;
45
+ /** Timestamp when the image was created */
21
46
  created_at: string;
47
+ /** Timestamp when the image was last updated */
22
48
  updated_at: string;
49
+ /** Timestamp when the image was deleted, null if active */
23
50
  deleted_at: string | null;
24
51
  }
52
+ /**
53
+ * Image associated with a product category
54
+ */
25
55
  interface ProductCategoryImage extends MedusaImage {
56
+ /** ID of the product category this image belongs to */
26
57
  product_category_id: string;
27
58
  }
59
+ /**
60
+ * Image associated with a product collection
61
+ */
28
62
  interface ProductCollectionImage extends MedusaImage {
63
+ /** ID of the product collection this image belongs to */
29
64
  product_collection_id: string;
30
65
  }
66
+ /**
67
+ * Image associated with a product variant
68
+ */
31
69
  interface ProductVariantImage extends MedusaImage {
70
+ /** ID of the product variant this image belongs to */
32
71
  product_variant_id: string;
33
72
  }
34
73
 
@@ -141,79 +180,147 @@ type WishlistEndpoints = {
141
180
  };
142
181
  declare const wishlistPlugin: Plugin<'wishlist', WishlistEndpoints>;
143
182
 
183
+ /**
184
+ * Response containing PayPal client token for frontend integration
185
+ */
144
186
  interface CreateClientTokenOutput {
187
+ /** PayPal client token used for initializing PayPal SDK on frontend */
145
188
  client_token: string;
146
189
  }
190
+ /**
191
+ * Payment session data structure for PayPal transactions
192
+ */
147
193
  interface PaypalPaymentSessionInputData {
194
+ /** Shipping address information */
148
195
  shipping_info?: StoreCartAddress;
196
+ /** Line items in the cart */
149
197
  items?: StoreCartLineItem[];
198
+ /** Customer email address */
150
199
  email?: string;
151
200
  }
201
+ /**
202
+ * Available PayPal plugin endpoints
203
+ */
152
204
  type PaypalEndpoints = {
205
+ /** Creates a PayPal client token for frontend integration */
153
206
  createClientToken: (headers?: ClientHeaders) => Promise<CreateClientTokenOutput>;
154
207
  };
208
+ /**
209
+ * PayPal payment integration plugin
210
+ * Provides endpoints for PayPal payment processing
211
+ */
155
212
  declare const paypalPlugin: Plugin<'paypal', PaypalEndpoints>;
156
213
 
214
+ /**
215
+ * Aggregate rating statistics for products
216
+ */
157
217
  interface AggregateCounts {
218
+ /** Average rating across all reviews */
158
219
  average: number;
220
+ /** Distribution of ratings (count per rating value) */
159
221
  counts: {
160
222
  rating: number;
161
223
  count: number;
162
224
  }[];
225
+ /** Product ID for which these counts apply */
163
226
  product_id?: string;
227
+ /** Total number of reviews */
164
228
  total_count: number;
165
229
  }
230
+ /**
231
+ * Represents a product review submitted by a customer
232
+ */
166
233
  interface Review {
234
+ /** Title of the review */
167
235
  title: string;
236
+ /** Detailed content of the review */
168
237
  content: string;
238
+ /** Rating value (typically 1-5) */
169
239
  rating: number;
240
+ /** Unique identifier for the review */
170
241
  id: string;
242
+ /** Timestamp when the review was created */
171
243
  created_at: string;
244
+ /** Array of image URLs attached to the review */
172
245
  image_urls: string[];
246
+ /** Whether the reviewer purchased this product */
173
247
  is_verified_purchase: boolean;
248
+ /** ID of the reviewed product */
174
249
  product_id: string;
250
+ /** Customer information (name only) */
175
251
  customer: Pick<CustomerDTO, 'first_name' | 'last_name'>;
252
+ /** Optional product details with aggregate ratings */
176
253
  product?: Pick<ProductDTO, 'thumbnail' | 'title' | 'handle' | 'id'> & AggregateCounts;
177
254
  }
255
+ /** Input for creating a new review */
178
256
  interface CreateReviewInput {
257
+ /** Detailed content of the review */
179
258
  content: string;
259
+ /** Rating value (typically 1-5) */
180
260
  rating: number;
261
+ /** ID of the product being reviewed */
181
262
  product_id: string;
263
+ /** Array of image URLs to attach to the review */
182
264
  image_urls: string[];
265
+ /** Optional title for the review */
183
266
  title?: string;
184
267
  }
268
+ /** Response after creating a review */
185
269
  interface CreateReviewOutput extends Review {
186
270
  }
271
+ /** Input for listing reviews with filters and pagination */
187
272
  interface ListReviewsInput extends PaginatedInput {
273
+ /** Filter by specific product IDs */
188
274
  product_ids?: string[];
275
+ /** Show only reviews by the current user */
189
276
  my_reviews_only?: boolean;
277
+ /** Show only reviews from verified purchases */
190
278
  verified_purchase_only?: boolean;
279
+ /** Filter by specific rating value */
191
280
  rating?: number;
281
+ /** Include product details in the response */
192
282
  include_product?: boolean;
283
+ /** Field to sort by */
193
284
  sort_by?: 'created_at' | 'rating';
285
+ /** Sort order */
194
286
  order?: 'asc' | 'desc';
195
287
  }
288
+ /** Response containing paginated review data */
196
289
  interface ListReviewsOutput extends PaginatedOutput<Review> {
197
290
  }
291
+ /** Input for listing reviews of a specific product */
198
292
  interface ListProductReviewsInput extends Omit<ListReviewsInput, 'product_ids'> {
293
+ /** Product ID to get reviews for */
199
294
  product_id: string;
295
+ /** Include aggregate counts in the response */
200
296
  include_aggregated_counts?: boolean;
201
297
  }
298
+ /** Response containing paginated product reviews with aggregate counts */
202
299
  interface ListProductReviewsOutput extends PaginatedOutput<Omit<Review, 'product'>>, AggregateCounts {
203
300
  }
301
+ /** Input for deleting a review */
204
302
  interface DeleteReviewInput {
303
+ /** Review ID to delete */
205
304
  id: string;
206
305
  }
306
+ /** Response after deleting a review */
207
307
  interface DeleteReviewOutput {
308
+ /** ID of the deleted review */
208
309
  id: string;
209
310
  }
311
+ /** Input for getting aggregate rating counts */
210
312
  interface AggregateCountsInput {
313
+ /** Product ID to get aggregate counts for */
211
314
  product_id: string;
315
+ /** Only count reviews from verified purchases */
212
316
  verified_purchase_only?: boolean;
213
317
  }
318
+ /** Response containing aggregate rating statistics */
214
319
  interface AggregateCountsOutput extends AggregateCounts {
215
320
  }
321
+ /** Input for uploading review image files */
216
322
  interface UploadImageFilesInput {
323
+ /** FormData containing the image files to upload */
217
324
  formData: FormData;
218
325
  }
219
326
  type ReviewsEndpoints = {
@@ -226,22 +333,183 @@ type ReviewsEndpoints = {
226
333
  };
227
334
  declare const reviewsPlugin: Plugin<'reviews', ReviewsEndpoints>;
228
335
 
336
+ /**
337
+ * Supported country codes for Econt delivery service
338
+ * Currently supports Bulgaria, can be extended with additional countries
339
+ */
340
+ type CountryCode = 'BGR';
341
+ /**
342
+ * Input for listing cities in a country
343
+ */
344
+ interface ListCitiesInput {
345
+ /**
346
+ * ISO 3166-1 alpha-3 country code
347
+ * @default "BGR"
348
+ */
349
+ countryCode?: CountryCode;
350
+ }
351
+ /**
352
+ * Response containing list of cities
353
+ */
354
+ interface ListCitiesOutput {
355
+ /**
356
+ * Array of cities with full details from Econt
357
+ * Includes: id, name, nameEn, postCode, region, etc.
358
+ */
359
+ cities: City[];
360
+ }
361
+ /**
362
+ * Input for listing quarters (neighborhoods) in a city
363
+ */
364
+ interface ListQuartersInput {
365
+ /**
366
+ * ISO 3166-1 alpha-3 country code
367
+ * @default "BGR"
368
+ */
369
+ countryCode?: CountryCode;
370
+ /**
371
+ * ID of the city to get quarters for
372
+ * Required parameter
373
+ */
374
+ cityId: string;
375
+ }
376
+ /**
377
+ * Response containing list of quarters
378
+ */
379
+ interface ListQuartersOutput {
380
+ /**
381
+ * Array of quarters with details from Econt
382
+ * Includes: id, cityID, name, nameEn
383
+ */
384
+ quarters: Quarter[];
385
+ }
386
+ /**
387
+ * Input for listing Econt offices with optional filtering
388
+ */
389
+ interface ListOfficesInput {
390
+ /**
391
+ * ISO 3166-1 alpha-3 country code
392
+ * @default "BGR"
393
+ */
394
+ countryCode?: CountryCode;
395
+ /**
396
+ * ID of the city to filter offices by
397
+ * At least cityId or officeCode should be provided
398
+ */
399
+ cityId?: string;
400
+ /**
401
+ * Quarter name to filter offices by
402
+ * Only works when cityId is also provided
403
+ */
404
+ quarter?: string;
405
+ /**
406
+ * Specific office code to retrieve
407
+ * Can be used alone or with cityId for faster filtering
408
+ */
409
+ officeCode?: string;
410
+ }
411
+ /**
412
+ * Response containing list of Econt offices
413
+ */
414
+ interface ListOfficesOutput {
415
+ /**
416
+ * Array of offices with full details from Econt
417
+ * Includes: code, name, address, phones, workingHours, etc.
418
+ */
419
+ offices: Office[];
420
+ }
421
+ /**
422
+ * Available Econt plugin endpoints
423
+ */
424
+ type EcontEndpoints = {
425
+ /**
426
+ * Lists cities for a given country
427
+ * Cities are cached and returned from Redis for fast responses
428
+ */
429
+ listCities: (input: ListCitiesInput, headers?: ClientHeaders) => Promise<ListCitiesOutput>;
430
+ /**
431
+ * Lists quarters (neighborhoods) for a specific city
432
+ * Quarters are cached per city for fast responses
433
+ */
434
+ listQuarters: (input: ListQuartersInput, headers?: ClientHeaders) => Promise<ListQuartersOutput>;
435
+ /**
436
+ * Lists Econt offices with optional filtering
437
+ * Supports filtering by city, quarter, or specific office code
438
+ * All data is served from hierarchical cache for instant responses
439
+ */
440
+ listOffices: (input: ListOfficesInput, headers?: ClientHeaders) => Promise<ListOfficesOutput>;
441
+ };
442
+ /**
443
+ * Econt fulfillment provider plugin
444
+ * Provides endpoints for fetching Econt delivery locations (cities, offices, quarters)
445
+ * to enable customers to select pickup locations in the storefront
446
+ */
447
+ declare const econtPlugin: Plugin<'econt', EcontEndpoints>;
448
+
449
+ /**
450
+ * Configuration options for Alphabite client functionality
451
+ */
229
452
  type AlphabiteClientOptions = {
453
+ /** Function to retrieve authentication headers (sync or async) */
230
454
  getAuthHeader?: () => Promise<Record<string, string>> | Record<string, string>;
231
455
  };
456
+ /**
457
+ * Medusa configuration type extracted from the Medusa SDK constructor
458
+ */
232
459
  type AlphabiteMedusaConfig = ConstructorParameters<typeof Medusa>[0];
460
+ /**
461
+ * Plugin definition structure for extending the SDK with custom endpoints
462
+ * @template Name - Unique string identifier for the plugin
463
+ * @template Endpoints - Type definition for the plugin's endpoint methods
464
+ */
233
465
  type Plugin<Name extends string, Endpoints> = {
466
+ /** Unique identifier for the plugin namespace */
234
467
  name: Name;
468
+ /** Function that returns the plugin's endpoint implementations */
235
469
  endpoints: (client: any, options?: AlphabiteClientOptions, medusaConfig?: AlphabiteMedusaConfig) => Endpoints;
236
470
  };
471
+ /**
472
+ * Transforms an array of plugins into a typed object with plugin names as keys
473
+ * @template T - Array of plugin definitions
474
+ */
237
475
  type PluginsToAlphabite<T extends readonly Plugin<any, any>[]> = {
238
476
  [K in T[number] as K['name']]: ReturnType<K['endpoints']>;
239
477
  };
478
+ /**
479
+ * Extended Medusa SDK with support for custom plugin endpoints
480
+ * Provides a modular way to add plugin-specific API methods while maintaining
481
+ * full compatibility with the base Medusa SDK functionality
482
+ *
483
+ * @template TPlugins - Array of plugin definitions to integrate
484
+ * @template TOptions - Client options configuration type
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * const sdk = new AlphabiteMedusaSdk(
489
+ * { baseUrl: 'https://api.example.com', publishableKey: 'pk_...' },
490
+ * [wishlistPlugin, reviewsPlugin, paypalPlugin],
491
+ * { getAuthHeader: async () => ({ Authorization: 'Bearer token' }) }
492
+ * )
493
+ *
494
+ * // Access plugin endpoints
495
+ * const wishlist = await sdk.alphabite.wishlist.create({ sales_channel_id: 'sc_123' })
496
+ * const reviews = await sdk.alphabite.reviews.list({ product_ids: ['prod_123'] })
497
+ * ```
498
+ */
240
499
  declare class AlphabiteMedusaSdk<TPlugins extends readonly Plugin<any, any>[], TOptions extends AlphabiteClientOptions = AlphabiteClientOptions> extends Medusa {
500
+ /** Object containing all plugin endpoints, keyed by plugin name */
241
501
  alphabite: PluginsToAlphabite<TPlugins>;
502
+ /** Client configuration options */
242
503
  protected options?: TOptions;
504
+ /** Medusa configuration passed to the constructor */
243
505
  medusaConfig: AlphabiteMedusaConfig;
506
+ /**
507
+ * Creates a new instance of the Alphabite Medusa SDK
508
+ * @param medusaOptions - Configuration for the base Medusa SDK
509
+ * @param plugins - Array of plugin definitions to integrate
510
+ * @param options - Optional client configuration (e.g., auth headers)
511
+ */
244
512
  constructor(medusaOptions: AlphabiteMedusaConfig, plugins: TPlugins, options?: TOptions);
245
513
  }
246
514
 
247
- export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, type AlphabiteMedusaConfig, AlphabiteMedusaSdk, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ImportWishlistInput, type ImportWishlistOutput, type ListItemsInput, type ListItemsOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type PaypalPaymentSessionInputData, type Plugin, type PluginsToAlphabite, type ProductCategoryImage, type ProductCollectionImage, type ProductVariantImage, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type ShareWishlistInput, type ShareWishlistOutput, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type UploadImageFilesInput, type Wishlist, type WishlistItem, paypalPlugin, reviewsPlugin, wishlistPlugin };
515
+ export { type AddItemToWishlistInput, type AddItemToWishlistOutput, type AggregateCounts, type AggregateCountsInput, type AggregateCountsOutput, type AlphabiteClientOptions, type AlphabiteMedusaConfig, AlphabiteMedusaSdk, type CountryCode, type CreateClientTokenOutput, type CreateReviewInput, type CreateReviewOutput, type CreateWishlistInput, type CreateWishlistOutput, type DeleteReviewInput, type DeleteReviewOutput, type DeleteWishlistInput, type DeleteWishlistOutput, type ImportWishlistInput, type ImportWishlistOutput, type ListCitiesInput, type ListCitiesOutput, type ListItemsInput, type ListItemsOutput, type ListOfficesInput, type ListOfficesOutput, type ListProductReviewsInput, type ListProductReviewsOutput, type ListQuartersInput, type ListQuartersOutput, type ListReviewsInput, type ListReviewsOutput, type ListWishlistsInput, type ListWishlistsOutput, type PaypalPaymentSessionInputData, type Plugin, type PluginsToAlphabite, type ProductCategoryImage, type ProductCollectionImage, type ProductVariantImage, type RemoveItemFromWishlistInput, type RemoveItemFromWishlistOutput, type RetrieveWishlistInput, type RetrieveWishlistOutput, type Review, type ShareWishlistInput, type ShareWishlistOutput, type TotalItemsCountInput, type TotalItemsCountOutput, type TransferWishlistInput, type TransferWishlistOutput, type UpdateWishlistInput, type UpdateWishlistOutput, type UploadImageFilesInput, type Wishlist, type WishlistItem, econtPlugin, paypalPlugin, reviewsPlugin, wishlistPlugin };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var u=require('@medusajs/js-sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var p={name:"wishlist",endpoints:(r,s)=>({create:async({...t},e)=>r.client.fetch("/store/wishlists",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),list:async({limit:t=10,offset:e=0,...i},n)=>r.client.fetch("/store/wishlists",{method:"GET",headers:{...await s?.getAuthHeader?.(),...n},query:{limit:t,offset:e,...i}}),retrieve:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),update:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"PUT",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),delete:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...e}}),totalItemsCount:async({wishlist_id:t},e)=>r.client.fetch("store/wishlists/total-items-count",{method:"GET",headers:{...await s?.getAuthHeader?.(),...e},query:{wishlist_id:t}}),transfer:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/transfer`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),share:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/share`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),import:async(t,e)=>r.client.fetch("/store/wishlists/import",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),addItem:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}/add-item`,{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),listItems:async({id:t,limit:e=10,offset:i=0,...n},a)=>r.client.fetch(`/store/wishlists/${t}/items`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...a},query:{limit:e,offset:i,...n}}),removeItem:async({wishlist_item_id:t,id:e},i)=>r.client.fetch(`/store/wishlists/${e}/items/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}})})};var h={name:"paypal",endpoints:(r,s)=>({createClientToken:async t=>r.client.fetch("/store/paypal/client-token",{method:"POST",headers:{...await s?.getAuthHeader?.(),...t}})})};var m={name:"reviews",endpoints:(r,s,t)=>({create:async(e,i)=>r.client.fetch("/store/reviews",{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),list:async({...e},i)=>r.client.fetch("/store/products/reviews",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),listProductReviews:async({product_id:e,...i},n)=>r.client.fetch(`store/reviews/product/${e}`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),aggregateCounts:async({product_id:e,...i},n)=>r.client.fetch(`/store/reviews/product/${e}/aggregate-counts`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),delete:async({id:e},i)=>r.client.fetch(`/store/reviews/${e}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}}),uploadImageFiles:async(e,i)=>{let n=t?.baseUrl,a=t?.publishableKey;if(!n||!a)throw new Error("Missing baseUrl or publishableKey");return await(await fetch(`${n}/store/reviews/files/images/upload`,{method:"POST",body:e.formData,headers:{...i,"x-publishable-api-key":a}})).json()}})};var o=class extends u__default.default{constructor(s,t,e){super(s),this.options=e,this.medusaConfig=s;let i={};t.forEach(n=>{i[n.name]=n.endpoints(this,this.options,this.medusaConfig);}),this.alphabite=i;}};exports.AlphabiteMedusaSdk=o;exports.paypalPlugin=h;exports.reviewsPlugin=m;exports.wishlistPlugin=p;
1
+ 'use strict';var u=require('@medusajs/js-sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var d={name:"wishlist",endpoints:(r,s)=>({create:async({...t},e)=>r.client.fetch("/store/wishlists",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),list:async({limit:t=10,offset:e=0,...i},n)=>r.client.fetch("/store/wishlists",{method:"GET",headers:{...await s?.getAuthHeader?.(),...n},query:{limit:t,offset:e,...i}}),retrieve:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),update:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"PUT",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),delete:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...e}}),totalItemsCount:async({wishlist_id:t},e)=>r.client.fetch("store/wishlists/total-items-count",{method:"GET",headers:{...await s?.getAuthHeader?.(),...e},query:{wishlist_id:t}}),transfer:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/transfer`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),share:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/share`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),import:async(t,e)=>r.client.fetch("/store/wishlists/import",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),addItem:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}/add-item`,{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),listItems:async({id:t,limit:e=10,offset:i=0,...n},a)=>r.client.fetch(`/store/wishlists/${t}/items`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...a},query:{limit:e,offset:i,...n}}),removeItem:async({wishlist_item_id:t,id:e},i)=>r.client.fetch(`/store/wishlists/${e}/items/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}})})};var c={name:"paypal",endpoints:(r,s)=>({createClientToken:async t=>r.client.fetch("/store/paypal/client-token",{method:"POST",headers:{...await s?.getAuthHeader?.(),...t}})})};var m={name:"reviews",endpoints:(r,s,t)=>({create:async(e,i)=>r.client.fetch("/store/reviews",{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),list:async({...e},i)=>r.client.fetch("/store/products/reviews",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),listProductReviews:async({product_id:e,...i},n)=>r.client.fetch(`/store/reviews/product/${e}`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),aggregateCounts:async({product_id:e,...i},n)=>r.client.fetch(`/store/reviews/product/${e}/aggregate-counts`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),delete:async({id:e},i)=>r.client.fetch(`/store/reviews/${e}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}}),uploadImageFiles:async(e,i)=>{let n=t?.baseUrl,a=t?.publishableKey;if(!n||!a)throw new Error("Missing baseUrl or publishableKey");return await(await fetch(`${n}/store/reviews/files/images/upload`,{method:"POST",body:e.formData,headers:{...i,"x-publishable-api-key":a}})).json()}})};var f={name:"econt",endpoints:(r,s)=>({listCities:async({countryCode:t="BGR"},e)=>r.client.fetch("/store/econt/cities",{method:"GET",headers:{...await s?.getAuthHeader?.(),...e},query:{countryCode:t}}),listQuarters:async({cityId:t,countryCode:e="BGR"},i)=>r.client.fetch("/store/econt/quarters",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:{cityId:t,countryCode:e}}),listOffices:async({countryCode:t="BGR",...e},i)=>r.client.fetch("/store/econt/offices",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:{countryCode:t,...e}})})};var o=class extends u__default.default{constructor(s,t,e){super(s),this.options=e,this.medusaConfig=s;let i={};t.forEach(n=>{i[n.name]=n.endpoints(this,this.options,this.medusaConfig);}),this.alphabite=i;}};exports.AlphabiteMedusaSdk=o;exports.econtPlugin=f;exports.paypalPlugin=c;exports.reviewsPlugin=m;exports.wishlistPlugin=d;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import u from'@medusajs/js-sdk';var p={name:"wishlist",endpoints:(r,s)=>({create:async({...t},e)=>r.client.fetch("/store/wishlists",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),list:async({limit:t=10,offset:e=0,...i},n)=>r.client.fetch("/store/wishlists",{method:"GET",headers:{...await s?.getAuthHeader?.(),...n},query:{limit:t,offset:e,...i}}),retrieve:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),update:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"PUT",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),delete:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...e}}),totalItemsCount:async({wishlist_id:t},e)=>r.client.fetch("store/wishlists/total-items-count",{method:"GET",headers:{...await s?.getAuthHeader?.(),...e},query:{wishlist_id:t}}),transfer:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/transfer`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),share:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/share`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),import:async(t,e)=>r.client.fetch("/store/wishlists/import",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),addItem:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}/add-item`,{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),listItems:async({id:t,limit:e=10,offset:i=0,...n},a)=>r.client.fetch(`/store/wishlists/${t}/items`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...a},query:{limit:e,offset:i,...n}}),removeItem:async({wishlist_item_id:t,id:e},i)=>r.client.fetch(`/store/wishlists/${e}/items/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}})})};var h={name:"paypal",endpoints:(r,s)=>({createClientToken:async t=>r.client.fetch("/store/paypal/client-token",{method:"POST",headers:{...await s?.getAuthHeader?.(),...t}})})};var m={name:"reviews",endpoints:(r,s,t)=>({create:async(e,i)=>r.client.fetch("/store/reviews",{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),list:async({...e},i)=>r.client.fetch("/store/products/reviews",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),listProductReviews:async({product_id:e,...i},n)=>r.client.fetch(`store/reviews/product/${e}`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),aggregateCounts:async({product_id:e,...i},n)=>r.client.fetch(`/store/reviews/product/${e}/aggregate-counts`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),delete:async({id:e},i)=>r.client.fetch(`/store/reviews/${e}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}}),uploadImageFiles:async(e,i)=>{let n=t?.baseUrl,a=t?.publishableKey;if(!n||!a)throw new Error("Missing baseUrl or publishableKey");return await(await fetch(`${n}/store/reviews/files/images/upload`,{method:"POST",body:e.formData,headers:{...i,"x-publishable-api-key":a}})).json()}})};var o=class extends u{constructor(s,t,e){super(s),this.options=e,this.medusaConfig=s;let i={};t.forEach(n=>{i[n.name]=n.endpoints(this,this.options,this.medusaConfig);}),this.alphabite=i;}};export{o as AlphabiteMedusaSdk,h as paypalPlugin,m as reviewsPlugin,p as wishlistPlugin};
1
+ import u from'@medusajs/js-sdk';var d={name:"wishlist",endpoints:(r,s)=>({create:async({...t},e)=>r.client.fetch("/store/wishlists",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),list:async({limit:t=10,offset:e=0,...i},n)=>r.client.fetch("/store/wishlists",{method:"GET",headers:{...await s?.getAuthHeader?.(),...n},query:{limit:t,offset:e,...i}}),retrieve:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),update:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}`,{method:"PUT",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),delete:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...e}}),totalItemsCount:async({wishlist_id:t},e)=>r.client.fetch("store/wishlists/total-items-count",{method:"GET",headers:{...await s?.getAuthHeader?.(),...e},query:{wishlist_id:t}}),transfer:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/transfer`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),share:async({id:t},e)=>r.client.fetch(`/store/wishlists/${t}/share`,{method:"POST",headers:{...await s?.getAuthHeader?.(),...e}}),import:async(t,e)=>r.client.fetch("/store/wishlists/import",{method:"POST",body:t,headers:{...await s?.getAuthHeader?.(),...e}}),addItem:async({id:t,...e},i)=>r.client.fetch(`/store/wishlists/${t}/add-item`,{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),listItems:async({id:t,limit:e=10,offset:i=0,...n},a)=>r.client.fetch(`/store/wishlists/${t}/items`,{method:"GET",headers:{...await s?.getAuthHeader?.(),...a},query:{limit:e,offset:i,...n}}),removeItem:async({wishlist_item_id:t,id:e},i)=>r.client.fetch(`/store/wishlists/${e}/items/${t}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}})})};var c={name:"paypal",endpoints:(r,s)=>({createClientToken:async t=>r.client.fetch("/store/paypal/client-token",{method:"POST",headers:{...await s?.getAuthHeader?.(),...t}})})};var m={name:"reviews",endpoints:(r,s,t)=>({create:async(e,i)=>r.client.fetch("/store/reviews",{method:"POST",body:e,headers:{...await s?.getAuthHeader?.(),...i}}),list:async({...e},i)=>r.client.fetch("/store/products/reviews",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:e}),listProductReviews:async({product_id:e,...i},n)=>r.client.fetch(`/store/reviews/product/${e}`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),aggregateCounts:async({product_id:e,...i},n)=>r.client.fetch(`/store/reviews/product/${e}/aggregate-counts`,{method:"GET",query:i,headers:{...await s?.getAuthHeader?.(),...n}}),delete:async({id:e},i)=>r.client.fetch(`/store/reviews/${e}`,{method:"DELETE",headers:{...await s?.getAuthHeader?.(),...i}}),uploadImageFiles:async(e,i)=>{let n=t?.baseUrl,a=t?.publishableKey;if(!n||!a)throw new Error("Missing baseUrl or publishableKey");return await(await fetch(`${n}/store/reviews/files/images/upload`,{method:"POST",body:e.formData,headers:{...i,"x-publishable-api-key":a}})).json()}})};var f={name:"econt",endpoints:(r,s)=>({listCities:async({countryCode:t="BGR"},e)=>r.client.fetch("/store/econt/cities",{method:"GET",headers:{...await s?.getAuthHeader?.(),...e},query:{countryCode:t}}),listQuarters:async({cityId:t,countryCode:e="BGR"},i)=>r.client.fetch("/store/econt/quarters",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:{cityId:t,countryCode:e}}),listOffices:async({countryCode:t="BGR",...e},i)=>r.client.fetch("/store/econt/offices",{method:"GET",headers:{...await s?.getAuthHeader?.(),...i},query:{countryCode:t,...e}})})};var o=class extends u{constructor(s,t,e){super(s),this.options=e,this.medusaConfig=s;let i={};t.forEach(n=>{i[n.name]=n.endpoints(this,this.options,this.medusaConfig);}),this.alphabite=i;}};export{o as AlphabiteMedusaSdk,f as econtPlugin,c as paypalPlugin,m as reviewsPlugin,d as wishlistPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphabite/medusa-sdk",
3
- "version": "0.5.7",
3
+ "version": "0.6.1",
4
4
  "description": "Extended Medusa utility sdk client, that adds Alphabite's plugins endpoints",
5
5
  "author": "Alphabite",
6
6
  "license": "MIT",
@@ -45,5 +45,8 @@
45
45
  "type": "git",
46
46
  "url": "git+ssh://git@github.com/alphabite-soft/medusa-sdk.git"
47
47
  },
48
- "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
48
+ "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610",
49
+ "dependencies": {
50
+ "@alphabite/econt-types": "^1.1.0"
51
+ }
49
52
  }