@malawistore/store-sdk 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -1
- package/README.md +94 -8
- package/dist/index.cjs +328 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +280 -13
- package/dist/index.d.ts +280 -13
- package/dist/index.js +328 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type QueryParams = Record<string, QueryValue>;
|
|
|
5
5
|
declare function buildQuery(query?: QueryParams): string;
|
|
6
6
|
|
|
7
7
|
/** Machine-readable error codes emitted by the API. */
|
|
8
|
-
type ApiErrorCode = "NOT_FOUND" | "VALIDATION_ERROR" | "UNAUTHORIZED" | "FORBIDDEN" | "CONFLICT" | "RATE_LIMITED" | "INTERNAL";
|
|
8
|
+
type ApiErrorCode = "NOT_FOUND" | "VALIDATION_ERROR" | "UNAUTHORIZED" | "FORBIDDEN" | "CONFLICT" | "RATE_LIMITED" | "INTERNAL" | "BULK_LIMIT_EXCEEDED" | "DUPLICATE_ITEM" | "IDEMPOTENCY_CONFLICT";
|
|
9
9
|
/** Error codes that can originate inside the SDK itself. */
|
|
10
10
|
type ClientErrorCode = "NETWORK_ERROR" | "TIMEOUT" | "ABORTED" | "PARSE_ERROR";
|
|
11
11
|
type ErrorCode = ApiErrorCode | ClientErrorCode;
|
|
@@ -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;
|
|
@@ -52,6 +52,51 @@ interface Paginated<T> {
|
|
|
52
52
|
data: T[];
|
|
53
53
|
meta: PaginationMeta;
|
|
54
54
|
}
|
|
55
|
+
/** One item's outcome inside a bulk response. */
|
|
56
|
+
type BulkItemStatus = "ok" | "error" | "rolled_back";
|
|
57
|
+
/** Machine-readable per-item failure. */
|
|
58
|
+
interface BulkItemError {
|
|
59
|
+
code: ApiErrorCode;
|
|
60
|
+
message: string;
|
|
61
|
+
}
|
|
62
|
+
/** Per-item bulk outcome. `index` lines the result up with the request. */
|
|
63
|
+
interface BulkResult<T> {
|
|
64
|
+
index: number;
|
|
65
|
+
/** Request line identity (row id, or `product_id|variant_id` for cart lines). */
|
|
66
|
+
id?: string;
|
|
67
|
+
status: BulkItemStatus;
|
|
68
|
+
data?: T;
|
|
69
|
+
error?: BulkItemError;
|
|
70
|
+
/** Customer writes: the row already existed / was already gone. */
|
|
71
|
+
alreadyExists?: boolean;
|
|
72
|
+
alreadyRemoved?: boolean;
|
|
73
|
+
/** Dry runs: the row would have been deleted; `blockers` explains refusals. */
|
|
74
|
+
wouldDelete?: boolean;
|
|
75
|
+
blockers?: string[];
|
|
76
|
+
}
|
|
77
|
+
/** Standard bulk envelope payload. */
|
|
78
|
+
interface BulkResponse<T> {
|
|
79
|
+
results: BulkResult<T>[];
|
|
80
|
+
summary: BulkSummary;
|
|
81
|
+
}
|
|
82
|
+
/** Batch counters. Anything not `ok` (error or rolled_back) counts as failed. */
|
|
83
|
+
interface BulkSummary {
|
|
84
|
+
total: number;
|
|
85
|
+
succeeded: number;
|
|
86
|
+
failed: number;
|
|
87
|
+
}
|
|
88
|
+
/** Shared options for every bulk write. */
|
|
89
|
+
interface BulkOptions {
|
|
90
|
+
/** All lines commit, or the batch rolls back on the first failure. */
|
|
91
|
+
atomic?: boolean;
|
|
92
|
+
/** Replay-safe request key (sent as `Idempotency-Key`, 24h window). */
|
|
93
|
+
idempotencyKey?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Bulk writes that can validate without writing. */
|
|
96
|
+
interface DryRunOptions extends BulkOptions {
|
|
97
|
+
/** Validate and project the outcome without writing. */
|
|
98
|
+
dryRun?: boolean;
|
|
99
|
+
}
|
|
55
100
|
|
|
56
101
|
type Role = "admin" | "customer";
|
|
57
102
|
/** Issued by register, login, and refresh. */
|
|
@@ -183,10 +228,12 @@ interface ProductVariantView {
|
|
|
183
228
|
available: number;
|
|
184
229
|
in_stock: boolean;
|
|
185
230
|
}
|
|
186
|
-
/** The storefront product page: product
|
|
231
|
+
/** The storefront product page: product, its sellable SKUs, and gallery. */
|
|
187
232
|
interface ProductDetail {
|
|
188
233
|
product: Product;
|
|
189
234
|
variants: ProductVariantView[];
|
|
235
|
+
/** Gallery rows; queued uploads (empty url) are excluded. */
|
|
236
|
+
images: ProductImage[];
|
|
190
237
|
}
|
|
191
238
|
type ProductSort = "name_asc" | "name_desc" | "price_asc" | "price_desc" | "newest" | "oldest" | "rating_asc" | "rating_desc" | "relevance";
|
|
192
239
|
interface ListProductsParams extends PageParams {
|
|
@@ -196,6 +243,8 @@ interface ListProductsParams extends PageParams {
|
|
|
196
243
|
* full-text finds nothing.
|
|
197
244
|
*/
|
|
198
245
|
q?: string;
|
|
246
|
+
/** Restrict to specific product ids (comma separated or repeated). */
|
|
247
|
+
ids?: string[];
|
|
199
248
|
category_id?: string;
|
|
200
249
|
category_slug?: string;
|
|
201
250
|
min_price_cents?: number;
|
|
@@ -237,6 +286,43 @@ interface UpdateProductInput {
|
|
|
237
286
|
/** Unfile the product. Slugs are immutable. */
|
|
238
287
|
clear_category?: boolean;
|
|
239
288
|
}
|
|
289
|
+
/** One product gallery image. `is_primary` mirrors the product's image_url. */
|
|
290
|
+
interface ProductImage {
|
|
291
|
+
id: string;
|
|
292
|
+
/** Empty while the upload is still queued. */
|
|
293
|
+
url: string;
|
|
294
|
+
position: number;
|
|
295
|
+
is_primary: boolean;
|
|
296
|
+
/** ISO-8601 timestamp. */
|
|
297
|
+
created_at: string;
|
|
298
|
+
}
|
|
299
|
+
/** Raw payload of the admin gallery list. */
|
|
300
|
+
interface ProductImageList {
|
|
301
|
+
images: ProductImage[];
|
|
302
|
+
}
|
|
303
|
+
/** Result of queuing a multi-file gallery upload (HTTP 202). */
|
|
304
|
+
interface UploadImagesResponse {
|
|
305
|
+
status: string;
|
|
306
|
+
queued: number;
|
|
307
|
+
failed: number;
|
|
308
|
+
}
|
|
309
|
+
interface BulkCreateProductsInput extends DryRunOptions {
|
|
310
|
+
items: CreateProductInput[];
|
|
311
|
+
}
|
|
312
|
+
interface BulkUpdateProductItem {
|
|
313
|
+
id: string;
|
|
314
|
+
patch: UpdateProductInput;
|
|
315
|
+
}
|
|
316
|
+
interface BulkUpdateProductsInput extends DryRunOptions {
|
|
317
|
+
updates: BulkUpdateProductItem[];
|
|
318
|
+
}
|
|
319
|
+
interface BulkDeleteProductsInput extends DryRunOptions {
|
|
320
|
+
ids: string[];
|
|
321
|
+
}
|
|
322
|
+
type BulkProductResult = BulkResult<Product>;
|
|
323
|
+
type BulkCreateProductsResponse = BulkResponse<Product>;
|
|
324
|
+
type BulkUpdateProductsResponse = BulkResponse<Product>;
|
|
325
|
+
type BulkDeleteProductsResponse = BulkResponse<never>;
|
|
240
326
|
|
|
241
327
|
/** A sellable SKU. Prices are absolute USD cents. */
|
|
242
328
|
interface Variant {
|
|
@@ -262,6 +348,18 @@ interface UpdateVariantInput {
|
|
|
262
348
|
price_cents?: number;
|
|
263
349
|
is_active?: boolean;
|
|
264
350
|
}
|
|
351
|
+
interface BulkCreateVariantsInput extends DryRunOptions {
|
|
352
|
+
items: CreateVariantInput[];
|
|
353
|
+
}
|
|
354
|
+
interface BulkUpdateVariantItem {
|
|
355
|
+
id: string;
|
|
356
|
+
patch: UpdateVariantInput;
|
|
357
|
+
}
|
|
358
|
+
interface BulkUpdateVariantsInput extends DryRunOptions {
|
|
359
|
+
updates: BulkUpdateVariantItem[];
|
|
360
|
+
}
|
|
361
|
+
type BulkCreateVariantsResponse = BulkResponse<Variant>;
|
|
362
|
+
type BulkUpdateVariantsResponse = BulkResponse<Variant>;
|
|
265
363
|
|
|
266
364
|
/** One cart row. Variant fields are empty for simple products. */
|
|
267
365
|
interface CartLine {
|
|
@@ -290,6 +388,32 @@ interface AddCartItemInput {
|
|
|
290
388
|
variant_id?: string;
|
|
291
389
|
qty: number;
|
|
292
390
|
}
|
|
391
|
+
interface BulkAddCartItemsInput extends BulkOptions {
|
|
392
|
+
items: AddCartItemInput[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Bulk add result: per-line outcomes plus the full updated cart, so no
|
|
396
|
+
* follow-up GET is needed.
|
|
397
|
+
*/
|
|
398
|
+
interface BulkAddCartItemsResponse extends BulkResponse<CartLine> {
|
|
399
|
+
cart: Cart;
|
|
400
|
+
}
|
|
401
|
+
type CartSort = "oldest" | "newest" | "name_asc" | "name_desc" | "price_asc" | "price_desc" | "qty_asc" | "qty_desc";
|
|
402
|
+
interface ListCartParams extends PageParams {
|
|
403
|
+
/** Case-insensitive substring over line name and SKU. */
|
|
404
|
+
q?: string;
|
|
405
|
+
product_id?: string;
|
|
406
|
+
variant_id?: string;
|
|
407
|
+
sort?: CartSort;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Raw paged cart envelope returned by `getPage`. `data.subtotal_cents`
|
|
411
|
+
* always covers the whole cart; `meta` counts cart lines.
|
|
412
|
+
*/
|
|
413
|
+
interface CartResponse {
|
|
414
|
+
data: Cart;
|
|
415
|
+
meta: PaginationMeta;
|
|
416
|
+
}
|
|
293
417
|
|
|
294
418
|
interface Stock {
|
|
295
419
|
product_id: string;
|
|
@@ -307,6 +431,21 @@ interface SetStockInput {
|
|
|
307
431
|
variant_id?: string;
|
|
308
432
|
qty: number;
|
|
309
433
|
}
|
|
434
|
+
/** One line of a batch restock. Stock is keyed by product + variant. */
|
|
435
|
+
interface BulkSetStockItemInput {
|
|
436
|
+
product_id: string;
|
|
437
|
+
variant_id?: string;
|
|
438
|
+
qty: number;
|
|
439
|
+
}
|
|
440
|
+
interface BulkSetStockInput extends BulkOptions {
|
|
441
|
+
items: BulkSetStockItemInput[];
|
|
442
|
+
}
|
|
443
|
+
type BulkSetStockResponse = BulkResponse<Stock>;
|
|
444
|
+
/** Batch availability read: rows plus ids that did not resolve. */
|
|
445
|
+
interface BulkStockResponse {
|
|
446
|
+
stock: Stock[];
|
|
447
|
+
notFound: string[];
|
|
448
|
+
}
|
|
310
449
|
interface ReserveLineInput {
|
|
311
450
|
product_id: string;
|
|
312
451
|
variant_id?: string;
|
|
@@ -340,6 +479,20 @@ interface Order {
|
|
|
340
479
|
/** ISO-8601 timestamp. */
|
|
341
480
|
created_at: string;
|
|
342
481
|
}
|
|
482
|
+
type OrderSort = "newest" | "oldest" | "total_asc" | "total_desc";
|
|
483
|
+
interface ListOrdersParams extends PageParams {
|
|
484
|
+
status?: OrderStatus;
|
|
485
|
+
currency?: string;
|
|
486
|
+
/** RFC3339 or YYYY-MM-DD. */
|
|
487
|
+
created_after?: string;
|
|
488
|
+
/** RFC3339 or YYYY-MM-DD; a date-only value includes the whole day. */
|
|
489
|
+
created_before?: string;
|
|
490
|
+
min_total_cents?: number;
|
|
491
|
+
max_total_cents?: number;
|
|
492
|
+
sort?: OrderSort;
|
|
493
|
+
}
|
|
494
|
+
/** Raw paged orders envelope returned by `listPage`. */
|
|
495
|
+
type OrderListResponse = Paginated<Order>;
|
|
343
496
|
|
|
344
497
|
type PaymentStatus = "pending" | "succeeded" | "failed" | "cancelled";
|
|
345
498
|
/**
|
|
@@ -383,6 +536,25 @@ interface WishlistItem {
|
|
|
383
536
|
/** ISO-8601 timestamp. */
|
|
384
537
|
added_at: string;
|
|
385
538
|
}
|
|
539
|
+
type WishlistSort = "newest" | "oldest" | "name_asc" | "name_desc" | "price_asc" | "price_desc";
|
|
540
|
+
interface ListWishlistParams extends PageParams {
|
|
541
|
+
/** Case-insensitive substring over product name and slug. */
|
|
542
|
+
q?: string;
|
|
543
|
+
category_id?: string;
|
|
544
|
+
sort?: WishlistSort;
|
|
545
|
+
}
|
|
546
|
+
/** Raw paged wishlist envelope returned by `listPage`. */
|
|
547
|
+
type WishlistListResponse = Paginated<WishlistItem>;
|
|
548
|
+
/** Body of `POST /wishlist/bulk` (the field is camelCase on the wire). */
|
|
549
|
+
interface BulkAddWishlistInput extends BulkOptions {
|
|
550
|
+
productIds: string[];
|
|
551
|
+
}
|
|
552
|
+
/** Body of `POST /wishlist/bulk-delete` (product ids, not wishlist row ids). */
|
|
553
|
+
interface BulkRemoveWishlistInput extends DryRunOptions {
|
|
554
|
+
ids: string[];
|
|
555
|
+
}
|
|
556
|
+
type BulkAddWishlistResponse = BulkResponse<WishlistItem>;
|
|
557
|
+
type BulkRemoveWishlistResponse = BulkResponse<never>;
|
|
386
558
|
|
|
387
559
|
interface Review {
|
|
388
560
|
id: string;
|
|
@@ -400,6 +572,16 @@ interface ReviewSummary {
|
|
|
400
572
|
average: number;
|
|
401
573
|
count: number;
|
|
402
574
|
reviews: Review[];
|
|
575
|
+
/** Counters for the filtered review page (average/count are unfiltered). */
|
|
576
|
+
meta: PaginationMeta;
|
|
577
|
+
}
|
|
578
|
+
type ReviewSort = "newest" | "oldest" | "highest" | "lowest";
|
|
579
|
+
interface ListReviewsParams extends PageParams {
|
|
580
|
+
/** Case-insensitive substring over title, body and author. */
|
|
581
|
+
q?: string;
|
|
582
|
+
/** Only this rating (1-5). */
|
|
583
|
+
rating?: number;
|
|
584
|
+
sort?: ReviewSort;
|
|
403
585
|
}
|
|
404
586
|
interface CreateReviewInput {
|
|
405
587
|
/** 1–5. */
|
|
@@ -412,6 +594,32 @@ interface UpdateReviewInput {
|
|
|
412
594
|
title?: string;
|
|
413
595
|
body?: string;
|
|
414
596
|
}
|
|
597
|
+
/** Catalog context attached to a review in the caller's own history. */
|
|
598
|
+
interface MyReviewProduct {
|
|
599
|
+
id: string;
|
|
600
|
+
name: string;
|
|
601
|
+
slug: string;
|
|
602
|
+
image_url?: string;
|
|
603
|
+
}
|
|
604
|
+
/** One of the caller's reviews, with product context. */
|
|
605
|
+
interface MyReview {
|
|
606
|
+
id: string;
|
|
607
|
+
user_id: string;
|
|
608
|
+
product_id: string;
|
|
609
|
+
rating: number;
|
|
610
|
+
title: string;
|
|
611
|
+
body: string;
|
|
612
|
+
/** ISO-8601 timestamp. */
|
|
613
|
+
created_at: string;
|
|
614
|
+
/** ISO-8601 timestamp. */
|
|
615
|
+
updated_at: string;
|
|
616
|
+
product: MyReviewProduct;
|
|
617
|
+
}
|
|
618
|
+
interface ListMyReviewsParams extends PageParams {
|
|
619
|
+
sort?: ReviewSort;
|
|
620
|
+
}
|
|
621
|
+
/** Raw paged envelope returned by `listMinePage`. */
|
|
622
|
+
type MyReviewsResponse = Paginated<MyReview>;
|
|
415
623
|
|
|
416
624
|
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
417
625
|
interface RetryOptions {
|
|
@@ -539,10 +747,17 @@ declare class AuthResource {
|
|
|
539
747
|
declare class CartResource {
|
|
540
748
|
private readonly http;
|
|
541
749
|
constructor(http: HttpClient);
|
|
542
|
-
/** Active cart, created empty on first use. */
|
|
543
|
-
get(): Promise<Cart>;
|
|
750
|
+
/** Active cart, created empty on first use (paging meta is dropped). */
|
|
751
|
+
get(params?: ListCartParams): Promise<Cart>;
|
|
752
|
+
/** Same as `get`, plus the `meta` paging counters. */
|
|
753
|
+
getPage(params?: ListCartParams): Promise<CartResponse>;
|
|
544
754
|
/** Validates against the catalog and snapshots the current price. */
|
|
545
755
|
addItem(input: AddCartItemInput): Promise<Cart>;
|
|
756
|
+
/**
|
|
757
|
+
* Adds up to MAX_BULK_ITEMS lines in one request. Per-line results carry
|
|
758
|
+
* the written line, plus the full updated cart.
|
|
759
|
+
*/
|
|
760
|
+
addItems(input: BulkAddCartItemsInput): Promise<BulkAddCartItemsResponse>;
|
|
546
761
|
/** `qty: 0` removes the line. */
|
|
547
762
|
setQty(itemId: string, qty: number): Promise<Cart>;
|
|
548
763
|
removeItem(itemId: string): Promise<Cart>;
|
|
@@ -561,8 +776,10 @@ type UploadFile = Blob | {
|
|
|
561
776
|
name: string;
|
|
562
777
|
type?: string;
|
|
563
778
|
};
|
|
564
|
-
/** Builds the `file` part expected by the admin image endpoints. */
|
|
779
|
+
/** Builds the single `file` part expected by the admin image endpoints. */
|
|
565
780
|
declare function createUploadForm(file: UploadFile, field?: string): FormData;
|
|
781
|
+
/** Builds repeated `files` parts for the gallery upload endpoint. */
|
|
782
|
+
declare function createUploadFormMany(files: UploadFile | UploadFile[], field?: string): FormData;
|
|
566
783
|
|
|
567
784
|
declare class CategoriesResource {
|
|
568
785
|
private readonly http;
|
|
@@ -591,8 +808,15 @@ declare class InventoryResource {
|
|
|
591
808
|
private readonly http;
|
|
592
809
|
constructor(http: HttpClient);
|
|
593
810
|
getStock(params: GetStockParams): Promise<Stock>;
|
|
811
|
+
/**
|
|
812
|
+
* Reads availability for up to MAX_BULK_ITEMS variants in one request.
|
|
813
|
+
* Unknown ids are returned in `notFound` instead of failing.
|
|
814
|
+
*/
|
|
815
|
+
getStockByVariants(variantIds: string | string[]): Promise<BulkStockResponse>;
|
|
594
816
|
/** Upserts the on-hand quantity (restocking). */
|
|
595
817
|
setStock(input: SetStockInput): Promise<Stock>;
|
|
818
|
+
/** Sets on-hand stock for many SKUs; `atomic` commits all or none. */
|
|
819
|
+
setStockBulk(input: BulkSetStockInput): Promise<BulkSetStockResponse>;
|
|
596
820
|
/** Holds all lines atomically; one short line fails the whole order. */
|
|
597
821
|
reserve(input: ReserveStockInput): Promise<StatusResponse>;
|
|
598
822
|
/** Idempotent. */
|
|
@@ -610,8 +834,10 @@ declare class OrdersResource {
|
|
|
610
834
|
* the cart.
|
|
611
835
|
*/
|
|
612
836
|
checkout(): Promise<Order>;
|
|
613
|
-
/** Newest first. */
|
|
614
|
-
list(): Promise<Order[]>;
|
|
837
|
+
/** Newest first (paging meta is dropped). */
|
|
838
|
+
list(params?: ListOrdersParams): Promise<Order[]>;
|
|
839
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
840
|
+
listPage(params?: ListOrdersParams): Promise<OrderListResponse>;
|
|
615
841
|
get(id: string): Promise<Order>;
|
|
616
842
|
/** Pending orders only; releases the stock hold. */
|
|
617
843
|
cancel(id: string): Promise<Order>;
|
|
@@ -651,13 +877,40 @@ declare class ProductsResource {
|
|
|
651
877
|
delete(id: string): Promise<void>;
|
|
652
878
|
/** Admin only. Queues an async Cloudinary upload (HTTP 202). */
|
|
653
879
|
uploadImage(id: string, file: UploadFile): Promise<StatusResponse>;
|
|
880
|
+
/**
|
|
881
|
+
* Admin only. Creates products in bulk. Per-item failures stay inside
|
|
882
|
+
* the 200 envelope; `atomic` rolls the whole batch back.
|
|
883
|
+
*/
|
|
884
|
+
bulkCreate(input: BulkCreateProductsInput): Promise<BulkCreateProductsResponse>;
|
|
885
|
+
/** Admin only. Applies one partial patch per product id. */
|
|
886
|
+
bulkUpdate(input: BulkUpdateProductsInput): Promise<BulkUpdateProductsResponse>;
|
|
887
|
+
/**
|
|
888
|
+
* Admin only. POST rather than DELETE so the id list can travel in JSON.
|
|
889
|
+
* `dryRun` reports `wouldDelete` without writing.
|
|
890
|
+
*/
|
|
891
|
+
bulkDelete(input: BulkDeleteProductsInput): Promise<BulkDeleteProductsResponse>;
|
|
892
|
+
/** Admin only. Gallery rows, including uploads still queued (empty url). */
|
|
893
|
+
listImages(id: string): Promise<ProductImage[]>;
|
|
894
|
+
/**
|
|
895
|
+
* Admin only. Multipart with repeated `files` parts (up to 20 per
|
|
896
|
+
* request). Each accepted file is queued asynchronously (HTTP 202).
|
|
897
|
+
*/
|
|
898
|
+
uploadImages(id: string, files: UploadFile | UploadFile[]): Promise<UploadImagesResponse>;
|
|
899
|
+
/** Admin only. Promotes the next ready image when the primary is deleted. */
|
|
900
|
+
deleteImage(id: string, imageId: string): Promise<void>;
|
|
901
|
+
/** Admin only. Points the storefront primary image at one gallery row. */
|
|
902
|
+
setPrimaryImage(id: string, imageId: string): Promise<Product>;
|
|
654
903
|
}
|
|
655
904
|
|
|
656
905
|
declare class ReviewsResource {
|
|
657
906
|
private readonly http;
|
|
658
907
|
constructor(http: HttpClient);
|
|
659
|
-
/** Public aggregate plus
|
|
660
|
-
summary(productId: string): Promise<ReviewSummary>;
|
|
908
|
+
/** Public aggregate plus one filtered review page (`summary.meta`). */
|
|
909
|
+
summary(productId: string, params?: ListReviewsParams): Promise<ReviewSummary>;
|
|
910
|
+
/** The caller's own reviews with product context (paging meta dropped). */
|
|
911
|
+
listMine(params?: ListMyReviewsParams): Promise<MyReview[]>;
|
|
912
|
+
/** Same as `listMine`, plus the `meta` paging counters. */
|
|
913
|
+
listMinePage(params?: ListMyReviewsParams): Promise<MyReviewsResponse>;
|
|
661
914
|
/** One review per user per product. */
|
|
662
915
|
create(productId: string, input: CreateReviewInput): Promise<Review>;
|
|
663
916
|
/** Edits the caller's own review. */
|
|
@@ -673,6 +926,7 @@ declare class UsersResource {
|
|
|
673
926
|
constructor(http: HttpClient);
|
|
674
927
|
/** The caller's own account, read from the JWT. */
|
|
675
928
|
me(): Promise<User>;
|
|
929
|
+
/** Admin only. There is no public `GET /users/{id}` — owners use `me()`. */
|
|
676
930
|
get(id: string): Promise<User>;
|
|
677
931
|
/** Admin only. User directory without envelope metadata. */
|
|
678
932
|
list(params?: ListUsersParams): Promise<User[]>;
|
|
@@ -692,18 +946,31 @@ declare class VariantsResource {
|
|
|
692
946
|
update(id: string, input: UpdateVariantInput): Promise<Variant>;
|
|
693
947
|
/** Admin only. */
|
|
694
948
|
delete(id: string): Promise<void>;
|
|
949
|
+
/** Admin only. Creates up to MAX_BULK_ITEMS SKUs for one product. */
|
|
950
|
+
createBulk(productId: string, input: BulkCreateVariantsInput): Promise<BulkCreateVariantsResponse>;
|
|
951
|
+
/** Admin only. Applies one partial patch per variant id. */
|
|
952
|
+
updateBulk(input: BulkUpdateVariantsInput): Promise<BulkUpdateVariantsResponse>;
|
|
695
953
|
}
|
|
696
954
|
|
|
697
955
|
/** Requires authentication. */
|
|
698
956
|
declare class WishlistResource {
|
|
699
957
|
private readonly http;
|
|
700
958
|
constructor(http: HttpClient);
|
|
701
|
-
/** Newest first. */
|
|
702
|
-
list(): Promise<WishlistItem[]>;
|
|
959
|
+
/** Newest first (paging meta is dropped). */
|
|
960
|
+
list(params?: ListWishlistParams): Promise<WishlistItem[]>;
|
|
961
|
+
/** Same filters as `list`, plus the `meta` paging counters. */
|
|
962
|
+
listPage(params?: ListWishlistParams): Promise<WishlistListResponse>;
|
|
703
963
|
/** Idempotent: re-hearting succeeds silently. */
|
|
704
964
|
add(productId: string): Promise<WishlistItem>;
|
|
705
965
|
/** `productId`, not the wishlist row ID. */
|
|
706
966
|
remove(productId: string): Promise<StatusResponse>;
|
|
967
|
+
/** Hearts up to MAX_BULK_ITEMS products; already-hearted rows succeed. */
|
|
968
|
+
addBulk(input: BulkAddWishlistInput): Promise<BulkAddWishlistResponse>;
|
|
969
|
+
/**
|
|
970
|
+
* Unhearts by product id. `dryRun` reports `wouldDelete` without
|
|
971
|
+
* writing; already-removed rows succeed.
|
|
972
|
+
*/
|
|
973
|
+
removeBulk(input: BulkRemoveWishlistInput): Promise<BulkRemoveWishlistResponse>;
|
|
707
974
|
}
|
|
708
975
|
|
|
709
976
|
/**
|
|
@@ -819,4 +1086,4 @@ declare function verifyStripeSignature(options: VerifyStripeSignatureOptions): P
|
|
|
819
1086
|
*/
|
|
820
1087
|
declare function constructStripeEvent<T = Record<string, unknown>>(options: VerifyStripeSignatureOptions): Promise<StripeEvent<T>>;
|
|
821
1088
|
|
|
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 };
|
|
1089
|
+
export { type AddCartItemInput, type ApiEnvelope, type ApiErrorCode, type ApiErrorEnvelope, type AuthStatusResponse, type BulkAddCartItemsInput, type BulkAddCartItemsResponse, type BulkAddWishlistInput, type BulkAddWishlistResponse, type BulkCreateProductsInput, type BulkCreateProductsResponse, type BulkCreateVariantsInput, type BulkCreateVariantsResponse, type BulkDeleteProductsInput, type BulkDeleteProductsResponse, type BulkItemError, type BulkItemStatus, type BulkOptions, type BulkProductResult, type BulkRemoveWishlistInput, type BulkRemoveWishlistResponse, type BulkResponse, type BulkResult, type BulkSetStockInput, type BulkSetStockItemInput, type BulkSetStockResponse, type BulkStockResponse, type BulkSummary, type BulkUpdateProductItem, type BulkUpdateProductsInput, type BulkUpdateProductsResponse, type BulkUpdateVariantItem, type BulkUpdateVariantsInput, type BulkUpdateVariantsResponse, 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 DryRunOptions, type ErrorCode, type FetchLike, type GetStockParams, type HealthResponse, type ListCartParams, type ListCategoriesParams, type ListMyReviewsParams, type ListOrdersParams, type ListProductsParams, type ListReviewsParams, type ListUsersParams, type ListWishlistParams, type LoginInput, MalawiStore, MalawiStoreError, type MalawiStoreErrorInit, type MalawiStoreOptions, type MyReview, type MyReviewProduct, type MyReviewsResponse, 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 ProductImage, type ProductImageList, 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 UploadImagesResponse, type User, type UserListResponse, type UserSort, type Variant, type VerifyEmailInput, type VerifyStripeSignatureOptions, type WishlistItem, type WishlistListResponse, type WishlistProduct, type WishlistSort, buildQuery, constructStripeEvent, createUploadForm, createUploadFormMany, isMalawiStoreError, verifyStripeSignature };
|