@wix/himalaya-cli 0.917.0 → 0.919.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ecom/src/extensions.d.ts +14 -4
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-feed-viewer/src/index.d.ts +3 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ecom.mjs +12 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members-feed-viewer.mjs +37 -6
- package/dist/cli.mjs +2 -2
- package/guides/sdk-reference.json +9 -3
- package/package.json +2 -2
- package/templates/branded-lite/tier5-src/himi-branded-lite-forms/index.ts +32 -11
|
@@ -92,10 +92,15 @@ export interface WixGetCartResponse {
|
|
|
92
92
|
cart?: WixCartDetail;
|
|
93
93
|
}
|
|
94
94
|
/** True when a thrown bridge/HTTP error means "no current cart yet" — Wix's
|
|
95
|
-
* empty-cart signal. `GET /ecom/v1/carts/current`
|
|
95
|
+
* empty-cart signal. `GET /ecom/v1/carts/current` answers 404
|
|
96
96
|
* `OWNED_CART_NOT_FOUND` until the visitor/member adds an item (a current cart
|
|
97
|
-
* is created on first add-to-cart)
|
|
98
|
-
*
|
|
97
|
+
* is created on first add-to-cart), and Wix's own description calls that the
|
|
98
|
+
* expected pre-first-add state.
|
|
99
|
+
*
|
|
100
|
+
* DELIBERATELY NARROW — it keys on the typed application error code, never on the
|
|
101
|
+
* 404 status and no longer on the human message "Cart not found". A bare
|
|
102
|
+
* 404 with no code, a 403, a 500, a transport failure and every other cart error
|
|
103
|
+
* code stay real failures and still throw. */
|
|
99
104
|
export declare function isEmptyCurrentCartError(error: unknown): boolean;
|
|
100
105
|
/** True when order search is denied for this member/site identity.
|
|
101
106
|
* Live Wix returns HTTP 403 `READ_ORDER_FORBIDDEN` / "read order: permission denied"
|
|
@@ -105,7 +110,12 @@ export declare function isOrdersForbiddenError(error: unknown): boolean;
|
|
|
105
110
|
/** Read the current cart — GET /ecom/v1/carts/current. The API wraps the cart in
|
|
106
111
|
* `{ cart: {...} }`; this unwraps it so callers get the cart (line items +
|
|
107
112
|
* subtotal) directly. Verified live. An `OWNED_CART_NOT_FOUND` 404 is the empty
|
|
108
|
-
* cart (never added an item) —
|
|
113
|
+
* cart (never added an item) — resolved as `{ lineItems: [] }`, not thrown, so a
|
|
114
|
+
* signed-out visitor's first mount is a successful read of an empty cart.
|
|
115
|
+
* `{ lineItems: [] }` is the shape every caller already handles: the badge readers
|
|
116
|
+
* sum `(cart.lineItems ?? [])` and the cart screen additionally takes
|
|
117
|
+
* `cart.subtotal?.formattedAmount ?? ""` and `(await getCurrentCart()).id || ""` —
|
|
118
|
+
* all three degrade to empty/0 on an absent field, so no caller special-cases it. */
|
|
109
119
|
export declare function getCurrentCart(): Promise<WixCartDetail>;
|
|
110
120
|
export interface WixRemoveLineItemsResponse {
|
|
111
121
|
cart?: WixCartDetail;
|
|
@@ -40,8 +40,9 @@ export interface MfvNotification {
|
|
|
40
40
|
icon?: MfvIcon;
|
|
41
41
|
memberId?: string;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/** Reset the learned route. Tests only — there is no runtime caller. */
|
|
44
|
+
export declare function __resetMfvRouteForTests(): void;
|
|
45
|
+
/** List the signed-in member's notifications, newest first. MOBILE channel. */
|
|
45
46
|
export declare function queryNotifications(limit?: number): Promise<MfvNotification[]>;
|
|
46
47
|
/** Mark the given notification ids as READ (bulk, by-filter). */
|
|
47
48
|
export declare function markRead(ids: string[]): Promise<void>;
|
|
@@ -29,9 +29,19 @@ function addToCurrentCart(productId, quantity = 1, options) {
|
|
|
29
29
|
lineItems: [{ catalogReference: { catalogItemId: productId, appId: WIX_STORES_APP_ID, ...options ? { options } : {} }, quantity }]
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
var OWNED_CART_NOT_FOUND = "OWNED_CART_NOT_FOUND";
|
|
33
|
+
function applicationErrorCode(error) {
|
|
34
|
+
const o = error;
|
|
35
|
+
if (o && typeof o === "object") {
|
|
36
|
+
const structured = o.details?.applicationError?.code ?? o.applicationError?.code ?? o.code;
|
|
37
|
+
if (typeof structured === "string" && structured) return structured;
|
|
38
|
+
}
|
|
33
39
|
const msg = error instanceof Error ? error.message : String(error ?? "");
|
|
34
|
-
|
|
40
|
+
const m = /"code"\s*:\s*"([A-Z0-9_]+)"/.exec(msg) ?? /\[([A-Z0-9_]{4,})\]/.exec(msg);
|
|
41
|
+
return m ? m[1] : "";
|
|
42
|
+
}
|
|
43
|
+
function isEmptyCurrentCartError(error) {
|
|
44
|
+
return applicationErrorCode(error) === OWNED_CART_NOT_FOUND;
|
|
35
45
|
}
|
|
36
46
|
function isOrdersForbiddenError(error) {
|
|
37
47
|
const msg = error instanceof Error ? error.message : String(error ?? "");
|
|
@@ -6,10 +6,40 @@ function wixCall(method, path, body, headers) {
|
|
|
6
6
|
return globalThis.himalaya.wixApi.call(method, path, body, headers);
|
|
7
7
|
}
|
|
8
8
|
var BASE = "/members-feed-viewer/v1";
|
|
9
|
+
var PROXY_PREFIX = "/_api";
|
|
10
|
+
var route;
|
|
11
|
+
var proxyRefused = false;
|
|
12
|
+
function __resetMfvRouteForTests() {
|
|
13
|
+
route = void 0;
|
|
14
|
+
proxyRefused = false;
|
|
15
|
+
}
|
|
16
|
+
function isNotFound(err) {
|
|
17
|
+
return /\bHTTP 404\b/.test(err instanceof Error ? err.message : String(err));
|
|
18
|
+
}
|
|
19
|
+
async function mfvCall(method, suffix, body) {
|
|
20
|
+
const bare = `${BASE}${suffix}`;
|
|
21
|
+
const proxy = `${PROXY_PREFIX}${BASE}${suffix}`;
|
|
22
|
+
if (route === "proxy") return wixCall(method, proxy, body);
|
|
23
|
+
try {
|
|
24
|
+
const res = await wixCall(method, bare, body);
|
|
25
|
+
route = "bare";
|
|
26
|
+
return res;
|
|
27
|
+
} catch (err) {
|
|
28
|
+
if (route === "bare" || proxyRefused || !isNotFound(err)) throw err;
|
|
29
|
+
try {
|
|
30
|
+
const res = await wixCall(method, proxy, body);
|
|
31
|
+
route = "proxy";
|
|
32
|
+
return res;
|
|
33
|
+
} catch (proxyErr) {
|
|
34
|
+
if (isNotFound(proxyErr)) proxyRefused = true;
|
|
35
|
+
throw proxyErr;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
9
39
|
async function queryNotifications(limit = 25) {
|
|
10
|
-
const res = await
|
|
40
|
+
const res = await mfvCall(
|
|
11
41
|
"POST",
|
|
12
|
-
|
|
42
|
+
"/members-viewer-feed-notifications/query",
|
|
13
43
|
{
|
|
14
44
|
query: {
|
|
15
45
|
cursorPaging: { limit },
|
|
@@ -22,20 +52,21 @@ async function queryNotifications(limit = 25) {
|
|
|
22
52
|
}
|
|
23
53
|
async function markRead(ids) {
|
|
24
54
|
if (!ids.length) return;
|
|
25
|
-
await
|
|
55
|
+
await mfvCall(
|
|
26
56
|
"POST",
|
|
27
|
-
|
|
57
|
+
"/bulk/members-viewer-feed-notifications/update-status-by-filter",
|
|
28
58
|
{ filter: { id: { $in: ids } }, status: "READ" }
|
|
29
59
|
);
|
|
30
60
|
}
|
|
31
61
|
async function markAllRead() {
|
|
32
|
-
await
|
|
62
|
+
await mfvCall(
|
|
33
63
|
"POST",
|
|
34
|
-
|
|
64
|
+
"/bulk/members-viewer-feed-notifications/update-status-by-filter",
|
|
35
65
|
{ filter: { channel: "MOBILE", status: { $ne: "READ" } }, status: "READ" }
|
|
36
66
|
);
|
|
37
67
|
}
|
|
38
68
|
export {
|
|
69
|
+
__resetMfvRouteForTests,
|
|
39
70
|
markAllRead,
|
|
40
71
|
markRead,
|
|
41
72
|
queryNotifications
|