@wocart/storefront 2.2.0 → 3.0.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.
@@ -53,10 +53,11 @@ export interface ActionDescriptor<TResult extends ActionHandlerResult = ActionHa
53
53
  handler: () => Promise<TResult>;
54
54
  }
55
55
  /**
56
- * `TSerialized` is the framework's result-cookie token, opaque to this SDK:
57
- * Astro 5 used a string, Astro 7 an object (`SerializedActionResult`). The
58
- * generics thread whatever `getActionContext()` hands the theme straight
59
- * through, so no theme ever casts.
56
+ * What `runFormAction` needs from `getActionContext()`. `TSerialized` is the
57
+ * framework's result-cookie token, opaque to this SDK: Astro 5 used a string,
58
+ * Astro 7 an object (`SerializedActionResult`). The generics thread whatever
59
+ * `getActionContext()` hands the theme straight through, so no theme ever
60
+ * casts.
60
61
  */
61
62
  export interface ActionMiddlewareDeps<TResult extends ActionHandlerResult = ActionHandlerResult, TSerialized = string> {
62
63
  action?: ActionDescriptor<TResult>;
@@ -64,31 +65,10 @@ export interface ActionMiddlewareDeps<TResult extends ActionHandlerResult = Acti
64
65
  setActionResult: (name: string, serialized: TSerialized) => void;
65
66
  /** Serializes an ActionResult into the cookie value (Astro's serializeActionResult). */
66
67
  serializeActionResult: (result: TResult) => TSerialized;
67
- /** @deprecated Unused since 1.2.0: nothing redirects. */
68
- referer?: string | null;
69
- /** @deprecated Unused since 1.2.0: nothing redirects. */
70
- pathname?: string;
71
68
  }
72
- export type PrgDecision =
73
- /** Never produced since 1.2.0 — kept so existing `decision.kind` checks compile. */
74
- {
75
- kind: "redirect";
76
- location: string;
77
- status: 303;
78
- }
79
- /** Render the page from this POST. */
80
- | {
81
- kind: "next";
82
- };
83
69
  /**
84
70
  * Run an action called from an HTML form and store its result for the page
85
71
  * this POST renders. Resolves to that result, or `undefined` when the request
86
72
  * is not a form-called action (a JSON call or a plain request is Astro's).
87
73
  */
88
- export declare function runFormAction<TResult extends ActionHandlerResult, TSerialized>(deps: Pick<ActionMiddlewareDeps<TResult, TSerialized>, "action" | "setActionResult" | "serializeActionResult">): Promise<TResult | undefined>;
89
- /**
90
- * @deprecated Use `runFormAction` and call `next()`. Runs the action the same
91
- * way and always answers `{ kind: "next" }`: an errored post renders in place,
92
- * because a redirect drops the result (see the note at the top of this file).
93
- */
94
- export declare function resolveActionRedirectDecision<TResult extends ActionHandlerResult, TSerialized>(deps: ActionMiddlewareDeps<TResult, TSerialized>): Promise<PrgDecision>;
74
+ export declare function runFormAction<TResult extends ActionHandlerResult, TSerialized>(deps: ActionMiddlewareDeps<TResult, TSerialized>): Promise<TResult | undefined>;
@@ -51,12 +51,3 @@ export async function runFormAction(deps) {
51
51
  setActionResult(action.name, serializeActionResult(result));
52
52
  return result;
53
53
  }
54
- /**
55
- * @deprecated Use `runFormAction` and call `next()`. Runs the action the same
56
- * way and always answers `{ kind: "next" }`: an errored post renders in place,
57
- * because a redirect drops the result (see the note at the top of this file).
58
- */
59
- export async function resolveActionRedirectDecision(deps) {
60
- await runFormAction(deps);
61
- return { kind: "next" };
62
- }
@@ -10,11 +10,3 @@ export interface ProductView {
10
10
  }
11
11
  export declare function getProductView(product: ProductDetail): ProductView;
12
12
  export declare function getProductListView(product: ProductList): ProductView;
13
- /**
14
- * A product's tags as a list, whichever read it came from: a product page's
15
- * `tags` is already a list, a listing's is the stored JSON text. Anything
16
- * that is not a list of text reads as no tags.
17
- */
18
- export declare function productTags(product: {
19
- tags: string | null | readonly string[];
20
- }): string[];
@@ -44,20 +44,3 @@ export function getProductListView(product) {
44
44
  ...stockOf(product),
45
45
  };
46
46
  }
47
- /**
48
- * A product's tags as a list, whichever read it came from: a product page's
49
- * `tags` is already a list, a listing's is the stored JSON text. Anything
50
- * that is not a list of text reads as no tags.
51
- */
52
- export function productTags(product) {
53
- let tags = product.tags;
54
- if (typeof tags === "string") {
55
- try {
56
- tags = JSON.parse(tags);
57
- }
58
- catch {
59
- return [];
60
- }
61
- }
62
- return Array.isArray(tags) ? tags.filter((tag) => typeof tag === "string") : [];
63
- }
package/dist/routes.d.ts CHANGED
@@ -28,6 +28,10 @@ export declare const STOREFRONT_PAGE_PATHS: {
28
28
  readonly thankYou: "/thank-you";
29
29
  /** Where a shopper follows an order by its number and phone; `?order=<number>` fills the number in. */
30
30
  readonly trackOrder: "/track-order";
31
+ /** The store's products matching a query; `?q=<words>` is the query. */
32
+ readonly search: "/search";
33
+ /** How to reach the store: its WhatsApp, phone, email and address. */
34
+ readonly contact: "/contact";
31
35
  };
32
36
  /** What a storefront URL means. */
33
37
  export type StorefrontPageType = keyof typeof STOREFRONT_PAGE_PATHS;
@@ -56,19 +60,6 @@ export declare function storefrontPath<T extends StorefrontPageType>(type: T, pa
56
60
  * language prefix (`resolveLocalePath` gives it).
57
61
  */
58
62
  export declare function matchStorefrontPath(rawPathname: string): StorefrontPageMatch | null;
59
- /** One route with a parameter or a fixed path of its own, and the widget surface that renders it. */
60
- export interface StorefrontRoute {
61
- /** Path pattern; `:handle` and `:slug` mark the single path parameter. */
62
- readonly path: string;
63
- /** The `surfaces` key this route belongs to. */
64
- readonly surface: keyof WidgetSurfaces;
65
- }
66
- /**
67
- * @deprecated Use `STOREFRONT_PAGE_PATHS` (every page type, the home and the
68
- * catalog index included) with `storefrontPath` and `matchStorefrontPath`.
69
- * Kept equal to what it always listed.
70
- */
71
- export declare const STOREFRONT_ROUTES: readonly StorefrontRoute[];
72
63
  /**
73
64
  * Whether the widget belongs on a pathname: the merchant answers "which
74
65
  * surfaces" (`surfaces[surface]`); this answers which surface a pathname *is*,
package/dist/routes.js CHANGED
@@ -11,6 +11,10 @@ export const STOREFRONT_PAGE_PATHS = {
11
11
  thankYou: "/thank-you",
12
12
  /** Where a shopper follows an order by its number and phone; `?order=<number>` fills the number in. */
13
13
  trackOrder: "/track-order",
14
+ /** The store's products matching a query; `?q=<words>` is the query. */
15
+ search: "/search",
16
+ /** How to reach the store: its WhatsApp, phone, email and address. */
17
+ contact: "/contact",
14
18
  };
15
19
  /**
16
20
  * The public path of a page type, its parameter encoded:
@@ -68,16 +72,9 @@ const WIDGET_SURFACE = {
68
72
  checkout: "checkout",
69
73
  thankYou: "thankYou",
70
74
  trackOrder: "pages",
75
+ search: "pages",
76
+ contact: "pages",
71
77
  };
72
- /**
73
- * @deprecated Use `STOREFRONT_PAGE_PATHS` (every page type, the home and the
74
- * catalog index included) with `storefrontPath` and `matchStorefrontPath`.
75
- * Kept equal to what it always listed.
76
- */
77
- export const STOREFRONT_ROUTES = ["product", "category", "page", "landing", "checkout", "thankYou"].map((type) => ({
78
- path: STOREFRONT_PAGE_PATHS[type],
79
- surface: WIDGET_SURFACE[type],
80
- }));
81
78
  /**
82
79
  * Whether the widget belongs on a pathname: the merchant answers "which
83
80
  * surfaces" (`surfaces[surface]`); this answers which surface a pathname *is*,