@brandlab-digital/site-core 3.16.0 → 3.17.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/jobs.d.ts +5 -0
- package/dist/jobs.d.ts.map +1 -1
- package/dist/jobs.js +3 -1
- package/dist/jobs.js.map +1 -1
- package/package.json +1 -1
package/dist/jobs.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface BrandlabJob {
|
|
|
18
18
|
readonly service: string;
|
|
19
19
|
/** What was done, in one line of Australian English. */
|
|
20
20
|
readonly outcome: string;
|
|
21
|
+
/**
|
|
22
|
+
* The job's own short title (3.17.0), for example "Leaning gum beside a pool". A job card uses it where its label
|
|
23
|
+
* would repeat another card's ("Tree removal in Eastwood" twice), or on every card with `cardTitle: 'job'`.
|
|
24
|
+
*/
|
|
25
|
+
readonly title?: string;
|
|
21
26
|
/** YYYY-MM, when the owner knows it. */
|
|
22
27
|
readonly month?: string;
|
|
23
28
|
/** Media-manifest ids of genuine photos of this job. */
|
package/dist/jobs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAE3E,MAAM,WAAW,WAAW;IAC1B,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,wCAAwC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,C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QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9H,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAiBxB;AAED,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE,CAEhE"}
|
package/dist/jobs.js
CHANGED
|
@@ -5,7 +5,7 @@ export const JOB_CARD_MAX_KM = 10;
|
|
|
5
5
|
export const JOB_CARD_LIMIT = 3;
|
|
6
6
|
const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
7
7
|
const MONTH = /^\d{4}-(?:0[1-9]|1[0-2])$/;
|
|
8
|
-
const JOB_KEYS = ['id', 'suburb', 'service', 'outcome', 'month', 'photos', 'source'];
|
|
8
|
+
const JOB_KEYS = ['id', 'suburb', 'service', 'outcome', 'title', 'month', 'photos', 'source'];
|
|
9
9
|
function assertText(value, field, maximum) {
|
|
10
10
|
if (typeof value !== 'string' || !value.trim() || value.trim() !== value || value.length > maximum || /[\u0000-\u001f\u007f]/.test(value)) {
|
|
11
11
|
throw new Error(`${field} must be bounded, trimmed text.`);
|
|
@@ -37,6 +37,8 @@ export function defineJobs(jobs, options = {}) {
|
|
|
37
37
|
throw new Error(`${field}.service must be the service slug.`);
|
|
38
38
|
assertText(job.outcome, `${field}.outcome`, 300);
|
|
39
39
|
assertText(job.source, `${field}.source`, 200);
|
|
40
|
+
if (job.title !== undefined)
|
|
41
|
+
assertText(job.title, `${field}.title`, 80);
|
|
40
42
|
if (job.month !== undefined && (typeof job.month !== 'string' || !MONTH.test(job.month)))
|
|
41
43
|
throw new Error(`${field}.month must be YYYY-MM, or left out.`);
|
|
42
44
|
if (job.photos !== undefined) {
|
package/dist/jobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAg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AC,UAAU,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;SACxH,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AACpB,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,SAAS,CAAC,IAA4B;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACtC,CAAC","sourcesContent":["/**\n * The job log (`src/data/jobs.ts`, 3.14.0): one row per completed job the owner has confirmed, shared by `NearbyJobs`,\n * project cards, the area map's job places and head-tier decisions. A job names its suburb (registry slug), service\n * and what was done; its month is optional, because owners often remember the job but not when (a card then shows the\n * suburb without \"Recent\" or a date: \"Tree removal nearby: Ryde\"). Photos are media-manifest ids, so each carries its\n * provenance; only genuine photos of that job may illustrate it.\n *\n * Distances rank job cards and are never printed: location copy carries no kilometre figures (L10).\n */\nimport type { SuburbCentreLookup } from './locations.js'\nimport { distanceBetweenCentresKm } from './locations.js'\nimport type { BrandlabMediaEntry, BrandlabMediaManifest } from './media.js'\n\nexport interface BrandlabJob {\n /** A stable kebab-case id; genuine photos of the job name it in their media entry's `job`. */\n readonly id: string\n /** The registry suburb slug, for example \"ryde\". */\n readonly suburb: string\n /** The service slug, as the site's service catalogue names it. */\n readonly service: string\n /** What was done, in one line of Australian English. */\n readonly outcome: string\n /** YYYY-MM, when the owner knows it. */\n readonly month?: string\n /** Media-manifest ids of genuine photos of this job. */\n readonly photos?: readonly string[]\n /** Who confirmed the job and when, for example \"Owner, WhatsApp 3 Oct 2026\". */\n readonly source: string\n}\n\n/** Job cards show jobs within this distance of the page's suburb (v2: the 10 km cap on job cards). */\nexport const JOB_CARD_MAX_KM = 10\n/** Cards per page (playbook: 1 to 3). */\nexport const JOB_CARD_LIMIT = 3\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\nconst MONTH = /^\\d{4}-(?:0[1-9]|1[0-2])$/\nconst JOB_KEYS = ['id', 'suburb', 'service', 'outcome', 'month', 'photos', 'source']\n\nfunction assertText(value: unknown, field: string, maximum: number) {\n if (typeof value !== 'string' || !value.trim() || value.trim() !== value || value.length > maximum || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n throw new Error(`${field} must be bounded, trimmed text.`)\n }\n}\n\n/**\n * Validates the job log. With the media manifest, every photo must exist, be `genuine` (stock and AI images never\n * stand for the client's work) and, when its entry names a job, name this one.\n */\nexport function defineJobs<const T extends readonly BrandlabJob[]>(jobs: T, options: { readonly media?: BrandlabMediaManifest } = {}): T {\n if (!Array.isArray(jobs)) throw new Error('The job log must be a list.')\n const ids = new Set<string>()\n jobs.forEach((job, index) => {\n const field = `jobs[${index}]`\n if (!job || typeof job !== 'object' || Array.isArray(job)) throw new Error(`${field} must be a record.`)\n const unknown = Object.keys(job).find((key) => !JOB_KEYS.includes(key))\n if (unknown) throw new Error(`${field}.${unknown} is not a job field.`)\n if (typeof job.id !== 'string' || !SLUG.test(job.id)) throw new Error(`${field}.id must be a kebab-case id.`)\n if (ids.has(job.id)) throw new Error(`The job log lists \"${job.id}\" more than once.`)\n ids.add(job.id)\n if (typeof job.suburb !== 'string' || !SLUG.test(job.suburb)) throw new Error(`${field}.suburb must be the registry suburb slug.`)\n if (typeof job.service !== 'string' || !SLUG.test(job.service)) throw new Error(`${field}.service must be the service slug.`)\n assertText(job.outcome, `${field}.outcome`, 300)\n assertText(job.source, `${field}.source`, 200)\n if (job.month !== undefined && (typeof job.month !== 'string' || !MONTH.test(job.month))) throw new Error(`${field}.month must be YYYY-MM, or left out.`)\n if (job.photos !== undefined) {\n if (!Array.isArray(job.photos)) throw new Error(`${field}.photos must be a list of media ids.`)\n for (const id of job.photos) {\n if (!options.media) continue\n const entry = Object.hasOwn(options.media, id) ? options.media[id] : undefined\n if (!entry) throw new Error(`${field}.photos: \"${id}\" is not in the media manifest.`)\n if (entry.provenance !== 'genuine') throw new Error(`${field}.photos: \"${id}\" is ${entry.provenance}; only genuine photos show a job.`)\n if (entry.job !== undefined && entry.job !== job.id) throw new Error(`${field}.photos: \"${id}\" is a photo of ${entry.job}, not ${job.id}.`)\n }\n }\n })\n return jobs\n}\n\n/** A job's photos from the media manifest, in order, with their ids and provenance. */\nexport function jobPhotos(job: BrandlabJob, media: BrandlabMediaManifest): (BrandlabMediaEntry & { readonly id: string })[] {\n return (job.photos ?? []).flatMap((id) => (Object.hasOwn(media, id) ? [{ id, ...media[id]! }] : []))\n}\n\nfunction formatMonth(month: string): string {\n return new Intl.DateTimeFormat('en-AU', { month: 'long', year: 'numeric', timeZone: 'UTC' }).format(new Date(`${month}-01T00:00:00Z`))\n}\n\n/**\n * A job card's label: \"{Service} in {Suburb}\" for the page's own suburb, \"{Service} nearby: {Suburb}\" for any other\n * (L4 needs the \"nearby\" label). Only a dated job says \"Recent\" (or `prefix`; `''` for none) and ends with\n * \", {Month Year}\": \"Recent tree removal nearby: Ryde, May 2026\", but \"Tree removal nearby: Ryde\" when the month is\n * unknown, because an undated job may not be recent.\n */\nexport function jobCardLabel(\n job: BrandlabJob,\n options: { readonly service: string; readonly suburbName: string; readonly pageSuburb?: string; readonly prefix?: string },\n): string {\n const service = options.service.trim().toLowerCase()\n const where = job.suburb === options.pageSuburb ? `in ${options.suburbName}` : `nearby: ${options.suburbName}`\n if (!job.month) return `${capitalise(service)} ${where}`\n const prefix = (options.prefix ?? 'Recent').trim()\n const lead = prefix ? `${prefix} ${service}` : capitalise(service)\n return `${lead} ${where}, ${formatMonth(job.month)}`\n}\n\nfunction capitalise(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1)\n}\n\nexport interface BrandlabNearbyJob<T extends BrandlabJob = BrandlabJob> {\n readonly job: T\n /** For ranking only; never printed. */\n readonly distanceKm: number\n readonly sameSuburb: boolean\n}\n\n/**\n * The job cards for a page about `origin`: its own suburb's jobs first, then other jobs by real distance between\n * registry centres, within `maxKm` (10) and at most `limit` (3); newest first among equals, undated last. Jobs whose\n * suburb has no centre are left out. Filter by `service` for a service-in-suburb page.\n */\nexport function nearbyJobs<T extends BrandlabJob>(\n origin: string,\n jobs: readonly T[],\n options: { readonly centreOf: SuburbCentreLookup; readonly service?: string; readonly maxKm?: number; readonly limit?: number },\n): BrandlabNearbyJob<T>[] {\n const from = options.centreOf(origin)\n if (!from) return []\n const maxKm = options.maxKm ?? JOB_CARD_MAX_KM\n const limit = options.limit ?? JOB_CARD_LIMIT\n const found: BrandlabNearbyJob<T>[] = []\n for (const job of jobs) {\n if (options.service !== undefined && job.service !== options.service) continue\n const sameSuburb = job.suburb === origin\n const to = sameSuburb ? from : options.centreOf(job.suburb)\n if (!to) continue\n const distanceKm = sameSuburb ? 0 : distanceBetweenCentresKm(from, to)\n if (distanceKm <= maxKm) found.push({ job, distanceKm, sameSuburb })\n }\n return found\n .sort((left, right) => left.distanceKm - right.distanceKm || (right.job.month ?? '').localeCompare(left.job.month ?? ''))\n .slice(0, limit)\n}\n\n/** One place per job, for the area map's job markers (`overviewMap`, `regionMap`, `suburbLocator` take `jobs`). */\nexport function jobPlaces(jobs: readonly BrandlabJob[]): string[] {\n return jobs.map((job) => job.suburb)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAyBzD,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAA;AACjC,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAA;AAE/B,MAAM,IAAI,GAAG,4BAA4B,CAAA;AACzC,MAAM,KAAK,GAAG,2BAA2B,CAAA;AACzC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE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CAAC,CAAA;AACpB,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,SAAS,CAAC,IAA4B;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACtC,CAAC","sourcesContent":["/**\n * The job log (`src/data/jobs.ts`, 3.14.0): one row per completed job the owner has confirmed, shared by `NearbyJobs`,\n * project cards, the area map's job places and head-tier decisions. A job names its suburb (registry slug), service\n * and what was done; its month is optional, because owners often remember the job but not when (a card then shows the\n * suburb without \"Recent\" or a date: \"Tree removal nearby: Ryde\"). Photos are media-manifest ids, so each carries its\n * provenance; only genuine photos of that job may illustrate it.\n *\n * Distances rank job cards and are never printed: location copy carries no kilometre figures (L10).\n */\nimport type { SuburbCentreLookup } from './locations.js'\nimport { distanceBetweenCentresKm } from './locations.js'\nimport type { BrandlabMediaEntry, BrandlabMediaManifest } from './media.js'\n\nexport interface BrandlabJob {\n /** A stable kebab-case id; genuine photos of the job name it in their media entry's `job`. */\n readonly id: string\n /** The registry suburb slug, for example \"ryde\". */\n readonly suburb: string\n /** The service slug, as the site's service catalogue names it. */\n readonly service: string\n /** What was done, in one line of Australian English. */\n readonly outcome: string\n /**\n * The job's own short title (3.17.0), for example \"Leaning gum beside a pool\". A job card uses it where its label\n * would repeat another card's (\"Tree removal in Eastwood\" twice), or on every card with `cardTitle: 'job'`.\n */\n readonly title?: string\n /** YYYY-MM, when the owner knows it. */\n readonly month?: string\n /** Media-manifest ids of genuine photos of this job. */\n readonly photos?: readonly string[]\n /** Who confirmed the job and when, for example \"Owner, WhatsApp 3 Oct 2026\". */\n readonly source: string\n}\n\n/** Job cards show jobs within this distance of the page's suburb (v2: the 10 km cap on job cards). */\nexport const JOB_CARD_MAX_KM = 10\n/** Cards per page (playbook: 1 to 3). */\nexport const JOB_CARD_LIMIT = 3\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\nconst MONTH = /^\\d{4}-(?:0[1-9]|1[0-2])$/\nconst JOB_KEYS = ['id', 'suburb', 'service', 'outcome', 'title', 'month', 'photos', 'source']\n\nfunction assertText(value: unknown, field: string, maximum: number) {\n if (typeof value !== 'string' || !value.trim() || value.trim() !== value || value.length > maximum || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n throw new Error(`${field} must be bounded, trimmed text.`)\n }\n}\n\n/**\n * Validates the job log. With the media manifest, every photo must exist, be `genuine` (stock and AI images never\n * stand for the client's work) and, when its entry names a job, name this one.\n */\nexport function defineJobs<const T extends readonly BrandlabJob[]>(jobs: T, options: { readonly media?: BrandlabMediaManifest } = {}): T {\n if (!Array.isArray(jobs)) throw new Error('The job log must be a list.')\n const ids = new Set<string>()\n jobs.forEach((job, index) => {\n const field = `jobs[${index}]`\n if (!job || typeof job !== 'object' || Array.isArray(job)) throw new Error(`${field} must be a record.`)\n const unknown = Object.keys(job).find((key) => !JOB_KEYS.includes(key))\n if (unknown) throw new Error(`${field}.${unknown} is not a job field.`)\n if (typeof job.id !== 'string' || !SLUG.test(job.id)) throw new Error(`${field}.id must be a kebab-case id.`)\n if (ids.has(job.id)) throw new Error(`The job log lists \"${job.id}\" more than once.`)\n ids.add(job.id)\n if (typeof job.suburb !== 'string' || !SLUG.test(job.suburb)) throw new Error(`${field}.suburb must be the registry suburb slug.`)\n if (typeof job.service !== 'string' || !SLUG.test(job.service)) throw new Error(`${field}.service must be the service slug.`)\n assertText(job.outcome, `${field}.outcome`, 300)\n assertText(job.source, `${field}.source`, 200)\n if (job.title !== undefined) assertText(job.title, `${field}.title`, 80)\n if (job.month !== undefined && (typeof job.month !== 'string' || !MONTH.test(job.month))) throw new Error(`${field}.month must be YYYY-MM, or left out.`)\n if (job.photos !== undefined) {\n if (!Array.isArray(job.photos)) throw new Error(`${field}.photos must be a list of media ids.`)\n for (const id of job.photos) {\n if (!options.media) continue\n const entry = Object.hasOwn(options.media, id) ? options.media[id] : undefined\n if (!entry) throw new Error(`${field}.photos: \"${id}\" is not in the media manifest.`)\n if (entry.provenance !== 'genuine') throw new Error(`${field}.photos: \"${id}\" is ${entry.provenance}; only genuine photos show a job.`)\n if (entry.job !== undefined && entry.job !== job.id) throw new Error(`${field}.photos: \"${id}\" is a photo of ${entry.job}, not ${job.id}.`)\n }\n }\n })\n return jobs\n}\n\n/** A job's photos from the media manifest, in order, with their ids and provenance. */\nexport function jobPhotos(job: BrandlabJob, media: BrandlabMediaManifest): (BrandlabMediaEntry & { readonly id: string })[] {\n return (job.photos ?? []).flatMap((id) => (Object.hasOwn(media, id) ? [{ id, ...media[id]! }] : []))\n}\n\nfunction formatMonth(month: string): string {\n return new Intl.DateTimeFormat('en-AU', { month: 'long', year: 'numeric', timeZone: 'UTC' }).format(new Date(`${month}-01T00:00:00Z`))\n}\n\n/**\n * A job card's label: \"{Service} in {Suburb}\" for the page's own suburb, \"{Service} nearby: {Suburb}\" for any other\n * (L4 needs the \"nearby\" label). Only a dated job says \"Recent\" (or `prefix`; `''` for none) and ends with\n * \", {Month Year}\": \"Recent tree removal nearby: Ryde, May 2026\", but \"Tree removal nearby: Ryde\" when the month is\n * unknown, because an undated job may not be recent.\n */\nexport function jobCardLabel(\n job: BrandlabJob,\n options: { readonly service: string; readonly suburbName: string; readonly pageSuburb?: string; readonly prefix?: string },\n): string {\n const service = options.service.trim().toLowerCase()\n const where = job.suburb === options.pageSuburb ? `in ${options.suburbName}` : `nearby: ${options.suburbName}`\n if (!job.month) return `${capitalise(service)} ${where}`\n const prefix = (options.prefix ?? 'Recent').trim()\n const lead = prefix ? `${prefix} ${service}` : capitalise(service)\n return `${lead} ${where}, ${formatMonth(job.month)}`\n}\n\nfunction capitalise(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1)\n}\n\nexport interface BrandlabNearbyJob<T extends BrandlabJob = BrandlabJob> {\n readonly job: T\n /** For ranking only; never printed. */\n readonly distanceKm: number\n readonly sameSuburb: boolean\n}\n\n/**\n * The job cards for a page about `origin`: its own suburb's jobs first, then other jobs by real distance between\n * registry centres, within `maxKm` (10) and at most `limit` (3); newest first among equals, undated last. Jobs whose\n * suburb has no centre are left out. Filter by `service` for a service-in-suburb page.\n */\nexport function nearbyJobs<T extends BrandlabJob>(\n origin: string,\n jobs: readonly T[],\n options: { readonly centreOf: SuburbCentreLookup; readonly service?: string; readonly maxKm?: number; readonly limit?: number },\n): BrandlabNearbyJob<T>[] {\n const from = options.centreOf(origin)\n if (!from) return []\n const maxKm = options.maxKm ?? JOB_CARD_MAX_KM\n const limit = options.limit ?? JOB_CARD_LIMIT\n const found: BrandlabNearbyJob<T>[] = []\n for (const job of jobs) {\n if (options.service !== undefined && job.service !== options.service) continue\n const sameSuburb = job.suburb === origin\n const to = sameSuburb ? from : options.centreOf(job.suburb)\n if (!to) continue\n const distanceKm = sameSuburb ? 0 : distanceBetweenCentresKm(from, to)\n if (distanceKm <= maxKm) found.push({ job, distanceKm, sameSuburb })\n }\n return found\n .sort((left, right) => left.distanceKm - right.distanceKm || (right.job.month ?? '').localeCompare(left.job.month ?? ''))\n .slice(0, limit)\n}\n\n/** One place per job, for the area map's job markers (`overviewMap`, `regionMap`, `suburbLocator` take `jobs`). */\nexport function jobPlaces(jobs: readonly BrandlabJob[]): string[] {\n return jobs.map((job) => job.suburb)\n}\n"]}
|