@tokenoftrust/storefront-runner 4.11.13 → 4.11.15
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.
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
ProviderOutcome,
|
|
26
26
|
PublicCommerceEvent,
|
|
27
27
|
StockState,
|
|
28
|
+
TenantConfig,
|
|
28
29
|
} from "@tot/public-runtime";
|
|
29
30
|
import {
|
|
30
31
|
actorMayCommand,
|
|
@@ -53,11 +54,30 @@ import type {
|
|
|
53
54
|
OrdersViewModel,
|
|
54
55
|
} from "../viewmodels/orders";
|
|
55
56
|
import type { CheckoutOrderClient } from "../orderClient";
|
|
56
|
-
import { DEFAULT_TIMEZONE } from "@tot/public-runtime/declared-tenant-config";
|
|
57
|
+
import { DEFAULT_TIMEZONE, resolveStoreTimeZone } from "@tot/public-runtime/declared-tenant-config";
|
|
58
|
+
import { DeclaredTenantConfigUnreadError, withDeclaredTenantConfig } from "@/config/declaredTenantConfig";
|
|
57
59
|
|
|
58
60
|
const EVIDENCE_STATES: readonly EvidenceState[] = ["fresh", "not-required", "UNKNOWN", "stale", "unreadable", "absent"];
|
|
59
61
|
const REFUND_PAYMENTS: ReadonlySet<PaymentState> = new Set(["refunded", "refund_requested", "refund_unknown"]);
|
|
60
62
|
|
|
63
|
+
/** Read the selected store's declared clock from its actual Orders scope's channel. */
|
|
64
|
+
export async function readOrdersTimeZone(
|
|
65
|
+
target: TenantConfig | null,
|
|
66
|
+
kvGet: (key: string) => Promise<string | null>,
|
|
67
|
+
scope: CommerceScope | null,
|
|
68
|
+
): Promise<string> {
|
|
69
|
+
if (!target || !scope) return DEFAULT_TIMEZONE;
|
|
70
|
+
try {
|
|
71
|
+
const env = scope.stage === "publication" ? "live" : "test";
|
|
72
|
+
const declared = await withDeclaredTenantConfig(target, kvGet, { env });
|
|
73
|
+
return resolveStoreTimeZone(declared.timezone);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
// An unreadable declaration cannot establish the store's clock. The formatter labels UTC.
|
|
76
|
+
if (error instanceof DeclaredTenantConfigUnreadError) return DEFAULT_TIMEZONE;
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
61
81
|
/** `YYYY-MM-DD` of an instant on the store's calendar. `null` when the instant does not parse. */
|
|
62
82
|
export function storeDay(instant: string | Date, timeZone: string): string | null {
|
|
63
83
|
const at = typeof instant === "string" ? new Date(instant) : instant;
|
|
@@ -67,18 +87,18 @@ export function storeDay(instant: string | Date, timeZone: string): string | nul
|
|
|
67
87
|
return `${part("year")}-${part("month")}-${part("day")}`;
|
|
68
88
|
}
|
|
69
89
|
|
|
70
|
-
/** An instant's clock time on the store's clock, e.g. `12:03 PM`. */
|
|
90
|
+
/** An instant's clock time and zone on the store's clock, e.g. `12:03 PM PDT`. */
|
|
71
91
|
export function formatStoreTime(instant: string, timeZone: string): string {
|
|
72
92
|
const at = new Date(instant);
|
|
73
93
|
if (Number.isNaN(at.getTime())) return "";
|
|
74
|
-
return new Intl.DateTimeFormat("en-US", { timeZone, hour: "numeric", minute: "2-digit" }).format(at);
|
|
94
|
+
return new Intl.DateTimeFormat("en-US", { timeZone, hour: "numeric", minute: "2-digit", timeZoneName: "short" }).format(at);
|
|
75
95
|
}
|
|
76
96
|
|
|
77
|
-
/** An instant's date
|
|
97
|
+
/** An instant's date, clock time and zone on the store's clock, e.g. `Oct 27, 12:03 PM PDT`. */
|
|
78
98
|
export function formatStoreDateTime(instant: string, timeZone: string): string {
|
|
79
99
|
const at = new Date(instant);
|
|
80
100
|
if (Number.isNaN(at.getTime())) return "";
|
|
81
|
-
return new Intl.DateTimeFormat("en-US", { timeZone, month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }).format(at);
|
|
101
|
+
return new Intl.DateTimeFormat("en-US", { timeZone, month: "short", day: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short" }).format(at);
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
/** An instant's date on the store's calendar, e.g. `Oct 27`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.15",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|