@standhigher/besttrack-page-extension 0.2.0 → 0.3.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/README.md CHANGED
@@ -1,9 +1,34 @@
1
1
  # @standhigher/besttrack-page-extension
2
2
 
3
3
  V0.7.1 adds the besttrack.branded built-in template. Its announcement, order
4
- query, order items, recommendations, quick links and Blog blocks use the same
5
- host-injected tracking query contract as Ready-to-go. Logo and content are
4
+ query, order items, recommendations, quick links and Blog blocks use the
5
+ shared, host-injected `TrackingPageQuery` contract. The
6
+ `ReadyToGoTrackingQuery` name remains a compatible alias. Logo and content are
6
7
  JSON-only block props; brand colour, font and radius use the template Theme
7
8
  Tokens and may be overridden through PageDocument.theme.
8
9
 
9
- V0.7.0 provides the Ready-to-go built-in template: order query, shipment progress, delivery information and recommendations. Live tracking is injected by the host Runtime; this package never stores credentials or network endpoints in a `PageDocument`.
10
+ V0.7.0 provides the Ready-to-go built-in template: order query, shipment
11
+ progress, delivery information and recommendations. The consumer surface follows
12
+ the Shopify Track Page layout (query card, five-step progress, shipping
13
+ timeline, package contents and product cards) using inline styles and `--pb-*`
14
+ Theme Tokens. Live tracking is injected by the host Runtime; this package never
15
+ stores credentials or network endpoints in a `PageDocument`.
16
+
17
+ V0.7.2 Sales uses the shared, transient `TrackingPageQuery` contract exported
18
+ by this package. The external Go Consumer Runtime API owns live-query
19
+ authorization and transport; Sales only receives its display-safe result and
20
+ never falls back to mock data after a live failure.
21
+
22
+ Sales keeps the stable `besttrack.sales` v1 template and seven block IDs.
23
+ Its host must inject the query from an authorized Consumer Runtime flow; this
24
+ package provides neither a Go client nor a BFF. The editor validates
25
+ merchant-authored text, preview-only tracking placeholders and collection
26
+ links, while the storefront renders only site-relative or HTTPS resource
27
+ links. See `docs/integration/sales-template.md` and
28
+ `docs/integration/consumer-runtime-api.md` for the host contract.
29
+
30
+ New Sales pages use the `hero` visual Variant: a token-driven announcement,
31
+ merchant HTTPS hero image and tracking-only query card. Existing `commerce`
32
+ Variants and published v1 documents stay valid. The browser does not offer an
33
+ order-number mode because the shared Consumer Runtime API currently accepts
34
+ only a tracking number.
package/dist/index.d.ts CHANGED
@@ -2,14 +2,22 @@ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { PageBuilderExtension, TemplateDefinition } from '@standhigher/puck-page-builder/runtime';
4
4
 
5
- type ReadyToGoOrderItem = {
5
+ /**
6
+ * Display-safe, transient data returned by a Consumer Runtime query.
7
+ *
8
+ * These types intentionally describe the boundary between a storefront host
9
+ * and the template. They are not PageDocument props and must never be saved
10
+ * with a draft or published document.
11
+ */
12
+ type TrackingPageOrderItem = {
6
13
  id: string;
7
14
  title: string;
8
15
  quantity: number;
9
16
  imageUrl?: string;
10
17
  description?: string;
18
+ href?: string;
11
19
  };
12
- type ReadyToGoRecommendation = {
20
+ type TrackingPageRecommendation = {
13
21
  id: string;
14
22
  title: string;
15
23
  description: string;
@@ -17,19 +25,21 @@ type ReadyToGoRecommendation = {
17
25
  href?: string;
18
26
  price?: string;
19
27
  };
20
- type ReadyToGoTrackingStep = {
28
+ type TrackingPageTrackingStep = {
21
29
  id: string;
22
30
  label: string;
23
31
  state: "complete" | "current" | "upcoming";
32
+ date?: string;
33
+ icon?: "check" | "bag" | "truck" | "box";
24
34
  };
25
- type ReadyToGoTrackingEvent = {
35
+ type TrackingPageTrackingEvent = {
26
36
  id: string;
27
37
  title: string;
28
38
  at?: string;
29
39
  detail?: string;
30
40
  state?: "complete" | "current" | "upcoming";
31
41
  };
32
- type ReadyToGoShipment = {
42
+ type TrackingPageShipment = {
33
43
  id: string;
34
44
  label: string;
35
45
  trackingNumber?: string;
@@ -38,25 +48,38 @@ type ReadyToGoShipment = {
38
48
  latestEvent?: string;
39
49
  updatedAt?: string;
40
50
  deliveryAddress?: string;
41
- progress?: ReadyToGoTrackingStep[];
42
- events?: ReadyToGoTrackingEvent[];
43
- orderItems?: ReadyToGoOrderItem[];
44
- recommendations?: ReadyToGoRecommendation[];
51
+ estimatedDelivery?: string;
52
+ progress?: TrackingPageTrackingStep[];
53
+ events?: TrackingPageTrackingEvent[];
54
+ orderItems?: TrackingPageOrderItem[];
55
+ recommendations?: TrackingPageRecommendation[];
45
56
  };
46
- type ReadyToGoTrackingResult = {
57
+ type TrackingPageQueryResult = {
58
+ /** `empty` is a successful query with no customer-visible tracking result. */
59
+ outcome?: "found" | "empty";
47
60
  trackingNumber: string;
48
61
  status: string;
49
62
  carrier?: string;
50
63
  latestEvent?: string;
51
64
  updatedAt?: string;
52
65
  deliveryAddress?: string;
53
- progress?: ReadyToGoTrackingStep[];
54
- events?: ReadyToGoTrackingEvent[];
55
- orderItems?: ReadyToGoOrderItem[];
56
- recommendations?: ReadyToGoRecommendation[];
57
- shipments?: ReadyToGoShipment[];
66
+ estimatedDelivery?: string;
67
+ progress?: TrackingPageTrackingStep[];
68
+ events?: TrackingPageTrackingEvent[];
69
+ orderItems?: TrackingPageOrderItem[];
70
+ recommendations?: TrackingPageRecommendation[];
71
+ shipments?: TrackingPageShipment[];
58
72
  };
59
- type ReadyToGoTrackingQuery = (trackingNumber: string) => Promise<ReadyToGoTrackingResult>;
73
+ /** The UI receives an injected function; it never knows a Go endpoint or credential. */
74
+ type TrackingPageQuery = (trackingNumber: string) => Promise<TrackingPageQueryResult>;
75
+ type TrackingPageRuntimePhase = "idle" | "loading" | "success" | "empty" | "error";
76
+ declare function isEmptyTrackingPageResult(result: TrackingPageQueryResult): boolean;
77
+
78
+ type ReadyToGoTrackingStep = TrackingPageTrackingStep;
79
+ type ReadyToGoTrackingEvent = TrackingPageTrackingEvent;
80
+ type ReadyToGoShipment = TrackingPageShipment;
81
+ type ReadyToGoTrackingResult = TrackingPageQueryResult;
82
+ type ReadyToGoTrackingQuery = TrackingPageQuery;
60
83
  type ReadyToGoRuntimeState = {
61
84
  phase: "idle" | "loading" | "success" | "error";
62
85
  result?: ReadyToGoTrackingResult;
@@ -74,31 +97,32 @@ declare const bestTrackPageExtension: PageBuilderExtension;
74
97
  declare function createBrandedTemplate(): TemplateDefinition;
75
98
  declare const bestTrackBrandedExtension: PageBuilderExtension;
76
99
 
100
+ /** Branded uses the shared, display-safe Consumer Runtime result without persisting it. */
77
101
  type BrandedRuntimeState = {
78
- phase: "idle" | "loading" | "success" | "error";
79
- result?: ReadyToGoTrackingResult;
102
+ phase: TrackingPageRuntimePhase;
103
+ result?: TrackingPageQueryResult;
80
104
  error?: string;
81
105
  };
82
106
  type BrandedRuntimeProviderProps = {
83
107
  children: ReactNode;
84
- queryTracking: ReadyToGoTrackingQuery;
108
+ queryTracking: TrackingPageQuery;
85
109
  };
86
110
  declare function BrandedRuntimeProvider({ children, queryTracking }: BrandedRuntimeProviderProps): react.JSX.Element;
87
111
 
112
+ /** Stable Sales v1 document and block IDs are intentionally retained for published-page compatibility. */
88
113
  declare function createSalesTemplate(): TemplateDefinition;
89
114
  declare const bestTrackSalesExtension: PageBuilderExtension;
90
115
 
91
- type SalesPhase = "idle" | "loading" | "success" | "error";
116
+ /** Transient, consumer-safe state. The host error is deliberately never retained for display. */
92
117
  type SalesRuntimeState = {
93
- phase: SalesPhase;
94
- result?: ReadyToGoTrackingResult;
95
- error?: string;
118
+ phase: TrackingPageRuntimePhase;
119
+ result?: TrackingPageQueryResult;
96
120
  };
97
121
  type SalesRuntimeProviderProps = {
98
122
  children: ReactNode;
99
- queryTracking: ReadyToGoTrackingQuery;
123
+ queryTracking: TrackingPageQuery;
100
124
  };
101
125
  /** The host injects a validated query; Sales never calls a DataSource itself. */
102
126
  declare function SalesRuntimeProvider({ children, queryTracking }: SalesRuntimeProviderProps): react.JSX.Element;
103
127
 
104
- export { BrandedRuntimeProvider, type BrandedRuntimeProviderProps, type BrandedRuntimeState, ReadyToGoRuntimeProvider, type ReadyToGoRuntimeProviderProps, type ReadyToGoRuntimeState, type ReadyToGoShipment, type ReadyToGoTrackingEvent, type ReadyToGoTrackingQuery, type ReadyToGoTrackingResult, type ReadyToGoTrackingStep, SalesRuntimeProvider, type SalesRuntimeProviderProps, type SalesRuntimeState, bestTrackBrandedExtension, bestTrackPageExtension, bestTrackSalesExtension, createBrandedTemplate, createReadyToGoTemplate, createSalesTemplate };
128
+ export { BrandedRuntimeProvider, type BrandedRuntimeProviderProps, type BrandedRuntimeState, ReadyToGoRuntimeProvider, type ReadyToGoRuntimeProviderProps, type ReadyToGoRuntimeState, type ReadyToGoShipment, type ReadyToGoTrackingEvent, type ReadyToGoTrackingQuery, type ReadyToGoTrackingResult, type ReadyToGoTrackingStep, SalesRuntimeProvider, type SalesRuntimeProviderProps, type SalesRuntimeState, type TrackingPageOrderItem, type TrackingPageQuery, type TrackingPageQueryResult, type TrackingPageRecommendation, type TrackingPageRuntimePhase, type TrackingPageShipment, type TrackingPageTrackingEvent, type TrackingPageTrackingStep, bestTrackBrandedExtension, bestTrackPageExtension, bestTrackSalesExtension, createBrandedTemplate, createReadyToGoTemplate, createSalesTemplate, isEmptyTrackingPageResult };