@tokenoftrust/storefront-runner 2.4.21 → 2.4.22
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.22",
|
|
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",
|
|
@@ -4,5 +4,6 @@ export interface BlogVisibilityInput {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export declare function exactPublicationTimestamp(value: unknown): string | null;
|
|
7
|
+
export declare function publicationAggregateClockV1(spaces: unknown): string | null;
|
|
7
8
|
export declare function isBlogPostVisibleOnLive(post: BlogVisibilityInput, now?: string | null): boolean;
|
|
8
9
|
export declare function isBlogPostListableOnLive(post: BlogVisibilityInput, now?: string | null): boolean;
|
|
@@ -10,6 +10,23 @@ export function exactPublicationTimestamp(value) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The clock of a publication-space aggregate: the latest of its spaces' own publication instants.
|
|
15
|
+
* Each space keeps its own instant in the vector; the aggregate's is derived from the vector alone,
|
|
16
|
+
* so every dispatch of the same vector, whichever space's activation sent it, names the same
|
|
17
|
+
* aggregate. Null when the vector is empty or any entry's instant is not exact.
|
|
18
|
+
* @param {unknown} spaces
|
|
19
|
+
* @returns {string | null}
|
|
20
|
+
*/
|
|
21
|
+
export function publicationAggregateClockV1(spaces) {
|
|
22
|
+
if (!spaces || typeof spaces !== "object" || Array.isArray(spaces)) return null;
|
|
23
|
+
const instants = Object.values(spaces).map((space) =>
|
|
24
|
+
space && typeof space === "object" ? exactPublicationTimestamp(/** @type {any} */ (space).publicationTimestamp) : null);
|
|
25
|
+
if (instants.length === 0 || instants.some((instant) => instant === null)) return null;
|
|
26
|
+
return /** @type {string[]} */ (instants).reduce((latest, instant) =>
|
|
27
|
+
Date.parse(instant) > Date.parse(latest) ? instant : latest);
|
|
28
|
+
}
|
|
29
|
+
|
|
13
30
|
/** @param {{status?: unknown, scheduledAt?: unknown}} post @param {unknown} now */
|
|
14
31
|
function scheduledIsDue(post, now) {
|
|
15
32
|
const publicationTimestamp = exactPublicationTimestamp(now);
|