@brandlab-digital/site-core 3.13.0 → 3.15.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.
Files changed (44) hide show
  1. package/README.md +105 -0
  2. package/dist/area-map.d.ts +36 -3
  3. package/dist/area-map.d.ts.map +1 -1
  4. package/dist/area-map.js +71 -11
  5. package/dist/area-map.js.map +1 -1
  6. package/dist/business.d.ts +97 -0
  7. package/dist/business.d.ts.map +1 -1
  8. package/dist/business.js +128 -0
  9. package/dist/business.js.map +1 -1
  10. package/dist/council-register.d.ts +53 -0
  11. package/dist/council-register.d.ts.map +1 -0
  12. package/dist/council-register.js +113 -0
  13. package/dist/council-register.js.map +1 -0
  14. package/dist/geography.js +2 -2
  15. package/dist/geography.js.map +1 -1
  16. package/dist/jobs.d.ts +74 -0
  17. package/dist/jobs.d.ts.map +1 -0
  18. package/dist/jobs.js +116 -0
  19. package/dist/jobs.js.map +1 -0
  20. package/dist/locations.d.ts +10 -0
  21. package/dist/locations.d.ts.map +1 -1
  22. package/dist/locations.js +15 -0
  23. package/dist/locations.js.map +1 -1
  24. package/dist/navigation.d.ts +37 -1
  25. package/dist/navigation.d.ts.map +1 -1
  26. package/dist/navigation.js +107 -2
  27. package/dist/navigation.js.map +1 -1
  28. package/dist/page-titles.d.ts +71 -0
  29. package/dist/page-titles.d.ts.map +1 -0
  30. package/dist/page-titles.js +161 -0
  31. package/dist/page-titles.js.map +1 -0
  32. package/dist/project.d.ts +23 -0
  33. package/dist/project.d.ts.map +1 -1
  34. package/dist/project.js +33 -1
  35. package/dist/project.js.map +1 -1
  36. package/dist/section-order.d.ts +49 -3
  37. package/dist/section-order.d.ts.map +1 -1
  38. package/dist/section-order.js +108 -3
  39. package/dist/section-order.js.map +1 -1
  40. package/dist/strategy.d.ts +208 -0
  41. package/dist/strategy.d.ts.map +1 -1
  42. package/dist/strategy.js +340 -2
  43. package/dist/strategy.js.map +1 -1
  44. package/package.json +13 -1
@@ -81,13 +81,48 @@ export interface SitePhrases {
81
81
  /** Every primary phrase with its owning page. No phrase has two owners. */
82
82
  owners: readonly SitePhraseOwner[];
83
83
  }
84
+ /**
85
+ * A wave's kind (3.14.0): `release` brings new pages (they may not be built before the day); `return` brings existing
86
+ * pages of an existing estate back to the index (they are built and live now, noindex until the day).
87
+ */
88
+ export declare const SITE_WAVE_KINDS: readonly ["release", "return"];
89
+ export type SiteWaveKind = (typeof SITE_WAVE_KINDS)[number];
84
90
  /** One wave of a location estate's release (v2 §4.4 step 8). */
85
91
  export interface SiteReleaseWave {
86
92
  /** YYYY-MM-DD: from this day the wave's pages are indexable and in the sitemap. */
87
93
  releaseOn: string;
94
+ /** Defaults to `release` (3.14.0). */
95
+ kind?: SiteWaveKind;
88
96
  /** Paths or patterns: `*` matches within one path segment, `**` across segments, for example "/services/decking/*". */
89
97
  routes: readonly string[];
90
98
  }
99
+ /**
100
+ * Where an estate's location pages live (3.14.0): one path per family, with `{region}` or `{suburb}` as the last
101
+ * segment. Service-in-suburb families may nest under a service (`/tree-services/stump-grinding/{suburb}`); their
102
+ * service-region hubs take `{region}` in the same place.
103
+ */
104
+ export interface SiteEstatePaths {
105
+ region?: string;
106
+ suburb?: string;
107
+ serviceInSuburb?: readonly string[];
108
+ }
109
+ /**
110
+ * An existing location estate's plan (3.14.0, D4 b): the pages indexed now, where the families live and the public
111
+ * slugs that differ from the registry's. Every location page is indexed now or listed in a wave; a page indexed now
112
+ * never waits for a wave. Where region and suburb pages share a parent, a region slug that is also a suburb's sends the
113
+ * suburb to "{slug}-suburb" (AA: region `ryde`, suburb `ryde-suburb`). Public slugs apply on every location path.
114
+ */
115
+ export interface SiteEstatePlan {
116
+ /** Paths or patterns of the location pages indexable and in the sitemap today. */
117
+ indexedNow: readonly string[];
118
+ paths?: SiteEstatePaths;
119
+ slugs?: {
120
+ /** Registry region slug → public slug, for example `{ 'ryde-area': 'ryde' }`. */
121
+ regions?: Readonly<Record<string, string>>;
122
+ /** Registry suburb slug → public slug, always "{slug}-suburb", for example `{ ryde: 'ryde-suburb' }`. */
123
+ suburbs?: Readonly<Record<string, string>>;
124
+ };
125
+ }
91
126
  /**
92
127
  * Both fields are optional so a site can start the record before its look is settled; check D4 still fails a new
93
128
  * build or redesign whose record lacks either.
@@ -106,6 +141,8 @@ export interface SiteStrategy {
106
141
  * noindex or out of the sitemap until that day; every other location page is indexable and listed now.
107
142
  */
108
143
  waves?: readonly SiteReleaseWave[];
144
+ /** An existing estate's plan: pages indexed now, family paths and public slugs (3.14.0). */
145
+ estate?: SiteEstatePlan;
109
146
  }
110
147
  /**
111
148
  * Consecutive waves go out at least 14 and at most 28 days apart, and the next wave still to come is at most 28 days
@@ -123,4 +160,175 @@ export declare function waveForRoute(waves: readonly SiteReleaseWave[], path: st
123
160
  export declare function sydneyToday(date?: Date): string;
124
161
  /** Validates a site strategy record and returns it with its literal types kept. */
125
162
  export declare function defineSiteStrategy<const T extends SiteStrategy>(strategy: T): T;
163
+ /** Job mode per money service (v2 §2.2): it sets which of phone and quote is styled primary, never their order. */
164
+ export declare const SITE_JOB_MODES: readonly ["urgent", "planned", "mixed"];
165
+ export type SiteJobMode = (typeof SITE_JOB_MODES)[number];
166
+ /** How a service is bought beside its job mode: as an add-on to another job, or in a season. */
167
+ export declare const SITE_JOB_PATTERNS: readonly ["add-on", "seasonal"];
168
+ export type SiteJobPattern = (typeof SITE_JOB_PATTERNS)[number];
169
+ /**
170
+ * Where a money service lives on location pages (v2 §4.4 step 1): the main trade owns the suburb page; a family of its
171
+ * own has service-in-suburb pages; anything else is a section on the suburb page.
172
+ */
173
+ export declare const SITE_LOCATION_ROLES: readonly ["owns-suburb-page", "service-in-suburb-pages", "suburb-page-section"];
174
+ export type SiteLocationRole = (typeof SITE_LOCATION_ROLES)[number];
175
+ /** The typed reasons Romie may give for not publishing a suburb (v2 §4.3), including the owner-set `too-far`. */
176
+ export declare const SITE_EXCLUSION_REASONS: readonly ["rural", "not-residential", "water-access", "too-far", "not-a-real-suburb"];
177
+ export type SiteExclusionReason = (typeof SITE_EXCLUSION_REASONS)[number];
178
+ export declare const SITE_CONTACT_CHANNELS: readonly ["phone", "sms", "whatsapp", "email", "form"];
179
+ export type SiteContactChannel = (typeof SITE_CONTACT_CHANNELS)[number];
180
+ /** The seven fields of the decision card (v2 §12.2 step 2), at the top of `strategy.ts`. */
181
+ export interface SiteDecisionCard {
182
+ desiredWorkAndArea: string;
183
+ currentEnquiryConstraint: string;
184
+ /** The dated evidence: Search Console, GA4, SERPs, reviews. */
185
+ evidence: string;
186
+ selectedAction: string;
187
+ expectedMechanism: string;
188
+ successMeasure: string;
189
+ reviewDate: string;
190
+ }
191
+ /** A money service: one the business sells as its own job, confirmed by Romie. */
192
+ export interface SiteMoneyService {
193
+ /** The service page slug. */
194
+ slug: string;
195
+ name: string;
196
+ jobMode: SiteJobMode;
197
+ pattern?: SiteJobPattern;
198
+ /** Whether the service has a page in every served suburb (its own family, or the suburb page itself). */
199
+ suburbFamily: boolean;
200
+ onLocationPages: SiteLocationRole;
201
+ reason: string;
202
+ }
203
+ /** The 90-day lead baseline, target and read dates (v2 §9.4). Counts are what GA4 and the profile recorded. */
204
+ export interface SiteLeadBaseline {
205
+ /** YYYY-MM-DD, about 90 days. */
206
+ window: {
207
+ start: string;
208
+ end: string;
209
+ };
210
+ /** Provider-accepted form sends (`contact_form`). */
211
+ acceptedForms: number;
212
+ /** `phone_link_click` events. */
213
+ phoneTaps: number;
214
+ businessProfileCalls?: number | null;
215
+ qualifiedEnquiries?: number | null;
216
+ organicActions?: number;
217
+ paidActions?: number;
218
+ note?: string;
219
+ target: string;
220
+ /** Dates or milestones ("day 28 after launch"). */
221
+ readDates: readonly string[];
222
+ }
223
+ /** A true reason to choose the business, with the claims-register ids or named sources behind it. */
224
+ export interface SiteReasonToChoose {
225
+ text: string;
226
+ claims: readonly string[];
227
+ }
228
+ /** The owner's job economics; `null` until the owner says. Nothing renders from them. */
229
+ export interface SiteJobEconomics {
230
+ /** Whole dollars. */
231
+ averageJobValue: number | null;
232
+ /** A fraction from 0 to 1. */
233
+ closeRate: number | null;
234
+ capacityWeeksBooked: number | null;
235
+ /** The minimum job or call-out fee, as the owner put it. */
236
+ minimumJob: string | null;
237
+ unwantedJobs: readonly string[] | null;
238
+ preferredContact: SiteContactChannel | null;
239
+ }
240
+ /** One of the owner's (at most five) questions, with its fallback and dates. */
241
+ export interface SiteOwnerQuestion {
242
+ id: string;
243
+ question: string;
244
+ fallback: string;
245
+ /** YYYY-MM-DD. */
246
+ drafted: string;
247
+ sent?: string;
248
+ answered?: string;
249
+ }
250
+ export interface SiteExclusion {
251
+ suburb: string;
252
+ reason: SiteExclusionReason;
253
+ }
254
+ /**
255
+ * The typed decisions a site records beside its `siteStrategy` (v2 §2.4, §12.2 step 2): the decision card, the money
256
+ * services with their job modes, the lead baseline, the reasons to choose, the owner's economics and questions.
257
+ */
258
+ export interface SiteStrategyDecisions {
259
+ /** YYYY-MM-DD. */
260
+ recordedOn: string;
261
+ trade: string;
262
+ mainArea: string;
263
+ /** The home page's phrase, for example "tree services sydney". */
264
+ homePhrase: string;
265
+ decisionCard: SiteDecisionCard;
266
+ moneyServices: readonly SiteMoneyService[];
267
+ leadBaseline: SiteLeadBaseline;
268
+ /** Up to three (the spec asks for three; fewer is allowed so none is invented). */
269
+ reasonsToChoose: readonly SiteReasonToChoose[];
270
+ jobEconomics?: SiteJobEconomics;
271
+ /** The client's lane: where proof goes first. */
272
+ homeTerritory?: readonly string[];
273
+ tiers?: {
274
+ head: string;
275
+ standard: string;
276
+ noPage: string;
277
+ };
278
+ exclusions?: readonly SiteExclusion[];
279
+ ownerQuestions?: readonly SiteOwnerQuestion[];
280
+ }
281
+ export declare const SITE_MAX_OWNER_QUESTIONS = 5;
282
+ export declare const SITE_MAX_REASONS_TO_CHOOSE = 3;
283
+ /** Validates the decisions a site records beside its `siteStrategy` and returns them with their literal types kept. */
284
+ export declare function defineStrategyDecisions<const T extends SiteStrategyDecisions>(decisions: T): T;
285
+ /**
286
+ * What breaks an estate plan, in plain sentences (empty when nothing does): malformed routes or paths, a page indexed
287
+ * now that a wave still to come also lists, suburb renames other than "{slug}-suburb" and region and suburb pages that
288
+ * would share a path. Conformance's LOC-INDEX reads the same plan against the built pages.
289
+ */
290
+ export declare function estatePlanProblems(plan: SiteEstatePlan, waves: readonly SiteReleaseWave[], today?: string): string[];
291
+ /** A place's public slug in the estate: the plan's rename, or the registry slug. */
292
+ export declare function estatePublicSlug(plan: SiteEstatePlan, kind: 'region' | 'suburb', registrySlug: string): string;
293
+ /**
294
+ * A location page's path: the family's path with the place's public slug. `template` picks a nested service-in-suburb
295
+ * family (or its service-region hub, with `kind: 'region'`); it must be one of the plan's paths.
296
+ */
297
+ export declare function estateLocationPath(plan: SiteEstatePlan, kind: 'region' | 'suburb', registrySlug: string, template?: string): string;
298
+ /** Whether a location page is linked (`link`) or named as plain text (`text`) on the site's indexable pages. */
299
+ export type EstateLinkState = 'link' | 'text';
300
+ export interface EstateLinkOptions {
301
+ /** The estate plan (`siteStrategy.estate`). */
302
+ readonly estate?: SiteEstatePlan;
303
+ /** The release and return waves (`siteStrategy.waves`). */
304
+ readonly waves?: readonly SiteReleaseWave[];
305
+ /** The day the page is built for: YYYY-MM-DD in Sydney, or a moment read as that day in Sydney. Defaults to today. */
306
+ readonly on?: string | Date;
307
+ }
308
+ /**
309
+ * Whether an indexable page may link a location page (D4 return waves; LOC-INDEX reads the same plan): a page indexed
310
+ * now and a page whose wave is due (`releaseOn` on or before `on`) are links; a page still waiting for its wave is plain
311
+ * text, because indexable pages never link a noindex location page. With an estate plan, a page it does not account for
312
+ * is plain text too (LOC-INDEX fails it until it is listed); without one, a page no wave dates is live now. `path` is
313
+ * the public path, as `estateLocationPath` builds it (renamed slugs, nested service-in-suburb families).
314
+ */
315
+ export declare function estateLinkState(path: string, { estate, waves, on }: EstateLinkOptions): EstateLinkState;
316
+ /** One `Coverage` entry: a link to the area's page, or the area's name as plain text while its page waits for its wave. */
317
+ export interface CoverageEntry {
318
+ readonly label: string;
319
+ readonly href?: string;
320
+ }
321
+ export interface CoverageEntryOptions<P> extends EstateLinkOptions {
322
+ /** The place's public path. Defaults to the plan's suburb path (`estateLocationPath(estate, 'suburb', slug)`). */
323
+ readonly pathFor?: (place: P) => string;
324
+ }
325
+ /**
326
+ * `Coverage` entries for a list of places (a region's suburbs from the registry, in the order given): each live page is
327
+ * a link, each page still waiting for its wave the place's name as plain text, so a region page can list every suburb
328
+ * in the region and still count it in "All {n} areas".
329
+ */
330
+ export declare function coverageEntries<P extends {
331
+ readonly slug: string;
332
+ readonly name: string;
333
+ }>(places: readonly P[], options: CoverageEntryOptions<P>): CoverageEntry[];
126
334
  //# sourceMappingURL=strategy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../src/strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAEjE,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,sHAQnB,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7D,oGAAoG;AACpG,MAAM,WAAW,aAAa;IAC5B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAA;IACd,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAA;CACf;AAED,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAA;IACjB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAA;CACd;AAED,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,qHAAqH;I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QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,iBAAiB;IAChE,kHAAkH;IAClH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAA;CACxC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACxF,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,aAAa,EAAE,CAQjB"}
package/dist/strategy.js CHANGED
@@ -22,6 +22,11 @@ export const SITE_LOOK_LEVERS = [
22
22
  'photoTreatment',
23
23
  'homeSections',
24
24
  ];
25
+ /**
26
+ * A wave's kind (3.14.0): `release` brings new pages (they may not be built before the day); `return` brings existing
27
+ * pages of an existing estate back to the index (they are built and live now, noindex until the day).
28
+ */
29
+ export const SITE_WAVE_KINDS = ['release', 'return'];
25
30
  /**
26
31
  * Consecutive waves go out at least 14 and at most 28 days apart, and the next wave still to come is at most 28 days
27
32
  * after the last one released (or after today when none is) (v2 §4.4 step 8: never all at once, never open-ended).
@@ -168,7 +173,10 @@ function assertWaves(waves, today) {
168
173
  let previous;
169
174
  waves.forEach((wave, index) => {
170
175
  const field = `strategy.waves[${index}]`;
171
- assertExactKeys(wave, ['releaseOn', 'routes'], field);
176
+ assertExactKeys(wave, ['releaseOn', 'kind', 'routes'], field, ['kind']);
177
+ if (wave.kind !== undefined && !SITE_WAVE_KINDS.includes(wave.kind)) {
178
+ throw new Error(`${field}.kind must be one of ${SITE_WAVE_KINDS.join(', ')}.`);
179
+ }
172
180
  const day = typeof wave.releaseOn === 'string' && ISO_DAY.test(wave.releaseOn) ? Date.parse(`${wave.releaseOn}T00:00:00Z`) : Number.NaN;
173
181
  if (Number.isNaN(day) || new Date(day).toISOString().slice(0, 10) !== wave.releaseOn) {
174
182
  throw new Error(`${field}.releaseOn must be a YYYY-MM-DD date.`);
@@ -202,13 +210,19 @@ function assertWaves(waves, today) {
202
210
  }
203
211
  /** Validates a site strategy record and returns it with its literal types kept. */
204
212
  export function defineSiteStrategy(strategy) {
205
- assertKnownKeys(strategy, ['competitors', 'look', 'navigation', 'phrases', 'waves'], 'strategy');
213
+ assertKnownKeys(strategy, ['competitors', 'look', 'navigation', 'phrases', 'waves', 'estate'], 'strategy');
206
214
  if (strategy.navigation !== undefined)
207
215
  assertNavigation(strategy.navigation, 'strategy.navigation');
208
216
  if (strategy.phrases !== undefined)
209
217
  assertPhrases(strategy.phrases);
210
218
  if (strategy.waves !== undefined)
211
219
  assertWaves(strategy.waves, sydneyToday());
220
+ if (strategy.estate !== undefined) {
221
+ assertExactKeys(strategy.estate, ['indexedNow', 'paths', 'slugs'], 'strategy.estate', ['paths', 'slugs']);
222
+ const problem = estatePlanProblems(strategy.estate, strategy.waves ?? [], sydneyToday())[0];
223
+ if (problem)
224
+ throw new Error(`strategy.${problem}`);
225
+ }
212
226
  if (strategy.look !== undefined)
213
227
  assertLook(strategy.look, 'strategy.look');
214
228
  if (strategy.competitors === undefined)
@@ -231,4 +245,328 @@ export function defineSiteStrategy(strategy) {
231
245
  throw new Error(`strategy.competitors lists "${duplicate}" more than once.`);
232
246
  return strategy;
233
247
  }
248
+ // ---------------------------------------------------------------------------
249
+ // The decision card and typed decisions (3.14.0), recorded beside `defineSiteStrategy`
250
+ // ---------------------------------------------------------------------------
251
+ /** Job mode per money service (v2 §2.2): it sets which of phone and quote is styled primary, never their order. */
252
+ export const SITE_JOB_MODES = ['urgent', 'planned', 'mixed'];
253
+ /** How a service is bought beside its job mode: as an add-on to another job, or in a season. */
254
+ export const SITE_JOB_PATTERNS = ['add-on', 'seasonal'];
255
+ /**
256
+ * Where a money service lives on location pages (v2 §4.4 step 1): the main trade owns the suburb page; a family of its
257
+ * own has service-in-suburb pages; anything else is a section on the suburb page.
258
+ */
259
+ export const SITE_LOCATION_ROLES = ['owns-suburb-page', 'service-in-suburb-pages', 'suburb-page-section'];
260
+ /** The typed reasons Romie may give for not publishing a suburb (v2 §4.3), including the owner-set `too-far`. */
261
+ export const SITE_EXCLUSION_REASONS = ['rural', 'not-residential', 'water-access', 'too-far', 'not-a-real-suburb'];
262
+ export const SITE_CONTACT_CHANNELS = ['phone', 'sms', 'whatsapp', 'email', 'form'];
263
+ export const SITE_MAX_OWNER_QUESTIONS = 5;
264
+ export const SITE_MAX_REASONS_TO_CHOOSE = 3;
265
+ const LEAD_WINDOW_DAYS = { min: 60, max: 120 };
266
+ function assertIsoDate(value, field) {
267
+ const day = typeof value === 'string' && ISO_DAY.test(value) ? Date.parse(`${value}T00:00:00Z`) : Number.NaN;
268
+ if (Number.isNaN(day) || new Date(day).toISOString().slice(0, 10) !== value)
269
+ throw new Error(`${field} must be a YYYY-MM-DD date.`);
270
+ return day;
271
+ }
272
+ function assertCount(value, field, nullable = false) {
273
+ if (nullable && value === null)
274
+ return;
275
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < 0)
276
+ throw new Error(`${field} must be a whole number, 0 or more.`);
277
+ }
278
+ function assertMoneyServices(services) {
279
+ if (!Array.isArray(services) || services.length === 0)
280
+ throw new Error('decisions.moneyServices must list at least one money service.');
281
+ const slugs = new Set();
282
+ services.forEach((service, index) => {
283
+ const field = `decisions.moneyServices[${index}]`;
284
+ assertExactKeys(service, ['slug', 'name', 'jobMode', 'pattern', 'suburbFamily', 'onLocationPages', 'reason'], field, ['pattern']);
285
+ if (typeof service.slug !== 'string' || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(service.slug))
286
+ throw new Error(`${field}.slug must be a kebab-case slug.`);
287
+ if (slugs.has(service.slug))
288
+ throw new Error(`decisions.moneyServices lists "${service.slug}" more than once.`);
289
+ slugs.add(service.slug);
290
+ assertText(service.name, `${field}.name`, 80);
291
+ assertText(service.reason, `${field}.reason`, 600);
292
+ if (!SITE_JOB_MODES.includes(service.jobMode))
293
+ throw new Error(`${field}.jobMode must be one of ${SITE_JOB_MODES.join(', ')}.`);
294
+ if (service.pattern !== undefined && !SITE_JOB_PATTERNS.includes(service.pattern)) {
295
+ throw new Error(`${field}.pattern must be one of ${SITE_JOB_PATTERNS.join(', ')}.`);
296
+ }
297
+ if (!SITE_LOCATION_ROLES.includes(service.onLocationPages)) {
298
+ throw new Error(`${field}.onLocationPages must be one of ${SITE_LOCATION_ROLES.join(', ')}.`);
299
+ }
300
+ if (typeof service.suburbFamily !== 'boolean' || service.suburbFamily !== (service.onLocationPages !== 'suburb-page-section')) {
301
+ throw new Error(`${field}.suburbFamily must be true exactly when the service owns the suburb page or has its own service-in-suburb pages.`);
302
+ }
303
+ });
304
+ if (services.filter((service) => service.onLocationPages === 'owns-suburb-page').length > 1) {
305
+ throw new Error('decisions.moneyServices: only one money service owns the suburb page (the main trade).');
306
+ }
307
+ }
308
+ function assertLeadBaseline(baseline) {
309
+ const field = 'decisions.leadBaseline';
310
+ const keys = ['window', 'acceptedForms', 'phoneTaps', 'businessProfileCalls', 'qualifiedEnquiries', 'organicActions', 'paidActions', 'note', 'target', 'readDates'];
311
+ assertExactKeys(baseline, keys, field, ['businessProfileCalls', 'qualifiedEnquiries', 'organicActions', 'paidActions', 'note']);
312
+ assertExactKeys(baseline.window, ['start', 'end'], `${field}.window`);
313
+ const span = (assertIsoDate(baseline.window.end, `${field}.window.end`) - assertIsoDate(baseline.window.start, `${field}.window.start`)) / DAY_MS;
314
+ if (span < LEAD_WINDOW_DAYS.min || span > LEAD_WINDOW_DAYS.max) {
315
+ throw new Error(`${field}.window spans ${span} days; the baseline covers the last 90 days.`);
316
+ }
317
+ assertCount(baseline.acceptedForms, `${field}.acceptedForms`);
318
+ assertCount(baseline.phoneTaps, `${field}.phoneTaps`);
319
+ if (baseline.businessProfileCalls !== undefined)
320
+ assertCount(baseline.businessProfileCalls, `${field}.businessProfileCalls`, true);
321
+ if (baseline.qualifiedEnquiries !== undefined)
322
+ assertCount(baseline.qualifiedEnquiries, `${field}.qualifiedEnquiries`, true);
323
+ if (baseline.organicActions !== undefined)
324
+ assertCount(baseline.organicActions, `${field}.organicActions`);
325
+ if (baseline.paidActions !== undefined)
326
+ assertCount(baseline.paidActions, `${field}.paidActions`);
327
+ if (baseline.note !== undefined)
328
+ assertText(baseline.note, `${field}.note`, 600);
329
+ assertText(baseline.target, `${field}.target`, 300);
330
+ assertTextList(baseline.readDates, `${field}.readDates`, 1);
331
+ }
332
+ function assertReasons(reasons) {
333
+ if (!Array.isArray(reasons) || reasons.length === 0)
334
+ throw new Error('decisions.reasonsToChoose must list at least one true reason.');
335
+ if (reasons.length > SITE_MAX_REASONS_TO_CHOOSE)
336
+ throw new Error('decisions.reasonsToChoose takes at most three reasons.');
337
+ reasons.forEach((reason, index) => {
338
+ const field = `decisions.reasonsToChoose[${index}]`;
339
+ assertExactKeys(reason, ['text', 'claims'], field);
340
+ assertText(reason.text, `${field}.text`, 300);
341
+ assertTextList(reason.claims, `${field}.claims`, 1);
342
+ });
343
+ }
344
+ function assertJobEconomics(economics) {
345
+ const field = 'decisions.jobEconomics';
346
+ assertExactKeys(economics, ['averageJobValue', 'closeRate', 'capacityWeeksBooked', 'minimumJob', 'unwantedJobs', 'preferredContact'], field);
347
+ assertCount(economics.averageJobValue, `${field}.averageJobValue`, true);
348
+ if (economics.closeRate !== null && (typeof economics.closeRate !== 'number' || !(economics.closeRate >= 0 && economics.closeRate <= 1))) {
349
+ throw new Error(`${field}.closeRate must be a fraction from 0 to 1, or null.`);
350
+ }
351
+ if (economics.capacityWeeksBooked !== null && (typeof economics.capacityWeeksBooked !== 'number' || !(economics.capacityWeeksBooked >= 0))) {
352
+ throw new Error(`${field}.capacityWeeksBooked must be 0 or more weeks, or null.`);
353
+ }
354
+ if (economics.minimumJob !== null)
355
+ assertText(economics.minimumJob, `${field}.minimumJob`);
356
+ if (economics.unwantedJobs !== null)
357
+ assertTextList(economics.unwantedJobs, `${field}.unwantedJobs`, 1);
358
+ if (economics.preferredContact !== null && !SITE_CONTACT_CHANNELS.includes(economics.preferredContact)) {
359
+ throw new Error(`${field}.preferredContact must be one of ${SITE_CONTACT_CHANNELS.join(', ')}, or null.`);
360
+ }
361
+ }
362
+ function assertOwnerQuestions(questions) {
363
+ if (!Array.isArray(questions))
364
+ throw new Error('decisions.ownerQuestions must be a list.');
365
+ if (questions.length > SITE_MAX_OWNER_QUESTIONS)
366
+ throw new Error('decisions.ownerQuestions holds at most five single questions per client.');
367
+ const ids = new Set();
368
+ questions.forEach((question, index) => {
369
+ const field = `decisions.ownerQuestions[${index}]`;
370
+ assertExactKeys(question, ['id', 'question', 'fallback', 'drafted', 'sent', 'answered'], field, ['sent', 'answered']);
371
+ assertText(question.id, `${field}.id`, 40);
372
+ if (ids.has(question.id))
373
+ throw new Error(`decisions.ownerQuestions lists "${question.id}" more than once.`);
374
+ ids.add(question.id);
375
+ assertText(question.question, `${field}.question`, 300);
376
+ assertText(question.fallback, `${field}.fallback`, 300);
377
+ const drafted = assertIsoDate(question.drafted, `${field}.drafted`);
378
+ const sent = question.sent === undefined ? undefined : assertIsoDate(question.sent, `${field}.sent`);
379
+ if (sent !== undefined && sent < drafted)
380
+ throw new Error(`${field}.sent is before it was drafted.`);
381
+ if (question.answered !== undefined) {
382
+ const answered = assertIsoDate(question.answered, `${field}.answered`);
383
+ if (answered < (sent ?? drafted))
384
+ throw new Error(`${field}.answered is before it was ${sent === undefined ? 'drafted' : 'sent'}.`);
385
+ }
386
+ });
387
+ }
388
+ /** Validates the decisions a site records beside its `siteStrategy` and returns them with their literal types kept. */
389
+ export function defineStrategyDecisions(decisions) {
390
+ const keys = [
391
+ 'recordedOn', 'trade', 'mainArea', 'homePhrase', 'decisionCard', 'moneyServices', 'leadBaseline', 'reasonsToChoose',
392
+ 'jobEconomics', 'homeTerritory', 'tiers', 'exclusions', 'ownerQuestions',
393
+ ];
394
+ assertExactKeys(decisions, keys, 'decisions', ['jobEconomics', 'homeTerritory', 'tiers', 'exclusions', 'ownerQuestions']);
395
+ assertIsoDate(decisions.recordedOn, 'decisions.recordedOn');
396
+ assertText(decisions.trade, 'decisions.trade', 80);
397
+ assertText(decisions.mainArea, 'decisions.mainArea', 80);
398
+ assertText(decisions.homePhrase, 'decisions.homePhrase', 80);
399
+ const cardKeys = ['desiredWorkAndArea', 'currentEnquiryConstraint', 'evidence', 'selectedAction', 'expectedMechanism', 'successMeasure', 'reviewDate'];
400
+ assertExactKeys(decisions.decisionCard, cardKeys, 'decisions.decisionCard');
401
+ for (const key of cardKeys)
402
+ assertText(decisions.decisionCard[key], `decisions.decisionCard.${key}`, 600);
403
+ assertMoneyServices(decisions.moneyServices);
404
+ assertLeadBaseline(decisions.leadBaseline);
405
+ assertReasons(decisions.reasonsToChoose);
406
+ if (decisions.jobEconomics !== undefined)
407
+ assertJobEconomics(decisions.jobEconomics);
408
+ if (decisions.homeTerritory !== undefined)
409
+ assertTextList(decisions.homeTerritory, 'decisions.homeTerritory', 1);
410
+ if (decisions.tiers !== undefined) {
411
+ assertExactKeys(decisions.tiers, ['head', 'standard', 'noPage'], 'decisions.tiers');
412
+ for (const key of ['head', 'standard', 'noPage'])
413
+ assertText(decisions.tiers[key], `decisions.tiers.${key}`, 300);
414
+ }
415
+ if (decisions.exclusions !== undefined) {
416
+ if (!Array.isArray(decisions.exclusions))
417
+ throw new Error('decisions.exclusions must be a list.');
418
+ decisions.exclusions.forEach((exclusion, index) => {
419
+ const field = `decisions.exclusions[${index}]`;
420
+ assertExactKeys(exclusion, ['suburb', 'reason'], field);
421
+ assertText(exclusion.suburb, `${field}.suburb`, 80);
422
+ if (!SITE_EXCLUSION_REASONS.includes(exclusion.reason)) {
423
+ throw new Error(`${field}.reason must be one of ${SITE_EXCLUSION_REASONS.join(', ')}.`);
424
+ }
425
+ });
426
+ }
427
+ if (decisions.ownerQuestions !== undefined)
428
+ assertOwnerQuestions(decisions.ownerQuestions);
429
+ return decisions;
430
+ }
431
+ // ---------------------------------------------------------------------------
432
+ // The estate plan (3.14.0)
433
+ // ---------------------------------------------------------------------------
434
+ const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
435
+ const PLACEHOLDER = { region: '{region}', suburb: '{suburb}' };
436
+ function templateProblem(template, placeholder) {
437
+ if (typeof template !== 'string' || !template.endsWith(`/${placeholder}`))
438
+ return true;
439
+ const parent = template.slice(0, -placeholder.length - 1);
440
+ return parent !== '' && (!ROUTE_PATTERN.test(parent) || parent.includes('*') || parent.includes('{'));
441
+ }
442
+ function parentOf(template) {
443
+ return template === undefined ? undefined : template.slice(0, template.lastIndexOf('/'));
444
+ }
445
+ /**
446
+ * What breaks an estate plan, in plain sentences (empty when nothing does): malformed routes or paths, a page indexed
447
+ * now that a wave still to come also lists, suburb renames other than "{slug}-suburb" and region and suburb pages that
448
+ * would share a path. Conformance's LOC-INDEX reads the same plan against the built pages.
449
+ */
450
+ export function estatePlanProblems(plan, waves, today = sydneyToday()) {
451
+ const problems = [];
452
+ if (!Array.isArray(plan.indexedNow))
453
+ return ['estate.indexedNow must be a list of paths or patterns.'];
454
+ plan.indexedNow.forEach((route, index) => {
455
+ if (typeof route !== 'string' || !ROUTE_PATTERN.test(route) || (route.length > 1 && route.endsWith('/'))) {
456
+ problems.push(`estate.indexedNow[${index}] must be a root-relative path or pattern such as "/services/decking/*".`);
457
+ }
458
+ });
459
+ for (const wave of waves) {
460
+ if (wave.releaseOn <= today)
461
+ continue;
462
+ for (const route of wave.routes) {
463
+ if (plan.indexedNow.includes(route))
464
+ problems.push(`"${route}" is indexed now and also in the wave of ${wave.releaseOn}; a page indexed now never waits for a wave.`);
465
+ }
466
+ }
467
+ const paths = plan.paths ?? {};
468
+ if (paths.region !== undefined && templateProblem(paths.region, PLACEHOLDER.region)) {
469
+ problems.push('estate.paths.region must be a root-relative path ending in "/{region}".');
470
+ }
471
+ if (paths.suburb !== undefined && templateProblem(paths.suburb, PLACEHOLDER.suburb)) {
472
+ problems.push('estate.paths.suburb must be a root-relative path ending in "/{suburb}".');
473
+ }
474
+ for (const template of paths.serviceInSuburb ?? []) {
475
+ if (templateProblem(template, PLACEHOLDER.suburb))
476
+ problems.push(`estate.paths.serviceInSuburb "${template}" must be a root-relative path ending in "/{suburb}".`);
477
+ else if (template === paths.suburb)
478
+ problems.push(`estate.paths.serviceInSuburb "${template}" is also the suburb path.`);
479
+ }
480
+ const regions = plan.slugs?.regions ?? {};
481
+ const suburbs = plan.slugs?.suburbs ?? {};
482
+ const regionSlugs = new Map();
483
+ for (const [registry, slug] of Object.entries(regions)) {
484
+ if (!SLUG.test(registry) || typeof slug !== 'string' || !SLUG.test(slug)) {
485
+ problems.push(`estate.slugs.regions.${registry} must map a registry slug to a kebab-case slug.`);
486
+ continue;
487
+ }
488
+ if (regionSlugs.has(slug))
489
+ problems.push(`estate.slugs.regions gives "${slug}" to more than one region.`);
490
+ regionSlugs.set(slug, registry);
491
+ }
492
+ for (const [registry, slug] of Object.entries(suburbs)) {
493
+ if (!SLUG.test(registry) || slug !== `${registry}-suburb`) {
494
+ problems.push(`estate.slugs.suburbs.${registry} is "${String(slug)}"; a suburb that clashes with a region takes "${registry}-suburb".`);
495
+ }
496
+ }
497
+ const shared = paths.region !== undefined && paths.suburb !== undefined && parentOf(paths.region) === parentOf(paths.suburb);
498
+ if (shared) {
499
+ for (const slug of Object.values(suburbs)) {
500
+ if (regionSlugs.has(slug))
501
+ problems.push(`The region "${regionSlugs.get(slug)}" and a suburb both take "${slug}" under ${parentOf(paths.suburb)}.`);
502
+ }
503
+ }
504
+ return problems;
505
+ }
506
+ /** A place's public slug in the estate: the plan's rename, or the registry slug. */
507
+ export function estatePublicSlug(plan, kind, registrySlug) {
508
+ const renames = kind === 'region' ? plan.slugs?.regions : plan.slugs?.suburbs;
509
+ return renames && Object.hasOwn(renames, registrySlug) ? renames[registrySlug] : registrySlug;
510
+ }
511
+ /**
512
+ * A location page's path: the family's path with the place's public slug. `template` picks a nested service-in-suburb
513
+ * family (or its service-region hub, with `kind: 'region'`); it must be one of the plan's paths.
514
+ */
515
+ export function estateLocationPath(plan, kind, registrySlug, template) {
516
+ const paths = plan.paths ?? {};
517
+ const own = kind === 'region' ? paths.region : paths.suburb;
518
+ const known = [paths.region, paths.suburb, ...(paths.serviceInSuburb ?? [])].filter((value) => value !== undefined);
519
+ let chosen = template ?? own;
520
+ if (template !== undefined && !known.includes(template)) {
521
+ // A service-in-suburb family's hub sits beside its suburb pages: "/x/{suburb}" also gives "/x/{region}".
522
+ const hub = (paths.serviceInSuburb ?? []).find((candidate) => candidate.replace(/\{suburb\}$/, '{region}') === template);
523
+ if (!hub)
524
+ throw new Error(`"${template}" is not one of the estate's paths.`);
525
+ chosen = template;
526
+ }
527
+ if (chosen === undefined)
528
+ throw new Error(`The estate plan records no ${kind} path.`);
529
+ const parent = chosen.slice(0, chosen.lastIndexOf('/'));
530
+ return `${parent}/${estatePublicSlug(plan, kind, registrySlug)}`;
531
+ }
532
+ function linkDay(on) {
533
+ if (on === undefined)
534
+ return sydneyToday();
535
+ if (on instanceof Date)
536
+ return sydneyToday(on);
537
+ if (!ISO_DAY.test(on) || Number.isNaN(Date.parse(on)))
538
+ throw new Error(`"${on}" is not a day; give it as YYYY-MM-DD.`);
539
+ return on;
540
+ }
541
+ /**
542
+ * Whether an indexable page may link a location page (D4 return waves; LOC-INDEX reads the same plan): a page indexed
543
+ * now and a page whose wave is due (`releaseOn` on or before `on`) are links; a page still waiting for its wave is plain
544
+ * text, because indexable pages never link a noindex location page. With an estate plan, a page it does not account for
545
+ * is plain text too (LOC-INDEX fails it until it is listed); without one, a page no wave dates is live now. `path` is
546
+ * the public path, as `estateLocationPath` builds it (renamed slugs, nested service-in-suburb families).
547
+ */
548
+ export function estateLinkState(path, { estate, waves = [], on }) {
549
+ const day = linkDay(on);
550
+ if (estate?.indexedNow.some((route) => matchesWaveRoute(path, route)))
551
+ return 'link';
552
+ const wave = waveForRoute(waves, path);
553
+ if (wave)
554
+ return wave.releaseOn <= day ? 'link' : 'text';
555
+ return estate ? 'text' : 'link';
556
+ }
557
+ /**
558
+ * `Coverage` entries for a list of places (a region's suburbs from the registry, in the order given): each live page is
559
+ * a link, each page still waiting for its wave the place's name as plain text, so a region page can list every suburb
560
+ * in the region and still count it in "All {n} areas".
561
+ */
562
+ export function coverageEntries(places, options) {
563
+ const { estate, pathFor } = options;
564
+ if (!pathFor && !estate?.paths?.suburb)
565
+ throw new Error('coverageEntries needs pathFor, or an estate plan with a suburb path.');
566
+ const day = linkDay(options.on);
567
+ return places.map((place) => {
568
+ const href = pathFor ? pathFor(place) : estateLocationPath(estate, 'suburb', place.slug);
569
+ return estateLinkState(href, { ...options, on: day }) === 'link' ? { label: place.name, href } : { label: place.name };
570
+ });
571
+ }
234
572
  //# sourceMappingURL=strategy.js.map