@brandlab-digital/site-core 3.12.1 → 3.13.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 +7 -0
- package/dist/google-business-reviews-refresh.d.ts +93 -0
- package/dist/google-business-reviews-refresh.d.ts.map +1 -0
- package/dist/google-business-reviews-refresh.js +140 -0
- package/dist/google-business-reviews-refresh.js.map +1 -0
- package/dist/google-business-reviews.d.ts +1 -0
- package/dist/google-business-reviews.d.ts.map +1 -1
- package/dist/google-business-reviews.js +1 -0
- package/dist/google-business-reviews.js.map +1 -1
- package/dist/project.d.ts +76 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +177 -1
- package/dist/project.js.map +1 -1
- package/dist/site.d.ts +9 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +19 -0
- package/dist/site.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,13 @@ Proprietary software © Brandlab Digital Marketing. All rights reserved. Publish
|
|
|
9
9
|
placement shows, newest first and word for word (`recent`, or `five-star` for
|
|
10
10
|
rating 5 only). The fetch is `site-next/google-business-reviews/server`.
|
|
11
11
|
|
|
12
|
+
### Refresh on change (from 3.13.0)
|
|
13
|
+
|
|
14
|
+
`hashBusinessProfileReviews(feed)` gives a feed one SHA-256 hash: the same reviews in any order give the same hash,
|
|
15
|
+
an edited, added, removed, re-rated or answered review a new one. The daily reviews checker compares it with the last
|
|
16
|
+
hash a site accepted and, only on a change, posts `createBusinessProfileReviewsRevalidateRequest({ site, hash, secret })`
|
|
17
|
+
to the site's revalidate route. The contract is in the site-next README ("Reviews: refresh on change").
|
|
18
|
+
|
|
12
19
|
### Leaving out related-party reviews (`exclude`, from 3.7.0)
|
|
13
20
|
|
|
14
21
|
Romie, 19 October 2026: "ok remove suspected Related-party reviews from
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refreshing pages when a site's Google reviews change, not on a timer (Brandlab 3.13.0). The daily reviews checker
|
|
3
|
+
* hashes each site's feed with `hashBusinessProfileReviews` and, only when the hash differs from the last one it
|
|
4
|
+
* delivered, signs a request with `signBusinessProfileReviewsRevalidate` and posts it to the site's revalidate route
|
|
5
|
+
* (`createBrandlabReviewsRevalidateRoute` in `site-next/google-business-reviews/server`). The route then invalidates
|
|
6
|
+
* the `brandlab-reviews:<site>` fetch tag, so only pages that show the reviews are rewritten, once per real change.
|
|
7
|
+
*
|
|
8
|
+
* Both helpers are pure apart from Web Crypto, so the feed side and the site share one definition.
|
|
9
|
+
*/
|
|
10
|
+
/** Bumped when the normalised form changes, so an old hash never matches a new one by accident. */
|
|
11
|
+
export declare const BUSINESS_PROFILE_REVIEWS_HASH_VERSION = 1;
|
|
12
|
+
/** Every reviews fetch carries this tag, so one call can refresh every site's reviews in a deployment. */
|
|
13
|
+
export declare const BUSINESS_PROFILE_REVIEWS_TAG = "brandlab-reviews";
|
|
14
|
+
/** The request headers the revalidate route reads: Unix seconds, and `v1=<hex HMAC-SHA256>`. */
|
|
15
|
+
export declare const BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS: {
|
|
16
|
+
readonly timestamp: "x-brandlab-timestamp";
|
|
17
|
+
readonly signature: "x-brandlab-signature";
|
|
18
|
+
};
|
|
19
|
+
/** The route's environment variable holding the shared signing secret. Never in git. */
|
|
20
|
+
export declare const BUSINESS_PROFILE_REVIEWS_REVALIDATE_SECRET_NAME = "BRANDLAB_REVALIDATE_SECRET";
|
|
21
|
+
/** The route path a site serves the revalidate route at. */
|
|
22
|
+
export declare const BUSINESS_PROFILE_REVIEWS_REVALIDATE_PATH = "/api/brandlab/reviews-revalidate";
|
|
23
|
+
/** The site's own fetch tag, `brandlab-reviews:<site>`. */
|
|
24
|
+
export declare function businessProfileReviewsSiteTag(site: string): string;
|
|
25
|
+
/** The tags the shared reviews fetch carries for a site. */
|
|
26
|
+
export declare function businessProfileReviewsTags(site: string): [string, string];
|
|
27
|
+
/**
|
|
28
|
+
* The parts of a reviews feed answer that change what a page shows. Extra fields are ignored. `reply` and
|
|
29
|
+
* `updateTime` are read when the feed sends them (the 23 Oct 2026 feed sends neither yet).
|
|
30
|
+
*/
|
|
31
|
+
export interface BusinessProfileReviewsHashInput {
|
|
32
|
+
averageRating?: number | null;
|
|
33
|
+
totalReviewCount?: number | null;
|
|
34
|
+
reviews: readonly {
|
|
35
|
+
id: string;
|
|
36
|
+
rating?: number | null;
|
|
37
|
+
text?: string | null;
|
|
38
|
+
authorName?: string | null;
|
|
39
|
+
createTime?: string | null;
|
|
40
|
+
updateTime?: string | null;
|
|
41
|
+
reply?: string | {
|
|
42
|
+
comment?: string | null;
|
|
43
|
+
updateTime?: string | null;
|
|
44
|
+
} | null;
|
|
45
|
+
}[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The normalised review list as one canonical string: the aggregate rating and count, then each review's id, rating,
|
|
49
|
+
* text, author, create and update times and reply, sorted by id. Whitespace runs and Unicode composition do not
|
|
50
|
+
* change it; the order the feed lists reviews in does not either.
|
|
51
|
+
*/
|
|
52
|
+
export declare function normaliseBusinessProfileReviews(feed: BusinessProfileReviewsHashInput): string;
|
|
53
|
+
/** SHA-256 of the normalised review list, as 64 lowercase hex characters. */
|
|
54
|
+
export declare function hashBusinessProfileReviews(feed: BusinessProfileReviewsHashInput): Promise<string>;
|
|
55
|
+
/** The body the revalidate route accepts. */
|
|
56
|
+
export interface BusinessProfileReviewsRevalidateBody {
|
|
57
|
+
site: string;
|
|
58
|
+
/** `hashBusinessProfileReviews` of the feed the site should now show. */
|
|
59
|
+
hash: string;
|
|
60
|
+
}
|
|
61
|
+
export declare const BUSINESS_PROFILE_REVIEWS_HASH_PATTERN: RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* The signing secret as both sides use it: surrounding whitespace (a trailing newline pasted into an environment
|
|
64
|
+
* variable, say) is dropped, so the checker and the route sign with the same key.
|
|
65
|
+
*/
|
|
66
|
+
export declare function normaliseBusinessProfileReviewsRevalidateSecret(secret: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* The HMAC-SHA256 of `<timestamp>.<body>` under the shared secret (normalised with
|
|
69
|
+
* `normaliseBusinessProfileReviewsRevalidateSecret`), as the signature header value `v1=<hex>`. The secret never
|
|
70
|
+
* travels with the request.
|
|
71
|
+
*/
|
|
72
|
+
export declare function signBusinessProfileReviewsRevalidate(input: {
|
|
73
|
+
secret: string;
|
|
74
|
+
/** The exact request body that will be sent. */
|
|
75
|
+
body: string;
|
|
76
|
+
/** Unix seconds; the route refuses a request more than 5 minutes either side of its clock. */
|
|
77
|
+
timestamp: number;
|
|
78
|
+
}): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* A ready-to-send revalidate request for the daily checker: the JSON body, and the headers with a fresh timestamp
|
|
81
|
+
* and signature. POST it to `https://<site>${BUSINESS_PROFILE_REVIEWS_REVALIDATE_PATH}`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function createBusinessProfileReviewsRevalidateRequest(input: {
|
|
84
|
+
site: string;
|
|
85
|
+
hash: string;
|
|
86
|
+
secret: string;
|
|
87
|
+
/** Unix seconds; defaults to now. */
|
|
88
|
+
timestamp?: number;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
body: string;
|
|
91
|
+
headers: Record<string, string>;
|
|
92
|
+
}>;
|
|
93
|
+
//# sourceMappingURL=google-business-reviews-refresh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-business-reviews-refresh.d.ts","sourceRoot":"","sources":["../src/google-business-reviews-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,mGAAmG;AACnG,eAAO,MAAM,qCAAqC,IAAI,CAAA;AAEtD,0GAA0G;AAC1G,eAAO,MAAM,4BAA4B,qBAAqB,CAAA;AAE9D,gGAAgG;AAChG,eAAO,MAAM,2CAA2C;;;CAG9C,CAAA;AAEV,wFAAwF;AACxF,eAAO,MAAM,+CAA+C,+BAA+B,CA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BAAgB,+CAA+C,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtF;AAED;;;;GAIG;AACH,wBAAsB,oCAAoC,CAAC,KAAK,EAAE;IAChE,MAAM,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBlB;AAED;;;GAGG;AACH,wBAAsB,6CAA6C,CAAC,KAAK,EAAE;IACzE,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAmB7D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refreshing pages when a site's Google reviews change, not on a timer (Brandlab 3.13.0). The daily reviews checker
|
|
3
|
+
* hashes each site's feed with `hashBusinessProfileReviews` and, only when the hash differs from the last one it
|
|
4
|
+
* delivered, signs a request with `signBusinessProfileReviewsRevalidate` and posts it to the site's revalidate route
|
|
5
|
+
* (`createBrandlabReviewsRevalidateRoute` in `site-next/google-business-reviews/server`). The route then invalidates
|
|
6
|
+
* the `brandlab-reviews:<site>` fetch tag, so only pages that show the reviews are rewritten, once per real change.
|
|
7
|
+
*
|
|
8
|
+
* Both helpers are pure apart from Web Crypto, so the feed side and the site share one definition.
|
|
9
|
+
*/
|
|
10
|
+
/** Bumped when the normalised form changes, so an old hash never matches a new one by accident. */
|
|
11
|
+
export const BUSINESS_PROFILE_REVIEWS_HASH_VERSION = 1;
|
|
12
|
+
/** Every reviews fetch carries this tag, so one call can refresh every site's reviews in a deployment. */
|
|
13
|
+
export const BUSINESS_PROFILE_REVIEWS_TAG = 'brandlab-reviews';
|
|
14
|
+
/** The request headers the revalidate route reads: Unix seconds, and `v1=<hex HMAC-SHA256>`. */
|
|
15
|
+
export const BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS = {
|
|
16
|
+
timestamp: 'x-brandlab-timestamp',
|
|
17
|
+
signature: 'x-brandlab-signature',
|
|
18
|
+
};
|
|
19
|
+
/** The route's environment variable holding the shared signing secret. Never in git. */
|
|
20
|
+
export const BUSINESS_PROFILE_REVIEWS_REVALIDATE_SECRET_NAME = 'BRANDLAB_REVALIDATE_SECRET';
|
|
21
|
+
/** The route path a site serves the revalidate route at. */
|
|
22
|
+
export const BUSINESS_PROFILE_REVIEWS_REVALIDATE_PATH = '/api/brandlab/reviews-revalidate';
|
|
23
|
+
const SITE_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
24
|
+
/** The site's own fetch tag, `brandlab-reviews:<site>`. */
|
|
25
|
+
export function businessProfileReviewsSiteTag(site) {
|
|
26
|
+
if (typeof site !== 'string' || !SITE_SLUG.test(site)) {
|
|
27
|
+
throw new Error('Business Profile reviews site must be a lowercase kebab-case slug.');
|
|
28
|
+
}
|
|
29
|
+
return `${BUSINESS_PROFILE_REVIEWS_TAG}:${site}`;
|
|
30
|
+
}
|
|
31
|
+
/** The tags the shared reviews fetch carries for a site. */
|
|
32
|
+
export function businessProfileReviewsTags(site) {
|
|
33
|
+
return [BUSINESS_PROFILE_REVIEWS_TAG, businessProfileReviewsSiteTag(site)];
|
|
34
|
+
}
|
|
35
|
+
function clean(value) {
|
|
36
|
+
return typeof value === 'string' ? value.normalize('NFC').replace(/\s+/g, ' ').trim() || null : null;
|
|
37
|
+
}
|
|
38
|
+
function numberOrNull(value) {
|
|
39
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
40
|
+
}
|
|
41
|
+
function toHex(buffer) {
|
|
42
|
+
return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
43
|
+
}
|
|
44
|
+
function subtle() {
|
|
45
|
+
const value = globalThis.crypto?.subtle;
|
|
46
|
+
if (!value)
|
|
47
|
+
throw new Error('A Web Crypto implementation is required.');
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The normalised review list as one canonical string: the aggregate rating and count, then each review's id, rating,
|
|
52
|
+
* text, author, create and update times and reply, sorted by id. Whitespace runs and Unicode composition do not
|
|
53
|
+
* change it; the order the feed lists reviews in does not either.
|
|
54
|
+
*/
|
|
55
|
+
export function normaliseBusinessProfileReviews(feed) {
|
|
56
|
+
if (!feed || typeof feed !== 'object' || !Array.isArray(feed.reviews)) {
|
|
57
|
+
throw new Error('Business Profile reviews to hash must have a review list.');
|
|
58
|
+
}
|
|
59
|
+
const reviews = feed.reviews.map((review) => {
|
|
60
|
+
if (!review || typeof review.id !== 'string' || !review.id.trim()) {
|
|
61
|
+
throw new Error('Every Business Profile review to hash needs an id.');
|
|
62
|
+
}
|
|
63
|
+
const reply = review.reply;
|
|
64
|
+
const replyText = typeof reply === 'string' ? clean(reply) : clean(reply?.comment);
|
|
65
|
+
const replyTime = typeof reply === 'object' && reply !== null ? clean(reply.updateTime) : null;
|
|
66
|
+
return [
|
|
67
|
+
review.id.trim(),
|
|
68
|
+
numberOrNull(review.rating),
|
|
69
|
+
clean(review.text),
|
|
70
|
+
clean(review.authorName),
|
|
71
|
+
clean(review.createTime),
|
|
72
|
+
clean(review.updateTime),
|
|
73
|
+
replyText,
|
|
74
|
+
replyTime,
|
|
75
|
+
];
|
|
76
|
+
});
|
|
77
|
+
reviews.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
78
|
+
return JSON.stringify([
|
|
79
|
+
BUSINESS_PROFILE_REVIEWS_HASH_VERSION,
|
|
80
|
+
numberOrNull(feed.averageRating),
|
|
81
|
+
numberOrNull(feed.totalReviewCount),
|
|
82
|
+
reviews,
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
/** SHA-256 of the normalised review list, as 64 lowercase hex characters. */
|
|
86
|
+
export async function hashBusinessProfileReviews(feed) {
|
|
87
|
+
const digest = await subtle().digest('SHA-256', new TextEncoder().encode(normaliseBusinessProfileReviews(feed)));
|
|
88
|
+
return toHex(digest);
|
|
89
|
+
}
|
|
90
|
+
export const BUSINESS_PROFILE_REVIEWS_HASH_PATTERN = /^[0-9a-f]{64}$/;
|
|
91
|
+
/**
|
|
92
|
+
* The signing secret as both sides use it: surrounding whitespace (a trailing newline pasted into an environment
|
|
93
|
+
* variable, say) is dropped, so the checker and the route sign with the same key.
|
|
94
|
+
*/
|
|
95
|
+
export function normaliseBusinessProfileReviewsRevalidateSecret(secret) {
|
|
96
|
+
return typeof secret === 'string' ? secret.trim() : '';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The HMAC-SHA256 of `<timestamp>.<body>` under the shared secret (normalised with
|
|
100
|
+
* `normaliseBusinessProfileReviewsRevalidateSecret`), as the signature header value `v1=<hex>`. The secret never
|
|
101
|
+
* travels with the request.
|
|
102
|
+
*/
|
|
103
|
+
export async function signBusinessProfileReviewsRevalidate(input) {
|
|
104
|
+
const secret = normaliseBusinessProfileReviewsRevalidateSecret(input.secret);
|
|
105
|
+
if (secret.length < 32) {
|
|
106
|
+
throw new Error('The revalidate secret must be at least 32 characters.');
|
|
107
|
+
}
|
|
108
|
+
if (!Number.isSafeInteger(input.timestamp) || input.timestamp < 0) {
|
|
109
|
+
throw new Error('The revalidate timestamp must be whole Unix seconds.');
|
|
110
|
+
}
|
|
111
|
+
const crypto = subtle();
|
|
112
|
+
const key = await crypto.importKey('raw', new TextEncoder().encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
113
|
+
const signature = await crypto.sign('HMAC', key, new TextEncoder().encode(`${input.timestamp}.${input.body}`));
|
|
114
|
+
return `v1=${toHex(signature)}`;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A ready-to-send revalidate request for the daily checker: the JSON body, and the headers with a fresh timestamp
|
|
118
|
+
* and signature. POST it to `https://<site>${BUSINESS_PROFILE_REVIEWS_REVALIDATE_PATH}`.
|
|
119
|
+
*/
|
|
120
|
+
export async function createBusinessProfileReviewsRevalidateRequest(input) {
|
|
121
|
+
businessProfileReviewsSiteTag(input.site);
|
|
122
|
+
if (typeof input.hash !== 'string' || !BUSINESS_PROFILE_REVIEWS_HASH_PATTERN.test(input.hash)) {
|
|
123
|
+
throw new Error('The reviews hash must be 64 lowercase hex characters from hashBusinessProfileReviews.');
|
|
124
|
+
}
|
|
125
|
+
const timestamp = input.timestamp ?? Math.floor(Date.now() / 1_000);
|
|
126
|
+
const body = JSON.stringify({ site: input.site, hash: input.hash });
|
|
127
|
+
return {
|
|
128
|
+
body,
|
|
129
|
+
headers: {
|
|
130
|
+
'content-type': 'application/json',
|
|
131
|
+
[BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS.timestamp]: String(timestamp),
|
|
132
|
+
[BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS.signature]: await signBusinessProfileReviewsRevalidate({
|
|
133
|
+
secret: input.secret,
|
|
134
|
+
body,
|
|
135
|
+
timestamp,
|
|
136
|
+
}),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=google-business-reviews-refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-business-reviews-refresh.js","sourceRoot":"","sources":["../src/google-business-reviews-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,mGAAmG;AACnG,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAC,CAAA;AAEtD,0GAA0G;AAC1G,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAA;AAE9D,gGAAgG;AAChG,MAAM,CAAC,MAAM,2CAA2C,GAAG;IACzD,SAAS,EAAE,sBAAsB;IACjC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AAG,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAiD,CAAC,CAAA;IAClH,OAAO;QACL,IAAI;QACJ,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,CAAC,2CAA2C,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;YAC1E,CAAC,2CAA2C,CAAC,SAAS,CAAC,EAAE,MAAM,oCAAoC,CAAC;gBAClG,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,IAAI;gBACJ,SAAS;aACV,CAAC;SACH;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * Refreshing pages when a site's Google reviews change, not on a timer (Brandlab 3.13.0). The daily reviews checker\n * hashes each site's feed with `hashBusinessProfileReviews` and, only when the hash differs from the last one it\n * delivered, signs a request with `signBusinessProfileReviewsRevalidate` and posts it to the site's revalidate route\n * (`createBrandlabReviewsRevalidateRoute` in `site-next/google-business-reviews/server`). The route then invalidates\n * the `brandlab-reviews:<site>` fetch tag, so only pages that show the reviews are rewritten, once per real change.\n *\n * Both helpers are pure apart from Web Crypto, so the feed side and the site share one definition.\n */\n\n/** Bumped when the normalised form changes, so an old hash never matches a new one by accident. */\nexport const BUSINESS_PROFILE_REVIEWS_HASH_VERSION = 1\n\n/** Every reviews fetch carries this tag, so one call can refresh every site's reviews in a deployment. */\nexport const BUSINESS_PROFILE_REVIEWS_TAG = 'brandlab-reviews'\n\n/** The request headers the revalidate route reads: Unix seconds, and `v1=<hex HMAC-SHA256>`. */\nexport const BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS = {\n timestamp: 'x-brandlab-timestamp',\n signature: 'x-brandlab-signature',\n} as const\n\n/** The route's environment variable holding the shared signing secret. Never in git. */\nexport const BUSINESS_PROFILE_REVIEWS_REVALIDATE_SECRET_NAME = 'BRANDLAB_REVALIDATE_SECRET'\n\n/** The route path a site serves the revalidate route at. */\nexport const BUSINESS_PROFILE_REVIEWS_REVALIDATE_PATH = '/api/brandlab/reviews-revalidate'\n\nconst SITE_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\n\n/** The site's own fetch tag, `brandlab-reviews:<site>`. */\nexport function businessProfileReviewsSiteTag(site: string): string {\n if (typeof site !== 'string' || !SITE_SLUG.test(site)) {\n throw new Error('Business Profile reviews site must be a lowercase kebab-case slug.')\n }\n return `${BUSINESS_PROFILE_REVIEWS_TAG}:${site}`\n}\n\n/** The tags the shared reviews fetch carries for a site. */\nexport function businessProfileReviewsTags(site: string): [string, string] {\n return [BUSINESS_PROFILE_REVIEWS_TAG, businessProfileReviewsSiteTag(site)]\n}\n\n/**\n * The parts of a reviews feed answer that change what a page shows. Extra fields are ignored. `reply` and\n * `updateTime` are read when the feed sends them (the 23 Oct 2026 feed sends neither yet).\n */\nexport interface BusinessProfileReviewsHashInput {\n averageRating?: number | null\n totalReviewCount?: number | null\n reviews: readonly {\n id: string\n rating?: number | null\n text?: string | null\n authorName?: string | null\n createTime?: string | null\n updateTime?: string | null\n reply?: string | { comment?: string | null; updateTime?: string | null } | null\n }[]\n}\n\nfunction clean(value: unknown): string | null {\n return typeof value === 'string' ? value.normalize('NFC').replace(/\\s+/g, ' ').trim() || null : null\n}\n\nfunction numberOrNull(value: unknown): number | null {\n return typeof value === 'number' && Number.isFinite(value) ? value : null\n}\n\nfunction toHex(buffer: ArrayBuffer): string {\n return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, '0')).join('')\n}\n\nfunction subtle(): SubtleCrypto {\n const value = globalThis.crypto?.subtle\n if (!value) throw new Error('A Web Crypto implementation is required.')\n return value\n}\n\n/**\n * The normalised review list as one canonical string: the aggregate rating and count, then each review's id, rating,\n * text, author, create and update times and reply, sorted by id. Whitespace runs and Unicode composition do not\n * change it; the order the feed lists reviews in does not either.\n */\nexport function normaliseBusinessProfileReviews(feed: BusinessProfileReviewsHashInput): string {\n if (!feed || typeof feed !== 'object' || !Array.isArray(feed.reviews)) {\n throw new Error('Business Profile reviews to hash must have a review list.')\n }\n const reviews = feed.reviews.map((review) => {\n if (!review || typeof review.id !== 'string' || !review.id.trim()) {\n throw new Error('Every Business Profile review to hash needs an id.')\n }\n const reply = review.reply\n const replyText = typeof reply === 'string' ? clean(reply) : clean(reply?.comment)\n const replyTime = typeof reply === 'object' && reply !== null ? clean(reply.updateTime) : null\n return [\n review.id.trim(),\n numberOrNull(review.rating),\n clean(review.text),\n clean(review.authorName),\n clean(review.createTime),\n clean(review.updateTime),\n replyText,\n replyTime,\n ] as const\n })\n reviews.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))\n return JSON.stringify([\n BUSINESS_PROFILE_REVIEWS_HASH_VERSION,\n numberOrNull(feed.averageRating),\n numberOrNull(feed.totalReviewCount),\n reviews,\n ])\n}\n\n/** SHA-256 of the normalised review list, as 64 lowercase hex characters. */\nexport async function hashBusinessProfileReviews(feed: BusinessProfileReviewsHashInput): Promise<string> {\n const digest = await subtle().digest('SHA-256', new TextEncoder().encode(normaliseBusinessProfileReviews(feed)))\n return toHex(digest)\n}\n\n/** The body the revalidate route accepts. */\nexport interface BusinessProfileReviewsRevalidateBody {\n site: string\n /** `hashBusinessProfileReviews` of the feed the site should now show. */\n hash: string\n}\n\nexport const BUSINESS_PROFILE_REVIEWS_HASH_PATTERN = /^[0-9a-f]{64}$/\n\n/**\n * The signing secret as both sides use it: surrounding whitespace (a trailing newline pasted into an environment\n * variable, say) is dropped, so the checker and the route sign with the same key.\n */\nexport function normaliseBusinessProfileReviewsRevalidateSecret(secret: string): string {\n return typeof secret === 'string' ? secret.trim() : ''\n}\n\n/**\n * The HMAC-SHA256 of `<timestamp>.<body>` under the shared secret (normalised with\n * `normaliseBusinessProfileReviewsRevalidateSecret`), as the signature header value `v1=<hex>`. The secret never\n * travels with the request.\n */\nexport async function signBusinessProfileReviewsRevalidate(input: {\n secret: string\n /** The exact request body that will be sent. */\n body: string\n /** Unix seconds; the route refuses a request more than 5 minutes either side of its clock. */\n timestamp: number\n}): Promise<string> {\n const secret = normaliseBusinessProfileReviewsRevalidateSecret(input.secret)\n if (secret.length < 32) {\n throw new Error('The revalidate secret must be at least 32 characters.')\n }\n if (!Number.isSafeInteger(input.timestamp) || input.timestamp < 0) {\n throw new Error('The revalidate timestamp must be whole Unix seconds.')\n }\n const crypto = subtle()\n const key = await crypto.importKey(\n 'raw',\n new TextEncoder().encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign'],\n )\n const signature = await crypto.sign('HMAC', key, new TextEncoder().encode(`${input.timestamp}.${input.body}`))\n return `v1=${toHex(signature)}`\n}\n\n/**\n * A ready-to-send revalidate request for the daily checker: the JSON body, and the headers with a fresh timestamp\n * and signature. POST it to `https://<site>${BUSINESS_PROFILE_REVIEWS_REVALIDATE_PATH}`.\n */\nexport async function createBusinessProfileReviewsRevalidateRequest(input: {\n site: string\n hash: string\n secret: string\n /** Unix seconds; defaults to now. */\n timestamp?: number\n}): Promise<{ body: string; headers: Record<string, string> }> {\n businessProfileReviewsSiteTag(input.site)\n if (typeof input.hash !== 'string' || !BUSINESS_PROFILE_REVIEWS_HASH_PATTERN.test(input.hash)) {\n throw new Error('The reviews hash must be 64 lowercase hex characters from hashBusinessProfileReviews.')\n }\n const timestamp = input.timestamp ?? Math.floor(Date.now() / 1_000)\n const body = JSON.stringify({ site: input.site, hash: input.hash } satisfies BusinessProfileReviewsRevalidateBody)\n return {\n body,\n headers: {\n 'content-type': 'application/json',\n [BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS.timestamp]: String(timestamp),\n [BUSINESS_PROFILE_REVIEWS_REVALIDATE_HEADERS.signature]: await signBusinessProfileReviewsRevalidate({\n secret: input.secret,\n body,\n timestamp,\n }),\n },\n }\n}\n"]}
|
|
@@ -122,4 +122,5 @@ export declare function prepareBusinessProfileReviews(feed: BusinessProfileRevie
|
|
|
122
122
|
* `selectBusinessProfileReviews` kept an excluded review because too few others remained. Sites can log it or test it.
|
|
123
123
|
*/
|
|
124
124
|
export declare function excludedBusinessProfileReviewsShown(shown: readonly BusinessProfileReview[], exclude: readonly BusinessProfileReviewExclusion[] | undefined): ExcludedBusinessProfileReviewShown[];
|
|
125
|
+
export * from './google-business-reviews-refresh.js';
|
|
125
126
|
//# sourceMappingURL=google-business-reviews.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-business-reviews.d.ts","sourceRoot":"","sources":["../src/google-business-reviews.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,qBAAqB,EAAE,CAAA;CACjC;AAED,mFAAmF;AACnF,MAAM,MAAM,4BAA4B,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,8BAA8B,GACtC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,UAAU,EAAE,MA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,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,IAAI,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3F,UAAU,EAAE,IAAI,CAAC,aAAa;QAC9B,OAAO;QACP,OAAO;KACR,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CACjD,KAAuC,EACvC,OAA8D;IAE9D,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC9B,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAChD,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACjD,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/**\n * Google reviews from the Business Profile API, as the Brandlab reviews feed serves them\n * (`{ status: 'available', source: 'google-business-profile', fetchedAt, googleMapsUri,\n * averageRating?, totalReviewCount?, reviews }`). Anything the feed sends that does not\n * match is treated as unavailable (the whole response) or dropped (one review), so a page\n * never shows a review it cannot vouch for. The fetch itself lives in\n * `site-next/google-business-reviews/server`.\n */\n\nexport interface BusinessProfileReview {\n id: string\n authorName: string\n /** Only an https image on a `*.googleusercontent.com` host. */\n authorPhotoUrl?: string\n rating: 1 | 2 | 3 | 4 | 5\n text: string\n /** The time Google records for the review, as the feed sent it. */\n createTime: string\n}\n\nexport interface BusinessProfileReviews {\n googleMapsUri: string\n /** Between 1 and 5 when Google supplies it. */\n averageRating?: number\n /** A whole number of reviews, 0 or more, when Google supplies it. */\n totalReviewCount?: number\n reviews: BusinessProfileReview[]\n}\n\n/** Which reviews a page shows: the newest of all, or the newest five-star ones. */\nexport type BusinessProfileReviewsPolicy = 'recent' | 'five-star'\n\n/**\n * A review a site would rather not feature (3.7.0), such as one written by a relative of the owner or of Brandlab.\n * Name exactly one of `reviewId` (that one review, matched exactly) or `authorName` (every review by that name,\n * ignoring case and spacing), and always the `reason`, so the next person knows who decided and why. The list lives\n * in the site's `src/config/reviews.ts` (`reviews.exclude`), never in brandlab.config.\n */\nexport type BusinessProfileReviewExclusion =\n | { reviewId: string; authorName?: never; reason: string }\n | { authorName: string; reviewId?: never; reason: string }\n\nexport interface SelectBusinessProfileReviewsOptions {\n policy: BusinessProfileReviewsPolicy\n /** How many reviews to show at most: a whole number, 1 or more. */\n limit: number\n /**\n * Reviews to leave out while enough others remain to fill `limit` (3.7.0). When too few others remain, the fewest\n * excluded reviews needed to fill it stay, newest first, so a page never shows fewer reviews because of the list.\n */\n exclude?: readonly BusinessProfileReviewExclusion[]\n}\n\n/** A review that was shown although it matches an exclusion, with the first exclusion it matches. */\nexport interface ExcludedBusinessProfileReviewShown {\n review: BusinessProfileReview\n exclusion: BusinessProfileReviewExclusion\n}\n\nconst POLICIES: ReadonlySet<string> = new Set<BusinessProfileReviewsPolicy>(['recent', 'five-star'])\n\nfunction isHttpsUrl(value: unknown, host?: (hostname: string) => boolean): value is string {\n if (typeof value !== 'string') return false\n try {\n const url = new URL(value)\n return url.protocol === 'https:' && (!host || host(url.hostname))\n } catch {\n return false\n }\n}\n\nfunction parseReview(value: unknown): BusinessProfileReview | null {\n if (!value || typeof value !== 'object') return null\n const record = value as Record<string, unknown>\n const rating = record.rating\n if (\n typeof record.id !== 'string' ||\n typeof record.authorName !== 'string' ||\n !record.authorName.trim() ||\n typeof record.text !== 'string' ||\n !record.text.trim() ||\n typeof record.createTime !== 'string' ||\n Number.isNaN(Date.parse(record.createTime)) ||\n (rating !== 1 && rating !== 2 && rating !== 3 && rating !== 4 && rating !== 5)\n ) {\n return null\n }\n const photo = isHttpsUrl(record.authorPhotoUrl, (host) => host.endsWith('.googleusercontent.com'))\n ? record.authorPhotoUrl\n : undefined\n return {\n id: record.id,\n authorName: record.authorName.trim(),\n ...(photo ? { authorPhotoUrl: photo } : {}),\n rating,\n text: record.text.trim(),\n createTime: record.createTime,\n }\n}\n\n/**\n * Validates a reviews feed response. Returns null for anything but an available response\n * with an https Google Maps link and a review list; drops each review that is not complete\n * (id, author, text, a valid time and a whole-star rating from 1 to 5). An author photo\n * outside `*.googleusercontent.com`, an average outside 1 to 5 and a total that is not a\n * whole number of 0 or more are left out.\n */\nexport function parseBusinessProfileReviews(value: unknown): BusinessProfileReviews | null {\n if (!value || typeof value !== 'object') return null\n const record = value as Record<string, unknown>\n if (record.status !== 'available' || !isHttpsUrl(record.googleMapsUri) || !Array.isArray(record.reviews)) {\n return null\n }\n const average = record.averageRating\n const total = record.totalReviewCount\n return {\n googleMapsUri: record.googleMapsUri,\n ...(typeof average === 'number' && average >= 1 && average <= 5 ? { averageRating: average } : {}),\n ...(typeof total === 'number' && Number.isInteger(total) && total >= 0 ? { totalReviewCount: total } : {}),\n reviews: record.reviews\n .map(parseReview)\n .filter((review): review is BusinessProfileReview => review !== null),\n }\n}\n\nconst EXCLUSION_KEYS: ReadonlySet<string> = new Set(['reviewId', 'authorName', 'reason'])\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0\n}\n\n/** Case, spacing and Unicode composition do not tell two author names apart. */\nfunction normaliseAuthorName(name: string): string {\n return name.normalize('NFC').replace(/\\s+/g, ' ').trim().toLowerCase()\n}\n\nfunction assertExclusions(exclude: unknown): readonly BusinessProfileReviewExclusion[] {\n if (exclude === undefined) return []\n if (!Array.isArray(exclude)) {\n throw new Error('Business Profile reviews exclude must be a list.')\n }\n exclude.forEach((entry: unknown, index) => {\n const field = `Business Profile reviews exclude[${index}]`\n if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {\n throw new Error(`${field} must be an object with reviewId or authorName and a reason.`)\n }\n const record = entry as Record<string, unknown>\n const unknown = Object.keys(record).find((key) => !EXCLUSION_KEYS.has(key))\n if (unknown) throw new Error(`${field} has an unknown field: ${unknown}.`)\n const hasId = record.reviewId !== undefined\n const hasName = record.authorName !== undefined\n if (hasId === hasName) {\n throw new Error(`${field} must name exactly one of reviewId or authorName.`)\n }\n if (hasId && !isNonEmptyString(record.reviewId)) throw new Error(`${field}.reviewId must be a non-empty string.`)\n if (hasName && !isNonEmptyString(record.authorName)) throw new Error(`${field}.authorName must be a non-empty string.`)\n if (!isNonEmptyString(record.reason)) {\n throw new Error(`${field}.reason is required: say who decided to exclude it and why.`)\n }\n })\n return exclude as readonly BusinessProfileReviewExclusion[]\n}\n\nfunction findExclusion(\n review: BusinessProfileReview,\n exclude: readonly BusinessProfileReviewExclusion[],\n): BusinessProfileReviewExclusion | undefined {\n if (exclude.length === 0) return undefined\n const author = normaliseAuthorName(review.authorName)\n return exclude.find((entry) =>\n entry.reviewId !== undefined\n ? entry.reviewId === review.id\n : normaliseAuthorName(entry.authorName) === author,\n )\n}\n\n/**\n * The reviews a page shows, newest first and word for word: every review (`recent`) or only the five-star ones\n * (`five-star`), at most `limit`. No feed gives no reviews.\n *\n * `exclude` (3.7.0) leaves out the reviews it names only while enough other reviews remain to fill `limit`; otherwise\n * the fewest excluded reviews needed to fill it stay (the newest of them), so the page shows as many reviews as it\n * would without the list, all in the policy's order. A kept review was already among those shown without the list.\n * The profile's own average and total are Google's and never change. `excludedBusinessProfileReviewsShown` names\n * any excluded review that stayed.\n */\nexport function selectBusinessProfileReviews(\n feed: BusinessProfileReviews | null | undefined,\n options: SelectBusinessProfileReviewsOptions,\n): BusinessProfileReview[] {\n const exclude = assertSelectOptions(options)\n if (!feed) return []\n return fillAvoidingExcluded(policyOrder(feed, options.policy), options.limit, exclude)\n}\n\nfunction assertSelectOptions(options: SelectBusinessProfileReviewsOptions): readonly BusinessProfileReviewExclusion[] {\n if (!POLICIES.has(options.policy)) {\n throw new Error('Business Profile reviews policy must be recent or five-star.')\n }\n if (!Number.isInteger(options.limit) || options.limit < 1) {\n throw new Error('Business Profile reviews limit must be a whole number of 1 or more.')\n }\n return assertExclusions(options.exclude)\n}\n\n/** The policy's reviews, newest first, ties in feed order. */\nfunction policyOrder(feed: BusinessProfileReviews, policy: BusinessProfileReviewsPolicy): BusinessProfileReview[] {\n return feed.reviews\n .filter((review) => policy === 'recent' || review.rating === 5)\n .map((review, index) => ({ review, index, time: Date.parse(review.createTime) }))\n .sort((a, b) => b.time - a.time || a.index - b.index)\n .map(({ review }) => review)\n}\n\n/** The 3.7.0 guard: the first `limit` of `ordered`, leaving out excluded reviews only while others remain to fill it. */\nfunction fillAvoidingExcluded(\n ordered: readonly BusinessProfileReview[],\n limit: number,\n exclude: readonly BusinessProfileReviewExclusion[],\n): BusinessProfileReview[] {\n if (exclude.length === 0) return ordered.slice(0, limit)\n\n const fill = Math.min(limit, ordered.length)\n const excluded = new Set(ordered.filter((review) => findExclusion(review, exclude) !== undefined))\n let keepExcluded = Math.max(0, fill - (ordered.length - excluded.size))\n const shown: BusinessProfileReview[] = []\n for (const review of ordered) {\n if (shown.length === fill) break\n if (!excluded.has(review)) {\n shown.push(review)\n } else if (keepExcluded > 0) {\n shown.push(review)\n keepExcluded -= 1\n }\n }\n return shown\n}\n\n/** Case, spacing and Unicode composition do not tell two spellings of a word apart. */\nfunction normaliseWords(value: string): string {\n return value.normalize('NFC').replace(/\\s+/g, ' ').trim().toLowerCase()\n}\n\nfunction assertMention(mention: unknown): readonly string[] {\n if (mention === undefined) return []\n if (!Array.isArray(mention) || mention.some((term) => typeof term !== 'string')) {\n throw new Error('Business Profile reviews mention must be a list of words, such as suburb or service names.')\n }\n return (mention as readonly string[]).map((term) => term.trim()).filter((term) => term.length > 0)\n}\n\nfunction mentionPattern(mention: readonly string[]): RegExp | null {\n const words = mention.map(normaliseWords).filter((word) => word.length > 0)\n if (words.length === 0) return null\n const alternatives = words.map((word) => word.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')).join('|')\n // Whole words: no letter or digit may touch either end of the match.\n return new RegExp(`(?<![\\\\p{L}\\\\p{N}])(?:${alternatives})(?![\\\\p{L}\\\\p{N}])`, 'u')\n}\n\n/**\n * Whether a review's text names any of the words, such as a suburb, region or service (3.11.0). Case, spacing and\n * Unicode composition are ignored and only whole words match: \"Castle Hill\" matches \"castle hill's deck\" but \"Hill\"\n * does not match \"Hills\".\n */\nexport function businessProfileReviewMentions(review: BusinessProfileReview, mention: readonly string[]): boolean {\n const pattern = mentionPattern(assertMention(mention))\n return pattern ? pattern.test(normaliseWords(review.text)) : false\n}\n\n/**\n * Mention ordering (3.11.0): the reviews that name any of the words first, then the rest, each group in the order it\n * was given. It only reorders: it never adds, drops or rewrites a review, and no words leave the order unchanged.\n */\nexport function orderBusinessProfileReviewsByMention<Review extends BusinessProfileReview>(\n reviews: readonly Review[],\n mention: readonly string[] | undefined,\n): Review[] {\n const pattern = mentionPattern(assertMention(mention))\n if (!pattern) return [...reviews]\n const named: Review[] = []\n const others: Review[] = []\n for (const review of reviews) (pattern.test(normaliseWords(review.text)) ? named : others).push(review)\n return [...named, ...others]\n}\n\nexport interface PrepareBusinessProfileReviewsOptions extends SelectBusinessProfileReviewsOptions {\n /**\n * Suburb, region or service names (3.11.0): the feed's reviews that name one come first, before `limit` applies, so\n * a matching review from anywhere in the feed can be shown. Reorders only; it never adds a review the feed lacks.\n */\n mention?: readonly string[]\n}\n\n/**\n * What a reviews band shows (3.11.0): the selected reviews with Google's own average, total and profile link. The\n * numbers come only from the feed; the policy is kept so the band can say how the reviews were chosen.\n */\nexport interface PreparedBusinessProfileReviews {\n policy: BusinessProfileReviewsPolicy\n /** Google's average, between 1 and 5, when the feed has it. */\n averageRating?: number\n /** Google's total, when the feed has it. */\n totalReviewCount?: number\n /** The Business Profile on Google Maps. */\n profileUrl: string\n /** The words the reviews were ordered by (empty when none). */\n mention: readonly string[]\n /** Newest first within the policy, reviews naming a `mention` word first; at most `limit`. */\n reviews: BusinessProfileReview[]\n}\n\n/**\n * The feed's reviews ready for a reviews band: `selectBusinessProfileReviews` with mention ordering applied before\n * the limit and the 3.7.0 `exclude` guard (unchanged) applied to that order. Returns null when there is no feed, or\n * when there are no reviews to show and no Google average and total either, so the band renders nothing at all.\n * With no reviews but an average and total, the band shows the rating alone.\n */\nexport function prepareBusinessProfileReviews(\n feed: BusinessProfileReviews | null | undefined,\n options: PrepareBusinessProfileReviewsOptions,\n): PreparedBusinessProfileReviews | null {\n const exclude = assertSelectOptions(options)\n const mention = assertMention(options.mention)\n if (!feed) return null\n const ordered = orderBusinessProfileReviewsByMention(policyOrder(feed, options.policy), mention)\n const reviews = fillAvoidingExcluded(ordered, options.limit, exclude)\n const hasRating = feed.averageRating !== undefined && (feed.totalReviewCount ?? 0) > 0\n if (reviews.length === 0 && !hasRating) return null\n return {\n policy: options.policy,\n ...(feed.averageRating !== undefined ? { averageRating: feed.averageRating } : {}),\n ...(feed.totalReviewCount !== undefined ? { totalReviewCount: feed.totalReviewCount } : {}),\n profileUrl: feed.googleMapsUri,\n mention,\n reviews,\n }\n}\n\n/**\n * The shown reviews that match an exclusion, each with the first exclusion it matches: empty unless the guard in\n * `selectBusinessProfileReviews` kept an excluded review because too few others remained. Sites can log it or test it.\n */\nexport function excludedBusinessProfileReviewsShown(\n shown: readonly BusinessProfileReview[],\n exclude: readonly BusinessProfileReviewExclusion[] | undefined,\n): ExcludedBusinessProfileReviewShown[] {\n const entries = assertExclusions(exclude)\n return shown.flatMap((review) => {\n const exclusion = findExclusion(review, entries)\n return exclusion ? [{ review, exclusion }] : []\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"google-business-reviews.js","sourceRoot":"","sources":["../src/google-business-reviews.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoDH,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAA+B,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAA;AAEpG,SAAS,UAAU,CAAC,KAAc,EAAE,IAAoC;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,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C,CAAA;IACrE,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACtF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAA;IACnD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,IAAI,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3F,UAAU,EAAE,IAAI,CAAC,aAAa;QAC9B,OAAO;QACP,OAAO;KACR,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CACjD,KAAuC,EACvC,OAA8D;IAE9D,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC9B,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAChD,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACjD,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,cAAc,sCAAsC,CAAA","sourcesContent":["/**\n * Google reviews from the Business Profile API, as the Brandlab reviews feed serves them\n * (`{ status: 'available', source: 'google-business-profile', fetchedAt, googleMapsUri,\n * averageRating?, totalReviewCount?, reviews }`). Anything the feed sends that does not\n * match is treated as unavailable (the whole response) or dropped (one review), so a page\n * never shows a review it cannot vouch for. The fetch itself lives in\n * `site-next/google-business-reviews/server`.\n */\n\nexport interface BusinessProfileReview {\n id: string\n authorName: string\n /** Only an https image on a `*.googleusercontent.com` host. */\n authorPhotoUrl?: string\n rating: 1 | 2 | 3 | 4 | 5\n text: string\n /** The time Google records for the review, as the feed sent it. */\n createTime: string\n}\n\nexport interface BusinessProfileReviews {\n googleMapsUri: string\n /** Between 1 and 5 when Google supplies it. */\n averageRating?: number\n /** A whole number of reviews, 0 or more, when Google supplies it. */\n totalReviewCount?: number\n reviews: BusinessProfileReview[]\n}\n\n/** Which reviews a page shows: the newest of all, or the newest five-star ones. */\nexport type BusinessProfileReviewsPolicy = 'recent' | 'five-star'\n\n/**\n * A review a site would rather not feature (3.7.0), such as one written by a relative of the owner or of Brandlab.\n * Name exactly one of `reviewId` (that one review, matched exactly) or `authorName` (every review by that name,\n * ignoring case and spacing), and always the `reason`, so the next person knows who decided and why. The list lives\n * in the site's `src/config/reviews.ts` (`reviews.exclude`), never in brandlab.config.\n */\nexport type BusinessProfileReviewExclusion =\n | { reviewId: string; authorName?: never; reason: string }\n | { authorName: string; reviewId?: never; reason: string }\n\nexport interface SelectBusinessProfileReviewsOptions {\n policy: BusinessProfileReviewsPolicy\n /** How many reviews to show at most: a whole number, 1 or more. */\n limit: number\n /**\n * Reviews to leave out while enough others remain to fill `limit` (3.7.0). When too few others remain, the fewest\n * excluded reviews needed to fill it stay, newest first, so a page never shows fewer reviews because of the list.\n */\n exclude?: readonly BusinessProfileReviewExclusion[]\n}\n\n/** A review that was shown although it matches an exclusion, with the first exclusion it matches. */\nexport interface ExcludedBusinessProfileReviewShown {\n review: BusinessProfileReview\n exclusion: BusinessProfileReviewExclusion\n}\n\nconst POLICIES: ReadonlySet<string> = new Set<BusinessProfileReviewsPolicy>(['recent', 'five-star'])\n\nfunction isHttpsUrl(value: unknown, host?: (hostname: string) => boolean): value is string {\n if (typeof value !== 'string') return false\n try {\n const url = new URL(value)\n return url.protocol === 'https:' && (!host || host(url.hostname))\n } catch {\n return false\n }\n}\n\nfunction parseReview(value: unknown): BusinessProfileReview | null {\n if (!value || typeof value !== 'object') return null\n const record = value as Record<string, unknown>\n const rating = record.rating\n if (\n typeof record.id !== 'string' ||\n typeof record.authorName !== 'string' ||\n !record.authorName.trim() ||\n typeof record.text !== 'string' ||\n !record.text.trim() ||\n typeof record.createTime !== 'string' ||\n Number.isNaN(Date.parse(record.createTime)) ||\n (rating !== 1 && rating !== 2 && rating !== 3 && rating !== 4 && rating !== 5)\n ) {\n return null\n }\n const photo = isHttpsUrl(record.authorPhotoUrl, (host) => host.endsWith('.googleusercontent.com'))\n ? record.authorPhotoUrl\n : undefined\n return {\n id: record.id,\n authorName: record.authorName.trim(),\n ...(photo ? { authorPhotoUrl: photo } : {}),\n rating,\n text: record.text.trim(),\n createTime: record.createTime,\n }\n}\n\n/**\n * Validates a reviews feed response. Returns null for anything but an available response\n * with an https Google Maps link and a review list; drops each review that is not complete\n * (id, author, text, a valid time and a whole-star rating from 1 to 5). An author photo\n * outside `*.googleusercontent.com`, an average outside 1 to 5 and a total that is not a\n * whole number of 0 or more are left out.\n */\nexport function parseBusinessProfileReviews(value: unknown): BusinessProfileReviews | null {\n if (!value || typeof value !== 'object') return null\n const record = value as Record<string, unknown>\n if (record.status !== 'available' || !isHttpsUrl(record.googleMapsUri) || !Array.isArray(record.reviews)) {\n return null\n }\n const average = record.averageRating\n const total = record.totalReviewCount\n return {\n googleMapsUri: record.googleMapsUri,\n ...(typeof average === 'number' && average >= 1 && average <= 5 ? { averageRating: average } : {}),\n ...(typeof total === 'number' && Number.isInteger(total) && total >= 0 ? { totalReviewCount: total } : {}),\n reviews: record.reviews\n .map(parseReview)\n .filter((review): review is BusinessProfileReview => review !== null),\n }\n}\n\nconst EXCLUSION_KEYS: ReadonlySet<string> = new Set(['reviewId', 'authorName', 'reason'])\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0\n}\n\n/** Case, spacing and Unicode composition do not tell two author names apart. */\nfunction normaliseAuthorName(name: string): string {\n return name.normalize('NFC').replace(/\\s+/g, ' ').trim().toLowerCase()\n}\n\nfunction assertExclusions(exclude: unknown): readonly BusinessProfileReviewExclusion[] {\n if (exclude === undefined) return []\n if (!Array.isArray(exclude)) {\n throw new Error('Business Profile reviews exclude must be a list.')\n }\n exclude.forEach((entry: unknown, index) => {\n const field = `Business Profile reviews exclude[${index}]`\n if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {\n throw new Error(`${field} must be an object with reviewId or authorName and a reason.`)\n }\n const record = entry as Record<string, unknown>\n const unknown = Object.keys(record).find((key) => !EXCLUSION_KEYS.has(key))\n if (unknown) throw new Error(`${field} has an unknown field: ${unknown}.`)\n const hasId = record.reviewId !== undefined\n const hasName = record.authorName !== undefined\n if (hasId === hasName) {\n throw new Error(`${field} must name exactly one of reviewId or authorName.`)\n }\n if (hasId && !isNonEmptyString(record.reviewId)) throw new Error(`${field}.reviewId must be a non-empty string.`)\n if (hasName && !isNonEmptyString(record.authorName)) throw new Error(`${field}.authorName must be a non-empty string.`)\n if (!isNonEmptyString(record.reason)) {\n throw new Error(`${field}.reason is required: say who decided to exclude it and why.`)\n }\n })\n return exclude as readonly BusinessProfileReviewExclusion[]\n}\n\nfunction findExclusion(\n review: BusinessProfileReview,\n exclude: readonly BusinessProfileReviewExclusion[],\n): BusinessProfileReviewExclusion | undefined {\n if (exclude.length === 0) return undefined\n const author = normaliseAuthorName(review.authorName)\n return exclude.find((entry) =>\n entry.reviewId !== undefined\n ? entry.reviewId === review.id\n : normaliseAuthorName(entry.authorName) === author,\n )\n}\n\n/**\n * The reviews a page shows, newest first and word for word: every review (`recent`) or only the five-star ones\n * (`five-star`), at most `limit`. No feed gives no reviews.\n *\n * `exclude` (3.7.0) leaves out the reviews it names only while enough other reviews remain to fill `limit`; otherwise\n * the fewest excluded reviews needed to fill it stay (the newest of them), so the page shows as many reviews as it\n * would without the list, all in the policy's order. A kept review was already among those shown without the list.\n * The profile's own average and total are Google's and never change. `excludedBusinessProfileReviewsShown` names\n * any excluded review that stayed.\n */\nexport function selectBusinessProfileReviews(\n feed: BusinessProfileReviews | null | undefined,\n options: SelectBusinessProfileReviewsOptions,\n): BusinessProfileReview[] {\n const exclude = assertSelectOptions(options)\n if (!feed) return []\n return fillAvoidingExcluded(policyOrder(feed, options.policy), options.limit, exclude)\n}\n\nfunction assertSelectOptions(options: SelectBusinessProfileReviewsOptions): readonly BusinessProfileReviewExclusion[] {\n if (!POLICIES.has(options.policy)) {\n throw new Error('Business Profile reviews policy must be recent or five-star.')\n }\n if (!Number.isInteger(options.limit) || options.limit < 1) {\n throw new Error('Business Profile reviews limit must be a whole number of 1 or more.')\n }\n return assertExclusions(options.exclude)\n}\n\n/** The policy's reviews, newest first, ties in feed order. */\nfunction policyOrder(feed: BusinessProfileReviews, policy: BusinessProfileReviewsPolicy): BusinessProfileReview[] {\n return feed.reviews\n .filter((review) => policy === 'recent' || review.rating === 5)\n .map((review, index) => ({ review, index, time: Date.parse(review.createTime) }))\n .sort((a, b) => b.time - a.time || a.index - b.index)\n .map(({ review }) => review)\n}\n\n/** The 3.7.0 guard: the first `limit` of `ordered`, leaving out excluded reviews only while others remain to fill it. */\nfunction fillAvoidingExcluded(\n ordered: readonly BusinessProfileReview[],\n limit: number,\n exclude: readonly BusinessProfileReviewExclusion[],\n): BusinessProfileReview[] {\n if (exclude.length === 0) return ordered.slice(0, limit)\n\n const fill = Math.min(limit, ordered.length)\n const excluded = new Set(ordered.filter((review) => findExclusion(review, exclude) !== undefined))\n let keepExcluded = Math.max(0, fill - (ordered.length - excluded.size))\n const shown: BusinessProfileReview[] = []\n for (const review of ordered) {\n if (shown.length === fill) break\n if (!excluded.has(review)) {\n shown.push(review)\n } else if (keepExcluded > 0) {\n shown.push(review)\n keepExcluded -= 1\n }\n }\n return shown\n}\n\n/** Case, spacing and Unicode composition do not tell two spellings of a word apart. */\nfunction normaliseWords(value: string): string {\n return value.normalize('NFC').replace(/\\s+/g, ' ').trim().toLowerCase()\n}\n\nfunction assertMention(mention: unknown): readonly string[] {\n if (mention === undefined) return []\n if (!Array.isArray(mention) || mention.some((term) => typeof term !== 'string')) {\n throw new Error('Business Profile reviews mention must be a list of words, such as suburb or service names.')\n }\n return (mention as readonly string[]).map((term) => term.trim()).filter((term) => term.length > 0)\n}\n\nfunction mentionPattern(mention: readonly string[]): RegExp | null {\n const words = mention.map(normaliseWords).filter((word) => word.length > 0)\n if (words.length === 0) return null\n const alternatives = words.map((word) => word.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')).join('|')\n // Whole words: no letter or digit may touch either end of the match.\n return new RegExp(`(?<![\\\\p{L}\\\\p{N}])(?:${alternatives})(?![\\\\p{L}\\\\p{N}])`, 'u')\n}\n\n/**\n * Whether a review's text names any of the words, such as a suburb, region or service (3.11.0). Case, spacing and\n * Unicode composition are ignored and only whole words match: \"Castle Hill\" matches \"castle hill's deck\" but \"Hill\"\n * does not match \"Hills\".\n */\nexport function businessProfileReviewMentions(review: BusinessProfileReview, mention: readonly string[]): boolean {\n const pattern = mentionPattern(assertMention(mention))\n return pattern ? pattern.test(normaliseWords(review.text)) : false\n}\n\n/**\n * Mention ordering (3.11.0): the reviews that name any of the words first, then the rest, each group in the order it\n * was given. It only reorders: it never adds, drops or rewrites a review, and no words leave the order unchanged.\n */\nexport function orderBusinessProfileReviewsByMention<Review extends BusinessProfileReview>(\n reviews: readonly Review[],\n mention: readonly string[] | undefined,\n): Review[] {\n const pattern = mentionPattern(assertMention(mention))\n if (!pattern) return [...reviews]\n const named: Review[] = []\n const others: Review[] = []\n for (const review of reviews) (pattern.test(normaliseWords(review.text)) ? named : others).push(review)\n return [...named, ...others]\n}\n\nexport interface PrepareBusinessProfileReviewsOptions extends SelectBusinessProfileReviewsOptions {\n /**\n * Suburb, region or service names (3.11.0): the feed's reviews that name one come first, before `limit` applies, so\n * a matching review from anywhere in the feed can be shown. Reorders only; it never adds a review the feed lacks.\n */\n mention?: readonly string[]\n}\n\n/**\n * What a reviews band shows (3.11.0): the selected reviews with Google's own average, total and profile link. The\n * numbers come only from the feed; the policy is kept so the band can say how the reviews were chosen.\n */\nexport interface PreparedBusinessProfileReviews {\n policy: BusinessProfileReviewsPolicy\n /** Google's average, between 1 and 5, when the feed has it. */\n averageRating?: number\n /** Google's total, when the feed has it. */\n totalReviewCount?: number\n /** The Business Profile on Google Maps. */\n profileUrl: string\n /** The words the reviews were ordered by (empty when none). */\n mention: readonly string[]\n /** Newest first within the policy, reviews naming a `mention` word first; at most `limit`. */\n reviews: BusinessProfileReview[]\n}\n\n/**\n * The feed's reviews ready for a reviews band: `selectBusinessProfileReviews` with mention ordering applied before\n * the limit and the 3.7.0 `exclude` guard (unchanged) applied to that order. Returns null when there is no feed, or\n * when there are no reviews to show and no Google average and total either, so the band renders nothing at all.\n * With no reviews but an average and total, the band shows the rating alone.\n */\nexport function prepareBusinessProfileReviews(\n feed: BusinessProfileReviews | null | undefined,\n options: PrepareBusinessProfileReviewsOptions,\n): PreparedBusinessProfileReviews | null {\n const exclude = assertSelectOptions(options)\n const mention = assertMention(options.mention)\n if (!feed) return null\n const ordered = orderBusinessProfileReviewsByMention(policyOrder(feed, options.policy), mention)\n const reviews = fillAvoidingExcluded(ordered, options.limit, exclude)\n const hasRating = feed.averageRating !== undefined && (feed.totalReviewCount ?? 0) > 0\n if (reviews.length === 0 && !hasRating) return null\n return {\n policy: options.policy,\n ...(feed.averageRating !== undefined ? { averageRating: feed.averageRating } : {}),\n ...(feed.totalReviewCount !== undefined ? { totalReviewCount: feed.totalReviewCount } : {}),\n profileUrl: feed.googleMapsUri,\n mention,\n reviews,\n }\n}\n\n/**\n * The shown reviews that match an exclusion, each with the first exclusion it matches: empty unless the guard in\n * `selectBusinessProfileReviews` kept an excluded review because too few others remained. Sites can log it or test it.\n */\nexport function excludedBusinessProfileReviewsShown(\n shown: readonly BusinessProfileReview[],\n exclude: readonly BusinessProfileReviewExclusion[] | undefined,\n): ExcludedBusinessProfileReviewShown[] {\n const entries = assertExclusions(exclude)\n return shown.flatMap((review) => {\n const exclusion = findExclusion(review, entries)\n return exclusion ? [{ review, exclusion }] : []\n })\n}\n\nexport * from './google-business-reviews-refresh.js'\n"]}
|
package/dist/project.d.ts
CHANGED
|
@@ -48,6 +48,70 @@ export interface BrandlabSiteSystemConfig {
|
|
|
48
48
|
thirdParties?: readonly string[];
|
|
49
49
|
/** Extra tel: links the site legitimately shows, for example a second line. */
|
|
50
50
|
phones?: readonly string[];
|
|
51
|
+
/**
|
|
52
|
+
* Estate families allowed to refresh more often than every 7 days (check W3, from 3.13.0), each with the reason
|
|
53
|
+
* and the recorded decision. Without an entry, a full-tier estate family refreshes at most weekly.
|
|
54
|
+
*/
|
|
55
|
+
refreshExceptions?: readonly BrandlabEstateRefreshException[];
|
|
56
|
+
}
|
|
57
|
+
/** The location estate families check W3 covers. */
|
|
58
|
+
export declare const BRANDLAB_ESTATE_REFRESH_FAMILIES: readonly ["suburb", "service-in-suburb", "region", "council"];
|
|
59
|
+
export type BrandlabEstateRefreshFamily = (typeof BRANDLAB_ESTATE_REFRESH_FAMILIES)[number];
|
|
60
|
+
/** The shortest refresh an estate family may use without an exception: 7 days, in seconds. */
|
|
61
|
+
export declare const BRANDLAB_ESTATE_MIN_REFRESH_SECONDS = 604800;
|
|
62
|
+
export interface BrandlabEstateRefreshException {
|
|
63
|
+
family: BrandlabEstateRefreshFamily;
|
|
64
|
+
/** The shortest refresh the family may use, in whole seconds (60 to 604,799). */
|
|
65
|
+
revalidateSeconds: number;
|
|
66
|
+
/** Why the family needs to refresh more often than weekly. */
|
|
67
|
+
reason: string;
|
|
68
|
+
/** The recorded decision that allows it, for example a Notion decision id. */
|
|
69
|
+
decisionId: string;
|
|
70
|
+
}
|
|
71
|
+
/** A Vercel function region a Brandlab site may run in: Sydney, or Washington with a recorded decision. */
|
|
72
|
+
export type BrandlabOriginRegion = 'syd1' | 'iad1';
|
|
73
|
+
/** `hosting.originRegion`: one region, or both (`['syd1', 'iad1']`; the ISR store then always goes to iad1). */
|
|
74
|
+
export type BrandlabOriginRegionSetting = BrandlabOriginRegion | readonly BrandlabOriginRegion[];
|
|
75
|
+
/** The region every site runs in unless a decision records another: Sydney, where the visitors are. */
|
|
76
|
+
export declare const BRANDLAB_DEFAULT_ORIGIN_REGION = "syd1";
|
|
77
|
+
/** The longest a non-Sydney origin decision lasts before it is reviewed: six calendar months. */
|
|
78
|
+
export declare const BRANDLAB_ORIGIN_DECISION_MAX_MONTHS = 6;
|
|
79
|
+
/**
|
|
80
|
+
* A recorded origin-region decision under rule `origin-region-v1` (operations/shared-platform/ORIGIN_REGION.md).
|
|
81
|
+
* Any region other than Sydney needs one; it lapses on `reviewBy`, at most six months after `decidedOn`.
|
|
82
|
+
*/
|
|
83
|
+
export interface BrandlabOriginRegionDecision {
|
|
84
|
+
rule: 'origin-region-v1';
|
|
85
|
+
/** YYYY-MM-DD. */
|
|
86
|
+
decidedOn: string;
|
|
87
|
+
/** Where the benchmark and the decision are recorded (a Notion page, a PR or a report path). */
|
|
88
|
+
evidence: string;
|
|
89
|
+
/** The expected saving per billing cycle in US dollars (at least US$2 under the rule). */
|
|
90
|
+
savingUsdPerCycle: number;
|
|
91
|
+
/** How much slower a cold miss was in the benchmark, in milliseconds (at most 250 under the rule). */
|
|
92
|
+
coldMissDeltaMs: number;
|
|
93
|
+
/** YYYY-MM-DD, after `decidedOn` and no more than six months after it. The ready gate fails once it passes. */
|
|
94
|
+
reviewBy: string;
|
|
95
|
+
}
|
|
96
|
+
/** A firewall rule recorded for the ready gate's crawler guard (W10): what it matches in the user agent and does. */
|
|
97
|
+
export interface BrandlabFirewallRuleRecord {
|
|
98
|
+
/** The rule's name or id in the Vercel or Cloudflare firewall. */
|
|
99
|
+
id: string;
|
|
100
|
+
action: 'deny' | 'challenge' | 'rate-limit' | 'log' | 'bypass';
|
|
101
|
+
/** How the rule matches the User-Agent header, as the firewall writes it. */
|
|
102
|
+
userAgent: {
|
|
103
|
+
match: 'contains' | 'equals' | 'regex';
|
|
104
|
+
value: string;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Where the site's server functions run (3.13.0). `vercel.json` `regions` must equal `originRegion`; the default is
|
|
109
|
+
* Sydney. Firewall rules that match on the user agent are recorded here so the ready gate can check them.
|
|
110
|
+
*/
|
|
111
|
+
export interface BrandlabHostingConfig {
|
|
112
|
+
originRegion: BrandlabOriginRegionSetting;
|
|
113
|
+
decision?: BrandlabOriginRegionDecision;
|
|
114
|
+
firewall?: readonly BrandlabFirewallRuleRecord[];
|
|
51
115
|
}
|
|
52
116
|
export type BrandlabSitemapConfig = {
|
|
53
117
|
mode: 'single';
|
|
@@ -86,7 +150,19 @@ export interface BrandlabProjectConfig {
|
|
|
86
150
|
};
|
|
87
151
|
exceptions?: readonly BrandlabException[];
|
|
88
152
|
siteSystem?: BrandlabSiteSystemConfig;
|
|
153
|
+
/** Where the server functions run; absent means Sydney (`syd1`). */
|
|
154
|
+
hosting?: BrandlabHostingConfig;
|
|
89
155
|
}
|
|
156
|
+
/** The last day a decision taken on `decidedOn` may be reviewed by: the same day six months later (or month end). */
|
|
157
|
+
export declare function brandlabOriginDecisionReviewLimit(decidedOn: string): string;
|
|
158
|
+
/** The regions `hosting.originRegion` names, sorted; Sydney alone when there is no hosting block. */
|
|
159
|
+
export declare function brandlabOriginRegions(hosting?: Pick<BrandlabHostingConfig, 'originRegion'>): BrandlabOriginRegion[];
|
|
160
|
+
/**
|
|
161
|
+
* Problems with a site's hosting record on `today` (YYYY-MM-DD): the ready gate (W5) fails on any. A region other
|
|
162
|
+
* than Sydney needs an `origin-region-v1` decision whose `reviewBy` has not passed and is no more than six months
|
|
163
|
+
* after `decidedOn`. The shape is checked too, because the gate reads the config without running it.
|
|
164
|
+
*/
|
|
165
|
+
export declare function brandlabHostingProblems(hosting: unknown, today: string): string[];
|
|
90
166
|
/**
|
|
91
167
|
* Defines project-owned variation only. Runtime versions and global Brandlab
|
|
92
168
|
* policy deliberately do not belong in this object.
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAEhF,MAAM,MAAM,mBAAmB,GAC3B,UAAU,GACV,WAAW,GACX,mBAAmB,GACnB,MAAM,GACN,UAAU,GACV,OAAO,CAAA;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAA;AAC/D,MAAM,MAAM,6BAA6B,GACrC,MAAM,GACN,iBAAiB,GACjB,iBAAiB,GACjB,0BAA0B,CAAA;AAC9B,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,uBAAuB,GACvB,mBAAmB,GACnB,gBAAgB,CAAA;AACpB,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,yBAAyB,GAAG,eAAe,CAAA;AACnG,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAAA;AAExE,MAAM,MAAM,yBAAyB,GACjC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,GAC7B;IACE,0HAA0H;IAC1H,QAAQ,EAAE,yBAAyB,CAAA;IACnC,sFAAsF;IACtF,SAAS,CAAC,EAAE,4BAA4B,CAAA;CACzC,GACD;IACE,QAAQ,EAAE,eAAe,CAAA;IACzB,IAAI,EAAE,yBAAyB,CAAA;IAC/B,oFAAoF;IACpF,SAAS,CAAC,EAAE,2BAA2B,CAAA;IACvC,sEAAsE;IACtE,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAC5B,CAAA;AAEL,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,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pE,OAAO,CAAC,EAAE,qBAAqB,CAAA;CAChC;AAyED,qHAAqH;AACrH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS3E;AAED,qGAAqG;AACrG,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG,oBAAoB,EAAE,CAGnH;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA6EjF;AAsED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,CAAC,CAAC,SAAS,qBAAqB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAsLzF"}
|
package/dist/project.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { normalizeBrandlabRoutePath } from './routes.js';
|
|
2
2
|
import { assertBrandlabCanonicalEntityId } from './entity-id.js';
|
|
3
|
+
/** The location estate families check W3 covers. */
|
|
4
|
+
export const BRANDLAB_ESTATE_REFRESH_FAMILIES = ['suburb', 'service-in-suburb', 'region', 'council'];
|
|
5
|
+
/** The shortest refresh an estate family may use without an exception: 7 days, in seconds. */
|
|
6
|
+
export const BRANDLAB_ESTATE_MIN_REFRESH_SECONDS = 604_800;
|
|
7
|
+
/** The region every site runs in unless a decision records another: Sydney, where the visitors are. */
|
|
8
|
+
export const BRANDLAB_DEFAULT_ORIGIN_REGION = 'syd1';
|
|
9
|
+
/** The longest a non-Sydney origin decision lasts before it is reviewed: six calendar months. */
|
|
10
|
+
export const BRANDLAB_ORIGIN_DECISION_MAX_MONTHS = 6;
|
|
3
11
|
const PROJECT_CONFIG_KEYS = [
|
|
4
12
|
'projectId',
|
|
5
13
|
'routes',
|
|
@@ -8,6 +16,7 @@ const PROJECT_CONFIG_KEYS = [
|
|
|
8
16
|
'searchCertification',
|
|
9
17
|
'exceptions',
|
|
10
18
|
'siteSystem',
|
|
19
|
+
'hosting',
|
|
11
20
|
];
|
|
12
21
|
const ROUTE_FAMILIES = new Set([
|
|
13
22
|
'services',
|
|
@@ -49,9 +58,141 @@ const BUSINESS_PROFILE_REVIEWS_SELECTIONS = new Set([
|
|
|
49
58
|
'five-star',
|
|
50
59
|
]);
|
|
51
60
|
const SITE_SYSTEM_TIERS = new Set(['shell', 'enquiry', 'full']);
|
|
52
|
-
const SITE_SYSTEM_KEYS = ['tier', 'newBuild', 'samples', 'labels', 'freeQuotes', 'thirdParties', 'phones'];
|
|
61
|
+
const SITE_SYSTEM_KEYS = ['tier', 'newBuild', 'samples', 'labels', 'freeQuotes', 'thirdParties', 'phones', 'refreshExceptions'];
|
|
62
|
+
const REFRESH_EXCEPTION_KEYS = ['family', 'revalidateSeconds', 'reason', 'decisionId'];
|
|
53
63
|
const HOSTNAME_PATTERN = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
|
54
64
|
const TEL_HREF_PATTERN = /^tel:\+?\d{6,15}$/;
|
|
65
|
+
const ORIGIN_REGIONS = new Set(['syd1', 'iad1']);
|
|
66
|
+
const HOSTING_KEYS = ['originRegion', 'decision', 'firewall'];
|
|
67
|
+
const DECISION_KEYS = ['rule', 'decidedOn', 'evidence', 'savingUsdPerCycle', 'coldMissDeltaMs', 'reviewBy'];
|
|
68
|
+
const FIREWALL_ACTIONS = new Set(['deny', 'challenge', 'rate-limit', 'log', 'bypass']);
|
|
69
|
+
const FIREWALL_MATCHES = new Set(['contains', 'equals', 'regex']);
|
|
70
|
+
const ISO_DAY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
71
|
+
/** A YYYY-MM-DD calendar day as a UTC timestamp, or null when it is not a real day. */
|
|
72
|
+
function isoDay(value) {
|
|
73
|
+
if (typeof value !== 'string')
|
|
74
|
+
return null;
|
|
75
|
+
const match = ISO_DAY.exec(value);
|
|
76
|
+
if (!match)
|
|
77
|
+
return null;
|
|
78
|
+
const time = Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
|
|
79
|
+
return new Date(time).toISOString().slice(0, 10) === value ? time : null;
|
|
80
|
+
}
|
|
81
|
+
/** The last day a decision taken on `decidedOn` may be reviewed by: the same day six months later (or month end). */
|
|
82
|
+
export function brandlabOriginDecisionReviewLimit(decidedOn) {
|
|
83
|
+
const start = isoDay(decidedOn);
|
|
84
|
+
if (start === null)
|
|
85
|
+
throw new Error('decidedOn must be a YYYY-MM-DD date.');
|
|
86
|
+
const date = new Date(start);
|
|
87
|
+
const day = date.getUTCDate();
|
|
88
|
+
const target = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + BRANDLAB_ORIGIN_DECISION_MAX_MONTHS, 1));
|
|
89
|
+
const lastDay = new Date(Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate();
|
|
90
|
+
target.setUTCDate(Math.min(day, lastDay));
|
|
91
|
+
return target.toISOString().slice(0, 10);
|
|
92
|
+
}
|
|
93
|
+
/** The regions `hosting.originRegion` names, sorted; Sydney alone when there is no hosting block. */
|
|
94
|
+
export function brandlabOriginRegions(hosting) {
|
|
95
|
+
const setting = hosting?.originRegion ?? BRANDLAB_DEFAULT_ORIGIN_REGION;
|
|
96
|
+
return [...new Set(typeof setting === 'string' ? [setting] : setting)].sort();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Problems with a site's hosting record on `today` (YYYY-MM-DD): the ready gate (W5) fails on any. A region other
|
|
100
|
+
* than Sydney needs an `origin-region-v1` decision whose `reviewBy` has not passed and is no more than six months
|
|
101
|
+
* after `decidedOn`. The shape is checked too, because the gate reads the config without running it.
|
|
102
|
+
*/
|
|
103
|
+
export function brandlabHostingProblems(hosting, today) {
|
|
104
|
+
if (hosting === undefined)
|
|
105
|
+
return [];
|
|
106
|
+
if (!hosting || typeof hosting !== 'object' || Array.isArray(hosting))
|
|
107
|
+
return ['hosting must be an object with an originRegion.'];
|
|
108
|
+
const record = hosting;
|
|
109
|
+
const problems = [];
|
|
110
|
+
const unknown = Object.keys(record).filter((key) => !HOSTING_KEYS.includes(key));
|
|
111
|
+
if (unknown.length > 0)
|
|
112
|
+
problems.push(`hosting contains unsupported keys: ${unknown.join(', ')}.`);
|
|
113
|
+
const setting = record.originRegion;
|
|
114
|
+
const list = typeof setting === 'string' ? [setting] : Array.isArray(setting) ? setting : null;
|
|
115
|
+
if (!list ||
|
|
116
|
+
list.length === 0 ||
|
|
117
|
+
list.some((region) => !ORIGIN_REGIONS.has(region)) ||
|
|
118
|
+
new Set(list).size !== list.length) {
|
|
119
|
+
problems.push(`hosting.originRegion must be 'syd1', 'iad1' or ['syd1', 'iad1'] (found ${JSON.stringify(setting)}).`);
|
|
120
|
+
return problems;
|
|
121
|
+
}
|
|
122
|
+
const sydneyOnly = list.length === 1 && list[0] === BRANDLAB_DEFAULT_ORIGIN_REGION;
|
|
123
|
+
const decision = record.decision;
|
|
124
|
+
if (decision === undefined) {
|
|
125
|
+
if (!sydneyOnly) {
|
|
126
|
+
problems.push(`hosting.originRegion ${JSON.stringify(setting)} needs a recorded origin-region-v1 decision (hosting.decision); only syd1 runs without one.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (!decision || typeof decision !== 'object' || Array.isArray(decision)) {
|
|
130
|
+
problems.push('hosting.decision must be an object.');
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const entry = decision;
|
|
134
|
+
const extra = Object.keys(entry).filter((key) => !DECISION_KEYS.includes(key));
|
|
135
|
+
if (extra.length > 0)
|
|
136
|
+
problems.push(`hosting.decision contains unsupported keys: ${extra.join(', ')}.`);
|
|
137
|
+
if (entry.rule !== 'origin-region-v1')
|
|
138
|
+
problems.push(`hosting.decision.rule must be 'origin-region-v1' (found ${JSON.stringify(entry.rule)}).`);
|
|
139
|
+
if (typeof entry.evidence !== 'string' || !entry.evidence.trim())
|
|
140
|
+
problems.push('hosting.decision.evidence must name where the benchmark and decision are recorded.');
|
|
141
|
+
for (const key of ['savingUsdPerCycle', 'coldMissDeltaMs']) {
|
|
142
|
+
if (typeof entry[key] !== 'number' || !Number.isFinite(entry[key]))
|
|
143
|
+
problems.push(`hosting.decision.${key} must be a number.`);
|
|
144
|
+
}
|
|
145
|
+
const decided = isoDay(entry.decidedOn);
|
|
146
|
+
const review = isoDay(entry.reviewBy);
|
|
147
|
+
if (decided === null)
|
|
148
|
+
problems.push('hosting.decision.decidedOn must be a YYYY-MM-DD date.');
|
|
149
|
+
if (review === null)
|
|
150
|
+
problems.push('hosting.decision.reviewBy must be a YYYY-MM-DD date.');
|
|
151
|
+
if (decided !== null && review !== null) {
|
|
152
|
+
const limit = brandlabOriginDecisionReviewLimit(entry.decidedOn);
|
|
153
|
+
if (review <= decided)
|
|
154
|
+
problems.push(`hosting.decision.reviewBy (${entry.reviewBy}) must be after decidedOn (${entry.decidedOn}).`);
|
|
155
|
+
else if (entry.reviewBy > limit) {
|
|
156
|
+
problems.push(`hosting.decision.reviewBy (${entry.reviewBy}) is more than ${BRANDLAB_ORIGIN_DECISION_MAX_MONTHS} months after decidedOn (${entry.decidedOn}); review by ${limit} at the latest.`);
|
|
157
|
+
}
|
|
158
|
+
if (!sydneyOnly && isoDay(today) !== null && today > entry.reviewBy) {
|
|
159
|
+
problems.push(`The origin-region decision for ${JSON.stringify(setting)} lapsed on ${entry.reviewBy}: review it under origin-region-v1 and record a new reviewBy, or move back to syd1.`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const firewall = record.firewall;
|
|
164
|
+
if (firewall !== undefined) {
|
|
165
|
+
if (!Array.isArray(firewall))
|
|
166
|
+
problems.push('hosting.firewall must be a list of recorded rules.');
|
|
167
|
+
else {
|
|
168
|
+
firewall.forEach((rule, index) => {
|
|
169
|
+
const field = `hosting.firewall[${index}]`;
|
|
170
|
+
if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
|
|
171
|
+
problems.push(`${field} must be an object.`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const entry = rule;
|
|
175
|
+
if (typeof entry.id !== 'string' || !entry.id.trim())
|
|
176
|
+
problems.push(`${field}.id must name the firewall rule.`);
|
|
177
|
+
if (!FIREWALL_ACTIONS.has(entry.action))
|
|
178
|
+
problems.push(`${field}.action must be one of ${[...FIREWALL_ACTIONS].join(', ')}.`);
|
|
179
|
+
const userAgent = entry.userAgent;
|
|
180
|
+
if (!userAgent || typeof userAgent !== 'object' || !FIREWALL_MATCHES.has(userAgent.match) || typeof userAgent.value !== 'string' || !userAgent.value) {
|
|
181
|
+
problems.push(`${field}.userAgent must be { match: 'contains' | 'equals' | 'regex', value }.`);
|
|
182
|
+
}
|
|
183
|
+
else if (userAgent.match === 'regex') {
|
|
184
|
+
try {
|
|
185
|
+
new RegExp(userAgent.value);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
problems.push(`${field}.userAgent.value is not a valid regular expression.`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return problems;
|
|
195
|
+
}
|
|
55
196
|
function assertNonEmpty(value, field) {
|
|
56
197
|
if (!value.trim()) {
|
|
57
198
|
throw new Error(`${field} cannot be empty.`);
|
|
@@ -71,6 +212,32 @@ function assertKnownKeys(value, allowed, field, hint = '') {
|
|
|
71
212
|
throw new Error(`${field} contains unsupported keys: ${unsupported.join(', ')}.${hint}`);
|
|
72
213
|
}
|
|
73
214
|
}
|
|
215
|
+
function assertRefreshExceptions(value) {
|
|
216
|
+
const field = 'siteSystem.refreshExceptions';
|
|
217
|
+
if (!Array.isArray(value))
|
|
218
|
+
throw new Error(`${field} must be a list.`);
|
|
219
|
+
value.forEach((entry, index) => {
|
|
220
|
+
const itemField = `${field}[${index}]`;
|
|
221
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
222
|
+
throw new Error(`${itemField} must be an object with family, revalidateSeconds, reason and decisionId.`);
|
|
223
|
+
}
|
|
224
|
+
assertKnownKeys(entry, REFRESH_EXCEPTION_KEYS, itemField);
|
|
225
|
+
const exception = entry;
|
|
226
|
+
if (!BRANDLAB_ESTATE_REFRESH_FAMILIES.includes(exception.family)) {
|
|
227
|
+
throw new Error(`${itemField}.family must be one of ${BRANDLAB_ESTATE_REFRESH_FAMILIES.join(', ')}.`);
|
|
228
|
+
}
|
|
229
|
+
const seconds = exception.revalidateSeconds;
|
|
230
|
+
if (!Number.isSafeInteger(seconds) || seconds < 60 || seconds >= BRANDLAB_ESTATE_MIN_REFRESH_SECONDS) {
|
|
231
|
+
throw new Error(`${itemField}.revalidateSeconds must be whole seconds from 60 to 604799; weekly or slower needs no exception.`);
|
|
232
|
+
}
|
|
233
|
+
for (const key of ['reason', 'decisionId']) {
|
|
234
|
+
if (typeof exception[key] !== 'string')
|
|
235
|
+
throw new Error(`${itemField}.${key} must be text.`);
|
|
236
|
+
assertNonEmpty(exception[key], `${itemField}.${key}`);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
assertUnique(value.map((entry) => entry.family), `${field}.family`);
|
|
240
|
+
}
|
|
74
241
|
function assertStringList(value, field, check) {
|
|
75
242
|
if (!Array.isArray(value)) {
|
|
76
243
|
throw new Error(`${field} must be a list.`);
|
|
@@ -218,6 +385,15 @@ export function defineBrandlabProject(config) {
|
|
|
218
385
|
throw new Error(`${field} must be a tel: link such as tel:+61290001234.`);
|
|
219
386
|
});
|
|
220
387
|
}
|
|
388
|
+
if (siteSystem.refreshExceptions !== undefined) {
|
|
389
|
+
assertRefreshExceptions(siteSystem.refreshExceptions);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (config.hosting !== undefined) {
|
|
393
|
+
// The date-bound lapse is the ready gate's (W5): a lapsed decision must not stop a build or a rollback.
|
|
394
|
+
const problems = brandlabHostingProblems(config.hosting, '0000-01-01');
|
|
395
|
+
if (problems.length > 0)
|
|
396
|
+
throw new Error(problems[0]);
|
|
221
397
|
}
|
|
222
398
|
assertUnique((config.exceptions ?? []).map((exception) => exception.ruleId), 'exceptions.ruleId');
|
|
223
399
|
(config.exceptions ?? []).forEach((exception, index) => {
|
package/dist/project.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AA8GhE,MAAM,mBAAmB,GAAG;IAC1B,WAAW;IACX,QAAQ;IACR,cAAc;IACd,SAAS;IACT,qBAAqB;IACrB,YAAY;IACZ,YAAY;CACJ,CAAA;AACV,MAAM,cAAc,GAAG,IAAI,GAAG,CAAsB;IAClD,UAAU;IACV,WAAW;IACX,mBAAmB;IACnB,MAAM;IACN,UAAU;IACV,OAAO;CACR,CAAC,CAAA;AACF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAA;AACjF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAgC;IAC9D,MAAM;IACN,iBAAiB;IACjB,iBAAiB;IACjB,0BAA0B;CAC3B,CAAC,CAAA;AACF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAA2B;IAC5D,MAAM;IACN,uBAAuB;IACvB,mBAAmB;IACnB,gBAAgB;CACjB,CAAC,CAAA;AACF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAA0B;IACzD,eAAe;IACf,yBAAyB;IACzB,eAAe;CAChB,CAAC,CAAA;AACF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAA4B;IAC9D,WAAW;IACX,SAAS;IACT,MAAM;CACP,CAAC,CAAA;AACF,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAA8B;IACrE,WAAW;IACX,oBAAoB;CACrB,CAAC,CAAA;AACF,MAAM,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C","sourcesContent":["import { normalizeBrandlabRoutePath } from './routes.js'\nimport { assertBrandlabCanonicalEntityId } from './entity-id.js'\nimport type { GooglePlaceReviewsSelection } from './google-reviews.js'\nimport type { BusinessProfileReviewsPolicy } from './google-business-reviews.js'\n\nexport type BrandlabRouteFamily =\n | 'services'\n | 'locations'\n | 'service-locations'\n | 'blog'\n | 'projects'\n | 'legal'\n\nexport type BrandlabBlogAdapter = 'none' | 'mdx' | 'structured'\nexport type BrandlabContactAttachmentMode =\n | 'none'\n | 'images-optional'\n | 'images-required'\n | 'images-and-pdfs-optional'\nexport type BrandlabLocationStrategy =\n | 'none'\n | 'approved-service-area'\n | 'physical-location'\n | 'multi-location'\nexport type BrandlabReviewsProvider = 'google-places' | 'google-business-profile' | 'project-owned'\nexport type BrandlabGoogleReviewsMode = 'link-only' | 'summary' | 'full'\n\nexport type BrandlabReviewsCapability =\n | { provider: 'project-owned' }\n | {\n /** 3.5.0: Google reviews read on the server from the Brandlab reviews feed (site-next/google-business-reviews/server). */\n provider: 'google-business-profile'\n /** Optional presentation policy: the newest reviews, or the newest five-star ones. */\n selection?: BusinessProfileReviewsPolicy\n }\n | {\n provider: 'google-places'\n mode: BrandlabGoogleReviewsMode\n /** Optional presentation policy. Five-star selection is valid only in full mode. */\n selection?: GooglePlaceReviewsSelection\n /** Stable route IDs where review proof is intentionally presented. */\n routeIds: readonly string[]\n }\n\nexport interface BrandlabException {\n ruleId: string\n rationale: string\n owner: 'Romie'\n evidence: string\n expiresAt?: string\n reviewTrigger: string\n}\n\nexport type BrandlabSiteSystemTier = 'shell' | 'enquiry' | 'full'\n\n/**\n * Site System v2 adoption. `brandlab-ready` blocks on the declared tier's checks and the tiers below it; higher\n * tiers report without blocking. Absent means the site has not adopted v2 and nothing in the ready gate blocks.\n */\nexport interface BrandlabSiteSystemConfig {\n tier: BrandlabSiteSystemTier\n /** A new build or redesign: the same-trade distinctness check (D4) blocks whatever the tier. */\n newBuild?: boolean\n /** Extra pages the ready gate samples, beyond home, the contact page and one page per route. */\n samples?: readonly string[]\n /** Quote and call-to-action labels Romie recorded for this site, beyond the closed list. */\n labels?: readonly string[]\n /** Whether the business offers free quotes (\"Get a free quote\" rather than \"Get a quote\"). */\n freeQuotes?: boolean\n /** Third-party hostnames the site may load, for example www.youtube.com. */\n thirdParties?: readonly string[]\n /** Extra tel: links the site legitimately shows, for example a second line. */\n phones?: readonly string[]\n}\n\nexport type BrandlabSitemapConfig =\n | { mode: 'single' }\n | {\n mode: 'split'\n families: readonly string[]\n reason: string\n }\n\nexport interface BrandlabProjectConfig {\n projectId: string\n routes: {\n families: readonly BrandlabRouteFamily[]\n }\n capabilities?: {\n blog?: { adapter: BrandlabBlogAdapter }\n contact?: {\n fieldProfile: string\n attachments: BrandlabContactAttachmentMode\n }\n locations?: { strategy: BrandlabLocationStrategy }\n reviews?: BrandlabReviewsCapability\n }\n sitemap?: BrandlabSitemapConfig\n searchCertification: {\n representativeRoutes: {\n home: string\n contact?: string\n service?: string\n location?: string\n blog?: string\n }\n }\n exceptions?: readonly BrandlabException[]\n siteSystem?: BrandlabSiteSystemConfig\n}\n\nconst PROJECT_CONFIG_KEYS = [\n 'projectId',\n 'routes',\n 'capabilities',\n 'sitemap',\n 'searchCertification',\n 'exceptions',\n 'siteSystem',\n] as const\nconst ROUTE_FAMILIES = new Set<BrandlabRouteFamily>([\n 'services',\n 'locations',\n 'service-locations',\n 'blog',\n 'projects',\n 'legal',\n])\nconst BLOG_ADAPTERS = new Set<BrandlabBlogAdapter>(['none', 'mdx', 'structured'])\nconst ATTACHMENT_MODES = new Set<BrandlabContactAttachmentMode>([\n 'none',\n 'images-optional',\n 'images-required',\n 'images-and-pdfs-optional',\n])\nconst LOCATION_STRATEGIES = new Set<BrandlabLocationStrategy>([\n 'none',\n 'approved-service-area',\n 'physical-location',\n 'multi-location',\n])\nconst REVIEWS_PROVIDERS = new Set<BrandlabReviewsProvider>([\n 'google-places',\n 'google-business-profile',\n 'project-owned',\n])\nconst GOOGLE_REVIEWS_MODES = new Set<BrandlabGoogleReviewsMode>([\n 'link-only',\n 'summary',\n 'full',\n])\nconst GOOGLE_REVIEWS_SELECTIONS = new Set<GooglePlaceReviewsSelection>([\n 'relevance',\n 'five-star-featured',\n])\nconst BUSINESS_PROFILE_REVIEWS_SELECTIONS = new Set<BusinessProfileReviewsPolicy>([\n 'recent',\n 'five-star',\n])\nconst SITE_SYSTEM_TIERS = new Set<BrandlabSiteSystemTier>(['shell', 'enquiry', 'full'])\nconst SITE_SYSTEM_KEYS = ['tier', 'newBuild', 'samples', 'labels', 'freeQuotes', 'thirdParties', 'phones']\nconst HOSTNAME_PATTERN = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/\nconst TEL_HREF_PATTERN = /^tel:\\+?\\d{6,15}$/\n\nfunction assertNonEmpty(value: string, field: string) {\n if (!value.trim()) {\n throw new Error(`${field} cannot be empty.`)\n }\n}\n\nfunction assertRootRelativePath(path: string, field: string) {\n try {\n normalizeBrandlabRoutePath(path)\n } catch {\n throw new Error(`${field} must be a root-relative path without a query string or hash.`)\n }\n}\n\nfunction assertKnownKeys(value: object, allowed: readonly string[], field: string, hint = '') {\n const unsupported = Object.keys(value).filter((key) => !allowed.includes(key))\n if (unsupported.length > 0) {\n throw new Error(`${field} contains unsupported keys: ${unsupported.join(', ')}.${hint}`)\n }\n}\n\nfunction assertStringList(\n value: unknown,\n field: string,\n check: (item: string, itemField: string) => void,\n) {\n if (!Array.isArray(value)) {\n throw new Error(`${field} must be a list.`)\n }\n value.forEach((item, index) => {\n if (typeof item !== 'string') throw new Error(`${field}[${index}] must be text.`)\n check(item, `${field}[${index}]`)\n })\n assertUnique(value as string[], field)\n}\n\nfunction assertUnique(values: readonly string[], field: string) {\n const duplicate = values.find((value, index) => values.indexOf(value) !== index)\n if (duplicate) {\n throw new Error(`${field} contains duplicate value \"${duplicate}\".`)\n }\n}\n\n/**\n * Defines project-owned variation only. Runtime versions and global Brandlab\n * policy deliberately do not belong in this object.\n */\nexport function defineBrandlabProject<const T extends BrandlabProjectConfig>(config: T): T {\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new TypeError('defineBrandlabProject requires a project configuration.')\n }\n assertKnownKeys(config, PROJECT_CONFIG_KEYS, 'Project configuration')\n assertNonEmpty(config.projectId, 'projectId')\n\n assertBrandlabCanonicalEntityId(config.projectId)\n\n if (!config.routes || typeof config.routes !== 'object') {\n throw new Error('routes.families is required.')\n }\n assertKnownKeys(\n config.routes,\n ['families'],\n 'routes',\n ' Redirects belong in the src/data/redirects.ts table.',\n )\n assertUnique(config.routes.families, 'routes.families')\n config.routes.families.forEach((family, index) => {\n if (!ROUTE_FAMILIES.has(family)) {\n throw new Error(`routes.families[${index}] is unsupported.`)\n }\n })\n\n const representativeRoutes = config.searchCertification.representativeRoutes\n Object.entries(representativeRoutes).forEach(([name, path]) => {\n if (path) assertRootRelativePath(path, `searchCertification.representativeRoutes.${name}`)\n })\n if (representativeRoutes.home !== '/') {\n throw new Error('searchCertification.representativeRoutes.home must be \"/\".')\n }\n\n if (config.capabilities?.contact) {\n assertNonEmpty(config.capabilities.contact.fieldProfile, 'contact.fieldProfile')\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(config.capabilities.contact.fieldProfile)) {\n throw new Error('contact.fieldProfile must be lowercase kebab-case.')\n }\n if (!ATTACHMENT_MODES.has(config.capabilities.contact.attachments)) {\n throw new Error('contact.attachments is unsupported.')\n }\n }\n if (\n config.capabilities?.blog &&\n !BLOG_ADAPTERS.has(config.capabilities.blog.adapter)\n ) {\n throw new Error('blog.adapter is unsupported.')\n }\n if (\n config.capabilities?.locations &&\n !LOCATION_STRATEGIES.has(config.capabilities.locations.strategy)\n ) {\n throw new Error('locations.strategy is unsupported.')\n }\n if (\n config.capabilities?.reviews &&\n !REVIEWS_PROVIDERS.has(config.capabilities.reviews.provider)\n ) {\n throw new Error('reviews.provider is unsupported.')\n }\n if (\n config.capabilities?.reviews?.provider === 'google-places' &&\n !config.routes.families.includes('legal')\n ) {\n throw new Error('Google Places reviews require the legal route family.')\n }\n if (config.capabilities?.reviews?.provider === 'google-places') {\n const reviews = config.capabilities.reviews\n if (!GOOGLE_REVIEWS_MODES.has(reviews.mode)) {\n throw new Error('reviews.mode is unsupported.')\n }\n if (reviews.selection && !GOOGLE_REVIEWS_SELECTIONS.has(reviews.selection)) {\n throw new Error('reviews.selection is unsupported.')\n }\n if (reviews.selection === 'five-star-featured' && reviews.mode !== 'full') {\n throw new Error('Five-star featured reviews require full mode.')\n }\n if (!Array.isArray(reviews.routeIds) || reviews.routeIds.length === 0) {\n throw new Error('Google Places reviews require at least one approved route ID.')\n }\n assertUnique(reviews.routeIds, 'reviews.routeIds')\n reviews.routeIds.forEach((routeId, index) => {\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(routeId)) {\n throw new Error(`reviews.routeIds[${index}] must be lowercase kebab-case.`)\n }\n })\n }\n\n if (config.capabilities?.reviews?.provider === 'google-business-profile') {\n const reviews = config.capabilities.reviews\n if (\n reviews.selection !== undefined &&\n !BUSINESS_PROFILE_REVIEWS_SELECTIONS.has(reviews.selection)\n ) {\n throw new Error('reviews.selection is unsupported.')\n }\n if ('exclude' in reviews) {\n throw new Error(\n 'reviews.exclude belongs in src/config/reviews.ts (reviews.exclude, passed to selectBusinessProfileReviews), not brandlab.config.',\n )\n }\n }\n\n if (config.sitemap?.mode === 'split') {\n if (config.sitemap.families.length === 0) {\n throw new Error('Split sitemap configuration requires at least one family.')\n }\n assertUnique(config.sitemap.families, 'sitemap.families')\n config.sitemap.families.forEach((path, index) =>\n assertRootRelativePath(path, `sitemap.families[${index}]`),\n )\n assertNonEmpty(config.sitemap.reason, 'sitemap.reason')\n }\n\n if (config.siteSystem !== undefined) {\n const siteSystem = config.siteSystem\n if (!siteSystem || typeof siteSystem !== 'object' || Array.isArray(siteSystem)) {\n throw new Error('siteSystem must be an object with a tier.')\n }\n assertKnownKeys(siteSystem, SITE_SYSTEM_KEYS, 'siteSystem')\n if (!SITE_SYSTEM_TIERS.has(siteSystem.tier)) {\n throw new Error('siteSystem.tier is unsupported.')\n }\n if (siteSystem.newBuild !== undefined && typeof siteSystem.newBuild !== 'boolean') {\n throw new Error('siteSystem.newBuild must be true or false.')\n }\n if (siteSystem.samples !== undefined) {\n if (!Array.isArray(siteSystem.samples)) {\n throw new Error('siteSystem.samples must be a list of paths.')\n }\n assertUnique(siteSystem.samples, 'siteSystem.samples')\n siteSystem.samples.forEach((path, index) =>\n assertRootRelativePath(path, `siteSystem.samples[${index}]`),\n )\n }\n if (siteSystem.labels !== undefined) {\n assertStringList(siteSystem.labels, 'siteSystem.labels', (label, field) => assertNonEmpty(label, field))\n }\n if (siteSystem.freeQuotes !== undefined && typeof siteSystem.freeQuotes !== 'boolean') {\n throw new Error('siteSystem.freeQuotes must be true or false.')\n }\n if (siteSystem.thirdParties !== undefined) {\n assertStringList(siteSystem.thirdParties, 'siteSystem.thirdParties', (host, field) => {\n if (!HOSTNAME_PATTERN.test(host)) throw new Error(`${field} must be a hostname such as www.youtube.com.`)\n })\n }\n if (siteSystem.phones !== undefined) {\n assertStringList(siteSystem.phones, 'siteSystem.phones', (href, field) => {\n if (!TEL_HREF_PATTERN.test(href)) throw new Error(`${field} must be a tel: link such as tel:+61290001234.`)\n })\n }\n }\n\n assertUnique(\n (config.exceptions ?? []).map((exception) => exception.ruleId),\n 'exceptions.ruleId',\n )\n\n ;(config.exceptions ?? []).forEach((exception, index) => {\n assertNonEmpty(exception.ruleId, `exceptions[${index}].ruleId`)\n assertNonEmpty(exception.rationale, `exceptions[${index}].rationale`)\n assertNonEmpty(exception.evidence, `exceptions[${index}].evidence`)\n assertNonEmpty(exception.reviewTrigger, `exceptions[${index}].reviewTrigger`)\n if (exception.owner !== 'Romie') {\n throw new Error(`exceptions[${index}].owner must be \"Romie\".`)\n }\n\n if (exception.expiresAt && Number.isNaN(Date.parse(exception.expiresAt))) {\n throw new Error(`exceptions[${index}].expiresAt must be a valid date.`)\n }\n })\n\n return config\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AA+EhE,oDAAoD;AACpD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAA;AAG7G,8FAA8F;AAC9F,MAAM,CAAC,MAAM,mCAAmC,GAAG,OAAO,CAAA;AAkB1D,uGAAuG;AACvG,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAqC,CAAA;AAEnF,iGAAiG;AACjG,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAA;AA6EpD,MAAM,mBAAmB,GAAG;IAC1B,WAAW;IACX,QAAQ;IACR,cAAc;IACd,SAAS;IACT,qBAAqB;IACrB,YAAY;IACZ,YAAY;IACZ,SAAS;CACD,CAAA;AACV,MAAM,cAAc,GAAG,IAAI,GAAG,CAAsB;IAClD,UAAU;IACV,WAAW;IACX,mBAAmB;IACnB,MAAM;IACN,UAAU;IACV,OAAO;CACR,CAAC,CAAA;AACF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAA;AACjF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAgC;IAC9D,MAAM;IACN,iBAAiB;IACjB,iBAAiB;IACjB,0BAA0B;CAC3B,CAAC,CAAA;AACF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAA2B;IAC5D,MAAM;IACN,uBAAuB;IACvB,mBAAmB;IACnB,gBAAgB;CACjB,CAAC,CAAA;AACF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAA0B;IACzD,eAAe;IACf,yBAAyB;IACzB,e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AAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { normalizeBrandlabRoutePath } from './routes.js'\nimport { assertBrandlabCanonicalEntityId } from './entity-id.js'\nimport type { GooglePlaceReviewsSelection } from './google-reviews.js'\nimport type { BusinessProfileReviewsPolicy } from './google-business-reviews.js'\n\nexport type BrandlabRouteFamily =\n | 'services'\n | 'locations'\n | 'service-locations'\n | 'blog'\n | 'projects'\n | 'legal'\n\nexport type BrandlabBlogAdapter = 'none' | 'mdx' | 'structured'\nexport type BrandlabContactAttachmentMode =\n | 'none'\n | 'images-optional'\n | 'images-required'\n | 'images-and-pdfs-optional'\nexport type BrandlabLocationStrategy =\n | 'none'\n | 'approved-service-area'\n | 'physical-location'\n | 'multi-location'\nexport type BrandlabReviewsProvider = 'google-places' | 'google-business-profile' | 'project-owned'\nexport type BrandlabGoogleReviewsMode = 'link-only' | 'summary' | 'full'\n\nexport type BrandlabReviewsCapability =\n | { provider: 'project-owned' }\n | {\n /** 3.5.0: Google reviews read on the server from the Brandlab reviews feed (site-next/google-business-reviews/server). */\n provider: 'google-business-profile'\n /** Optional presentation policy: the newest reviews, or the newest five-star ones. */\n selection?: BusinessProfileReviewsPolicy\n }\n | {\n provider: 'google-places'\n mode: BrandlabGoogleReviewsMode\n /** Optional presentation policy. Five-star selection is valid only in full mode. */\n selection?: GooglePlaceReviewsSelection\n /** Stable route IDs where review proof is intentionally presented. */\n routeIds: readonly string[]\n }\n\nexport interface BrandlabException {\n ruleId: string\n rationale: string\n owner: 'Romie'\n evidence: string\n expiresAt?: string\n reviewTrigger: string\n}\n\nexport type BrandlabSiteSystemTier = 'shell' | 'enquiry' | 'full'\n\n/**\n * Site System v2 adoption. `brandlab-ready` blocks on the declared tier's checks and the tiers below it; higher\n * tiers report without blocking. Absent means the site has not adopted v2 and nothing in the ready gate blocks.\n */\nexport interface BrandlabSiteSystemConfig {\n tier: BrandlabSiteSystemTier\n /** A new build or redesign: the same-trade distinctness check (D4) blocks whatever the tier. */\n newBuild?: boolean\n /** Extra pages the ready gate samples, beyond home, the contact page and one page per route. */\n samples?: readonly string[]\n /** Quote and call-to-action labels Romie recorded for this site, beyond the closed list. */\n labels?: readonly string[]\n /** Whether the business offers free quotes (\"Get a free quote\" rather than \"Get a quote\"). */\n freeQuotes?: boolean\n /** Third-party hostnames the site may load, for example www.youtube.com. */\n thirdParties?: readonly string[]\n /** Extra tel: links the site legitimately shows, for example a second line. */\n phones?: readonly string[]\n /**\n * Estate families allowed to refresh more often than every 7 days (check W3, from 3.13.0), each with the reason\n * and the recorded decision. Without an entry, a full-tier estate family refreshes at most weekly.\n */\n refreshExceptions?: readonly BrandlabEstateRefreshException[]\n}\n\n/** The location estate families check W3 covers. */\nexport const BRANDLAB_ESTATE_REFRESH_FAMILIES = ['suburb', 'service-in-suburb', 'region', 'council'] as const\nexport type BrandlabEstateRefreshFamily = (typeof BRANDLAB_ESTATE_REFRESH_FAMILIES)[number]\n\n/** The shortest refresh an estate family may use without an exception: 7 days, in seconds. */\nexport const BRANDLAB_ESTATE_MIN_REFRESH_SECONDS = 604_800\n\nexport interface BrandlabEstateRefreshException {\n family: BrandlabEstateRefreshFamily\n /** The shortest refresh the family may use, in whole seconds (60 to 604,799). */\n revalidateSeconds: number\n /** Why the family needs to refresh more often than weekly. */\n reason: string\n /** The recorded decision that allows it, for example a Notion decision id. */\n decisionId: string\n}\n\n/** A Vercel function region a Brandlab site may run in: Sydney, or Washington with a recorded decision. */\nexport type BrandlabOriginRegion = 'syd1' | 'iad1'\n\n/** `hosting.originRegion`: one region, or both (`['syd1', 'iad1']`; the ISR store then always goes to iad1). */\nexport type BrandlabOriginRegionSetting = BrandlabOriginRegion | readonly BrandlabOriginRegion[]\n\n/** The region every site runs in unless a decision records another: Sydney, where the visitors are. */\nexport const BRANDLAB_DEFAULT_ORIGIN_REGION = 'syd1' satisfies BrandlabOriginRegion\n\n/** The longest a non-Sydney origin decision lasts before it is reviewed: six calendar months. */\nexport const BRANDLAB_ORIGIN_DECISION_MAX_MONTHS = 6\n\n/**\n * A recorded origin-region decision under rule `origin-region-v1` (operations/shared-platform/ORIGIN_REGION.md).\n * Any region other than Sydney needs one; it lapses on `reviewBy`, at most six months after `decidedOn`.\n */\nexport interface BrandlabOriginRegionDecision {\n rule: 'origin-region-v1'\n /** YYYY-MM-DD. */\n decidedOn: string\n /** Where the benchmark and the decision are recorded (a Notion page, a PR or a report path). */\n evidence: string\n /** The expected saving per billing cycle in US dollars (at least US$2 under the rule). */\n savingUsdPerCycle: number\n /** How much slower a cold miss was in the benchmark, in milliseconds (at most 250 under the rule). */\n coldMissDeltaMs: number\n /** YYYY-MM-DD, after `decidedOn` and no more than six months after it. The ready gate fails once it passes. */\n reviewBy: string\n}\n\n/** A firewall rule recorded for the ready gate's crawler guard (W10): what it matches in the user agent and does. */\nexport interface BrandlabFirewallRuleRecord {\n /** The rule's name or id in the Vercel or Cloudflare firewall. */\n id: string\n action: 'deny' | 'challenge' | 'rate-limit' | 'log' | 'bypass'\n /** How the rule matches the User-Agent header, as the firewall writes it. */\n userAgent: { match: 'contains' | 'equals' | 'regex'; value: string }\n}\n\n/**\n * Where the site's server functions run (3.13.0). `vercel.json` `regions` must equal `originRegion`; the default is\n * Sydney. Firewall rules that match on the user agent are recorded here so the ready gate can check them.\n */\nexport interface BrandlabHostingConfig {\n originRegion: BrandlabOriginRegionSetting\n decision?: BrandlabOriginRegionDecision\n firewall?: readonly BrandlabFirewallRuleRecord[]\n}\n\nexport type BrandlabSitemapConfig =\n | { mode: 'single' }\n | {\n mode: 'split'\n families: readonly string[]\n reason: string\n }\n\nexport interface BrandlabProjectConfig {\n projectId: string\n routes: {\n families: readonly BrandlabRouteFamily[]\n }\n capabilities?: {\n blog?: { adapter: BrandlabBlogAdapter }\n contact?: {\n fieldProfile: string\n attachments: BrandlabContactAttachmentMode\n }\n locations?: { strategy: BrandlabLocationStrategy }\n reviews?: BrandlabReviewsCapability\n }\n sitemap?: BrandlabSitemapConfig\n searchCertification: {\n representativeRoutes: {\n home: string\n contact?: string\n service?: string\n location?: string\n blog?: string\n }\n }\n exceptions?: readonly BrandlabException[]\n siteSystem?: BrandlabSiteSystemConfig\n /** Where the server functions run; absent means Sydney (`syd1`). */\n hosting?: BrandlabHostingConfig\n}\n\nconst PROJECT_CONFIG_KEYS = [\n 'projectId',\n 'routes',\n 'capabilities',\n 'sitemap',\n 'searchCertification',\n 'exceptions',\n 'siteSystem',\n 'hosting',\n] as const\nconst ROUTE_FAMILIES = new Set<BrandlabRouteFamily>([\n 'services',\n 'locations',\n 'service-locations',\n 'blog',\n 'projects',\n 'legal',\n])\nconst BLOG_ADAPTERS = new Set<BrandlabBlogAdapter>(['none', 'mdx', 'structured'])\nconst ATTACHMENT_MODES = new Set<BrandlabContactAttachmentMode>([\n 'none',\n 'images-optional',\n 'images-required',\n 'images-and-pdfs-optional',\n])\nconst LOCATION_STRATEGIES = new Set<BrandlabLocationStrategy>([\n 'none',\n 'approved-service-area',\n 'physical-location',\n 'multi-location',\n])\nconst REVIEWS_PROVIDERS = new Set<BrandlabReviewsProvider>([\n 'google-places',\n 'google-business-profile',\n 'project-owned',\n])\nconst GOOGLE_REVIEWS_MODES = new Set<BrandlabGoogleReviewsMode>([\n 'link-only',\n 'summary',\n 'full',\n])\nconst GOOGLE_REVIEWS_SELECTIONS = new Set<GooglePlaceReviewsSelection>([\n 'relevance',\n 'five-star-featured',\n])\nconst BUSINESS_PROFILE_REVIEWS_SELECTIONS = new Set<BusinessProfileReviewsPolicy>([\n 'recent',\n 'five-star',\n])\nconst SITE_SYSTEM_TIERS = new Set<BrandlabSiteSystemTier>(['shell', 'enquiry', 'full'])\nconst SITE_SYSTEM_KEYS = ['tier', 'newBuild', 'samples', 'labels', 'freeQuotes', 'thirdParties', 'phones', 'refreshExceptions']\nconst REFRESH_EXCEPTION_KEYS = ['family', 'revalidateSeconds', 'reason', 'decisionId']\nconst HOSTNAME_PATTERN = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/\nconst TEL_HREF_PATTERN = /^tel:\\+?\\d{6,15}$/\n\nconst ORIGIN_REGIONS = new Set<BrandlabOriginRegion>(['syd1', 'iad1'])\nconst HOSTING_KEYS = ['originRegion', 'decision', 'firewall']\nconst DECISION_KEYS = ['rule', 'decidedOn', 'evidence', 'savingUsdPerCycle', 'coldMissDeltaMs', 'reviewBy']\nconst FIREWALL_ACTIONS = new Set(['deny', 'challenge', 'rate-limit', 'log', 'bypass'])\nconst FIREWALL_MATCHES = new Set(['contains', 'equals', 'regex'])\nconst ISO_DAY = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\n/** A YYYY-MM-DD calendar day as a UTC timestamp, or null when it is not a real day. */\nfunction isoDay(value: unknown): number | null {\n if (typeof value !== 'string') return null\n const match = ISO_DAY.exec(value)\n if (!match) return null\n const time = Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]))\n return new Date(time).toISOString().slice(0, 10) === value ? time : null\n}\n\n/** The last day a decision taken on `decidedOn` may be reviewed by: the same day six months later (or month end). */\nexport function brandlabOriginDecisionReviewLimit(decidedOn: string): string {\n const start = isoDay(decidedOn)\n if (start === null) throw new Error('decidedOn must be a YYYY-MM-DD date.')\n const date = new Date(start)\n const day = date.getUTCDate()\n const target = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + BRANDLAB_ORIGIN_DECISION_MAX_MONTHS, 1))\n const lastDay = new Date(Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate()\n target.setUTCDate(Math.min(day, lastDay))\n return target.toISOString().slice(0, 10)\n}\n\n/** The regions `hosting.originRegion` names, sorted; Sydney alone when there is no hosting block. */\nexport function brandlabOriginRegions(hosting?: Pick<BrandlabHostingConfig, 'originRegion'>): BrandlabOriginRegion[] {\n const setting = hosting?.originRegion ?? BRANDLAB_DEFAULT_ORIGIN_REGION\n return [...new Set(typeof setting === 'string' ? [setting] : setting)].sort()\n}\n\n/**\n * Problems with a site's hosting record on `today` (YYYY-MM-DD): the ready gate (W5) fails on any. A region other\n * than Sydney needs an `origin-region-v1` decision whose `reviewBy` has not passed and is no more than six months\n * after `decidedOn`. The shape is checked too, because the gate reads the config without running it.\n */\nexport function brandlabHostingProblems(hosting: unknown, today: string): string[] {\n if (hosting === undefined) return []\n if (!hosting || typeof hosting !== 'object' || Array.isArray(hosting)) return ['hosting must be an object with an originRegion.']\n const record = hosting as Record<string, unknown>\n const problems: string[] = []\n const unknown = Object.keys(record).filter((key) => !HOSTING_KEYS.includes(key))\n if (unknown.length > 0) problems.push(`hosting contains unsupported keys: ${unknown.join(', ')}.`)\n const setting = record.originRegion\n const list = typeof setting === 'string' ? [setting] : Array.isArray(setting) ? setting : null\n if (\n !list ||\n list.length === 0 ||\n list.some((region) => !ORIGIN_REGIONS.has(region as BrandlabOriginRegion)) ||\n new Set(list).size !== list.length\n ) {\n problems.push(`hosting.originRegion must be 'syd1', 'iad1' or ['syd1', 'iad1'] (found ${JSON.stringify(setting)}).`)\n return problems\n }\n const sydneyOnly = list.length === 1 && list[0] === BRANDLAB_DEFAULT_ORIGIN_REGION\n const decision = record.decision\n if (decision === undefined) {\n if (!sydneyOnly) {\n problems.push(`hosting.originRegion ${JSON.stringify(setting)} needs a recorded origin-region-v1 decision (hosting.decision); only syd1 runs without one.`)\n }\n } else if (!decision || typeof decision !== 'object' || Array.isArray(decision)) {\n problems.push('hosting.decision must be an object.')\n } else {\n const entry = decision as Record<string, unknown>\n const extra = Object.keys(entry).filter((key) => !DECISION_KEYS.includes(key))\n if (extra.length > 0) problems.push(`hosting.decision contains unsupported keys: ${extra.join(', ')}.`)\n if (entry.rule !== 'origin-region-v1') problems.push(`hosting.decision.rule must be 'origin-region-v1' (found ${JSON.stringify(entry.rule)}).`)\n if (typeof entry.evidence !== 'string' || !entry.evidence.trim()) problems.push('hosting.decision.evidence must name where the benchmark and decision are recorded.')\n for (const key of ['savingUsdPerCycle', 'coldMissDeltaMs'] as const) {\n if (typeof entry[key] !== 'number' || !Number.isFinite(entry[key])) problems.push(`hosting.decision.${key} must be a number.`)\n }\n const decided = isoDay(entry.decidedOn)\n const review = isoDay(entry.reviewBy)\n if (decided === null) problems.push('hosting.decision.decidedOn must be a YYYY-MM-DD date.')\n if (review === null) problems.push('hosting.decision.reviewBy must be a YYYY-MM-DD date.')\n if (decided !== null && review !== null) {\n const limit = brandlabOriginDecisionReviewLimit(entry.decidedOn as string)\n if (review <= decided) problems.push(`hosting.decision.reviewBy (${entry.reviewBy}) must be after decidedOn (${entry.decidedOn}).`)\n else if ((entry.reviewBy as string) > limit) {\n problems.push(`hosting.decision.reviewBy (${entry.reviewBy}) is more than ${BRANDLAB_ORIGIN_DECISION_MAX_MONTHS} months after decidedOn (${entry.decidedOn}); review by ${limit} at the latest.`)\n }\n if (!sydneyOnly && isoDay(today) !== null && today > (entry.reviewBy as string)) {\n problems.push(`The origin-region decision for ${JSON.stringify(setting)} lapsed on ${entry.reviewBy}: review it under origin-region-v1 and record a new reviewBy, or move back to syd1.`)\n }\n }\n }\n const firewall = record.firewall\n if (firewall !== undefined) {\n if (!Array.isArray(firewall)) problems.push('hosting.firewall must be a list of recorded rules.')\n else {\n firewall.forEach((rule: unknown, index) => {\n const field = `hosting.firewall[${index}]`\n if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {\n problems.push(`${field} must be an object.`)\n return\n }\n const entry = rule as Record<string, unknown>\n if (typeof entry.id !== 'string' || !entry.id.trim()) problems.push(`${field}.id must name the firewall rule.`)\n if (!FIREWALL_ACTIONS.has(entry.action as string)) problems.push(`${field}.action must be one of ${[...FIREWALL_ACTIONS].join(', ')}.`)\n const userAgent = entry.userAgent as Record<string, unknown> | undefined\n if (!userAgent || typeof userAgent !== 'object' || !FIREWALL_MATCHES.has(userAgent.match as string) || typeof userAgent.value !== 'string' || !userAgent.value) {\n problems.push(`${field}.userAgent must be { match: 'contains' | 'equals' | 'regex', value }.`)\n } else if (userAgent.match === 'regex') {\n try {\n new RegExp(userAgent.value)\n } catch {\n problems.push(`${field}.userAgent.value is not a valid regular expression.`)\n }\n }\n })\n }\n }\n return problems\n}\n\nfunction assertNonEmpty(value: string, field: string) {\n if (!value.trim()) {\n throw new Error(`${field} cannot be empty.`)\n }\n}\n\nfunction assertRootRelativePath(path: string, field: string) {\n try {\n normalizeBrandlabRoutePath(path)\n } catch {\n throw new Error(`${field} must be a root-relative path without a query string or hash.`)\n }\n}\n\nfunction assertKnownKeys(value: object, allowed: readonly string[], field: string, hint = '') {\n const unsupported = Object.keys(value).filter((key) => !allowed.includes(key))\n if (unsupported.length > 0) {\n throw new Error(`${field} contains unsupported keys: ${unsupported.join(', ')}.${hint}`)\n }\n}\n\nfunction assertRefreshExceptions(value: unknown) {\n const field = 'siteSystem.refreshExceptions'\n if (!Array.isArray(value)) throw new Error(`${field} must be a list.`)\n value.forEach((entry: unknown, index) => {\n const itemField = `${field}[${index}]`\n if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {\n throw new Error(`${itemField} must be an object with family, revalidateSeconds, reason and decisionId.`)\n }\n assertKnownKeys(entry, REFRESH_EXCEPTION_KEYS, itemField)\n const exception = entry as Record<string, unknown>\n if (!(BRANDLAB_ESTATE_REFRESH_FAMILIES as readonly unknown[]).includes(exception.family)) {\n throw new Error(`${itemField}.family must be one of ${BRANDLAB_ESTATE_REFRESH_FAMILIES.join(', ')}.`)\n }\n const seconds = exception.revalidateSeconds\n if (!Number.isSafeInteger(seconds) || (seconds as number) < 60 || (seconds as number) >= BRANDLAB_ESTATE_MIN_REFRESH_SECONDS) {\n throw new Error(`${itemField}.revalidateSeconds must be whole seconds from 60 to 604799; weekly or slower needs no exception.`)\n }\n for (const key of ['reason', 'decisionId'] as const) {\n if (typeof exception[key] !== 'string') throw new Error(`${itemField}.${key} must be text.`)\n assertNonEmpty(exception[key] as string, `${itemField}.${key}`)\n }\n })\n assertUnique(value.map((entry: { family: string }) => entry.family), `${field}.family`)\n}\n\nfunction assertStringList(\n value: unknown,\n field: string,\n check: (item: string, itemField: string) => void,\n) {\n if (!Array.isArray(value)) {\n throw new Error(`${field} must be a list.`)\n }\n value.forEach((item, index) => {\n if (typeof item !== 'string') throw new Error(`${field}[${index}] must be text.`)\n check(item, `${field}[${index}]`)\n })\n assertUnique(value as string[], field)\n}\n\nfunction assertUnique(values: readonly string[], field: string) {\n const duplicate = values.find((value, index) => values.indexOf(value) !== index)\n if (duplicate) {\n throw new Error(`${field} contains duplicate value \"${duplicate}\".`)\n }\n}\n\n/**\n * Defines project-owned variation only. Runtime versions and global Brandlab\n * policy deliberately do not belong in this object.\n */\nexport function defineBrandlabProject<const T extends BrandlabProjectConfig>(config: T): T {\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new TypeError('defineBrandlabProject requires a project configuration.')\n }\n assertKnownKeys(config, PROJECT_CONFIG_KEYS, 'Project configuration')\n assertNonEmpty(config.projectId, 'projectId')\n\n assertBrandlabCanonicalEntityId(config.projectId)\n\n if (!config.routes || typeof config.routes !== 'object') {\n throw new Error('routes.families is required.')\n }\n assertKnownKeys(\n config.routes,\n ['families'],\n 'routes',\n ' Redirects belong in the src/data/redirects.ts table.',\n )\n assertUnique(config.routes.families, 'routes.families')\n config.routes.families.forEach((family, index) => {\n if (!ROUTE_FAMILIES.has(family)) {\n throw new Error(`routes.families[${index}] is unsupported.`)\n }\n })\n\n const representativeRoutes = config.searchCertification.representativeRoutes\n Object.entries(representativeRoutes).forEach(([name, path]) => {\n if (path) assertRootRelativePath(path, `searchCertification.representativeRoutes.${name}`)\n })\n if (representativeRoutes.home !== '/') {\n throw new Error('searchCertification.representativeRoutes.home must be \"/\".')\n }\n\n if (config.capabilities?.contact) {\n assertNonEmpty(config.capabilities.contact.fieldProfile, 'contact.fieldProfile')\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(config.capabilities.contact.fieldProfile)) {\n throw new Error('contact.fieldProfile must be lowercase kebab-case.')\n }\n if (!ATTACHMENT_MODES.has(config.capabilities.contact.attachments)) {\n throw new Error('contact.attachments is unsupported.')\n }\n }\n if (\n config.capabilities?.blog &&\n !BLOG_ADAPTERS.has(config.capabilities.blog.adapter)\n ) {\n throw new Error('blog.adapter is unsupported.')\n }\n if (\n config.capabilities?.locations &&\n !LOCATION_STRATEGIES.has(config.capabilities.locations.strategy)\n ) {\n throw new Error('locations.strategy is unsupported.')\n }\n if (\n config.capabilities?.reviews &&\n !REVIEWS_PROVIDERS.has(config.capabilities.reviews.provider)\n ) {\n throw new Error('reviews.provider is unsupported.')\n }\n if (\n config.capabilities?.reviews?.provider === 'google-places' &&\n !config.routes.families.includes('legal')\n ) {\n throw new Error('Google Places reviews require the legal route family.')\n }\n if (config.capabilities?.reviews?.provider === 'google-places') {\n const reviews = config.capabilities.reviews\n if (!GOOGLE_REVIEWS_MODES.has(reviews.mode)) {\n throw new Error('reviews.mode is unsupported.')\n }\n if (reviews.selection && !GOOGLE_REVIEWS_SELECTIONS.has(reviews.selection)) {\n throw new Error('reviews.selection is unsupported.')\n }\n if (reviews.selection === 'five-star-featured' && reviews.mode !== 'full') {\n throw new Error('Five-star featured reviews require full mode.')\n }\n if (!Array.isArray(reviews.routeIds) || reviews.routeIds.length === 0) {\n throw new Error('Google Places reviews require at least one approved route ID.')\n }\n assertUnique(reviews.routeIds, 'reviews.routeIds')\n reviews.routeIds.forEach((routeId, index) => {\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(routeId)) {\n throw new Error(`reviews.routeIds[${index}] must be lowercase kebab-case.`)\n }\n })\n }\n\n if (config.capabilities?.reviews?.provider === 'google-business-profile') {\n const reviews = config.capabilities.reviews\n if (\n reviews.selection !== undefined &&\n !BUSINESS_PROFILE_REVIEWS_SELECTIONS.has(reviews.selection)\n ) {\n throw new Error('reviews.selection is unsupported.')\n }\n if ('exclude' in reviews) {\n throw new Error(\n 'reviews.exclude belongs in src/config/reviews.ts (reviews.exclude, passed to selectBusinessProfileReviews), not brandlab.config.',\n )\n }\n }\n\n if (config.sitemap?.mode === 'split') {\n if (config.sitemap.families.length === 0) {\n throw new Error('Split sitemap configuration requires at least one family.')\n }\n assertUnique(config.sitemap.families, 'sitemap.families')\n config.sitemap.families.forEach((path, index) =>\n assertRootRelativePath(path, `sitemap.families[${index}]`),\n )\n assertNonEmpty(config.sitemap.reason, 'sitemap.reason')\n }\n\n if (config.siteSystem !== undefined) {\n const siteSystem = config.siteSystem\n if (!siteSystem || typeof siteSystem !== 'object' || Array.isArray(siteSystem)) {\n throw new Error('siteSystem must be an object with a tier.')\n }\n assertKnownKeys(siteSystem, SITE_SYSTEM_KEYS, 'siteSystem')\n if (!SITE_SYSTEM_TIERS.has(siteSystem.tier)) {\n throw new Error('siteSystem.tier is unsupported.')\n }\n if (siteSystem.newBuild !== undefined && typeof siteSystem.newBuild !== 'boolean') {\n throw new Error('siteSystem.newBuild must be true or false.')\n }\n if (siteSystem.samples !== undefined) {\n if (!Array.isArray(siteSystem.samples)) {\n throw new Error('siteSystem.samples must be a list of paths.')\n }\n assertUnique(siteSystem.samples, 'siteSystem.samples')\n siteSystem.samples.forEach((path, index) =>\n assertRootRelativePath(path, `siteSystem.samples[${index}]`),\n )\n }\n if (siteSystem.labels !== undefined) {\n assertStringList(siteSystem.labels, 'siteSystem.labels', (label, field) => assertNonEmpty(label, field))\n }\n if (siteSystem.freeQuotes !== undefined && typeof siteSystem.freeQuotes !== 'boolean') {\n throw new Error('siteSystem.freeQuotes must be true or false.')\n }\n if (siteSystem.thirdParties !== undefined) {\n assertStringList(siteSystem.thirdParties, 'siteSystem.thirdParties', (host, field) => {\n if (!HOSTNAME_PATTERN.test(host)) throw new Error(`${field} must be a hostname such as www.youtube.com.`)\n })\n }\n if (siteSystem.phones !== undefined) {\n assertStringList(siteSystem.phones, 'siteSystem.phones', (href, field) => {\n if (!TEL_HREF_PATTERN.test(href)) throw new Error(`${field} must be a tel: link such as tel:+61290001234.`)\n })\n }\n if (siteSystem.refreshExceptions !== undefined) {\n assertRefreshExceptions(siteSystem.refreshExceptions)\n }\n }\n\n if (config.hosting !== undefined) {\n // The date-bound lapse is the ready gate's (W5): a lapsed decision must not stop a build or a rollback.\n const problems = brandlabHostingProblems(config.hosting, '0000-01-01')\n if (problems.length > 0) throw new Error(problems[0])\n }\n\n assertUnique(\n (config.exceptions ?? []).map((exception) => exception.ruleId),\n 'exceptions.ruleId',\n )\n\n ;(config.exceptions ?? []).forEach((exception, index) => {\n assertNonEmpty(exception.ruleId, `exceptions[${index}].ruleId`)\n assertNonEmpty(exception.rationale, `exceptions[${index}].rationale`)\n assertNonEmpty(exception.evidence, `exceptions[${index}].evidence`)\n assertNonEmpty(exception.reviewTrigger, `exceptions[${index}].reviewTrigger`)\n if (exception.owner !== 'Romie') {\n throw new Error(`exceptions[${index}].owner must be \"Romie\".`)\n }\n\n if (exception.expiresAt && Number.isNaN(Date.parse(exception.expiresAt))) {\n throw new Error(`exceptions[${index}].expiresAt must be a valid date.`)\n }\n })\n\n return config\n}\n"]}
|
package/dist/site.d.ts
CHANGED
|
@@ -25,6 +25,15 @@ export type BrandlabEnvironment = Readonly<Record<string, string | undefined>>;
|
|
|
25
25
|
* environment fails closed to `preview`: never analytics, never indexable.
|
|
26
26
|
*/
|
|
27
27
|
export declare function resolveBrandlabDeployment(environment: BrandlabEnvironment): BrandlabDeployment;
|
|
28
|
+
/**
|
|
29
|
+
* The search and answer crawlers every production site keeps open (3.13.0): neither robots.txt nor a firewall rule
|
|
30
|
+
* may block them (ready-gate check W10). These are their robots.txt user-agent tokens. Meta's crawler is not listed:
|
|
31
|
+
* it has mixed uses, and a site limits it only with a recorded decision.
|
|
32
|
+
*/
|
|
33
|
+
export declare const BRANDLAB_SEARCH_CRAWLERS: readonly ["Googlebot", "Bingbot", "OAI-SearchBot", "Applebot", "Claude-SearchBot", "Claude-User", "PerplexityBot"];
|
|
34
|
+
export type BrandlabSearchCrawler = (typeof BRANDLAB_SEARCH_CRAWLERS)[number];
|
|
35
|
+
/** The protected crawler a robots.txt user-agent token names (case-insensitive), if any. */
|
|
36
|
+
export declare function brandlabSearchCrawlerNamed(token: string): BrandlabSearchCrawler | undefined;
|
|
28
37
|
export interface BrandlabSiteDefinition {
|
|
29
38
|
/** Public site name: Open Graph `siteName` and the brand guard for templated titles. */
|
|
30
39
|
name: string;
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAA;AAEtB;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;AAEpF,MAAM,WAAW,kBAAkB;IACjC,2GAA2G;IAC3G,QAAQ,CAAC,WAAW,EAAE,6BAA6B,CAAA;IACnD;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;AAE9E;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,mBAAmB,GAAG,kBAAkB,CAe9F;AAED,MAAM,WAAW,sBAAsB;IACrC,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAA;IACZ,4FAA4F;IAC5F,YAAY,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,sFAAsF;IACtF,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,mBAAmB,CAAA;IACvC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,uFAAuF;IACvF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;I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ment) {
|
|
|
23
23
|
productionBuild: environment.NODE_ENV === 'production',
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The search and answer crawlers every production site keeps open (3.13.0): neither robots.txt nor a firewall rule
|
|
28
|
+
* may block them (ready-gate check W10). These are their robots.txt user-agent tokens. Meta's crawler is not listed:
|
|
29
|
+
* it has mixed uses, and a site limits it only with a recorded decision.
|
|
30
|
+
*/
|
|
31
|
+
export const BRANDLAB_SEARCH_CRAWLERS = Object.freeze([
|
|
32
|
+
'Googlebot',
|
|
33
|
+
'Bingbot',
|
|
34
|
+
'OAI-SearchBot',
|
|
35
|
+
'Applebot',
|
|
36
|
+
'Claude-SearchBot',
|
|
37
|
+
'Claude-User',
|
|
38
|
+
'PerplexityBot',
|
|
39
|
+
]);
|
|
40
|
+
/** The protected crawler a robots.txt user-agent token names (case-insensitive), if any. */
|
|
41
|
+
export function brandlabSearchCrawlerNamed(token) {
|
|
42
|
+
const name = token.trim().toLowerCase();
|
|
43
|
+
return BRANDLAB_SEARCH_CRAWLERS.find((crawler) => crawler.toLowerCase() === name);
|
|
44
|
+
}
|
|
26
45
|
const SITE_KEYS = new Set([
|
|
27
46
|
'name',
|
|
28
47
|
'canonicalUrl',
|
package/dist/site.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.js","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,eAAe,CAAA;AAqBtB;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAgC;IACxE,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAA;IAClF,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,WAAW,CAAC,UAAU,IAAI,WAAW,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,CAAA;I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AAM,IAAI,KAAK,CAAC,GAAG,KAAK,+DAA+D,CAAC,CAAA;IAC1F,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,KAAK,gEAAgE,CAAC,CAAA;QACpG,CAAC;QACD,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,KAAK,iCAAiC,CAAC,CAAA;QACrE,CAAC;IACH,CAAC,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAA;IAC5E,IAAI,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,6BAA6B,SAAS,IAAI,CAAC,CAAA;AACpF,CAAC","sourcesContent":["import {\n assertBrandlabSocialImage,\n type BrandlabSocialImage,\n} from './metadata.js'\n\n/**\n * `production` and `preview` are real Vercel deployments. Everything else —\n * `next dev`, a local `next start`, CI and tests — is `development`.\n */\nexport type BrandlabDeploymentEnvironment = 'production' | 'preview' | 'development'\n\nexport interface BrandlabDeployment {\n /** The single gate for production-only behaviour: analytics, contact delivery and Preview restrictions. */\n readonly environment: BrandlabDeploymentEnvironment\n /**\n * An optimised build (`NODE_ENV=production`), on Vercel or locally. Security\n * headers and crawler access follow the build so a local `next start` serves\n * exactly the production headers.\n */\n readonly productionBuild: boolean\n}\n\nexport type BrandlabEnvironment = Readonly<Record<string, string | undefined>>\n\n/**\n * Resolves the deployment once for every consumer (next.config headers,\n * robots, analytics and contact delivery). Server code passes `process.env`;\n * browser code passes `{ NEXT_PUBLIC_VERCEL_ENV: process.env.NEXT_PUBLIC_VERCEL_ENV }`,\n * which `defineBrandlabNextConfig` inlines at build time.\n *\n * `VERCEL_ENV` wins over `NEXT_PUBLIC_VERCEL_ENV`. An unrecognised declared\n * environment fails closed to `preview`: never analytics, never indexable.\n */\nexport function resolveBrandlabDeployment(environment: BrandlabEnvironment): BrandlabDeployment {\n if (!environment || typeof environment !== 'object') {\n throw new TypeError('resolveBrandlabDeployment requires an environment record.')\n }\n const declared = (environment.VERCEL_ENV ?? environment.NEXT_PUBLIC_VERCEL_ENV)?.trim()\n const deploymentEnvironment: BrandlabDeploymentEnvironment =\n !declared || declared === 'development'\n ? 'development'\n : declared === 'production'\n ? 'production'\n : 'preview'\n return Object.freeze({\n environment: deploymentEnvironment,\n productionBuild: environment.NODE_ENV === 'production',\n })\n}\n\nexport interface BrandlabSiteDefinition {\n /** Public site name: Open Graph `siteName` and the brand guard for templated titles. */\n name: string\n /** Canonical HTTPS origin written as a source constant, never read from the environment. */\n canonicalUrl: string\n /** Open Graph locale, for example `en_AU`. */\n locale: string\n /** Page title template with exactly one `%s`, for example `%s | Example Services`. */\n titleTemplate: string\n defaultSocialImage: BrandlabSocialImage\n /**\n * Hosts that permanently redirect every path to the canonical origin, such as\n * the `www` host, the Vercel project host or a retired domain.\n *\n * Optional from 3.2.1: declare them in next.config with\n * `defineBrandlabNextConfig({ aliasHosts })` instead, so they stay out of the\n * browser bundles of every client component that imports the site identity.\n */\n aliasHosts?: readonly string[]\n}\n\nexport interface BrandlabSite {\n readonly name: string\n /** Canonical origin without a trailing slash, for example `https://example.com.au`. */\n readonly canonicalUrl: string\n readonly canonicalHost: string\n readonly locale: string\n readonly titleTemplate: string\n readonly defaultSocialImage: Readonly<BrandlabSocialImage>\n readonly aliasHosts: readonly string[]\n}\n\nconst SITE_KEYS = new Set([\n 'name',\n 'canonicalUrl',\n 'locale',\n 'titleTemplate',\n 'defaultSocialImage',\n 'aliasHosts',\n])\nconst HOSTNAME_PATTERN =\n /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$/\n\nfunction assertSiteText(value: unknown, field: string, maximum: number): asserts value is string {\n if (\n typeof value !== 'string' ||\n !value.trim() ||\n value.trim() !== value ||\n value.length > maximum ||\n /[\\u0000-\\u001f\\u007f]/.test(value)\n ) {\n throw new Error(`${field} must be bounded, trimmed, single-line text.`)\n }\n}\n\nexport function isBrandlabHostname(value: unknown): value is string {\n return typeof value === 'string' && HOSTNAME_PATTERN.test(value)\n}\n\nfunction canonicalOrigin(value: unknown) {\n assertSiteText(value, 'canonicalUrl', 2_048)\n let url: URL\n try {\n url = new URL(value)\n } catch {\n throw new Error(`canonicalUrl must be an absolute HTTPS origin: \"${value}\".`)\n }\n if (\n url.protocol !== 'https:' ||\n url.username ||\n url.password ||\n url.port ||\n url.search ||\n url.hash ||\n (url.pathname !== '/' && url.pathname !== '') ||\n value.replace(/\\/$/, '') !== url.origin ||\n !isBrandlabHostname(url.hostname)\n ) {\n throw new Error(`canonicalUrl must be an absolute HTTPS origin: \"${value}\".`)\n }\n return url\n}\n\n/**\n * Declares the site-wide SEO identity once (`src/config/site.ts`). The result\n * feeds metadata, robots, sitemaps, redirects and next.config.\n */\nexport function defineBrandlabSite(definition: BrandlabSiteDefinition): BrandlabSite {\n if (!definition || typeof definition !== 'object' || Array.isArray(definition)) {\n throw new TypeError('defineBrandlabSite requires a site definition.')\n }\n const unsupported = Object.keys(definition).filter((key) => !SITE_KEYS.has(key))\n if (unsupported.length > 0) {\n throw new Error(`Site definition contains unsupported keys: ${unsupported.join(', ')}.`)\n }\n assertSiteText(definition.name, 'name', 160)\n const origin = canonicalOrigin(definition.canonicalUrl)\n assertSiteText(definition.locale, 'locale', 20)\n if (!/^[a-z]{2}(?:_[A-Z]{2})?$/.test(definition.locale)) {\n throw new Error('locale must use a language or language_REGION identifier.')\n }\n assertSiteText(definition.titleTemplate, 'titleTemplate', 240)\n if ((definition.titleTemplate.match(/%s/g) ?? []).length !== 1) {\n throw new Error('titleTemplate must contain exactly one %s placeholder.')\n }\n assertBrandlabSocialImage(definition.defaultSocialImage, 'defaultSocialImage')\n const aliasHosts = definition.aliasHosts ?? []\n assertBrandlabAliasHosts(aliasHosts, origin.hostname)\n\n return Object.freeze({\n name: definition.name,\n canonicalUrl: origin.origin,\n canonicalHost: origin.hostname,\n locale: definition.locale,\n titleTemplate: definition.titleTemplate,\n defaultSocialImage: Object.freeze({ ...definition.defaultSocialImage }),\n aliasHosts: Object.freeze([...aliasHosts]),\n })\n}\n\n/**\n * Checks a list of alias hosts: lowercase hostnames without a scheme, port or\n * path, never the canonical host, each listed once. `defineBrandlabSite` and\n * `defineBrandlabNextConfig({ aliasHosts })` share it.\n */\nexport function assertBrandlabAliasHosts(\n hosts: unknown,\n canonicalHost: string,\n field = 'aliasHosts',\n): asserts hosts is readonly string[] {\n if (!Array.isArray(hosts)) {\n throw new Error(`${field} must list every host that redirects to the canonical origin.`)\n }\n hosts.forEach((host, index) => {\n if (!isBrandlabHostname(host)) {\n throw new Error(`${field}[${index}] must be a lowercase hostname without a scheme, port or path.`)\n }\n if (host === canonicalHost) {\n throw new Error(`${field}[${index}] cannot be the canonical host.`)\n }\n })\n const duplicate = hosts.find((host, index) => hosts.indexOf(host) !== index)\n if (duplicate) throw new Error(`${field} contains duplicate host \"${duplicate}\".`)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"site.js","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,eAAe,CAAA;AAqBtB;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAgC;IACxE,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAA;IAClF,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,WAAW,CAAC,UAAU,IAAI,WAAW,CAAC,sB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are real Vercel deployments. Everything else —\n * `next dev`, a local `next start`, CI and tests — is `development`.\n */\nexport type BrandlabDeploymentEnvironment = 'production' | 'preview' | 'development'\n\nexport interface BrandlabDeployment {\n /** The single gate for production-only behaviour: analytics, contact delivery and Preview restrictions. */\n readonly environment: BrandlabDeploymentEnvironment\n /**\n * An optimised build (`NODE_ENV=production`), on Vercel or locally. Security\n * headers and crawler access follow the build so a local `next start` serves\n * exactly the production headers.\n */\n readonly productionBuild: boolean\n}\n\nexport type BrandlabEnvironment = Readonly<Record<string, string | undefined>>\n\n/**\n * Resolves the deployment once for every consumer (next.config headers,\n * robots, analytics and contact delivery). Server code passes `process.env`;\n * browser code passes `{ NEXT_PUBLIC_VERCEL_ENV: process.env.NEXT_PUBLIC_VERCEL_ENV }`,\n * which `defineBrandlabNextConfig` inlines at build time.\n *\n * `VERCEL_ENV` wins over `NEXT_PUBLIC_VERCEL_ENV`. An unrecognised declared\n * environment fails closed to `preview`: never analytics, never indexable.\n */\nexport function resolveBrandlabDeployment(environment: BrandlabEnvironment): BrandlabDeployment {\n if (!environment || typeof environment !== 'object') {\n throw new TypeError('resolveBrandlabDeployment requires an environment record.')\n }\n const declared = (environment.VERCEL_ENV ?? environment.NEXT_PUBLIC_VERCEL_ENV)?.trim()\n const deploymentEnvironment: BrandlabDeploymentEnvironment =\n !declared || declared === 'development'\n ? 'development'\n : declared === 'production'\n ? 'production'\n : 'preview'\n return Object.freeze({\n environment: deploymentEnvironment,\n productionBuild: environment.NODE_ENV === 'production',\n })\n}\n\n/**\n * The search and answer crawlers every production site keeps open (3.13.0): neither robots.txt nor a firewall rule\n * may block them (ready-gate check W10). These are their robots.txt user-agent tokens. Meta's crawler is not listed:\n * it has mixed uses, and a site limits it only with a recorded decision.\n */\nexport const BRANDLAB_SEARCH_CRAWLERS = Object.freeze([\n 'Googlebot',\n 'Bingbot',\n 'OAI-SearchBot',\n 'Applebot',\n 'Claude-SearchBot',\n 'Claude-User',\n 'PerplexityBot',\n] as const)\n\nexport type BrandlabSearchCrawler = (typeof BRANDLAB_SEARCH_CRAWLERS)[number]\n\n/** The protected crawler a robots.txt user-agent token names (case-insensitive), if any. */\nexport function brandlabSearchCrawlerNamed(token: string): BrandlabSearchCrawler | undefined {\n const name = token.trim().toLowerCase()\n return BRANDLAB_SEARCH_CRAWLERS.find((crawler) => crawler.toLowerCase() === name)\n}\n\nexport interface BrandlabSiteDefinition {\n /** Public site name: Open Graph `siteName` and the brand guard for templated titles. */\n name: string\n /** Canonical HTTPS origin written as a source constant, never read from the environment. */\n canonicalUrl: string\n /** Open Graph locale, for example `en_AU`. */\n locale: string\n /** Page title template with exactly one `%s`, for example `%s | Example Services`. */\n titleTemplate: string\n defaultSocialImage: BrandlabSocialImage\n /**\n * Hosts that permanently redirect every path to the canonical origin, such as\n * the `www` host, the Vercel project host or a retired domain.\n *\n * Optional from 3.2.1: declare them in next.config with\n * `defineBrandlabNextConfig({ aliasHosts })` instead, so they stay out of the\n * browser bundles of every client component that imports the site identity.\n */\n aliasHosts?: readonly string[]\n}\n\nexport interface BrandlabSite {\n readonly name: string\n /** Canonical origin without a trailing slash, for example `https://example.com.au`. */\n readonly canonicalUrl: string\n readonly canonicalHost: string\n readonly locale: string\n readonly titleTemplate: string\n readonly defaultSocialImage: Readonly<BrandlabSocialImage>\n readonly aliasHosts: readonly string[]\n}\n\nconst SITE_KEYS = new Set([\n 'name',\n 'canonicalUrl',\n 'locale',\n 'titleTemplate',\n 'defaultSocialImage',\n 'aliasHosts',\n])\nconst HOSTNAME_PATTERN =\n /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$/\n\nfunction assertSiteText(value: unknown, field: string, maximum: number): asserts value is string {\n if (\n typeof value !== 'string' ||\n !value.trim() ||\n value.trim() !== value ||\n value.length > maximum ||\n /[\\u0000-\\u001f\\u007f]/.test(value)\n ) {\n throw new Error(`${field} must be bounded, trimmed, single-line text.`)\n }\n}\n\nexport function isBrandlabHostname(value: unknown): value is string {\n return typeof value === 'string' && HOSTNAME_PATTERN.test(value)\n}\n\nfunction canonicalOrigin(value: unknown) {\n assertSiteText(value, 'canonicalUrl', 2_048)\n let url: URL\n try {\n url = new URL(value)\n } catch {\n throw new Error(`canonicalUrl must be an absolute HTTPS origin: \"${value}\".`)\n }\n if (\n url.protocol !== 'https:' ||\n url.username ||\n url.password ||\n url.port ||\n url.search ||\n url.hash ||\n (url.pathname !== '/' && url.pathname !== '') ||\n value.replace(/\\/$/, '') !== url.origin ||\n !isBrandlabHostname(url.hostname)\n ) {\n throw new Error(`canonicalUrl must be an absolute HTTPS origin: \"${value}\".`)\n }\n return url\n}\n\n/**\n * Declares the site-wide SEO identity once (`src/config/site.ts`). The result\n * feeds metadata, robots, sitemaps, redirects and next.config.\n */\nexport function defineBrandlabSite(definition: BrandlabSiteDefinition): BrandlabSite {\n if (!definition || typeof definition !== 'object' || Array.isArray(definition)) {\n throw new TypeError('defineBrandlabSite requires a site definition.')\n }\n const unsupported = Object.keys(definition).filter((key) => !SITE_KEYS.has(key))\n if (unsupported.length > 0) {\n throw new Error(`Site definition contains unsupported keys: ${unsupported.join(', ')}.`)\n }\n assertSiteText(definition.name, 'name', 160)\n const origin = canonicalOrigin(definition.canonicalUrl)\n assertSiteText(definition.locale, 'locale', 20)\n if (!/^[a-z]{2}(?:_[A-Z]{2})?$/.test(definition.locale)) {\n throw new Error('locale must use a language or language_REGION identifier.')\n }\n assertSiteText(definition.titleTemplate, 'titleTemplate', 240)\n if ((definition.titleTemplate.match(/%s/g) ?? []).length !== 1) {\n throw new Error('titleTemplate must contain exactly one %s placeholder.')\n }\n assertBrandlabSocialImage(definition.defaultSocialImage, 'defaultSocialImage')\n const aliasHosts = definition.aliasHosts ?? []\n assertBrandlabAliasHosts(aliasHosts, origin.hostname)\n\n return Object.freeze({\n name: definition.name,\n canonicalUrl: origin.origin,\n canonicalHost: origin.hostname,\n locale: definition.locale,\n titleTemplate: definition.titleTemplate,\n defaultSocialImage: Object.freeze({ ...definition.defaultSocialImage }),\n aliasHosts: Object.freeze([...aliasHosts]),\n })\n}\n\n/**\n * Checks a list of alias hosts: lowercase hostnames without a scheme, port or\n * path, never the canonical host, each listed once. `defineBrandlabSite` and\n * `defineBrandlabNextConfig({ aliasHosts })` share it.\n */\nexport function assertBrandlabAliasHosts(\n hosts: unknown,\n canonicalHost: string,\n field = 'aliasHosts',\n): asserts hosts is readonly string[] {\n if (!Array.isArray(hosts)) {\n throw new Error(`${field} must list every host that redirects to the canonical origin.`)\n }\n hosts.forEach((host, index) => {\n if (!isBrandlabHostname(host)) {\n throw new Error(`${field}[${index}] must be a lowercase hostname without a scheme, port or path.`)\n }\n if (host === canonicalHost) {\n throw new Error(`${field}[${index}] cannot be the canonical host.`)\n }\n })\n const duplicate = hosts.find((host, index) => hosts.indexOf(host) !== index)\n if (duplicate) throw new Error(`${field} contains duplicate host \"${duplicate}\".`)\n}\n"]}
|