@tokenoftrust/storefront-runner 6.17.2 → 7.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
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",
|
|
@@ -2,11 +2,11 @@ export interface CatalogSize {
|
|
|
2
2
|
readonly products: number;
|
|
3
3
|
readonly bytes: number;
|
|
4
4
|
}
|
|
5
|
-
export type CatalogScaleLevel = "ok" | "warn" | "
|
|
5
|
+
export type CatalogScaleLevel = "ok" | "warn" | "large";
|
|
6
6
|
|
|
7
7
|
export declare const CATALOG_SCALE_WARN: Readonly<CatalogSize>;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const CATALOG_SCALE_LARGE: Readonly<CatalogSize>;
|
|
9
9
|
export declare function catalogScaleLevel(size: CatalogSize): CatalogScaleLevel;
|
|
10
10
|
export declare function catalogScaleFinding(
|
|
11
11
|
size: CatalogSize,
|
|
12
|
-
): { level: "warn" | "
|
|
12
|
+
): { level: "warn" | "large"; message: string } | null;
|
|
@@ -1,70 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Catalog scale thresholds: the one place the platform says how large a store's own
|
|
3
|
-
* `content/catalog/` may grow before
|
|
3
|
+
* `content/catalog/` may grow before a release gets slow or heavy (ADR 0033).
|
|
4
4
|
*
|
|
5
5
|
* Two measures, because either can be the one that bites:
|
|
6
6
|
* - products: the count of `catalog/products/*.json` files;
|
|
7
7
|
* - bytes: the raw size of every file under `catalog/`.
|
|
8
8
|
*
|
|
9
|
-
* Evidence (synthetic Giant-shaped tenants
|
|
10
|
-
* `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* Evidence (synthetic Giant-shaped tenants):
|
|
10
|
+
* - Listing projection, measured 2026-11-16 by `catalogScale.test.ts`: ~150 ms and ~47 MB of
|
|
11
|
+
* heap to parse at 10,000 products, so the hosted preview read path fits well inside the
|
|
12
|
+
* Worker's 128 MB isolate. Reading the files one by one costs ~111 MB at 10,000.
|
|
13
|
+
* - Static materialize (`materialize-tenant.mjs`, apps/storefront build + wrangler dev render),
|
|
14
|
+
* measured 2026-11-16 on a developer laptop (darwin arm64, Node 24) against the `catalog.e2e.test` fixture tenant:
|
|
15
|
+
*
|
|
16
|
+
* products catalog files routes wall time
|
|
17
|
+
* 2,000 21 MB 2,746 170 s
|
|
18
|
+
* 3,500 37 MB 5,026 394 s
|
|
19
|
+
* 5,000 53 MB 6,827 658 s
|
|
20
|
+
* 7,000 74 MB 10,027 1,265 s
|
|
21
|
+
*
|
|
22
|
+
* It completed at every size with every route rendered: no size here fails to materialize, so
|
|
23
|
+
* nothing is refused. The cost is publish time, which grows faster than the catalog.
|
|
24
|
+
* fb-1794371798042-4rqyh4 reported a 3,571-file / 42 MB release that rendered 6 routes; that did
|
|
25
|
+
* not reproduce here, so its cause is not catalog size alone.
|
|
16
26
|
*/
|
|
17
27
|
|
|
18
28
|
/** A catalog at or past either line gets a non-blocking finding naming the next line. */
|
|
19
29
|
export const CATALOG_SCALE_WARN = Object.freeze({ products: 3000, bytes: 25_000_000 });
|
|
20
30
|
|
|
21
|
-
/**
|
|
22
|
-
export const
|
|
31
|
+
/** At or past either line a release took over ten minutes to materialize in the measurement above. */
|
|
32
|
+
export const CATALOG_SCALE_LARGE = Object.freeze({ products: 5000, bytes: 40_000_000 });
|
|
23
33
|
|
|
24
34
|
/**
|
|
25
35
|
* @param {{ products: number, bytes: number }} size
|
|
26
|
-
* @returns {"ok" | "warn" | "
|
|
36
|
+
* @returns {"ok" | "warn" | "large"}
|
|
27
37
|
*/
|
|
28
38
|
export function catalogScaleLevel({ products, bytes }) {
|
|
29
|
-
if (products >=
|
|
39
|
+
if (products >= CATALOG_SCALE_LARGE.products || bytes >= CATALOG_SCALE_LARGE.bytes) return "large";
|
|
30
40
|
if (products >= CATALOG_SCALE_WARN.products || bytes >= CATALOG_SCALE_WARN.bytes) return "warn";
|
|
31
41
|
return "ok";
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
const mb = (bytes) => `${(bytes / 1_000_000).toFixed(1)} MB`;
|
|
35
45
|
|
|
36
|
-
const REMEDY =
|
|
37
|
-
"ask Token of Trust to serve this catalog from the D1 projection (`catalog.serving` is a platform " +
|
|
38
|
-
"setting, not a .tot/config.json key; public and static renders never read D1, ADR 0013), " +
|
|
39
|
-
"or split the catalog";
|
|
40
|
-
|
|
41
46
|
/**
|
|
42
|
-
* The finding text for a catalog at `warn` or `
|
|
43
|
-
*
|
|
47
|
+
* The finding text for a catalog at `warn` or `large`, or null when it is `ok`. Names the count,
|
|
48
|
+
* the size, the measured publish time and the next line, and says what each CDN does.
|
|
44
49
|
*
|
|
45
50
|
* @param {{ products: number, bytes: number }} size
|
|
46
|
-
* @returns {{ level: "warn" | "
|
|
51
|
+
* @returns {{ level: "warn" | "large"; message: string } | null}
|
|
47
52
|
*/
|
|
48
53
|
export function catalogScaleFinding(size) {
|
|
49
54
|
const level = catalogScaleLevel(size);
|
|
50
55
|
if (level === "ok") return null;
|
|
51
56
|
const have = `${size.products} products, ${mb(size.bytes)} of catalog files`;
|
|
52
57
|
const cdns =
|
|
53
|
-
"Cloudflare preview
|
|
54
|
-
"CloudFront static publication renders on a build machine
|
|
58
|
+
"Cloudflare preview reads the catalog from one listing projection inside the Worker; " +
|
|
59
|
+
"CloudFront static publication renders every page on a build machine.";
|
|
55
60
|
if (level === "warn") {
|
|
56
61
|
return {
|
|
57
62
|
level,
|
|
58
63
|
message:
|
|
59
|
-
`catalog is ${have}
|
|
60
|
-
|
|
61
|
-
`${
|
|
64
|
+
`catalog is ${have}. Static publication of a catalog this size took about 6 minutes at ` +
|
|
65
|
+
`3,500 products in measurement, and past ${CATALOG_SCALE_LARGE.products} products or ` +
|
|
66
|
+
`${mb(CATALOG_SCALE_LARGE.bytes)} it took over 10 minutes. ${cdns}`,
|
|
62
67
|
};
|
|
63
68
|
}
|
|
64
69
|
return {
|
|
65
70
|
level,
|
|
66
71
|
message:
|
|
67
|
-
`catalog is ${have}, past the ${
|
|
68
|
-
`${mb(
|
|
72
|
+
`catalog is ${have}, past the ${CATALOG_SCALE_LARGE.products}-product / ` +
|
|
73
|
+
`${mb(CATALOG_SCALE_LARGE.bytes)} line. Static publication took 11 minutes at 5,000 products ` +
|
|
74
|
+
`and 21 minutes at 7,000 in measurement, growing faster than the catalog. ${cdns}`,
|
|
69
75
|
};
|
|
70
76
|
}
|