@wix/himalaya-cli 0.876.0 → 0.878.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.
@@ -37,7 +37,18 @@ export interface WixGetPostRequest {
37
37
  * filter-by-id — a graceful degrade to the LIST projection (no body) that keeps
38
38
  * blog detail + saved screens rendering instead of erroring out. `queryPosts`'s
39
39
  * request type has no `fieldsets` field, so that fallback path cannot carry the
40
- * body. */
40
+ * body.
41
+ *
42
+ * When that fallback ALSO finds nothing (#2658) — a deleted post, or one this
43
+ * visitor may not see — we reject rather than resolve. `WixGetPostResponse.post`
44
+ * is non-optional, so returning `{ post: resp.posts?.[0] }` would hand callers an
45
+ * `undefined` the type promises is present, and the `post.title` access that type
46
+ * licenses throws a `TypeError` deep inside the caller — the exact hard error
47
+ * this fallback exists to prevent, and harder to diagnose than a clean rejection.
48
+ * Every call site rides its own rejection path (cached-post state, draft-only
49
+ * `catch`, or an `allSettled` filter), so rejecting is what routes them into the
50
+ * graceful degrade they already implement. The originating failure travels as
51
+ * `cause`, so the 404-vs-network distinction is not lost. */
41
52
  export declare function getPost(postId: string, req?: WixGetPostRequest): Promise<WixGetPostResponse>;
42
53
  export interface WixBlogCategory {
43
54
  id: string;
@@ -12,9 +12,13 @@ function getPost(postId, req = {}) {
12
12
  return wixCall(
13
13
  "GET",
14
14
  `/blog/v3/posts/${encodeURIComponent(postId)}` + query
15
- ).catch(async () => {
15
+ ).catch(async (cause) => {
16
16
  const resp = await queryPosts({ query: { filter: { id: postId } } });
17
- return { post: resp.posts?.[0] };
17
+ const post = resp.posts?.[0];
18
+ if (!post) {
19
+ throw new Error(`Blog post not found: ${postId}`, { cause });
20
+ }
21
+ return { post };
18
22
  });
19
23
  }
20
24
  function queryCategories(req = {}) {
@@ -1,4 +1,9 @@
1
1
  // ../../stdlib/wix-sdk/portfolio/src/index.ts
2
+ function pagingQuery(limit, cursor) {
3
+ const parts = [`paging.limit=${encodeURIComponent(String(limit))}`];
4
+ if (cursor) parts.push(`paging.cursor=${encodeURIComponent(cursor)}`);
5
+ return parts.join("&");
6
+ }
2
7
  function wixCall(method, path, body) {
3
8
  if (!globalThis.himalaya?.wixApi) {
4
9
  return Promise.reject(new Error("@himalaya/wix-portfolio: host did not install the wixApi bridge"));
@@ -6,22 +11,13 @@ function wixCall(method, path, body) {
6
11
  return globalThis.himalaya.wixApi.call(method, path, body);
7
12
  }
8
13
  function listProjects(limit = 100, cursor) {
9
- const q = new URLSearchParams();
10
- q.set("paging.limit", String(limit));
11
- if (cursor) q.set("paging.cursor", cursor);
12
- return wixCall("GET", `/portfolio/v1/projects?${q.toString()}`);
14
+ return wixCall("GET", `/portfolio/v1/projects?${pagingQuery(limit, cursor)}`);
13
15
  }
14
16
  function listCollections(limit = 100, cursor) {
15
- const q = new URLSearchParams();
16
- q.set("paging.limit", String(limit));
17
- if (cursor) q.set("paging.cursor", cursor);
18
- return wixCall("GET", `/portfolio/v1/collections?${q.toString()}`);
17
+ return wixCall("GET", `/portfolio/v1/collections?${pagingQuery(limit, cursor)}`);
19
18
  }
20
19
  function listProjectItems(projectId, limit = 100, cursor) {
21
- const q = new URLSearchParams();
22
- q.set("paging.limit", String(limit));
23
- if (cursor) q.set("paging.cursor", cursor);
24
- return wixCall("GET", `/portfolio/v1/projects/${encodeURIComponent(projectId)}/items?${q.toString()}`);
20
+ return wixCall("GET", `/portfolio/v1/projects/${encodeURIComponent(projectId)}/items?${pagingQuery(limit, cursor)}`);
25
21
  }
26
22
  export {
27
23
  listCollections,
package/dist/cli.mjs CHANGED
@@ -27400,6 +27400,7 @@ function shouldRevealError(args) {
27400
27400
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE;
27401
27401
  var init_validation = __esm({
27402
27402
  "../../core/ts/src/validation.ts"() {
27403
+ "use strict";
27403
27404
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
27404
27405
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
27405
27406
  INTEGER_RE = /^[+-]?[0-9]+$/;
@@ -30823,6 +30824,7 @@ function validateWorkerSubtree(raw, slotId, policy, actionCatalog) {
30823
30824
  var WORKER_SUBTREE_CEILINGS, ID_PART, ACTION_ID;
30824
30825
  var init_worker_subtree = __esm({
30825
30826
  "../../core/ts/src/worker-subtree.ts"() {
30827
+ "use strict";
30826
30828
  init_worker_subtree_safe_types_generated();
30827
30829
  WORKER_SUBTREE_CEILINGS = Object.freeze({
30828
30830
  maxEncodedBytes: 65536,
@@ -6590,7 +6590,7 @@
6590
6590
  {
6591
6591
  "name": "getPost",
6592
6592
  "kind": "function",
6593
- "jsdoc": "/** Fetch a single PUBLISHED post by id — GET /blog/v3/posts/{id}. The list\n * (queryPosts) returns published posts, so the detail reads them here (draft\n * ids are a different space — getDraftPost is for the edit/create flow).\n *\n * Body fieldsets (#826): Blog v3 `GET /posts/{id}` returns 200 but only the\n * LIST projection (title / excerpt / meta) unless the caller asks for the body —\n * the bare GET has NO `richContent` / `contentText`. So we request\n * RICH_CONTENT + CONTENT_TEXT by default and the article body loads on the happy\n * path; callers can override via `req.fieldsets`. (Supersedes the old #507 note:\n * the 502 this GET once returned for anonymous visitors is gone — it 200s now —\n * but a body-less 200 was never the \"body preserved whenever the backend is\n * healthy\" the earlier comment claimed; the body was simply never requested.)\n *\n * On any rejection (network / backend error) we still fall back to a queryPosts\n * filter-by-id — a graceful degrade to the LIST projection (no body) that keeps\n * blog detail + saved screens rendering instead of erroring out. `queryPosts`'s\n * request type has no `fieldsets` field, so that fallback path cannot carry the\n * body. */",
6593
+ "jsdoc": "/** Fetch a single PUBLISHED post by id — GET /blog/v3/posts/{id}. The list\n * (queryPosts) returns published posts, so the detail reads them here (draft\n * ids are a different space — getDraftPost is for the edit/create flow).\n *\n * Body fieldsets (#826): Blog v3 `GET /posts/{id}` returns 200 but only the\n * LIST projection (title / excerpt / meta) unless the caller asks for the body —\n * the bare GET has NO `richContent` / `contentText`. So we request\n * RICH_CONTENT + CONTENT_TEXT by default and the article body loads on the happy\n * path; callers can override via `req.fieldsets`. (Supersedes the old #507 note:\n * the 502 this GET once returned for anonymous visitors is gone — it 200s now —\n * but a body-less 200 was never the \"body preserved whenever the backend is\n * healthy\" the earlier comment claimed; the body was simply never requested.)\n *\n * On any rejection (network / backend error) we still fall back to a queryPosts\n * filter-by-id — a graceful degrade to the LIST projection (no body) that keeps\n * blog detail + saved screens rendering instead of erroring out. `queryPosts`'s\n * request type has no `fieldsets` field, so that fallback path cannot carry the\n * body.\n *\n * When that fallback ALSO finds nothing (#2658) — a deleted post, or one this\n * visitor may not see — we reject rather than resolve. `WixGetPostResponse.post`\n * is non-optional, so returning `{ post: resp.posts?.[0] }` would hand callers an\n * `undefined` the type promises is present, and the `post.title` access that type\n * licenses throws a `TypeError` deep inside the caller — the exact hard error\n * this fallback exists to prevent, and harder to diagnose than a clean rejection.\n * Every call site rides its own rejection path (cached-post state, draft-only\n * `catch`, or an `allSettled` filter), so rejecting is what routes them into the\n * graceful degrade they already implement. The originating failure travels as\n * `cause`, so the 404-vs-network distinction is not lost. */",
6594
6594
  "decl": "export function getPost(\n postId: string,\n req: WixGetPostRequest = {},\n): Promise<WixGetPostResponse>;",
6595
6595
  "http": "GET /blog/v3/posts/{…}"
6596
6596
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.876.0",
3
+ "version": "0.878.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -63,5 +63,5 @@
63
63
  "artifactId": "himalaya-cli"
64
64
  }
65
65
  },
66
- "falconPackageHash": "7be3e709d4d0bff872e0d278fffa17c9757247f0260fdd291e4d2f1a"
66
+ "falconPackageHash": "f191342a43dc741dcb30330836f5daafa7f1b917e8a252461dfc1cf2"
67
67
  }