@brandlab-digital/site-core 3.10.0 → 3.12.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/dist/prices.js ADDED
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Typical prices (`src/data/prices.ts`). One band per job, site-wide, each with where its figures came from and when
3
+ * they were checked. A band renders only in a renderable status: confirmed by the owner, the business's own published
4
+ * prices, or researched bands Romie has signed off for that client (`romie-approved`, his accepted risk, dated by
5
+ * `checkedOn`). A `held` band never renders; the page links to the cost guide instead.
6
+ *
7
+ * Prices are labelled "Typical prices", never "{suburb} prices" or "market rates". A part price (a call-out fee, an
8
+ * hourly rate) only ever shows beside the full price of the job: NSW Fair Trading, "you cannot state a price that is
9
+ * only a part of the cost unless the single price is also clearly stated".
10
+ */
11
+ export const BRANDLAB_PRICE_STATUSES = ['owner-confirmed', 'published', 'romie-approved', 'held'];
12
+ /** The statuses that may render on a page. */
13
+ export const RENDERABLE_PRICE_STATUSES = ['owner-confirmed', 'published', 'romie-approved'];
14
+ /** The default caption of every price table. */
15
+ export const PRICE_CAPTION = 'Typical prices';
16
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
17
+ const SERVICE_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
18
+ const MARKET_WORDING = /\bmarket\s+(?:rates?|prices?|pricing)\b/i;
19
+ const RENDERABLE = new Set(RENDERABLE_PRICE_STATUSES);
20
+ function isText(value, max = 500) {
21
+ return typeof value === 'string' && value.trim() !== '' && value.length <= max;
22
+ }
23
+ function isAmount(value) {
24
+ return typeof value === 'number' && Number.isFinite(value) && value > 0;
25
+ }
26
+ /** The duplicate key for a job: case, spacing and punctuation don't make a second band. */
27
+ function jobKey(job) {
28
+ return job
29
+ .toLowerCase()
30
+ .replace(/[^a-z0-9]+/g, ' ')
31
+ .trim();
32
+ }
33
+ function rowIssues(row) {
34
+ const issues = [];
35
+ if (!row || typeof row !== 'object')
36
+ return ['A price row is a record.'];
37
+ if (typeof row.service !== 'string' || !SERVICE_SLUG.test(row.service))
38
+ issues.push('service must be a service slug.');
39
+ if (!isText(row.job, 120))
40
+ issues.push('job needs a short label (at most 120 characters).');
41
+ if (!isAmount(row.low) || !isAmount(row.high))
42
+ issues.push('low and high must be dollar amounts above zero.');
43
+ else if (row.low > row.high)
44
+ issues.push('low cannot be above high.');
45
+ if (row.unit !== undefined && (!isText(row.unit, 60) || /gst/i.test(row.unit) || /^\s*from\b/i.test(row.unit))) {
46
+ issues.push('unit names what the band is per, for example "per square metre"; GST is the gstIncluded flag.');
47
+ }
48
+ for (const field of ['includes', 'excludes']) {
49
+ const list = row[field];
50
+ if (list !== undefined && (!Array.isArray(list) || !list.every((item) => isText(item, 200)))) {
51
+ issues.push(`${field} must be a list of short phrases.`);
52
+ }
53
+ }
54
+ if (row.gstIncluded !== undefined && typeof row.gstIncluded !== 'boolean')
55
+ issues.push('gstIncluded must be true or false.');
56
+ if (row.parts !== undefined) {
57
+ if (!Array.isArray(row.parts))
58
+ issues.push('parts must be a list.');
59
+ else {
60
+ for (const part of row.parts) {
61
+ if (!part || !isText(part.label, 80))
62
+ issues.push('every part needs a short label.');
63
+ else if (!isAmount(part.low) || (part.high !== undefined && (!isAmount(part.high) || part.high < part.low))) {
64
+ issues.push(`part "${part.label}" needs a dollar amount above zero (low, and high when it is a band).`);
65
+ }
66
+ else if (isAmount(row.high) && (part.high ?? part.low) > row.high) {
67
+ issues.push(`part "${part.label}" cannot be more than the full price.`);
68
+ }
69
+ }
70
+ }
71
+ }
72
+ if (!BRANDLAB_PRICE_STATUSES.includes(row.status)) {
73
+ issues.push(`status must be one of ${BRANDLAB_PRICE_STATUSES.join(', ')}.`);
74
+ }
75
+ if (!isText(row.source))
76
+ issues.push('source must say where the figures came from (at most 500 characters).');
77
+ if (typeof row.checkedOn !== 'string' || !ISO_DATE.test(row.checkedOn) || Number.isNaN(Date.parse(row.checkedOn))) {
78
+ issues.push('checkedOn must be a YYYY-MM-DD date.');
79
+ }
80
+ const words = [row.job, row.unit, ...(row.includes ?? []), ...(row.excludes ?? [])].filter((value) => typeof value === 'string');
81
+ if (words.some((value) => MARKET_WORDING.test(value)))
82
+ issues.push('prices are the business\'s typical prices, never "market rates".');
83
+ return issues;
84
+ }
85
+ /**
86
+ * Every problem in a price list: malformed rows, part prices above the full price, "market" wording and any job priced
87
+ * twice (one band per job, site-wide).
88
+ */
89
+ export function validatePrices(rows) {
90
+ const issues = [];
91
+ const seen = new Map();
92
+ rows.forEach((row, index) => {
93
+ const job = typeof row?.job === 'string' ? row.job : '';
94
+ for (const detail of rowIssues(row))
95
+ issues.push({ index, job, detail });
96
+ if (!job.trim())
97
+ return;
98
+ const key = jobKey(job);
99
+ const first = seen.get(key);
100
+ if (first === undefined)
101
+ seen.set(key, index);
102
+ else
103
+ issues.push({ index, job, detail: `repeats prices[${first}]: one band per job, site-wide.` });
104
+ });
105
+ return issues;
106
+ }
107
+ /**
108
+ * Declares the site's typical prices (`src/data/prices.ts`). Fails on malformed rows, part prices above the full
109
+ * price, "market" wording and duplicate jobs; fills `gstIncluded` (true), `includes`, `excludes` and `parts`.
110
+ */
111
+ export function definePrices(rows) {
112
+ if (!Array.isArray(rows))
113
+ throw new Error('Prices are a list of rows.');
114
+ const issues = validatePrices(rows);
115
+ if (issues.length > 0) {
116
+ const shown = issues.slice(0, 20).map((issue) => `- prices[${issue.index}] ${issue.job || '(no job)'}: ${issue.detail}`);
117
+ const more = issues.length > shown.length ? `\n- …and ${issues.length - shown.length} more` : '';
118
+ throw new Error(`Invalid prices:\n${shown.join('\n')}${more}`);
119
+ }
120
+ return Object.freeze(rows.map((row) => Object.freeze({
121
+ ...row,
122
+ gstIncluded: row.gstIncluded ?? true,
123
+ includes: Object.freeze([...(row.includes ?? [])]),
124
+ excludes: Object.freeze([...(row.excludes ?? [])]),
125
+ parts: Object.freeze((row.parts ?? []).map((part) => Object.freeze({ ...part }))),
126
+ })));
127
+ }
128
+ /** Whether a band may render: owner-confirmed, published or romie-approved. `held` never renders. */
129
+ export function isRenderablePrice(price) {
130
+ return RENDERABLE.has(price.status);
131
+ }
132
+ /** The bands a page may show, in file order, optionally for one service. */
133
+ export function renderablePrices(prices, service) {
134
+ return prices.filter((price) => isRenderablePrice(price) && (service === undefined || price.service === service));
135
+ }
136
+ /** Whole dollars as "$1,200"; cents only when the amount has them ("$89.50"). */
137
+ export function formatAud(amount) {
138
+ const whole = Number.isInteger(amount);
139
+ return new Intl.NumberFormat('en-AU', {
140
+ style: 'currency',
141
+ currency: 'AUD',
142
+ minimumFractionDigits: whole ? 0 : 2,
143
+ maximumFractionDigits: whole ? 0 : 2,
144
+ }).format(amount);
145
+ }
146
+ /** A band as "$1,200–$2,500", or one figure when the bottom and top match. Never "from $X". */
147
+ export function formatPriceBand(band) {
148
+ if (band.high === undefined || band.high === band.low)
149
+ return formatAud(band.low);
150
+ return `${formatAud(band.low)}–${formatAud(band.high)}`;
151
+ }
152
+ /**
153
+ * Whether a price table caption keeps to the rule: "Typical prices", or "Typical {service} prices" where {service} is
154
+ * one of the given service slugs with hyphens as spaces ("Typical tree removal prices" for `tree-removal`). A place
155
+ * name ("Typical parramatta prices") or "market rates" never passes.
156
+ */
157
+ export function isAllowedPriceCaption(caption, services = []) {
158
+ if (typeof caption !== 'string')
159
+ return false;
160
+ if (caption === PRICE_CAPTION)
161
+ return true;
162
+ return services.some((service) => SERVICE_SLUG.test(service) && caption === `Typical ${service.replace(/-/g, ' ')} prices`);
163
+ }
164
+ /** Throws when a caption breaks the "Typical prices" rule. */
165
+ export function assertPriceCaption(caption, services = []) {
166
+ if (!isAllowedPriceCaption(caption, services)) {
167
+ throw new Error(`Price caption "${caption}" is not allowed: use "${PRICE_CAPTION}" or "Typical {service} prices" for a service on the page, never a place name or "market rates".`);
168
+ }
169
+ }
170
+ /** Throws when a GST flag label is missing "GST" or reads as a "+ GST" teaser. */
171
+ export function assertGstLabel(label, field = 'GST label') {
172
+ if (!isText(label, 40) || !/\bGST\b/.test(label) || label.includes('+')) {
173
+ throw new Error(`${field} "${label}" must name GST in a short phrase such as "incl. GST", never "+ GST".`);
174
+ }
175
+ }
176
+ //# sourceMappingURL=prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prices.js","sourceRoot":"","sources":["../src/prices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,CAAU,CAAA;AAG1G,8CAA8C;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,CAAmD,CAAA;AAE7I,gDAAgD;AAChD,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAA;AAkD7C,MAAM,QAAQ,GAAG,qBAAqB,CAAA;AACtC,MAAM,YAAY,GAAG,4BAA4B,CAAA;AACjD,MAAM,cAAc,GAAG,0CAA0C,CAAA;AACjE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS,yBAAyB,CAAC,CAAA;AAE7D,SAAS,MAAM,CAAC,KAAc,EAAE,GAAG,GAAG,GAAG;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAA;AAChF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAA;AACzE,CAAC;AAED,2FAA2F;AAC3F,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,GAAG;SACP,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,IAAI,EAAE,CAAA;AACX,CAAC;AAED,SAAS,SAAS,CAAC,GAAuB;IACxC,MAAM,MAA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kB,CAAC,OAAe,EAAE,WAA8B,EAAE;IAClF,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,kBAAkB,OAAO,0BAA0B,aAAa,kGAAkG,CACnK,CAAA;IACH,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,KAAK,GAAG,WAAW;IAC/D,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,KAAK,uEAAuE,CAAC,CAAA;IAC5G,CAAC;AACH,CAAC","sourcesContent":["/**\n * Typical prices (`src/data/prices.ts`). One band per job, site-wide, each with where its figures came from and when\n * they were checked. A band renders only in a renderable status: confirmed by the owner, the business's own published\n * prices, or researched bands Romie has signed off for that client (`romie-approved`, his accepted risk, dated by\n * `checkedOn`). A `held` band never renders; the page links to the cost guide instead.\n *\n * Prices are labelled \"Typical prices\", never \"{suburb} prices\" or \"market rates\". A part price (a call-out fee, an\n * hourly rate) only ever shows beside the full price of the job: NSW Fair Trading, \"you cannot state a price that is\n * only a part of the cost unless the single price is also clearly stated\".\n */\n\nexport const BRANDLAB_PRICE_STATUSES = ['owner-confirmed', 'published', 'romie-approved', 'held'] as const\nexport type BrandlabPriceStatus = (typeof BRANDLAB_PRICE_STATUSES)[number]\n\n/** The statuses that may render on a page. */\nexport const RENDERABLE_PRICE_STATUSES = ['owner-confirmed', 'published', 'romie-approved'] as const satisfies readonly BrandlabPriceStatus[]\n\n/** The default caption of every price table. */\nexport const PRICE_CAPTION = 'Typical prices'\n\n/** A part of a job's price, such as a call-out fee. It only ever renders beside the job's full price. */\nexport interface BrandlabPricePart {\n /** What the part covers, for example \"Call-out fee\" or \"Each extra hour\". */\n readonly label: string\n readonly low: number\n /** The top of the part's band; omit for a fixed amount. */\n readonly high?: number\n}\n\n/** One row of `prices.ts` as a site writes it. */\nexport interface BrandlabPriceInput {\n /** The service slug the band belongs to (its money-service page). */\n readonly service: string\n /** The job the band prices, for example \"Single tree removal up to 10 m\". One band per job, site-wide. */\n readonly job: string\n /** The full price in dollars: the bottom and the top of the typical band. */\n readonly low: number\n readonly high: number\n /** What the band is per when it isn't the whole job, for example \"per square metre\". */\n readonly unit?: string\n readonly includes?: readonly string[]\n readonly excludes?: readonly string[]\n /** Whether the figures include GST. Defaults to true. */\n readonly gstIncluded?: boolean\n /** Parts of the price (a call-out fee, an hourly rate), shown only beside the full price. */\n readonly parts?: readonly BrandlabPricePart[]\n readonly status: BrandlabPriceStatus\n /** Where the figures came from: the owner's answer, the published price list or Romie's sign-off. */\n readonly source: string\n /** When the band was last checked, YYYY-MM-DD. */\n readonly checkedOn: string\n}\n\n/** A validated price row, with its defaults applied. */\nexport interface BrandlabPrice\n extends Readonly<Omit<BrandlabPriceInput, 'gstIncluded' | 'includes' | 'excludes' | 'parts'>> {\n readonly gstIncluded: boolean\n readonly includes: readonly string[]\n readonly excludes: readonly string[]\n readonly parts: readonly BrandlabPricePart[]\n}\n\nexport interface BrandlabPriceIssue {\n readonly index: number\n readonly job: string\n readonly detail: string\n}\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}$/\nconst SERVICE_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\nconst MARKET_WORDING = /\\bmarket\\s+(?:rates?|prices?|pricing)\\b/i\nconst RENDERABLE = new Set<string>(RENDERABLE_PRICE_STATUSES)\n\nfunction isText(value: unknown, max = 500): value is string {\n return typeof value === 'string' && value.trim() !== '' && value.length <= max\n}\n\nfunction isAmount(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value > 0\n}\n\n/** The duplicate key for a job: case, spacing and punctuation don't make a second band. */\nfunction jobKey(job: string) {\n return job\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, ' ')\n .trim()\n}\n\nfunction rowIssues(row: BrandlabPriceInput): string[] {\n const issues: string[] = []\n if (!row || typeof row !== 'object') return ['A price row is a record.']\n if (typeof row.service !== 'string' || !SERVICE_SLUG.test(row.service)) issues.push('service must be a service slug.')\n if (!isText(row.job, 120)) issues.push('job needs a short label (at most 120 characters).')\n if (!isAmount(row.low) || !isAmount(row.high)) issues.push('low and high must be dollar amounts above zero.')\n else if (row.low > row.high) issues.push('low cannot be above high.')\n if (row.unit !== undefined && (!isText(row.unit, 60) || /gst/i.test(row.unit) || /^\\s*from\\b/i.test(row.unit))) {\n issues.push('unit names what the band is per, for example \"per square metre\"; GST is the gstIncluded flag.')\n }\n for (const field of ['includes', 'excludes'] as const) {\n const list = row[field]\n if (list !== undefined && (!Array.isArray(list) || !list.every((item) => isText(item, 200)))) {\n issues.push(`${field} must be a list of short phrases.`)\n }\n }\n if (row.gstIncluded !== undefined && typeof row.gstIncluded !== 'boolean') issues.push('gstIncluded must be true or false.')\n if (row.parts !== undefined) {\n if (!Array.isArray(row.parts)) issues.push('parts must be a list.')\n else {\n for (const part of row.parts) {\n if (!part || !isText(part.label, 80)) issues.push('every part needs a short label.')\n else if (!isAmount(part.low) || (part.high !== undefined && (!isAmount(part.high) || part.high < part.low))) {\n issues.push(`part \"${part.label}\" needs a dollar amount above zero (low, and high when it is a band).`)\n } else if (isAmount(row.high) && (part.high ?? part.low) > row.high) {\n issues.push(`part \"${part.label}\" cannot be more than the full price.`)\n }\n }\n }\n }\n if (!(BRANDLAB_PRICE_STATUSES as readonly string[]).includes(row.status)) {\n issues.push(`status must be one of ${BRANDLAB_PRICE_STATUSES.join(', ')}.`)\n }\n if (!isText(row.source)) issues.push('source must say where the figures came from (at most 500 characters).')\n if (typeof row.checkedOn !== 'string' || !ISO_DATE.test(row.checkedOn) || Number.isNaN(Date.parse(row.checkedOn))) {\n issues.push('checkedOn must be a YYYY-MM-DD date.')\n }\n const words = [row.job, row.unit, ...(row.includes ?? []), ...(row.excludes ?? [])].filter((value) => typeof value === 'string')\n if (words.some((value) => MARKET_WORDING.test(value))) issues.push('prices are the business\\'s typical prices, never \"market rates\".')\n return issues\n}\n\n/**\n * Every problem in a price list: malformed rows, part prices above the full price, \"market\" wording and any job priced\n * twice (one band per job, site-wide).\n */\nexport function validatePrices(rows: readonly BrandlabPriceInput[]): BrandlabPriceIssue[] {\n const issues: BrandlabPriceIssue[] = []\n const seen = new Map<string, number>()\n rows.forEach((row, index) => {\n const job = typeof row?.job === 'string' ? row.job : ''\n for (const detail of rowIssues(row)) issues.push({ index, job, detail })\n if (!job.trim()) return\n const key = jobKey(job)\n const first = seen.get(key)\n if (first === undefined) seen.set(key, index)\n else issues.push({ index, job, detail: `repeats prices[${first}]: one band per job, site-wide.` })\n })\n return issues\n}\n\n/**\n * Declares the site's typical prices (`src/data/prices.ts`). Fails on malformed rows, part prices above the full\n * price, \"market\" wording and duplicate jobs; fills `gstIncluded` (true), `includes`, `excludes` and `parts`.\n */\nexport function definePrices(rows: readonly BrandlabPriceInput[]): readonly BrandlabPrice[] {\n if (!Array.isArray(rows)) throw new Error('Prices are a list of rows.')\n const issues = validatePrices(rows)\n if (issues.length > 0) {\n const shown = issues.slice(0, 20).map((issue) => `- prices[${issue.index}] ${issue.job || '(no job)'}: ${issue.detail}`)\n const more = issues.length > shown.length ? `\\n- …and ${issues.length - shown.length} more` : ''\n throw new Error(`Invalid prices:\\n${shown.join('\\n')}${more}`)\n }\n return Object.freeze(\n rows.map((row) =>\n Object.freeze({\n ...row,\n gstIncluded: row.gstIncluded ?? true,\n includes: Object.freeze([...(row.includes ?? [])]),\n excludes: Object.freeze([...(row.excludes ?? [])]),\n parts: Object.freeze((row.parts ?? []).map((part: BrandlabPricePart) => Object.freeze({ ...part }))),\n }),\n ),\n )\n}\n\n/** Whether a band may render: owner-confirmed, published or romie-approved. `held` never renders. */\nexport function isRenderablePrice(price: Pick<BrandlabPrice, 'status'>): boolean {\n return RENDERABLE.has(price.status)\n}\n\n/** The bands a page may show, in file order, optionally for one service. */\nexport function renderablePrices<T extends Pick<BrandlabPrice, 'status' | 'service'>>(\n prices: readonly T[],\n service?: string,\n): T[] {\n return prices.filter((price) => isRenderablePrice(price) && (service === undefined || price.service === service))\n}\n\n/** Whole dollars as \"$1,200\"; cents only when the amount has them (\"$89.50\"). */\nexport function formatAud(amount: number): string {\n const whole = Number.isInteger(amount)\n return new Intl.NumberFormat('en-AU', {\n style: 'currency',\n currency: 'AUD',\n minimumFractionDigits: whole ? 0 : 2,\n maximumFractionDigits: whole ? 0 : 2,\n }).format(amount)\n}\n\n/** A band as \"$1,200–$2,500\", or one figure when the bottom and top match. Never \"from $X\". */\nexport function formatPriceBand(band: { readonly low: number; readonly high?: number | undefined }): string {\n if (band.high === undefined || band.high === band.low) return formatAud(band.low)\n return `${formatAud(band.low)}–${formatAud(band.high)}`\n}\n\n/**\n * Whether a price table caption keeps to the rule: \"Typical prices\", or \"Typical {service} prices\" where {service} is\n * one of the given service slugs with hyphens as spaces (\"Typical tree removal prices\" for `tree-removal`). A place\n * name (\"Typical parramatta prices\") or \"market rates\" never passes.\n */\nexport function isAllowedPriceCaption(caption: string, services: readonly string[] = []): boolean {\n if (typeof caption !== 'string') return false\n if (caption === PRICE_CAPTION) return true\n return services.some((service) => SERVICE_SLUG.test(service) && caption === `Typical ${service.replace(/-/g, ' ')} prices`)\n}\n\n/** Throws when a caption breaks the \"Typical prices\" rule. */\nexport function assertPriceCaption(caption: string, services: readonly string[] = []): void {\n if (!isAllowedPriceCaption(caption, services)) {\n throw new Error(\n `Price caption \"${caption}\" is not allowed: use \"${PRICE_CAPTION}\" or \"Typical {service} prices\" for a service on the page, never a place name or \"market rates\".`,\n )\n }\n}\n\n/** Throws when a GST flag label is missing \"GST\" or reads as a \"+ GST\" teaser. */\nexport function assertGstLabel(label: string, field = 'GST label'): void {\n if (!isText(label, 40) || !/\\bGST\\b/.test(label) || label.includes('+')) {\n throw new Error(`${field} \"${label}\" must name GST in a short phrase such as \"incl. GST\", never \"+ GST\".`)\n }\n}\n"]}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Section order (v2 §3.3 matrix part A; LIB §7a for hubs and company pages). Every page family has a default order of
3
+ * sections, each required (R: skipped only when nothing true exists, and the manifest says why), conditional (C:
4
+ * renders when its data exists), recommended (Rec) or optional (O). Sections a family doesn't use (N) are not in its
5
+ * list. The hero or page header comes first and the CTA band last; a site may record an alternative order per family.
6
+ * The permit note is a line inside `LocalFacts` (permit trades), not a section of its own.
7
+ *
8
+ * `planSectionSequence` is the sequencer's logic (F15), shared by `SectionSequence` in site-next and the K8 and K12
9
+ * checks: skip what has nothing true to show, enforce the cap (only optional and recommended sections drop),
10
+ * alternate the light tones so neighbours differ (at most one `band` and one `photo`) and write the per-page manifest.
11
+ */
12
+ export declare const BRANDLAB_SECTION_IDS: readonly ["hero", "page-header", "article-header", "answer", "proof-strip", "emergency", "services", "local-facts", "nearby-jobs", "service-detail", "price-guide", "projects", "before-after", "gallery", "reviews", "comparison", "about-owner", "signature", "process", "guarantee", "licences", "partners", "team", "coverage", "area-map", "faqs", "nearby-areas", "related-services", "guides", "contact", "cta"];
13
+ export type BrandlabSectionId = (typeof BRANDLAB_SECTION_IDS)[number];
14
+ export declare const BRANDLAB_PAGE_FAMILIES: readonly ["home", "service", "service-in-suburb", "region", "suburb", "cost-guide", "services-hub", "locations-hub", "projects-hub", "project", "gallery", "reviews", "about", "faqs", "contact", "guides-hub", "guide", "council", "emergency"];
15
+ export type BrandlabPageFamily = (typeof BRANDLAB_PAGE_FAMILIES)[number];
16
+ /** R required, C conditional, Rec recommended, O optional (N, not used, is simply absent from a family's list). */
17
+ export declare const BRANDLAB_SECTION_REQUIREMENTS: readonly ["R", "C", "Rec", "O"];
18
+ export type BrandlabSectionRequirement = (typeof BRANDLAB_SECTION_REQUIREMENTS)[number];
19
+ /** The section tones: two alternating grounds, one optional band and one optional photo ground. */
20
+ export declare const BRANDLAB_SECTION_TONES: readonly ["canvas", "surface", "band", "photo"];
21
+ export type BrandlabSectionTone = (typeof BRANDLAB_SECTION_TONES)[number];
22
+ /** What a section asks for: a light tone the sequencer picks (`auto`), the page's one band or its one photo ground. */
23
+ export type BrandlabSectionToneRequest = 'auto' | 'band' | 'photo';
24
+ export interface BrandlabSectionOrderEntry {
25
+ readonly id: BrandlabSectionId;
26
+ readonly requirement: BrandlabSectionRequirement;
27
+ /** Sections that may fill this place instead, for example `before-after` for `projects`. */
28
+ readonly alternatives?: readonly BrandlabSectionId[];
29
+ /** Shares one matrix position with that section: when both render they count once toward the cap. */
30
+ readonly countsWith?: BrandlabSectionId;
31
+ }
32
+ export interface BrandlabFamilyOrder {
33
+ readonly family: BrandlabPageFamily;
34
+ /** The most sections the page renders (v1 §7.1). */
35
+ readonly cap: number;
36
+ readonly source: 'default' | 'recorded';
37
+ readonly entries: readonly BrandlabSectionOrderEntry[];
38
+ }
39
+ /** 11 on home and service-in-suburb pages, 12 on service, region and suburb pages, 6 on hubs and company pages. */
40
+ export declare const SECTION_CAPS: Readonly<Record<BrandlabPageFamily, number>>;
41
+ /** The playbook trades (v2 §5, matrix part B). */
42
+ export declare const BRANDLAB_TRADES: readonly ["building", "electrical", "exterior", "interiors", "landscaping", "plumbing", "pools", "renovations", "roofing", "tiling", "trees"];
43
+ export type BrandlabTrade = (typeof BRANDLAB_TRADES)[number];
44
+ /** A trade's changes to the defaults: a new requirement for a section already in a family's order. */
45
+ export type BrandlabTradeSectionRules = Readonly<Partial<Record<BrandlabPageFamily, Readonly<Partial<Record<BrandlabSectionId, BrandlabSectionRequirement>>>>>>;
46
+ /**
47
+ * The trade map (matrix part B). A stub in 3.11.0: every trade uses the defaults until its playbook's rules are
48
+ * confirmed per client (licence classes, permit notes and emergency work are "inferred, confirm" in the matrix).
49
+ */
50
+ export declare const SECTION_ORDER_TRADE_MAP: Readonly<Record<BrandlabTrade, BrandlabTradeSectionRules>>;
51
+ /** A family's default order, with the trade's rules applied. */
52
+ export declare function defaultSectionOrder(family: BrandlabPageFamily, trade?: BrandlabTrade, tradeMap?: Readonly<Partial<Record<BrandlabTrade, BrandlabTradeSectionRules>>>): BrandlabFamilyOrder;
53
+ /** A site's recorded alternative order for one family (LIB §7a), with the decision that recorded it. */
54
+ export interface BrandlabRecordedSectionOrder {
55
+ readonly order: readonly BrandlabSectionId[];
56
+ /** Who decided and why, for example "Romie, 19 Oct 2026: reviews before prices for Superior". */
57
+ readonly decision: string;
58
+ /** YYYY-MM-DD. */
59
+ readonly recordedOn: string;
60
+ }
61
+ export interface BrandlabSectionOrderInput {
62
+ readonly trade?: BrandlabTrade;
63
+ readonly recorded?: Readonly<Partial<Record<BrandlabPageFamily, BrandlabRecordedSectionOrder>>>;
64
+ }
65
+ export type BrandlabSectionOrders = Readonly<Record<BrandlabPageFamily, BrandlabFamilyOrder>>;
66
+ /**
67
+ * Declares a site's section orders (`src/data/strategy.ts`): the defaults for every family, the trade's rules and any
68
+ * recorded alternative orders. A recorded order keeps every required and conditional section, the first section
69
+ * first, the CTA band last and the proof strip within the first five; the contact page can't be reordered.
70
+ */
71
+ export declare function defineSectionOrder(input?: BrandlabSectionOrderInput, tradeMap?: Readonly<Partial<Record<BrandlabTrade, BrandlabTradeSectionRules>>>): BrandlabSectionOrders;
72
+ /** The reasons the sequencer itself skips a section. */
73
+ export declare const SEQUENCER_SKIP_REASONS: readonly ["not-provided", "not-in-order", "duplicate", "cap"];
74
+ export type BrandlabSequencerSkipReason = (typeof SEQUENCER_SKIP_REASONS)[number];
75
+ /**
76
+ * A section's own, data-backed reason for rendering nothing: the data it needs isn't there (`no-feed-reviews`,
77
+ * `no-approved-prices`, `no-jobs-nearby`, `no-faqs` and so on), or its content belongs in the hero checklist.
78
+ */
79
+ export type BrandlabSectionDataReason = `no-${string}` | 'merge-into-hero-checklist';
80
+ export type BrandlabSectionSkipReason = BrandlabSectionDataReason | BrandlabSequencerSkipReason;
81
+ /** A section's guard, computed from the same data it renders: render, or render nothing and say why. */
82
+ export type BrandlabSectionReadiness = {
83
+ readonly render: true;
84
+ } | {
85
+ readonly render: false;
86
+ readonly reason: BrandlabSectionDataReason;
87
+ };
88
+ export declare const SECTION_READY: BrandlabSectionReadiness;
89
+ /** Whether a skip reason says the data isn't there (as opposed to the sequencer's own reasons). */
90
+ export declare function isDataBackedSkipReason(reason: string): reason is BrandlabSectionDataReason;
91
+ /** The attribute on the manifest's `<script type="application/json">`. */
92
+ export declare const SECTION_MANIFEST_ATTRIBUTE = "data-bl-manifest";
93
+ /**
94
+ * Page-level notes in the manifest. `cap-exceeded`: the required and conditional sections with data are more than
95
+ * the cap, so they all render (neither drops for the cap) and the page is over its cap.
96
+ */
97
+ export declare const SECTION_MANIFEST_FLAGS: readonly ["cap-exceeded"];
98
+ export type BrandlabSectionManifestFlag = (typeof SECTION_MANIFEST_FLAGS)[number];
99
+ /** The per-page manifest K12 reads: what was planned, what rendered with which tone, and what was skipped and why. */
100
+ export interface BrandlabSectionManifest {
101
+ readonly version: 1;
102
+ readonly family: BrandlabPageFamily;
103
+ readonly page?: string;
104
+ readonly cap: number;
105
+ readonly order: 'default' | 'recorded';
106
+ readonly planned: readonly {
107
+ readonly id: BrandlabSectionId;
108
+ readonly requirement: BrandlabSectionRequirement;
109
+ }[];
110
+ /** `id` is the planned place; `section` is what filled it (an alternative such as `before-after`, or the same id). */
111
+ readonly rendered: readonly {
112
+ readonly id: BrandlabSectionId;
113
+ readonly section: BrandlabSectionId;
114
+ readonly requirement: BrandlabSectionRequirement;
115
+ readonly tone: BrandlabSectionTone;
116
+ }[];
117
+ readonly skipped: readonly {
118
+ readonly id: BrandlabSectionId;
119
+ readonly section: BrandlabSectionId;
120
+ readonly requirement: BrandlabSectionRequirement | 'N';
121
+ readonly reason: BrandlabSectionSkipReason;
122
+ }[];
123
+ /** The rendered sections counted toward the cap (sections sharing one matrix position count once). */
124
+ readonly counted: number;
125
+ readonly flags: readonly BrandlabSectionManifestFlag[];
126
+ }
127
+ /** One section a page offers the sequencer. */
128
+ export interface BrandlabSequenceCandidate {
129
+ readonly id: BrandlabSectionId;
130
+ /** Defaults to ready. */
131
+ readonly ready?: BrandlabSectionReadiness;
132
+ /** Defaults to `auto`. */
133
+ readonly tone?: BrandlabSectionToneRequest;
134
+ }
135
+ export interface BrandlabSequencePlan {
136
+ /** What renders, in order: the candidate's index, the planned place and the tone. */
137
+ readonly rendered: readonly {
138
+ readonly candidate: number;
139
+ readonly id: BrandlabSectionId;
140
+ readonly tone: BrandlabSectionTone;
141
+ }[];
142
+ readonly manifest: BrandlabSectionManifest;
143
+ }
144
+ /**
145
+ * Tones for the sections that render, in order. `auto` sections alternate canvas and surface, so neighbours never
146
+ * share a background; after a band or photo section the next light tone is the one the last light section didn't
147
+ * have (Omega's `alternateTones`). Only the first `band` request and the first `photo` request are honoured, and
148
+ * never twice in a row; later requests fall back to the light tones.
149
+ */
150
+ export declare function assignSectionTones(requests: readonly BrandlabSectionToneRequest[]): BrandlabSectionTone[];
151
+ /**
152
+ * Plans one page: matches the page's candidate sections to the family order, skips what isn't ready, isn't offered or
153
+ * isn't in the order, enforces the cap (optional, then recommended sections drop, last first; required and
154
+ * conditional sections with data never drop: when they alone exceed the cap they all render and the manifest flags
155
+ * `cap-exceeded`), assigns tones and writes the manifest.
156
+ */
157
+ export declare function planSectionSequence(order: BrandlabFamilyOrder, candidates: readonly BrandlabSequenceCandidate[], page?: string): BrandlabSequencePlan;
158
+ //# sourceMappingURL=section-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section-order.d.ts","sourceRoot":"","sources":["../src/section-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,oBAAoB,yZAgCvB,CAAA;AACV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAErE,eAAO,MAAM,sBAAsB,kPAoBzB,CAAA;AACV,MAAM,MAAM,kBAAkB,GAA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