@malawistore/store-sdk 0.1.2 → 0.1.3
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/CHANGELOG.md +19 -0
- package/README.md +26 -2
- package/dist/index.cjs +101 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -10
- package/dist/index.d.ts +65 -10
- package/dist/index.js +101 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -32,7 +32,7 @@ interface StatusResponse {
|
|
|
32
32
|
interface PageParams {
|
|
33
33
|
/** 1-based page. Wins over `offset` when both are sent. */
|
|
34
34
|
page?: number;
|
|
35
|
-
/** Page size.
|
|
35
|
+
/** Page size. Storefront/shopper lists default to 12; admin user lists default to 20. Capped at 100. */
|
|
36
36
|
limit?: number;
|
|
37
37
|
/** Number of rows to skip. */
|
|
38
38
|
offset?: number;
|
|
@@ -290,6 +290,22 @@ interface AddCartItemInput {
|
|
|
290
290
|
variant_id?: string;
|
|
291
291
|
qty: number;
|
|
292
292
|
}
|
|
293
|
+
type CartSort = "oldest" | "newest" | "name_asc" | "name_desc" | "price_asc" | "price_desc" | "qty_asc" | "qty_desc";
|
|
294
|
+
interface ListCartParams extends PageParams {
|
|
295
|
+
/** Case-insensitive substring over line name and SKU. */
|
|
296
|
+
q?: string;
|
|
297
|
+
product_id?: string;
|
|
298
|
+
variant_id?: string;
|
|
299
|
+
sort?: CartSort;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Raw paged cart envelope returned by `getPage`. `data.subtotal_cents`
|
|
303
|
+
* always covers the whole cart; `meta` counts cart lines.
|
|
304
|
+
*/
|
|
305
|
+
interface CartResponse {
|
|
306
|
+
data: Cart;
|
|
307
|
+
meta: PaginationMeta;
|
|
308
|
+
}
|
|
293
309
|
|
|
294
310
|
interface Stock {
|
|
295
311
|
product_id: string;
|
|
@@ -340,6 +356,20 @@ interface Order {
|
|
|
340
356
|
/** ISO-8601 timestamp. */
|
|
341
357
|
created_at: string;
|
|
342
358
|
}
|
|
359
|
+
type OrderSort = "newest" | "oldest" | "total_asc" | "total_desc";
|
|
360
|
+
interface ListOrdersParams extends PageParams {
|
|
361
|
+
status?: OrderStatus;
|
|
362
|
+
currency?: string;
|
|
363
|
+
/** RFC3339 or YYYY-MM-DD. */
|
|
364
|
+
created_after?: string;
|
|
365
|
+
/** RFC3339 or YYYY-MM-DD; a date-only value includes the whole day. */
|
|
366
|
+
created_before?: string;
|
|
367
|
+
min_total_cents?: number;
|
|
368
|
+
max_total_cents?: number;
|
|
369
|
+
sort?: OrderSort;
|
|
370
|
+
}
|
|
371
|
+
/** Raw paged orders envelope returned by `listPage`. */
|
|
372
|
+
type OrderListResponse = Paginated<Order>;
|
|
343
373
|
|
|
344
374
|
type PaymentStatus = "pending" | "succeeded" | "failed" | "cancelled";
|
|
345
375
|
/**
|
|
@@ -383,6 +413,15 @@ interface WishlistItem {
|
|
|
383
413
|
/** ISO-8601 timestamp. */
|
|
384
414
|
added_at: string;
|
|
385
415
|
}
|
|
416
|
+
type WishlistSort = "newest" | "oldest" | "name_asc" | "name_desc" | "price_asc" | "price_desc";
|
|
417
|
+
interface ListWishlistParams extends PageParams {
|
|
418
|
+
/** Case-insensitive substring over product name and slug. */
|
|
419
|
+
q?: string;
|
|
420
|
+
category_id?: string;
|
|
421
|
+
sort?: WishlistSort;
|
|
422
|
+
}
|
|
423
|
+
/** Raw paged wishlist envelope returned by `listPage`. */
|
|
424
|
+
type WishlistListResponse = Paginated<WishlistItem>;
|
|
386
425
|
|
|
387
426
|
interface Review {
|
|
388
427
|
id: string;
|
|
@@ -400,6 +439,16 @@ interface ReviewSummary {
|
|
|
400
439
|
average: number;
|
|
401
440
|
count: number;
|
|
402
441
|
reviews: Review[];
|
|
442
|
+
/** Counters for the filtered review page (average/count are unfiltered). */
|
|
443
|
+
meta: PaginationMeta;
|
|
444
|
+
}
|
|
445
|
+
type ReviewSort = "newest" | "oldest" | "highest" | "lowest";
|
|
446
|
+
interface ListReviewsParams extends PageParams {
|
|
447
|
+
/** Case-insensitive substring over title, body and author. */
|
|
448
|
+
q?: string;
|
|
449
|
+
/** Only this rating (1-5). */
|
|
450
|
+
rating?: number;
|
|
451
|
+
sort?: ReviewSort;
|
|
403
452
|
}
|
|
404
453
|
interface CreateReviewInput {
|
|
405
454
|
/** 1–5. */
|
|
@@ -539,8 +588,10 @@ declare class AuthResource {
|
|
|
539
588
|
declare class CartResource {
|
|
540
589
|
private readonly http;
|
|
541
590
|
constructor(http: HttpClient);
|
|
542
|
-
/** Active cart, created empty on first use. */
|
|
543
|
-
get(): Promise<Cart>;
|
|
591
|
+
/** Active cart, created empty on first use (paging meta is dropped). */
|
|
592
|
+
get(params?: ListCartParams): Promise<Cart>;
|
|
593
|
+
/** Same as `get`, plus the `meta` paging counters. */
|
|
594
|
+
getPage(params?: ListCartParams): Promise<CartResponse>;
|
|
544
595
|
/** Validates against the catalog and snapshots the current price. */
|
|
545
596
|
addItem(input: AddCartItemInput): Promise<Cart>;
|
|
546
597
|
/** `qty: 0` removes the line. */
|
|
@@ -610,8 +661,10 @@ declare class OrdersResource {
|
|
|
610
661
|
* the cart.
|
|
611
662
|
*/
|
|
612
663
|
checkout(): Promise<Order>;
|
|
613
|
-
/** Newest first. */
|
|
614
|
-
list(): Promise<Order[]>;
|
|
664
|
+
/** Newest first (paging meta is dropped). */
|
|
665
|
+
list(params?: ListOrdersParams): Promise<Order[]>;
|
|
666
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
667
|
+
listPage(params?: ListOrdersParams): Promise<OrderListResponse>;
|
|
615
668
|
get(id: string): Promise<Order>;
|
|
616
669
|
/** Pending orders only; releases the stock hold. */
|
|
617
670
|
cancel(id: string): Promise<Order>;
|
|
@@ -656,8 +709,8 @@ declare class ProductsResource {
|
|
|
656
709
|
declare class ReviewsResource {
|
|
657
710
|
private readonly http;
|
|
658
711
|
constructor(http: HttpClient);
|
|
659
|
-
/** Public aggregate plus
|
|
660
|
-
summary(productId: string): Promise<ReviewSummary>;
|
|
712
|
+
/** Public aggregate plus one filtered review page (`summary.meta`). */
|
|
713
|
+
summary(productId: string, params?: ListReviewsParams): Promise<ReviewSummary>;
|
|
661
714
|
/** One review per user per product. */
|
|
662
715
|
create(productId: string, input: CreateReviewInput): Promise<Review>;
|
|
663
716
|
/** Edits the caller's own review. */
|
|
@@ -698,8 +751,10 @@ declare class VariantsResource {
|
|
|
698
751
|
declare class WishlistResource {
|
|
699
752
|
private readonly http;
|
|
700
753
|
constructor(http: HttpClient);
|
|
701
|
-
/** Newest first. */
|
|
702
|
-
list(): Promise<WishlistItem[]>;
|
|
754
|
+
/** Newest first (paging meta is dropped). */
|
|
755
|
+
list(params?: ListWishlistParams): Promise<WishlistItem[]>;
|
|
756
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
757
|
+
listPage(params?: ListWishlistParams): Promise<WishlistListResponse>;
|
|
703
758
|
/** Idempotent: re-hearting succeeds silently. */
|
|
704
759
|
add(productId: string): Promise<WishlistItem>;
|
|
705
760
|
/** `productId`, not the wishlist row ID. */
|
|
@@ -819,4 +874,4 @@ declare function verifyStripeSignature(options: VerifyStripeSignatureOptions): P
|
|
|
819
874
|
*/
|
|
820
875
|
declare function constructStripeEvent<T = Record<string, unknown>>(options: VerifyStripeSignatureOptions): Promise<StripeEvent<T>>;
|
|
821
876
|
|
|
822
|
-
export { type AddCartItemInput, type ApiEnvelope, type ApiErrorCode, type ApiErrorEnvelope, type AuthStatusResponse, type Cart, type CartLine, type Category, type CategoryListResponse, type CategorySort, type CheckoutSession, type ClientErrorCode, type CreateCategoryInput, type CreateProductInput, type CreateReviewInput, type CreateVariantInput, type ErrorCode, type FetchLike, type GetStockParams, type HealthResponse, type ListCategoriesParams, type ListProductsParams, type ListUsersParams, type LoginInput, MalawiStore, MalawiStoreError, type MalawiStoreErrorInit, type MalawiStoreOptions, type Order, type OrderLine, type OrderStatus, type PageParams, type Paginated, type PaginationMeta, type PasswordResetInput, type Payment, type PaymentStatus, type Product, type ProductDetail, type ProductListResponse, type ProductSort, type ProductVariantView, type QueryParams, type QueryScalar, type QueryValue, type RegisterInput, type RequestOptions, type ReserveLineInput, type ReserveStockInput, type RetryOptions, type Review, type ReviewSummary, type Role, type SetRoleInput, type SetStockInput, type StatusResponse, type Stock, type StripeEvent, type TokenPair, type TokenState, type UpdateCategoryInput, type UpdateProductInput, type UpdateReviewInput, type UpdateVariantInput, type UploadData, type UploadFile, type User, type UserListResponse, type UserSort, type Variant, type VerifyEmailInput, type VerifyStripeSignatureOptions, type WishlistItem, type WishlistProduct, buildQuery, constructStripeEvent, createUploadForm, isMalawiStoreError, verifyStripeSignature };
|
|
877
|
+
export { type AddCartItemInput, type ApiEnvelope, type ApiErrorCode, type ApiErrorEnvelope, type AuthStatusResponse, type Cart, type CartLine, type CartResponse, type CartSort, type Category, type CategoryListResponse, type CategorySort, type CheckoutSession, type ClientErrorCode, type CreateCategoryInput, type CreateProductInput, type CreateReviewInput, type CreateVariantInput, type ErrorCode, type FetchLike, type GetStockParams, type HealthResponse, type ListCartParams, type ListCategoriesParams, type ListOrdersParams, type ListProductsParams, type ListReviewsParams, type ListUsersParams, type ListWishlistParams, type LoginInput, MalawiStore, MalawiStoreError, type MalawiStoreErrorInit, type MalawiStoreOptions, type Order, type OrderLine, type OrderListResponse, type OrderSort, type OrderStatus, type PageParams, type Paginated, type PaginationMeta, type PasswordResetInput, type Payment, type PaymentStatus, type Product, type ProductDetail, type ProductListResponse, type ProductSort, type ProductVariantView, type QueryParams, type QueryScalar, type QueryValue, type RegisterInput, type RequestOptions, type ReserveLineInput, type ReserveStockInput, type RetryOptions, type Review, type ReviewSort, type ReviewSummary, type Role, type SetRoleInput, type SetStockInput, type StatusResponse, type Stock, type StripeEvent, type TokenPair, type TokenState, type UpdateCategoryInput, type UpdateProductInput, type UpdateReviewInput, type UpdateVariantInput, type UploadData, type UploadFile, type User, type UserListResponse, type UserSort, type Variant, type VerifyEmailInput, type VerifyStripeSignatureOptions, type WishlistItem, type WishlistListResponse, type WishlistProduct, type WishlistSort, buildQuery, constructStripeEvent, createUploadForm, isMalawiStoreError, verifyStripeSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ interface StatusResponse {
|
|
|
32
32
|
interface PageParams {
|
|
33
33
|
/** 1-based page. Wins over `offset` when both are sent. */
|
|
34
34
|
page?: number;
|
|
35
|
-
/** Page size.
|
|
35
|
+
/** Page size. Storefront/shopper lists default to 12; admin user lists default to 20. Capped at 100. */
|
|
36
36
|
limit?: number;
|
|
37
37
|
/** Number of rows to skip. */
|
|
38
38
|
offset?: number;
|
|
@@ -290,6 +290,22 @@ interface AddCartItemInput {
|
|
|
290
290
|
variant_id?: string;
|
|
291
291
|
qty: number;
|
|
292
292
|
}
|
|
293
|
+
type CartSort = "oldest" | "newest" | "name_asc" | "name_desc" | "price_asc" | "price_desc" | "qty_asc" | "qty_desc";
|
|
294
|
+
interface ListCartParams extends PageParams {
|
|
295
|
+
/** Case-insensitive substring over line name and SKU. */
|
|
296
|
+
q?: string;
|
|
297
|
+
product_id?: string;
|
|
298
|
+
variant_id?: string;
|
|
299
|
+
sort?: CartSort;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Raw paged cart envelope returned by `getPage`. `data.subtotal_cents`
|
|
303
|
+
* always covers the whole cart; `meta` counts cart lines.
|
|
304
|
+
*/
|
|
305
|
+
interface CartResponse {
|
|
306
|
+
data: Cart;
|
|
307
|
+
meta: PaginationMeta;
|
|
308
|
+
}
|
|
293
309
|
|
|
294
310
|
interface Stock {
|
|
295
311
|
product_id: string;
|
|
@@ -340,6 +356,20 @@ interface Order {
|
|
|
340
356
|
/** ISO-8601 timestamp. */
|
|
341
357
|
created_at: string;
|
|
342
358
|
}
|
|
359
|
+
type OrderSort = "newest" | "oldest" | "total_asc" | "total_desc";
|
|
360
|
+
interface ListOrdersParams extends PageParams {
|
|
361
|
+
status?: OrderStatus;
|
|
362
|
+
currency?: string;
|
|
363
|
+
/** RFC3339 or YYYY-MM-DD. */
|
|
364
|
+
created_after?: string;
|
|
365
|
+
/** RFC3339 or YYYY-MM-DD; a date-only value includes the whole day. */
|
|
366
|
+
created_before?: string;
|
|
367
|
+
min_total_cents?: number;
|
|
368
|
+
max_total_cents?: number;
|
|
369
|
+
sort?: OrderSort;
|
|
370
|
+
}
|
|
371
|
+
/** Raw paged orders envelope returned by `listPage`. */
|
|
372
|
+
type OrderListResponse = Paginated<Order>;
|
|
343
373
|
|
|
344
374
|
type PaymentStatus = "pending" | "succeeded" | "failed" | "cancelled";
|
|
345
375
|
/**
|
|
@@ -383,6 +413,15 @@ interface WishlistItem {
|
|
|
383
413
|
/** ISO-8601 timestamp. */
|
|
384
414
|
added_at: string;
|
|
385
415
|
}
|
|
416
|
+
type WishlistSort = "newest" | "oldest" | "name_asc" | "name_desc" | "price_asc" | "price_desc";
|
|
417
|
+
interface ListWishlistParams extends PageParams {
|
|
418
|
+
/** Case-insensitive substring over product name and slug. */
|
|
419
|
+
q?: string;
|
|
420
|
+
category_id?: string;
|
|
421
|
+
sort?: WishlistSort;
|
|
422
|
+
}
|
|
423
|
+
/** Raw paged wishlist envelope returned by `listPage`. */
|
|
424
|
+
type WishlistListResponse = Paginated<WishlistItem>;
|
|
386
425
|
|
|
387
426
|
interface Review {
|
|
388
427
|
id: string;
|
|
@@ -400,6 +439,16 @@ interface ReviewSummary {
|
|
|
400
439
|
average: number;
|
|
401
440
|
count: number;
|
|
402
441
|
reviews: Review[];
|
|
442
|
+
/** Counters for the filtered review page (average/count are unfiltered). */
|
|
443
|
+
meta: PaginationMeta;
|
|
444
|
+
}
|
|
445
|
+
type ReviewSort = "newest" | "oldest" | "highest" | "lowest";
|
|
446
|
+
interface ListReviewsParams extends PageParams {
|
|
447
|
+
/** Case-insensitive substring over title, body and author. */
|
|
448
|
+
q?: string;
|
|
449
|
+
/** Only this rating (1-5). */
|
|
450
|
+
rating?: number;
|
|
451
|
+
sort?: ReviewSort;
|
|
403
452
|
}
|
|
404
453
|
interface CreateReviewInput {
|
|
405
454
|
/** 1–5. */
|
|
@@ -539,8 +588,10 @@ declare class AuthResource {
|
|
|
539
588
|
declare class CartResource {
|
|
540
589
|
private readonly http;
|
|
541
590
|
constructor(http: HttpClient);
|
|
542
|
-
/** Active cart, created empty on first use. */
|
|
543
|
-
get(): Promise<Cart>;
|
|
591
|
+
/** Active cart, created empty on first use (paging meta is dropped). */
|
|
592
|
+
get(params?: ListCartParams): Promise<Cart>;
|
|
593
|
+
/** Same as `get`, plus the `meta` paging counters. */
|
|
594
|
+
getPage(params?: ListCartParams): Promise<CartResponse>;
|
|
544
595
|
/** Validates against the catalog and snapshots the current price. */
|
|
545
596
|
addItem(input: AddCartItemInput): Promise<Cart>;
|
|
546
597
|
/** `qty: 0` removes the line. */
|
|
@@ -610,8 +661,10 @@ declare class OrdersResource {
|
|
|
610
661
|
* the cart.
|
|
611
662
|
*/
|
|
612
663
|
checkout(): Promise<Order>;
|
|
613
|
-
/** Newest first. */
|
|
614
|
-
list(): Promise<Order[]>;
|
|
664
|
+
/** Newest first (paging meta is dropped). */
|
|
665
|
+
list(params?: ListOrdersParams): Promise<Order[]>;
|
|
666
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
667
|
+
listPage(params?: ListOrdersParams): Promise<OrderListResponse>;
|
|
615
668
|
get(id: string): Promise<Order>;
|
|
616
669
|
/** Pending orders only; releases the stock hold. */
|
|
617
670
|
cancel(id: string): Promise<Order>;
|
|
@@ -656,8 +709,8 @@ declare class ProductsResource {
|
|
|
656
709
|
declare class ReviewsResource {
|
|
657
710
|
private readonly http;
|
|
658
711
|
constructor(http: HttpClient);
|
|
659
|
-
/** Public aggregate plus
|
|
660
|
-
summary(productId: string): Promise<ReviewSummary>;
|
|
712
|
+
/** Public aggregate plus one filtered review page (`summary.meta`). */
|
|
713
|
+
summary(productId: string, params?: ListReviewsParams): Promise<ReviewSummary>;
|
|
661
714
|
/** One review per user per product. */
|
|
662
715
|
create(productId: string, input: CreateReviewInput): Promise<Review>;
|
|
663
716
|
/** Edits the caller's own review. */
|
|
@@ -698,8 +751,10 @@ declare class VariantsResource {
|
|
|
698
751
|
declare class WishlistResource {
|
|
699
752
|
private readonly http;
|
|
700
753
|
constructor(http: HttpClient);
|
|
701
|
-
/** Newest first. */
|
|
702
|
-
list(): Promise<WishlistItem[]>;
|
|
754
|
+
/** Newest first (paging meta is dropped). */
|
|
755
|
+
list(params?: ListWishlistParams): Promise<WishlistItem[]>;
|
|
756
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
757
|
+
listPage(params?: ListWishlistParams): Promise<WishlistListResponse>;
|
|
703
758
|
/** Idempotent: re-hearting succeeds silently. */
|
|
704
759
|
add(productId: string): Promise<WishlistItem>;
|
|
705
760
|
/** `productId`, not the wishlist row ID. */
|
|
@@ -819,4 +874,4 @@ declare function verifyStripeSignature(options: VerifyStripeSignatureOptions): P
|
|
|
819
874
|
*/
|
|
820
875
|
declare function constructStripeEvent<T = Record<string, unknown>>(options: VerifyStripeSignatureOptions): Promise<StripeEvent<T>>;
|
|
821
876
|
|
|
822
|
-
export { type AddCartItemInput, type ApiEnvelope, type ApiErrorCode, type ApiErrorEnvelope, type AuthStatusResponse, type Cart, type CartLine, type Category, type CategoryListResponse, type CategorySort, type CheckoutSession, type ClientErrorCode, type CreateCategoryInput, type CreateProductInput, type CreateReviewInput, type CreateVariantInput, type ErrorCode, type FetchLike, type GetStockParams, type HealthResponse, type ListCategoriesParams, type ListProductsParams, type ListUsersParams, type LoginInput, MalawiStore, MalawiStoreError, type MalawiStoreErrorInit, type MalawiStoreOptions, type Order, type OrderLine, type OrderStatus, type PageParams, type Paginated, type PaginationMeta, type PasswordResetInput, type Payment, type PaymentStatus, type Product, type ProductDetail, type ProductListResponse, type ProductSort, type ProductVariantView, type QueryParams, type QueryScalar, type QueryValue, type RegisterInput, type RequestOptions, type ReserveLineInput, type ReserveStockInput, type RetryOptions, type Review, type ReviewSummary, type Role, type SetRoleInput, type SetStockInput, type StatusResponse, type Stock, type StripeEvent, type TokenPair, type TokenState, type UpdateCategoryInput, type UpdateProductInput, type UpdateReviewInput, type UpdateVariantInput, type UploadData, type UploadFile, type User, type UserListResponse, type UserSort, type Variant, type VerifyEmailInput, type VerifyStripeSignatureOptions, type WishlistItem, type WishlistProduct, buildQuery, constructStripeEvent, createUploadForm, isMalawiStoreError, verifyStripeSignature };
|
|
877
|
+
export { type AddCartItemInput, type ApiEnvelope, type ApiErrorCode, type ApiErrorEnvelope, type AuthStatusResponse, type Cart, type CartLine, type CartResponse, type CartSort, type Category, type CategoryListResponse, type CategorySort, type CheckoutSession, type ClientErrorCode, type CreateCategoryInput, type CreateProductInput, type CreateReviewInput, type CreateVariantInput, type ErrorCode, type FetchLike, type GetStockParams, type HealthResponse, type ListCartParams, type ListCategoriesParams, type ListOrdersParams, type ListProductsParams, type ListReviewsParams, type ListUsersParams, type ListWishlistParams, type LoginInput, MalawiStore, MalawiStoreError, type MalawiStoreErrorInit, type MalawiStoreOptions, type Order, type OrderLine, type OrderListResponse, type OrderSort, type OrderStatus, type PageParams, type Paginated, type PaginationMeta, type PasswordResetInput, type Payment, type PaymentStatus, type Product, type ProductDetail, type ProductListResponse, type ProductSort, type ProductVariantView, type QueryParams, type QueryScalar, type QueryValue, type RegisterInput, type RequestOptions, type ReserveLineInput, type ReserveStockInput, type RetryOptions, type Review, type ReviewSort, type ReviewSummary, type Role, type SetRoleInput, type SetStockInput, type StatusResponse, type Stock, type StripeEvent, type TokenPair, type TokenState, type UpdateCategoryInput, type UpdateProductInput, type UpdateReviewInput, type UpdateVariantInput, type UploadData, type UploadFile, type User, type UserListResponse, type UserSort, type Variant, type VerifyEmailInput, type VerifyStripeSignatureOptions, type WishlistItem, type WishlistListResponse, type WishlistProduct, type WishlistSort, buildQuery, constructStripeEvent, createUploadForm, isMalawiStoreError, verifyStripeSignature };
|
package/dist/index.js
CHANGED
|
@@ -442,9 +442,34 @@ var CartResource = class {
|
|
|
442
442
|
this.http = http;
|
|
443
443
|
}
|
|
444
444
|
http;
|
|
445
|
-
/** Active cart, created empty on first use. */
|
|
446
|
-
get() {
|
|
447
|
-
return this.http.request("GET", "/cart"
|
|
445
|
+
/** Active cart, created empty on first use (paging meta is dropped). */
|
|
446
|
+
get(params = {}) {
|
|
447
|
+
return this.http.request("GET", "/cart", {
|
|
448
|
+
query: {
|
|
449
|
+
q: params.q,
|
|
450
|
+
product_id: params.product_id,
|
|
451
|
+
variant_id: params.variant_id,
|
|
452
|
+
sort: params.sort,
|
|
453
|
+
page: params.page,
|
|
454
|
+
limit: params.limit,
|
|
455
|
+
offset: params.offset
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
/** Same as `get`, plus the `meta` paging counters. */
|
|
460
|
+
getPage(params = {}) {
|
|
461
|
+
return this.http.request("GET", "/cart", {
|
|
462
|
+
query: {
|
|
463
|
+
q: params.q,
|
|
464
|
+
product_id: params.product_id,
|
|
465
|
+
variant_id: params.variant_id,
|
|
466
|
+
sort: params.sort,
|
|
467
|
+
page: params.page,
|
|
468
|
+
limit: params.limit,
|
|
469
|
+
offset: params.offset
|
|
470
|
+
},
|
|
471
|
+
unwrap: false
|
|
472
|
+
});
|
|
448
473
|
}
|
|
449
474
|
/** Validates against the catalog and snapshots the current price. */
|
|
450
475
|
addItem(input) {
|
|
@@ -643,9 +668,40 @@ var OrdersResource = class {
|
|
|
643
668
|
retry: false
|
|
644
669
|
});
|
|
645
670
|
}
|
|
646
|
-
/** Newest first. */
|
|
647
|
-
list() {
|
|
648
|
-
return this.http.request("GET", "/orders"
|
|
671
|
+
/** Newest first (paging meta is dropped). */
|
|
672
|
+
list(params = {}) {
|
|
673
|
+
return this.http.request("GET", "/orders", {
|
|
674
|
+
query: {
|
|
675
|
+
status: params.status,
|
|
676
|
+
currency: params.currency,
|
|
677
|
+
created_after: params.created_after,
|
|
678
|
+
created_before: params.created_before,
|
|
679
|
+
min_total_cents: params.min_total_cents,
|
|
680
|
+
max_total_cents: params.max_total_cents,
|
|
681
|
+
sort: params.sort,
|
|
682
|
+
page: params.page,
|
|
683
|
+
limit: params.limit,
|
|
684
|
+
offset: params.offset
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
689
|
+
listPage(params = {}) {
|
|
690
|
+
return this.http.request("GET", "/orders", {
|
|
691
|
+
query: {
|
|
692
|
+
status: params.status,
|
|
693
|
+
currency: params.currency,
|
|
694
|
+
created_after: params.created_after,
|
|
695
|
+
created_before: params.created_before,
|
|
696
|
+
min_total_cents: params.min_total_cents,
|
|
697
|
+
max_total_cents: params.max_total_cents,
|
|
698
|
+
sort: params.sort,
|
|
699
|
+
page: params.page,
|
|
700
|
+
limit: params.limit,
|
|
701
|
+
offset: params.offset
|
|
702
|
+
},
|
|
703
|
+
unwrap: false
|
|
704
|
+
});
|
|
649
705
|
}
|
|
650
706
|
get(id) {
|
|
651
707
|
return this.http.request("GET", `/orders/${segment(id)}`);
|
|
@@ -795,12 +851,22 @@ var ReviewsResource = class {
|
|
|
795
851
|
this.http = http;
|
|
796
852
|
}
|
|
797
853
|
http;
|
|
798
|
-
/** Public aggregate plus
|
|
799
|
-
summary(productId) {
|
|
854
|
+
/** Public aggregate plus one filtered review page (`summary.meta`). */
|
|
855
|
+
summary(productId, params = {}) {
|
|
800
856
|
return this.http.request(
|
|
801
857
|
"GET",
|
|
802
858
|
`/products/${segment(productId)}/reviews`,
|
|
803
|
-
{
|
|
859
|
+
{
|
|
860
|
+
query: {
|
|
861
|
+
q: params.q,
|
|
862
|
+
rating: params.rating,
|
|
863
|
+
sort: params.sort,
|
|
864
|
+
page: params.page,
|
|
865
|
+
limit: params.limit,
|
|
866
|
+
offset: params.offset
|
|
867
|
+
},
|
|
868
|
+
skipAuth: true
|
|
869
|
+
}
|
|
804
870
|
);
|
|
805
871
|
}
|
|
806
872
|
/** One review per user per product. */
|
|
@@ -936,9 +1002,32 @@ var WishlistResource = class {
|
|
|
936
1002
|
this.http = http;
|
|
937
1003
|
}
|
|
938
1004
|
http;
|
|
939
|
-
/** Newest first. */
|
|
940
|
-
list() {
|
|
941
|
-
return this.http.request("GET", "/wishlist"
|
|
1005
|
+
/** Newest first (paging meta is dropped). */
|
|
1006
|
+
list(params = {}) {
|
|
1007
|
+
return this.http.request("GET", "/wishlist", {
|
|
1008
|
+
query: {
|
|
1009
|
+
q: params.q,
|
|
1010
|
+
category_id: params.category_id,
|
|
1011
|
+
sort: params.sort,
|
|
1012
|
+
page: params.page,
|
|
1013
|
+
limit: params.limit,
|
|
1014
|
+
offset: params.offset
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
1019
|
+
listPage(params = {}) {
|
|
1020
|
+
return this.http.request("GET", "/wishlist", {
|
|
1021
|
+
query: {
|
|
1022
|
+
q: params.q,
|
|
1023
|
+
category_id: params.category_id,
|
|
1024
|
+
sort: params.sort,
|
|
1025
|
+
page: params.page,
|
|
1026
|
+
limit: params.limit,
|
|
1027
|
+
offset: params.offset
|
|
1028
|
+
},
|
|
1029
|
+
unwrap: false
|
|
1030
|
+
});
|
|
942
1031
|
}
|
|
943
1032
|
/** Idempotent: re-hearting succeeds silently. */
|
|
944
1033
|
add(productId) {
|