@standhigher/besttrack-page-extension 0.2.1 → 0.4.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 +69 -12
- package/dist/chunk-KD7KFFFK.js +127 -0
- package/dist/index.d.ts +396 -34
- package/dist/index.js +2065 -413
- package/dist/validation.d.ts +9 -0
- package/dist/validation.js +121 -0
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,148 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { PageBuilderExtension, TemplateDefinition } from '@standhigher/puck-page-builder/runtime';
|
|
3
|
+
import { PageBuilderExtension, TemplateDefinition, FieldProps } from '@standhigher/puck-page-builder/runtime';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
declare const SUPPORTED_LOCALES: readonly ["EN", "ZH-HANS", "FR", "ES", "DE", "PT-BR", "IT", "ID", "VI", "TH"];
|
|
6
|
+
type Locale = (typeof SUPPORTED_LOCALES)[number];
|
|
7
|
+
declare function resolveInitialLocale(): Locale;
|
|
8
|
+
|
|
9
|
+
type ApiResponse<T> = {
|
|
10
|
+
data: T;
|
|
11
|
+
message?: string;
|
|
12
|
+
msg?: string;
|
|
13
|
+
code?: string | number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type SearchTab = 'order' | 'tracking';
|
|
17
|
+
type TrackingNode = {
|
|
18
|
+
node: string;
|
|
19
|
+
description: string;
|
|
20
|
+
time: string;
|
|
21
|
+
location: string;
|
|
22
|
+
country: string;
|
|
23
|
+
state: string;
|
|
24
|
+
city: string;
|
|
25
|
+
street: string;
|
|
26
|
+
carrier: string;
|
|
27
|
+
};
|
|
28
|
+
type RawEvent = {
|
|
29
|
+
stage: string;
|
|
30
|
+
sub_status: string;
|
|
31
|
+
description: string;
|
|
32
|
+
time: string;
|
|
33
|
+
location: string;
|
|
34
|
+
country: string;
|
|
35
|
+
state: string;
|
|
36
|
+
city: string;
|
|
37
|
+
street: string;
|
|
38
|
+
};
|
|
39
|
+
type PackageItem = {
|
|
40
|
+
product_id: string;
|
|
41
|
+
variant_id: string;
|
|
42
|
+
title: string;
|
|
43
|
+
variant_title: string;
|
|
44
|
+
image_url: string;
|
|
45
|
+
quantity: number;
|
|
46
|
+
};
|
|
47
|
+
type EstimatedDelivery = {
|
|
48
|
+
from: string;
|
|
49
|
+
to: string;
|
|
50
|
+
source: 'carrier' | 'custom';
|
|
51
|
+
carrier_source?: string;
|
|
52
|
+
display_state: 'in_transit' | 'date_updated';
|
|
53
|
+
changed_at?: string;
|
|
54
|
+
};
|
|
55
|
+
type TrackMilestone = {
|
|
56
|
+
tracking_number: string;
|
|
57
|
+
nodeList: TrackingNode[];
|
|
58
|
+
rawEventList?: RawEvent[];
|
|
59
|
+
carrier: string;
|
|
60
|
+
package_items: PackageItem[];
|
|
61
|
+
estimated_delivery?: EstimatedDelivery;
|
|
62
|
+
};
|
|
63
|
+
type AdConfig = {
|
|
64
|
+
image_url: string;
|
|
65
|
+
link_url: string;
|
|
66
|
+
};
|
|
67
|
+
type TrackResponse = {
|
|
68
|
+
order_number: string;
|
|
69
|
+
mileStoneList: TrackMilestone[];
|
|
70
|
+
ad_config: AdConfig;
|
|
71
|
+
trace_id: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Display-safe, transient data returned by a Consumer Runtime query.
|
|
76
|
+
*
|
|
77
|
+
* These types intentionally describe the boundary between a storefront host
|
|
78
|
+
* and the template. They are not PageDocument props and must never be saved
|
|
79
|
+
* with a draft or published document.
|
|
80
|
+
*/
|
|
81
|
+
type TrackingPageOrderItem = {
|
|
6
82
|
id: string;
|
|
7
83
|
title: string;
|
|
8
84
|
quantity: number;
|
|
9
85
|
imageUrl?: string;
|
|
10
86
|
description?: string;
|
|
11
87
|
href?: string;
|
|
88
|
+
price?: TrackingPageMoney;
|
|
12
89
|
};
|
|
13
|
-
|
|
90
|
+
/** A stable Shopify object reference stored in PageDocument props. */
|
|
91
|
+
type TrackingPageResourceReference = Readonly<{
|
|
92
|
+
id: string;
|
|
93
|
+
kind: "product" | "collection" | "media";
|
|
94
|
+
}>;
|
|
95
|
+
type TrackingPageProductReference = TrackingPageResourceReference & {
|
|
96
|
+
kind: "product";
|
|
97
|
+
};
|
|
98
|
+
type TrackingPageCollectionReference = TrackingPageResourceReference & {
|
|
99
|
+
kind: "collection";
|
|
100
|
+
};
|
|
101
|
+
type TrackingPageMediaReference = TrackingPageResourceReference & {
|
|
102
|
+
kind: "media";
|
|
103
|
+
};
|
|
104
|
+
/** Values are minor currency units; formatted display strings never persist in PageDocument. */
|
|
105
|
+
type TrackingPageMoney = Readonly<{
|
|
106
|
+
amount: number;
|
|
107
|
+
currencyCode: string;
|
|
108
|
+
compareAtAmount?: number;
|
|
109
|
+
startsAt?: boolean;
|
|
110
|
+
}>;
|
|
111
|
+
type TrackingPageRecommendation = {
|
|
14
112
|
id: string;
|
|
15
113
|
title: string;
|
|
16
114
|
description: string;
|
|
17
115
|
imageUrl?: string;
|
|
18
116
|
href?: string;
|
|
19
|
-
price?:
|
|
117
|
+
price?: TrackingPageMoney;
|
|
20
118
|
};
|
|
21
|
-
|
|
119
|
+
/** Host callback for page-level recommendations, independent of tracking queries. */
|
|
120
|
+
type TrackingPageRecommendationsQuery = () => Promise<TrackingPageRecommendation[]>;
|
|
121
|
+
type TrackingPageRecommendationsState = {
|
|
122
|
+
phase: TrackingPageRuntimePhase;
|
|
123
|
+
items: TrackingPageRecommendation[];
|
|
124
|
+
};
|
|
125
|
+
/** Dynamic merchant promotion returned by the trusted storefront host. */
|
|
126
|
+
type TrackingPageAd = Readonly<{
|
|
127
|
+
imageUrl: string;
|
|
128
|
+
href?: string;
|
|
129
|
+
alt?: string;
|
|
130
|
+
}>;
|
|
131
|
+
type TrackingPageTrackingStep = {
|
|
22
132
|
id: string;
|
|
23
133
|
label: string;
|
|
24
134
|
state: "complete" | "current" | "upcoming";
|
|
25
135
|
date?: string;
|
|
26
136
|
icon?: "check" | "bag" | "truck" | "box";
|
|
27
137
|
};
|
|
28
|
-
type
|
|
138
|
+
type TrackingPageTrackingEvent = {
|
|
29
139
|
id: string;
|
|
30
140
|
title: string;
|
|
31
141
|
at?: string;
|
|
32
142
|
detail?: string;
|
|
33
143
|
state?: "complete" | "current" | "upcoming";
|
|
34
144
|
};
|
|
35
|
-
type
|
|
145
|
+
type TrackingPageShipment = {
|
|
36
146
|
id: string;
|
|
37
147
|
label: string;
|
|
38
148
|
trackingNumber?: string;
|
|
@@ -40,70 +150,322 @@ type ReadyToGoShipment = {
|
|
|
40
150
|
carrier?: string;
|
|
41
151
|
latestEvent?: string;
|
|
42
152
|
updatedAt?: string;
|
|
43
|
-
|
|
153
|
+
/** City/region-level destination only. Never include a street address or contact data. */
|
|
154
|
+
destination?: string;
|
|
44
155
|
estimatedDelivery?: string;
|
|
45
|
-
progress?:
|
|
46
|
-
events?:
|
|
47
|
-
orderItems?:
|
|
48
|
-
recommendations?:
|
|
156
|
+
progress?: TrackingPageTrackingStep[];
|
|
157
|
+
events?: TrackingPageTrackingEvent[];
|
|
158
|
+
orderItems?: TrackingPageOrderItem[];
|
|
159
|
+
recommendations?: TrackingPageRecommendation[];
|
|
160
|
+
ad?: TrackingPageAd;
|
|
49
161
|
};
|
|
50
|
-
type
|
|
162
|
+
type TrackingPageQueryResult = {
|
|
163
|
+
/** `empty` is a successful query with no customer-visible tracking result. */
|
|
164
|
+
outcome?: "found" | "empty";
|
|
51
165
|
trackingNumber: string;
|
|
52
166
|
status: string;
|
|
53
167
|
carrier?: string;
|
|
54
168
|
latestEvent?: string;
|
|
55
169
|
updatedAt?: string;
|
|
56
|
-
|
|
170
|
+
/** City/region-level destination only. Never include a street address or contact data. */
|
|
171
|
+
destination?: string;
|
|
172
|
+
transitDuration?: string;
|
|
173
|
+
orderNumber?: string;
|
|
57
174
|
estimatedDelivery?: string;
|
|
58
|
-
progress?:
|
|
59
|
-
events?:
|
|
60
|
-
orderItems?:
|
|
61
|
-
recommendations?:
|
|
62
|
-
|
|
175
|
+
progress?: TrackingPageTrackingStep[];
|
|
176
|
+
events?: TrackingPageTrackingEvent[];
|
|
177
|
+
orderItems?: TrackingPageOrderItem[];
|
|
178
|
+
recommendations?: TrackingPageRecommendation[];
|
|
179
|
+
ad?: TrackingPageAd;
|
|
180
|
+
shipments?: TrackingPageShipment[];
|
|
181
|
+
};
|
|
182
|
+
/** A carrier lookup. The browser only supplies the display-safe identifier. */
|
|
183
|
+
type TrackingPageTrackingQueryRequest = {
|
|
184
|
+
mode: "tracking";
|
|
185
|
+
trackingNumber: string;
|
|
186
|
+
};
|
|
187
|
+
/** An order lookup always carries both values; hosts must authorize it separately. */
|
|
188
|
+
type TrackingPageOrderQueryRequest = {
|
|
189
|
+
mode: "order";
|
|
190
|
+
orderNumber: string;
|
|
191
|
+
email: string;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* The injected host boundary. It deliberately contains no endpoint, token,
|
|
195
|
+
* tenant, or PageDocument data. The host owns authorization and transport.
|
|
196
|
+
*/
|
|
197
|
+
type TrackingPageQueryRequest = TrackingPageTrackingQueryRequest | TrackingPageOrderQueryRequest;
|
|
198
|
+
type TrackingPageQuery = (request: TrackingPageQueryRequest) => Promise<TrackingPageQueryResult>;
|
|
199
|
+
/** Host-decided display state. This package never derives entitlement status. */
|
|
200
|
+
type TrackingPageWatermark = Readonly<{
|
|
201
|
+
visible: boolean;
|
|
202
|
+
label?: string;
|
|
203
|
+
}>;
|
|
204
|
+
type TrackingPageRuntimePhase = "idle" | "loading" | "success" | "empty" | "error";
|
|
205
|
+
/** PRD input rules; hosts must validate again before reaching any upstream. */
|
|
206
|
+
declare function isValidTrackingNumber(value: string): boolean;
|
|
207
|
+
declare function isValidOrderNumber(value: string): boolean;
|
|
208
|
+
declare function isValidOrderEmail(value: string): boolean;
|
|
209
|
+
declare function isEmptyTrackingPageResult(result: TrackingPageQueryResult): boolean;
|
|
210
|
+
declare function isTrackingPageResourceReference(value: unknown, kind?: TrackingPageResourceReference["kind"]): value is TrackingPageResourceReference;
|
|
211
|
+
declare function formatTrackingPageMoney(value: TrackingPageMoney, locale?: string): {
|
|
212
|
+
amount: string;
|
|
213
|
+
compareAt: string | undefined;
|
|
214
|
+
startsAt: boolean;
|
|
215
|
+
} | undefined;
|
|
216
|
+
|
|
217
|
+
declare function syncTrackingQueryToUrl(type: SearchTab, value: string, contactValue?: string): void;
|
|
218
|
+
type TrackingQueryLocationState = {
|
|
219
|
+
tab: SearchTab;
|
|
220
|
+
trackingNumber: string;
|
|
221
|
+
orderNumber: string;
|
|
222
|
+
email: string;
|
|
223
|
+
canAutoQuery: boolean;
|
|
63
224
|
};
|
|
64
|
-
|
|
225
|
+
declare function readTrackingQueryLocationState(search?: string, hash?: string): TrackingQueryLocationState;
|
|
226
|
+
declare function readTrackingQueryFromLocation(search?: string, hash?: string): TrackingPageQueryRequest | undefined;
|
|
227
|
+
|
|
228
|
+
/** Same hide rule as the original Shopify Track Page Home screen. */
|
|
229
|
+
declare function shouldHidePoweredBy(targetWindow?: Window): boolean;
|
|
230
|
+
|
|
231
|
+
declare const SHOPIFY_TRACK_QUERY_PATH = "/track/query";
|
|
232
|
+
declare const SHOPIFY_RECOMMEND_PATH = "/products/recommend";
|
|
233
|
+
type ShopifyTrackApiResponse<T> = ApiResponse<T>;
|
|
234
|
+
/** Host-owned POST. The package never stores credentials or chooses the App Proxy prefix. */
|
|
235
|
+
type ShopifyTrackPagePost = <T>(url: string, body?: Record<string, unknown>) => Promise<ShopifyTrackApiResponse<T>>;
|
|
236
|
+
type ShopifyTrackPageTransport = {
|
|
237
|
+
post: ShopifyTrackPagePost;
|
|
238
|
+
/** Static locale or the original page resolver (`?lang=` then `bestrack_locale`). */
|
|
239
|
+
locale?: Locale | (() => Locale);
|
|
240
|
+
/** Original locale-switch path only: retry the lookup in English after a miss or throw. */
|
|
241
|
+
fallbackToEnglish?: boolean;
|
|
242
|
+
retries?: number;
|
|
243
|
+
};
|
|
244
|
+
declare function resolveShopifyTrackQueryLocale(locale?: Locale | (() => Locale)): "EN" | "ZH-HANS" | "FR" | "ES" | "DE" | "PT-BR" | "IT" | "ID" | "VI" | "TH";
|
|
245
|
+
/**
|
|
246
|
+
* Prefix a Track Page path the way `withAppProxyPrefix` did. The host still
|
|
247
|
+
* chooses the prefix (`/apps/bestrack` or the storefront basename).
|
|
248
|
+
*/
|
|
249
|
+
declare function withShopifyAppProxyPrefix(path: string, prefix: string): string;
|
|
250
|
+
type ShopifyRecommendProduct = {
|
|
251
|
+
id: string;
|
|
252
|
+
title: string;
|
|
253
|
+
handle?: string;
|
|
254
|
+
onlineStoreUrl?: string | null;
|
|
255
|
+
featuredImage?: {
|
|
256
|
+
url?: string;
|
|
257
|
+
altText?: string | null;
|
|
258
|
+
} | null;
|
|
259
|
+
price?: string;
|
|
260
|
+
variants?: Array<{
|
|
261
|
+
price?: string;
|
|
262
|
+
}> | null;
|
|
263
|
+
};
|
|
264
|
+
/** Append `_t=Date.now()` so storefront and App Proxy caches cannot reuse a previous lookup. */
|
|
265
|
+
declare function withShopifyTrackCacheBust(url: string, now?: number): string;
|
|
266
|
+
declare function buildShopifyTrackQueryPayload(request: TrackingPageQueryRequest, locale?: Locale): {
|
|
267
|
+
readonly order_number: string;
|
|
268
|
+
readonly email: string;
|
|
269
|
+
readonly tracking_number: string;
|
|
270
|
+
readonly lang: "EN" | "ZH-HANS" | "FR" | "ES" | "DE" | "PT-BR" | "IT" | "ID" | "VI" | "TH";
|
|
271
|
+
};
|
|
272
|
+
declare function buildShopifyRecommendPayload(page?: number, pageSize?: number): {
|
|
273
|
+
readonly page: number;
|
|
274
|
+
readonly page_size: number;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Convert a legacy `/track/query` envelope into the display-safe runtime result.
|
|
278
|
+
* A non-zero business `code` becomes `outcome: "empty"`. Network failures must
|
|
279
|
+
* still throw so the template can keep them distinct from a missing order.
|
|
280
|
+
*/
|
|
281
|
+
declare function mapShopifyTrackQueryResponse(response: ShopifyTrackApiResponse<TrackResponse | null | undefined>, request: TrackingPageQueryRequest, locale?: Locale): TrackingPageQueryResult;
|
|
282
|
+
declare function mapShopifyRecommendationsResponse(response: ShopifyTrackApiResponse<{
|
|
283
|
+
products?: ShopifyRecommendProduct[];
|
|
284
|
+
} | null | undefined>): TrackingPageRecommendation[];
|
|
285
|
+
/**
|
|
286
|
+
* Original `/track/query` lookup: snake_case body, `_t` cache-bust, one retry,
|
|
287
|
+
* and `code !== 0` or exhausted throws become a missing-order result.
|
|
288
|
+
*/
|
|
289
|
+
declare function createShopifyTrackQuery(transport: ShopifyTrackPageTransport): TrackingPageQuery;
|
|
290
|
+
declare function createShopifyRecommendationsQuery(post: ShopifyTrackPagePost): TrackingPageRecommendationsQuery;
|
|
291
|
+
|
|
292
|
+
type ReadyToGoTrackingStep = TrackingPageTrackingStep;
|
|
293
|
+
type ReadyToGoTrackingEvent = TrackingPageTrackingEvent;
|
|
294
|
+
type ReadyToGoShipment = TrackingPageShipment;
|
|
295
|
+
type ReadyToGoTrackingResult = TrackingPageQueryResult;
|
|
65
296
|
type ReadyToGoRuntimeState = {
|
|
66
|
-
phase: "idle" | "loading" | "success" | "error";
|
|
297
|
+
phase: "idle" | "loading" | "success" | "empty" | "error";
|
|
67
298
|
result?: ReadyToGoTrackingResult;
|
|
68
299
|
error?: string;
|
|
69
300
|
};
|
|
70
301
|
type ReadyToGoRuntimeProviderProps = {
|
|
71
302
|
children: ReactNode;
|
|
72
|
-
|
|
303
|
+
/** The discriminated, host-authorized query boundary. */
|
|
304
|
+
query?: TrackingPageQuery;
|
|
305
|
+
/** Independent recommended-product loader; does not share tracking loading/error. */
|
|
306
|
+
queryRecommendations?: TrackingPageRecommendationsQuery;
|
|
307
|
+
/**
|
|
308
|
+
* Shopify Track Page live transport. When `query` is omitted, lookups use the
|
|
309
|
+
* original `/track/query` body, `_t` cache-bust, retry, and mapping rules.
|
|
310
|
+
*/
|
|
311
|
+
transport?: ShopifyTrackPageTransport;
|
|
312
|
+
/** When omitted, URL deep-link auto-query is on only for the Shopify Track Page `transport` path. */
|
|
313
|
+
autoQueryFromUrl?: boolean;
|
|
314
|
+
/** Host-decided display state. Omitted values follow the original powered-by hide rule. */
|
|
315
|
+
watermark?: TrackingPageWatermark;
|
|
73
316
|
};
|
|
74
|
-
declare function ReadyToGoRuntimeProvider({ children,
|
|
317
|
+
declare function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark }: ReadyToGoRuntimeProviderProps): react.JSX.Element;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Compatibility metadata for template-aware hosts.
|
|
321
|
+
*
|
|
322
|
+
* Block cardinality and deletion are now enforced by the matching native
|
|
323
|
+
* `BlockDefinition.policy` declarations. This remains an ergonomic template
|
|
324
|
+
* overview for hosts that need to present the default composition.
|
|
325
|
+
*/
|
|
326
|
+
type TemplateBlockPolicy = Readonly<{
|
|
327
|
+
blockType: string;
|
|
328
|
+
singleton: boolean;
|
|
329
|
+
deletable: boolean;
|
|
330
|
+
}>;
|
|
331
|
+
type TemplatePolicy = Readonly<{
|
|
332
|
+
templateId: string;
|
|
333
|
+
displayName: string;
|
|
334
|
+
defaultBlockOrder: readonly string[];
|
|
335
|
+
blocks: readonly TemplateBlockPolicy[];
|
|
336
|
+
enforcement: "core-block-policy";
|
|
337
|
+
}>;
|
|
75
338
|
|
|
339
|
+
declare const readyToGoTemplatePolicy: Readonly<{
|
|
340
|
+
templateId: string;
|
|
341
|
+
displayName: string;
|
|
342
|
+
defaultBlockOrder: readonly string[];
|
|
343
|
+
blocks: readonly TemplateBlockPolicy[];
|
|
344
|
+
enforcement: "core-block-policy";
|
|
345
|
+
}>;
|
|
76
346
|
declare function createReadyToGoTemplate(): TemplateDefinition;
|
|
77
347
|
declare const bestTrackPageExtension: PageBuilderExtension;
|
|
78
348
|
|
|
349
|
+
declare const brandedTemplatePolicy: Readonly<{
|
|
350
|
+
templateId: string;
|
|
351
|
+
displayName: string;
|
|
352
|
+
defaultBlockOrder: readonly string[];
|
|
353
|
+
blocks: readonly TemplateBlockPolicy[];
|
|
354
|
+
enforcement: "core-block-policy";
|
|
355
|
+
}>;
|
|
79
356
|
declare function createBrandedTemplate(): TemplateDefinition;
|
|
80
357
|
declare const bestTrackBrandedExtension: PageBuilderExtension;
|
|
81
358
|
|
|
359
|
+
/** Branded uses the shared, display-safe Consumer Runtime result without persisting it. */
|
|
82
360
|
type BrandedRuntimeState = {
|
|
83
|
-
phase:
|
|
84
|
-
result?:
|
|
361
|
+
phase: TrackingPageRuntimePhase;
|
|
362
|
+
result?: TrackingPageQueryResult;
|
|
85
363
|
error?: string;
|
|
86
364
|
};
|
|
87
365
|
type BrandedRuntimeProviderProps = {
|
|
88
366
|
children: ReactNode;
|
|
89
|
-
|
|
367
|
+
/** The discriminated, host-authorized request contract. */
|
|
368
|
+
query?: TrackingPageQuery;
|
|
369
|
+
/** Host-decided display state; no entitlement checks happen in this package. */
|
|
370
|
+
watermark?: TrackingPageWatermark;
|
|
90
371
|
};
|
|
91
|
-
declare function BrandedRuntimeProvider({ children,
|
|
372
|
+
declare function BrandedRuntimeProvider({ children, query: injectedQuery, watermark }: BrandedRuntimeProviderProps): react.JSX.Element;
|
|
92
373
|
|
|
374
|
+
declare const salesTemplatePolicy: Readonly<{
|
|
375
|
+
templateId: string;
|
|
376
|
+
displayName: string;
|
|
377
|
+
defaultBlockOrder: readonly string[];
|
|
378
|
+
blocks: readonly TemplateBlockPolicy[];
|
|
379
|
+
enforcement: "core-block-policy";
|
|
380
|
+
}>;
|
|
381
|
+
/** Sales v3 uses stable IDs and JSON-only Shopify resource references in new documents. */
|
|
93
382
|
declare function createSalesTemplate(): TemplateDefinition;
|
|
94
383
|
declare const bestTrackSalesExtension: PageBuilderExtension;
|
|
95
384
|
|
|
96
|
-
|
|
385
|
+
/** The JSON-only Shopify reference that may be persisted in PageDocument props. */
|
|
386
|
+
type ShopifyResourceReference = Readonly<{
|
|
387
|
+
id: string;
|
|
388
|
+
kind: "product" | "collection";
|
|
389
|
+
title: string;
|
|
390
|
+
handle?: string;
|
|
391
|
+
}>;
|
|
392
|
+
type ShopifyResourceKind = ShopifyResourceReference["kind"];
|
|
393
|
+
type ShopifyResourceSearchInput = Readonly<{
|
|
394
|
+
kinds: readonly ShopifyResourceKind[];
|
|
395
|
+
query: string;
|
|
396
|
+
cursor?: string;
|
|
397
|
+
limit: number;
|
|
398
|
+
}>;
|
|
399
|
+
type ShopifyResourceSearchPage = Readonly<{
|
|
400
|
+
items: readonly ShopifyResourceReference[];
|
|
401
|
+
nextCursor?: string;
|
|
402
|
+
}>;
|
|
403
|
+
/** Injected by the authenticated Admin host; it owns browse, search, pagination, and authorization. */
|
|
404
|
+
type ShopifyResourceBrowser = {
|
|
405
|
+
search(input: ShopifyResourceSearchInput): Promise<ShopifyResourceSearchPage>;
|
|
406
|
+
};
|
|
407
|
+
declare function isShopifyResourceReference(value: unknown, kind?: ShopifyResourceKind): value is ShopifyResourceReference;
|
|
408
|
+
type ShopifyResourceAvailability = "available" | "sold-out" | "unavailable" | "unknown";
|
|
409
|
+
/** A trusted Runtime may add these values transiently; they must never be saved back to PageDocument. */
|
|
410
|
+
type ShopifyResolvedResource = ShopifyResourceReference & Readonly<{
|
|
411
|
+
status: "resolved";
|
|
412
|
+
href?: string;
|
|
413
|
+
imageUrl?: string;
|
|
414
|
+
availability: ShopifyResourceAvailability;
|
|
415
|
+
}>;
|
|
416
|
+
type ShopifyResourceResolutionError = Readonly<{
|
|
417
|
+
code: "invalid-reference" | "missing" | "unavailable" | "resolution-failed";
|
|
418
|
+
}>;
|
|
419
|
+
type ShopifyResourceResolution = Readonly<{
|
|
420
|
+
resources: Readonly<Record<string, ShopifyResolvedResource>>;
|
|
421
|
+
errors: Readonly<Record<string, ShopifyResourceResolutionError>>;
|
|
422
|
+
}>;
|
|
423
|
+
/** Server-side host contract. The extension never contacts Shopify or supplies an implementation. */
|
|
424
|
+
type ShopifyResourceResolver = {
|
|
425
|
+
resolve(input: {
|
|
426
|
+
references: readonly ShopifyResourceReference[];
|
|
427
|
+
}): Promise<readonly ShopifyResolvedResource[]>;
|
|
428
|
+
};
|
|
429
|
+
/** Validates and normalizes a host response; a live resolution failure never becomes mock data. */
|
|
430
|
+
declare function resolveShopifyResources(references: readonly unknown[], resolver: ShopifyResourceResolver): Promise<ShopifyResourceResolution>;
|
|
431
|
+
declare function getResolvedShopifyResource(reference: unknown, resolution?: ShopifyResourceResolution): ShopifyResolvedResource | undefined;
|
|
432
|
+
declare function getShopifyResourceResolutionError(reference: unknown, resolution?: ShopifyResourceResolution): Readonly<{
|
|
433
|
+
code: "invalid-reference" | "missing" | "unavailable" | "resolution-failed";
|
|
434
|
+
}> | undefined;
|
|
435
|
+
|
|
436
|
+
/** Transient, consumer-safe state. The host error is deliberately never retained for display. */
|
|
97
437
|
type SalesRuntimeState = {
|
|
98
|
-
phase:
|
|
99
|
-
result?:
|
|
100
|
-
error?: string;
|
|
438
|
+
phase: TrackingPageRuntimePhase;
|
|
439
|
+
result?: TrackingPageQueryResult;
|
|
101
440
|
};
|
|
102
441
|
type SalesRuntimeProviderProps = {
|
|
103
442
|
children: ReactNode;
|
|
104
|
-
|
|
443
|
+
/** The discriminated, host-authorized request contract. */
|
|
444
|
+
query?: TrackingPageQuery;
|
|
445
|
+
/** Host-decided display state; no entitlement checks happen in this package. */
|
|
446
|
+
watermark?: TrackingPageWatermark;
|
|
447
|
+
/** Server-resolved and transient; this provider never resolves Shopify resources. */
|
|
448
|
+
resourceResolution?: ShopifyResourceResolution;
|
|
105
449
|
};
|
|
106
450
|
/** The host injects a validated query; Sales never calls a DataSource itself. */
|
|
107
|
-
declare function SalesRuntimeProvider({ children,
|
|
451
|
+
declare function SalesRuntimeProvider({ children, query: injectedQuery, watermark, resourceResolution }: SalesRuntimeProviderProps): react.JSX.Element;
|
|
452
|
+
|
|
453
|
+
type TrackingPageUrlOptions = Readonly<{
|
|
454
|
+
allowLocalhost?: boolean;
|
|
455
|
+
}>;
|
|
456
|
+
/**
|
|
457
|
+
* Sanitizes merchant-configured URLs before they enter a rendered href or src.
|
|
458
|
+
* Production accepts public HTTPS only. HTTP is limited to an explicitly local
|
|
459
|
+
* development host and relative URLs are never part of the template protocol.
|
|
460
|
+
*/
|
|
461
|
+
declare function safeTrackingPageUrl(value: unknown, options?: TrackingPageUrlOptions): string | undefined;
|
|
462
|
+
declare function isSafeTrackingPageUrl(value: unknown, options?: TrackingPageUrlOptions): boolean;
|
|
463
|
+
|
|
464
|
+
declare function ShopifyResourcePickerProvider({ browser, children }: {
|
|
465
|
+
browser?: ShopifyResourceBrowser;
|
|
466
|
+
children: ReactNode;
|
|
467
|
+
}): react.JSX.Element;
|
|
468
|
+
declare function ShopifyProductResourceField(props: FieldProps<unknown>): react.JSX.Element;
|
|
469
|
+
declare function ShopifyCollectionResourceField(props: FieldProps<unknown>): react.JSX.Element;
|
|
108
470
|
|
|
109
|
-
export { BrandedRuntimeProvider, type BrandedRuntimeProviderProps, type BrandedRuntimeState, ReadyToGoRuntimeProvider, type ReadyToGoRuntimeProviderProps, type ReadyToGoRuntimeState, type ReadyToGoShipment, type ReadyToGoTrackingEvent, type
|
|
471
|
+
export { BrandedRuntimeProvider, type BrandedRuntimeProviderProps, type BrandedRuntimeState, type Locale, ReadyToGoRuntimeProvider, type ReadyToGoRuntimeProviderProps, type ReadyToGoRuntimeState, type ReadyToGoShipment, type ReadyToGoTrackingEvent, type ReadyToGoTrackingResult, type ReadyToGoTrackingStep, SHOPIFY_RECOMMEND_PATH, SHOPIFY_TRACK_QUERY_PATH, SalesRuntimeProvider, type SalesRuntimeProviderProps, type SalesRuntimeState, ShopifyCollectionResourceField, ShopifyProductResourceField, type ShopifyResolvedResource, type ShopifyResourceAvailability, type ShopifyResourceBrowser, type ShopifyResourceKind, ShopifyResourcePickerProvider, type ShopifyResourceReference, type ShopifyResourceResolution, type ShopifyResourceResolutionError, type ShopifyResourceResolver, type ShopifyResourceSearchInput, type ShopifyResourceSearchPage, type ShopifyTrackPageTransport, type TemplateBlockPolicy, type TemplatePolicy, type TrackingPageAd, type TrackingPageCollectionReference, type TrackingPageMediaReference, type TrackingPageMoney, type TrackingPageOrderItem, type TrackingPageOrderQueryRequest, type TrackingPageProductReference, type TrackingPageQuery, type TrackingPageQueryRequest, type TrackingPageQueryResult, type TrackingPageRecommendation, type TrackingPageRecommendationsQuery, type TrackingPageRecommendationsState, type TrackingPageResourceReference, type TrackingPageRuntimePhase, type TrackingPageShipment, type TrackingPageTrackingEvent, type TrackingPageTrackingQueryRequest, type TrackingPageTrackingStep, type TrackingPageUrlOptions, type TrackingPageWatermark, bestTrackBrandedExtension, bestTrackPageExtension, bestTrackSalesExtension, brandedTemplatePolicy, buildShopifyRecommendPayload, buildShopifyTrackQueryPayload, createBrandedTemplate, createReadyToGoTemplate, createSalesTemplate, createShopifyRecommendationsQuery, createShopifyTrackQuery, formatTrackingPageMoney, getResolvedShopifyResource, getShopifyResourceResolutionError, isEmptyTrackingPageResult, isSafeTrackingPageUrl, isShopifyResourceReference, isTrackingPageResourceReference, isValidOrderEmail, isValidOrderNumber, isValidTrackingNumber, mapShopifyRecommendationsResponse, mapShopifyTrackQueryResponse, readTrackingQueryFromLocation, readTrackingQueryLocationState, readyToGoTemplatePolicy, resolveInitialLocale, resolveShopifyResources, resolveShopifyTrackQueryLocale, safeTrackingPageUrl, salesTemplatePolicy, shouldHidePoweredBy, syncTrackingQueryToUrl, withShopifyAppProxyPrefix, withShopifyTrackCacheBust };
|