@casomoltd/nhs-pay 0.32.0 → 0.34.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 (125) hide show
  1. package/README.md +24 -22
  2. package/dist/afc-band.d.ts +4 -4
  3. package/dist/afc-band.js +4 -4
  4. package/dist/afc-scales.d.ts +89 -60
  5. package/dist/afc-scales.js +166 -182
  6. package/dist/afc-scales.js.map +1 -1
  7. package/dist/allowances.js +11 -11
  8. package/dist/allowances.js.map +1 -1
  9. package/dist/award.d.ts +3 -3
  10. package/dist/award.js +21 -21
  11. package/dist/award.js.map +1 -1
  12. package/dist/circulars/afc-shapes.d.ts +41 -21
  13. package/dist/circulars/afc-shapes.js +9 -8
  14. package/dist/circulars/afc-shapes.js.map +1 -1
  15. package/dist/circulars/england-md-1-2026-r2.d.ts +13 -0
  16. package/dist/circulars/england-md-1-2026-r2.js +13 -0
  17. package/dist/circulars/england-md-1-2026-r2.js.map +1 -1
  18. package/dist/circulars/ni-hsc-afc-06-2025.d.ts +3 -2
  19. package/dist/circulars/ni-hsc-afc-06-2025.js +3 -2
  20. package/dist/circulars/ni-hsc-afc-06-2025.js.map +1 -1
  21. package/dist/circulars/ni-hsc-tc8-05-2025.d.ts +22 -0
  22. package/dist/circulars/ni-hsc-tc8-05-2025.js +22 -0
  23. package/dist/circulars/ni-hsc-tc8-05-2025.js.map +1 -1
  24. package/dist/circulars/scotland-pcs-dd-2025-01.d.ts +20 -0
  25. package/dist/circulars/scotland-pcs-dd-2025-01.js +20 -0
  26. package/dist/circulars/scotland-pcs-dd-2025-01.js.map +1 -1
  27. package/dist/circulars/scotland-pcs-dd-2026-01.d.ts +19 -0
  28. package/dist/circulars/scotland-pcs-dd-2026-01.js +30 -10
  29. package/dist/circulars/scotland-pcs-dd-2026-01.js.map +1 -1
  30. package/dist/circulars/scotland-pcs-dd-2026-02.d.ts +10 -0
  31. package/dist/circulars/scotland-pcs-dd-2026-02.js +10 -0
  32. package/dist/circulars/scotland-pcs-dd-2026-02.js.map +1 -1
  33. package/dist/circulars/wales-mdw-01-2025.d.ts +17 -0
  34. package/dist/circulars/wales-mdw-01-2025.js +17 -0
  35. package/dist/circulars/wales-mdw-01-2025.js.map +1 -1
  36. package/dist/circulars/wales-mdw-01-2026.d.ts +20 -0
  37. package/dist/circulars/wales-mdw-01-2026.js +20 -0
  38. package/dist/circulars/wales-mdw-01-2026.js.map +1 -1
  39. package/dist/commutation.js +3 -2
  40. package/dist/commutation.js.map +1 -1
  41. package/dist/dental-grades.d.ts +25 -0
  42. package/dist/dental-grades.js +25 -0
  43. package/dist/dental-grades.js.map +1 -0
  44. package/dist/dental-scales.d.ts +5 -21
  45. package/dist/dental-scales.js +73 -72
  46. package/dist/dental-scales.js.map +1 -1
  47. package/dist/format.js +3 -2
  48. package/dist/format.js.map +1 -1
  49. package/dist/hcas-pcts.d.ts +1 -1
  50. package/dist/hcas-pcts.js +1 -1
  51. package/dist/hcas-pcts.js.map +1 -1
  52. package/dist/hcas-zone.d.ts +23 -0
  53. package/dist/hcas-zone.js +17 -0
  54. package/dist/hcas-zone.js.map +1 -0
  55. package/dist/hcas.d.ts +26 -18
  56. package/dist/hcas.js +45 -24
  57. package/dist/hcas.js.map +1 -1
  58. package/dist/index.d.ts +25 -16
  59. package/dist/index.js +14 -10
  60. package/dist/index.js.map +1 -1
  61. package/dist/medical-grades.d.ts +33 -0
  62. package/dist/medical-grades.js +33 -0
  63. package/dist/medical-grades.js.map +1 -0
  64. package/dist/medical-scales.d.ts +10 -33
  65. package/dist/medical-scales.js +104 -158
  66. package/dist/medical-scales.js.map +1 -1
  67. package/dist/member/input-period.d.ts +18 -5
  68. package/dist/member/input-period.js +24 -13
  69. package/dist/member/input-period.js.map +1 -1
  70. package/dist/pay-round.js +3 -3
  71. package/dist/pay-round.js.map +1 -1
  72. package/dist/pay-year.d.ts +17 -0
  73. package/dist/pay-year.js +20 -0
  74. package/dist/pay-year.js.map +1 -0
  75. package/dist/pension/ledger.d.ts +7 -0
  76. package/dist/pension/ledger.js +18 -11
  77. package/dist/pension/ledger.js.map +1 -1
  78. package/dist/pension.js +2 -1
  79. package/dist/pension.js.map +1 -1
  80. package/dist/post.d.ts +20 -21
  81. package/dist/post.js +54 -53
  82. package/dist/post.js.map +1 -1
  83. package/dist/published/england-afc.d.ts +72 -0
  84. package/dist/published/england-afc.js +86 -0
  85. package/dist/published/england-afc.js.map +1 -0
  86. package/dist/published/hcas-zones.d.ts +18 -0
  87. package/dist/published/hcas-zones.js +46 -0
  88. package/dist/published/hcas-zones.js.map +1 -0
  89. package/dist/published/wales-living-wage.d.ts +36 -0
  90. package/dist/published/wales-living-wage.js +30 -0
  91. package/dist/published/wales-living-wage.js.map +1 -0
  92. package/dist/regions.d.ts +25 -14
  93. package/dist/regions.js +61 -71
  94. package/dist/regions.js.map +1 -1
  95. package/dist/resolver.d.ts +46 -41
  96. package/dist/resolver.js +70 -142
  97. package/dist/resolver.js.map +1 -1
  98. package/dist/role.d.ts +3 -3
  99. package/dist/scale-point.d.ts +11 -7
  100. package/dist/scale-point.js +29 -1
  101. package/dist/scale-point.js.map +1 -1
  102. package/dist/scale-tables.d.ts +42 -60
  103. package/dist/scale-tables.js +65 -105
  104. package/dist/scale-tables.js.map +1 -1
  105. package/dist/scale-translators.d.ts +90 -0
  106. package/dist/scale-translators.js +97 -0
  107. package/dist/scale-translators.js.map +1 -0
  108. package/dist/scales.d.ts +164 -102
  109. package/dist/scales.js +242 -462
  110. package/dist/scales.js.map +1 -1
  111. package/dist/sources.d.ts +8 -12
  112. package/dist/sources.js +9 -15
  113. package/dist/sources.js.map +1 -1
  114. package/dist/take-home.js +1 -2
  115. package/dist/take-home.js.map +1 -1
  116. package/dist/values.d.ts +10 -3
  117. package/dist/values.js +11 -4
  118. package/dist/values.js.map +1 -1
  119. package/dist/working-week.d.ts +23 -8
  120. package/dist/working-week.js +55 -25
  121. package/dist/working-week.js.map +1 -1
  122. package/package.json +3 -3
  123. package/dist/bands.d.ts +0 -63
  124. package/dist/bands.js +0 -78
  125. package/dist/bands.js.map +0 -1
@@ -1,2 +1,30 @@
1
- export {};
1
+ /**
2
+ * The canonical pay-scale point — the single shape every pay scale
3
+ * reduces to (AfC band points, medical grades, dental spines), read by
4
+ * the resolvers to build a Post, with `PayLadder` (a scale's points and
5
+ * the member's own) and `onlyPointLabelled`, the rule every family's
6
+ * label lookup applies. Domain-neutral: it belongs to no one pay family,
7
+ * which is why it lives here rather than in any one scale file.
8
+ */
9
+ import { AmbiguousScalePoint } from './errors.js';
10
+ /**
11
+ * The one point labelled `label` among `points`, or a throw: none is
12
+ * {@link ScaleUnavailable}, several is {@link AmbiguousScalePoint}. `scale`
13
+ * names the band or grade for the error.
14
+ *
15
+ * Loud, not first-match, on every family's path. Where a label names
16
+ * several points the caller has asked a question the data cannot answer,
17
+ * and the salaries happening to agree today is not a reason to guess.
18
+ */
19
+ export function onlyPointLabelled(points, label, scale, unavailable) {
20
+ const matches = points.filter((p) => p.label === label);
21
+ const [first] = matches;
22
+ if (first === undefined) {
23
+ throw unavailable();
24
+ }
25
+ if (matches.length > 1) {
26
+ throw new AmbiguousScalePoint(scale, label, matches.length);
27
+ }
28
+ return first;
29
+ }
2
30
  //# sourceMappingURL=scale-point.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale-point.js","sourceRoot":"","sources":["../src/scale-point.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"scale-point.js","sourceRoot":"","sources":["../src/scale-point.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAmDhD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoB,EACpB,KAAa,EACb,KAAa,EACb,WAAmC;IAEnC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -5,9 +5,10 @@
5
5
  * `(grade, nation, year)` and resolve to `ScalePoint[]`, uniform with
6
6
  * AfC. Verbatim transcription lives in `circulars/*`; the per-family
7
7
  * selection + mapping lives in the translation layers
8
- * (`medical-scales.ts`, `dental-scales.ts`). This module owns only the
9
- * canonical container, the grouping accessor, and the translators
10
- * generic enough to be shared across both families.
8
+ * (`medical-scales.ts`, `dental-scales.ts`), with the row translators
9
+ * they share in `scale-translators.ts`. This module owns the canonical
10
+ * container and the family object every read goes through
11
+ * ({@link gradeFamily}).
11
12
  */
12
13
  import type { Nation, PayYear, YearLabel } from '@casomoltd/paye-calc';
13
14
  import type { DocumentSource } from './document-source.js';
@@ -39,6 +40,39 @@ export interface GradeMeta<G extends string> {
39
40
  }
40
41
  /** Canonical basic-pay tables keyed year → nation → grade → scale. */
41
42
  export type GradeScaleTables<G extends string> = Partial<Record<YearLabel, Partial<Record<Nation, Partial<Record<G, GradeScale>>>>>>;
43
+ /**
44
+ * One nation-based pay family (medical, dental): every read over its
45
+ * tables, so the families share one implementation rather than two
46
+ * copies that can drift.
47
+ */
48
+ export interface GradeFamily<G extends string> {
49
+ /** Pay years with a published table, newest first. */
50
+ readonly years: readonly PayYear[];
51
+ /** The grades published for a nation and year, in the family's grade
52
+ * order. Throws {@link ScaleUnavailable} where none is published,
53
+ * rather than defaulting to another nation's or year's figures. */
54
+ scalesFor(year: PayYear, nation: Nation): GradeMeta<G>[];
55
+ /** True where the nation and year publish `grade`: the non-throwing
56
+ * question a consumer asks before reading a year it is not sure of. */
57
+ publishes(grade: G, year: PayYear, nation: Nation): boolean;
58
+ /** The points of one grade's scale. Throws {@link ScaleUnavailable}
59
+ * where the nation and year do not publish it. */
60
+ pointsFor(grade: G, year: PayYear, nation: Nation): readonly ScalePoint[];
61
+ /** The newest year the family publishes any grade for a nation, or null
62
+ * where it publishes none. */
63
+ latestYear(nation: Nation): PayYear | null;
64
+ /** The newest year the family publishes `grade` for a nation, or null. */
65
+ latestYearOf(grade: G, nation: Nation): PayYear | null;
66
+ /** The newest document of the newest year the family publishes for a
67
+ * nation: by issue date among that year's grades, so a round split
68
+ * over two circulars cites the later one, and a nation behind cites
69
+ * its last year's. */
70
+ latestSource(nation: Nation): DocumentSource;
71
+ /** The document that publishes one grade's scale. Throws
72
+ * {@link ScaleUnavailable} where the nation and year publish a table
73
+ * but not this grade. */
74
+ sourceFor(grade: G, year: PayYear, nation: Nation): DocumentSource;
75
+ }
42
76
  /**
43
77
  * Bind every grade in a mapping to the document it was read from.
44
78
  *
@@ -60,62 +94,10 @@ export declare function fromDocument<G extends string>(source: DocumentSource, p
60
94
  *
61
95
  * A grade can have exactly one publishing circular in a nation and
62
96
  * year. Spreading two partial records instead would let the later one
63
- * win in silence — the same first-match-by-accident this module's
64
- * callers were rewritten to stop doing.
97
+ * win in silence, so the grade's figures would be whichever document was
98
+ * listed last rather than the one that publishes them.
65
99
  */
66
100
  export declare function combineScales<G extends string>(...parts: Partial<Record<G, GradeScale>>[]): Partial<Record<G, GradeScale>>;
67
- /**
68
- * Group a nation/year's grades into metas, in `gradeIds` order. `year`
69
- * and `nation` are both required; an absent combination throws
70
- * {@link ScaleUnavailable} rather than defaulting to another nation's
71
- * or year's figures.
72
- */
73
- export declare function resolveGradeMetas<G extends string>(tables: GradeScaleTables<G>, gradeIds: readonly G[], year: PayYear, nation: Nation): GradeMeta<G>[];
74
- /**
75
- * An incremental scale with no distinct labels beyond position: the
76
- * first point is "Minimum", the rest "Point 1", "Point 2", … (the
77
- * devolved training grades). Input is the salary column, top to bottom.
78
- */
79
- export declare const stepped: (salaries: readonly number[]) => readonly ScalePoint[];
80
- /** A two-point salary range (salaried GP), min then max. */
81
- export declare const range: (r: SalaryRange) => readonly ScalePoint[];
82
- /** Plain "Point 1", "Point 2"… labelling (1-based). */
83
- export declare const numbered: (salaries: readonly number[]) => readonly ScalePoint[];
84
- /**
85
- * One point per row, labelled by the row's `stage` (training grades).
86
- * Carries the row's `nodalPoint` onto the point where the source lists one
87
- * (the 2016-contract resident scales); rows without it stay stage-only.
88
- */
89
- export declare const byStage: (rows: readonly {
90
- stage: string;
91
- salary: number;
92
- nodalPoint?: string;
93
- }[]) => readonly ScalePoint[];
94
- /**
95
- * One point per row, labelled by the row's pay-scale `code`. Carries
96
- * whichever axis the source lists beside the code, because the code
97
- * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
98
- * for locally employed doctors, whose codes England publishes against
99
- * the 2016-contract points and NOT in code order. Rows with neither
100
- * (GP educators, closed grades) stay code-only.
101
- */
102
- export declare const byCode: (rows: readonly {
103
- code: string;
104
- salary: number;
105
- yearsExperience?: number;
106
- nodalPoint?: string;
107
- }[]) => readonly ScalePoint[];
108
- /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
109
- export declare const bySpine: (rows: readonly {
110
- band: string | number;
111
- point: number;
112
- salary: number;
113
- }[]) => readonly ScalePoint[];
114
- /**
115
- * The `salaries` of the named incremental scale in a circular's list.
116
- * Fails loud (at module load) on a mapping key that doesn't match a
117
- * source scale — a translation-layer typo can't ship silently.
118
- */
119
- export declare const scaleSalaries: <T extends {
120
- salaries: readonly number[];
121
- }>(rows: readonly T[], match: (r: T) => boolean, key: string) => readonly number[];
101
+ /** Build a {@link GradeFamily} over a family's tables, reading grades in
102
+ * `gradeIds` order. */
103
+ export declare function gradeFamily<G extends string>(tables: GradeScaleTables<G>, gradeIds: readonly G[]): GradeFamily<G>;
@@ -5,11 +5,13 @@
5
5
  * `(grade, nation, year)` and resolve to `ScalePoint[]`, uniform with
6
6
  * AfC. Verbatim transcription lives in `circulars/*`; the per-family
7
7
  * selection + mapping lives in the translation layers
8
- * (`medical-scales.ts`, `dental-scales.ts`). This module owns only the
9
- * canonical container, the grouping accessor, and the translators
10
- * generic enough to be shared across both families.
8
+ * (`medical-scales.ts`, `dental-scales.ts`), with the row translators
9
+ * they share in `scale-translators.ts`. This module owns the canonical
10
+ * container and the family object every read goes through
11
+ * ({@link gradeFamily}).
11
12
  */
12
- import { ScaleUnavailable } from './errors.js';
13
+ import { salaryRangeOf } from './values.js';
14
+ import { ScaleUnavailable, invariant } from './errors.js';
13
15
  /**
14
16
  * Bind every grade in a mapping to the document it was read from.
15
17
  *
@@ -35,8 +37,8 @@ export function fromDocument(source, points) {
35
37
  *
36
38
  * A grade can have exactly one publishing circular in a nation and
37
39
  * year. Spreading two partial records instead would let the later one
38
- * win in silence — the same first-match-by-accident this module's
39
- * callers were rewritten to stop doing.
40
+ * win in silence, so the grade's figures would be whichever document was
41
+ * listed last rather than the one that publishes them.
40
42
  */
41
43
  export function combineScales(...parts) {
42
44
  const out = {};
@@ -51,105 +53,63 @@ export function combineScales(...parts) {
51
53
  }
52
54
  return out;
53
55
  }
54
- /**
55
- * Group a nation/year's grades into metas, in `gradeIds` order. `year`
56
- * and `nation` are both required; an absent combination throws
57
- * {@link ScaleUnavailable} rather than defaulting to another nation's
58
- * or year's figures.
59
- */
60
- export function resolveGradeMetas(tables, gradeIds, year, nation) {
61
- // The table keys on the label; the signature carries the basis.
62
- const key = year;
63
- const grades = tables[key]?.[nation];
64
- const metas = grades
65
- ? gradeIds.flatMap((grade) => {
66
- const scale = grades[grade];
67
- if (!scale) {
68
- return [];
56
+ /** Build a {@link GradeFamily} over a family's tables, reading grades in
57
+ * `gradeIds` order. */
58
+ export function gradeFamily(tables, gradeIds) {
59
+ // The table keys on the label; each signature carries the basis.
60
+ const gradesOf = (year, nation) => {
61
+ const key = year;
62
+ return tables[key]?.[nation];
63
+ };
64
+ const metasOf = (year, nation) => gradeMetas(gradesOf(year, nation), gradeIds);
65
+ const years = Object.keys(tables)
66
+ .sort((a, b) => b.localeCompare(a));
67
+ const publishes = (grade, year, nation) => gradesOf(year, nation)?.[grade] !== undefined;
68
+ const holds = (year, nation) => metasOf(year, nation).length > 0;
69
+ const latestYear = (nation) => years.find((year) => holds(year, nation)) ?? null;
70
+ const scaleOf = (grade, year, nation) => {
71
+ const scale = gradesOf(year, nation)?.[grade];
72
+ if (scale === undefined) {
73
+ throw new ScaleUnavailable(nation, year, grade);
74
+ }
75
+ return scale;
76
+ };
77
+ return {
78
+ years,
79
+ scalesFor(year, nation) {
80
+ const metas = metasOf(year, nation);
81
+ if (metas.length === 0) {
82
+ throw new ScaleUnavailable(nation, year);
69
83
  }
70
- const salaries = scale.points.map((p) => p.salary);
71
- return [
72
- {
73
- grade,
74
- points: scale.points,
75
- salary: {
76
- min: Math.min(...salaries),
77
- max: Math.max(...salaries),
78
- },
79
- source: scale.source,
80
- },
81
- ];
82
- })
83
- : [];
84
- if (metas.length === 0) {
85
- throw new ScaleUnavailable(nation, year);
86
- }
87
- return metas;
84
+ return metas;
85
+ },
86
+ publishes,
87
+ pointsFor: (grade, year, nation) => scaleOf(grade, year, nation).points,
88
+ latestYear,
89
+ latestYearOf: (grade, nation) => years.find((year) => publishes(grade, year, nation)) ?? null,
90
+ sourceFor: (grade, year, nation) => scaleOf(grade, year, nation).source,
91
+ latestSource(nation) {
92
+ const year = latestYear(nation);
93
+ // A plain error, not ScaleUnavailable: there is no year to name.
94
+ invariant(year !== null, `gradeFamily: ${nation} publishes no scale`);
95
+ // metasOf is never empty for a year latestYear found, so there is
96
+ // always a first.
97
+ const [first, ...rest] = metasOf(year, nation).map((m) => m.source);
98
+ return rest.reduce((a, b) => (b.issued > a.issued ? b : a), first);
99
+ },
100
+ };
101
+ }
102
+ /** A nation-year's grades as metas, in `gradeIds` order, skipping a grade
103
+ * the nation-year does not publish. */
104
+ function gradeMetas(grades, gradeIds) {
105
+ return gradeIds.flatMap((grade) => {
106
+ const scale = grades?.[grade];
107
+ return scale === undefined ? [] : [{
108
+ grade,
109
+ points: scale.points,
110
+ salary: salaryRangeOf(scale.points),
111
+ source: scale.source,
112
+ }];
113
+ });
88
114
  }
89
- // ── Shared translators ──────────────────────────
90
- // Small pure maps from a circular's verbatim rows to canonical points.
91
- // The per-family selection (which scale feeds which grade) lives in the
92
- // `*-scales.ts` translation layers; these translators are the pieces
93
- // generic enough to be shared by both.
94
- /**
95
- * An incremental scale with no distinct labels beyond position: the
96
- * first point is "Minimum", the rest "Point 1", "Point 2", … (the
97
- * devolved training grades). Input is the salary column, top to bottom.
98
- */
99
- export const stepped = (salaries) => salaries.map((salary, i) => ({
100
- label: i === 0 ? 'Minimum' : `Point ${i}`,
101
- salary,
102
- }));
103
- /** A two-point salary range (salaried GP), min then max. */
104
- export const range = (r) => [
105
- { label: 'Range minimum', salary: r.min },
106
- { label: 'Range maximum', salary: r.max },
107
- ];
108
- /** Plain "Point 1", "Point 2"… labelling (1-based). */
109
- export const numbered = (salaries) => salaries.map((salary, i) => ({ label: `Point ${i + 1}`, salary }));
110
- /**
111
- * One point per row, labelled by the row's `stage` (training grades).
112
- * Carries the row's `nodalPoint` onto the point where the source lists one
113
- * (the 2016-contract resident scales); rows without it stay stage-only.
114
- */
115
- export const byStage = (rows) => rows.map((r) => ({
116
- label: r.stage,
117
- salary: r.salary,
118
- ...(r.nodalPoint !== undefined ? { nodalPoint: r.nodalPoint } : {}),
119
- }));
120
- /**
121
- * One point per row, labelled by the row's pay-scale `code`. Carries
122
- * whichever axis the source lists beside the code, because the code
123
- * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
124
- * for locally employed doctors, whose codes England publishes against
125
- * the 2016-contract points and NOT in code order. Rows with neither
126
- * (GP educators, closed grades) stay code-only.
127
- */
128
- export const byCode = (rows) => rows.map((r) => ({
129
- label: r.code,
130
- salary: r.salary,
131
- ...(r.yearsExperience !== undefined
132
- ? { yearsExperience: r.yearsExperience }
133
- : {}),
134
- ...(r.nodalPoint !== undefined
135
- ? { nodalPoint: r.nodalPoint }
136
- : {}),
137
- }));
138
- /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
139
- export const bySpine = (rows) => rows.map((r) => ({
140
- label: `Band ${r.band} Point ${r.point}`,
141
- salary: r.salary,
142
- }));
143
- /**
144
- * The `salaries` of the named incremental scale in a circular's list.
145
- * Fails loud (at module load) on a mapping key that doesn't match a
146
- * source scale — a translation-layer typo can't ship silently.
147
- */
148
- export const scaleSalaries = (rows, match, key) => {
149
- const found = rows.find(match);
150
- if (!found) {
151
- throw new Error(`scale-tables: no source scale for "${key}"`);
152
- }
153
- return found.salaries;
154
- };
155
115
  //# sourceMappingURL=scale-tables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale-tables.js","sourceRoot":"","sources":["../src/scale-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAmC7C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAsB,EACtB,MAA0C;IAE1C,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAE7C,EAAE,CAAC;QACJ,GAAG,CAAC,KAAK,CAAC,GAAG,EAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAG,KAAuC;IAE1C,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAE7C,EA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CAAC,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC;AAED;wCACwC;AACxC,SAAS,UAAU,CACjB,MAAkD,EAClD,QAAsB;IAEtB,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACjC,KAAK;gBACL,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;gBACnC,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The row translators the medical and dental translation layers share:
3
+ * small pure maps from a circular's verbatim rows to canonical points,
4
+ * and the row selectors that pick a scale out of a circular's list. The
5
+ * per-family selection (which scale feeds which grade) lives in the
6
+ * `*-scales.ts` translation layers; these are the pieces generic enough
7
+ * to be shared by both.
8
+ */
9
+ import type { ScalePoint } from './scale-point.js';
10
+ import type { SalaryRange } from './values.js';
11
+ /**
12
+ * An incremental scale with no distinct labels beyond position: the
13
+ * first point is "Minimum", the rest "Point 1", "Point 2", … (the
14
+ * devolved training grades). Input is the salary column, top to bottom.
15
+ */
16
+ export declare const stepped: (salaries: readonly number[]) => readonly ScalePoint[];
17
+ /** One point per row, labelled by the row's printed grade (the GP
18
+ * educator and associate adviser posts). */
19
+ export declare const byGrade: (rows: readonly {
20
+ readonly grade: string;
21
+ readonly salary: number;
22
+ }[]) => readonly ScalePoint[];
23
+ /** One point per row, labelled "Point n" from the printed pay point, with
24
+ * its years of service (Northern Ireland's 2022 SAS scales). */
25
+ export declare const byPayPoint: (rows: readonly {
26
+ readonly payPoint: number;
27
+ readonly salary: number;
28
+ readonly yearsExperience: number;
29
+ }[]) => readonly ScalePoint[];
30
+ /**
31
+ * A scale printed by scale point with years of service (the 2022 specialty
32
+ * doctor and specialist contracts): point 0 is "Minimum", the rest
33
+ * "Point n", and a point's years of experience are its number.
34
+ */
35
+ export declare const byScalePoint: (rows: readonly {
36
+ readonly scalePoint: number;
37
+ readonly salary: number;
38
+ }[]) => readonly ScalePoint[];
39
+ /** A two-point salary range (salaried GP), min then max. */
40
+ export declare const range: (r: SalaryRange) => readonly ScalePoint[];
41
+ /** Plain "Point 1", "Point 2"… labelling (1-based). */
42
+ export declare const numbered: (salaries: readonly number[]) => readonly ScalePoint[];
43
+ /**
44
+ * One point per row, labelled by the row's `stage` (training grades).
45
+ * Carries the row's `nodalPoint` onto the point where the source lists one
46
+ * (the 2016-contract resident scales); rows without it stay stage-only.
47
+ */
48
+ export declare const byStage: (rows: readonly {
49
+ stage: string;
50
+ salary: number;
51
+ nodalPoint?: string;
52
+ }[]) => readonly ScalePoint[];
53
+ /**
54
+ * One point per row, labelled by the row's pay-scale `code`. Carries
55
+ * whichever axis the source lists beside the code, because the code
56
+ * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
57
+ * for locally employed doctors, whose codes England publishes against
58
+ * the 2016-contract points and NOT in code order. Rows with neither
59
+ * (GP educators, closed grades) stay code-only.
60
+ */
61
+ export declare const byCode: (rows: readonly {
62
+ code: string;
63
+ salary: number;
64
+ yearsExperience?: number;
65
+ nodalPoint?: string;
66
+ }[]) => readonly ScalePoint[];
67
+ /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
68
+ export declare const bySpine: (rows: readonly {
69
+ band: string | number;
70
+ point: number;
71
+ salary: number;
72
+ }[]) => readonly ScalePoint[];
73
+ /**
74
+ * The `salaries` of the named incremental scale in a circular's list.
75
+ * Fails loud (at module load) on a mapping key that doesn't match a
76
+ * source scale — a translation-layer typo can't ship silently.
77
+ */
78
+ export declare const scaleSalaries: <T extends {
79
+ salaries: readonly number[];
80
+ }>(rows: readonly T[], match: (r: T) => boolean, key: string) => readonly number[];
81
+ /**
82
+ * The salaries of the row a circular prints under pay-scale `code`, the
83
+ * way the translation layer selects most rows. Throws where no row carries
84
+ * it, which happens at module load, so a code the circular does not print
85
+ * fails every test rather than serving an empty scale.
86
+ */
87
+ export declare const salariesOfCode: <T extends {
88
+ code: string;
89
+ salaries: readonly number[];
90
+ }>(rows: readonly T[], code: string) => readonly number[];
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The row translators the medical and dental translation layers share:
3
+ * small pure maps from a circular's verbatim rows to canonical points,
4
+ * and the row selectors that pick a scale out of a circular's list. The
5
+ * per-family selection (which scale feeds which grade) lives in the
6
+ * `*-scales.ts` translation layers; these are the pieces generic enough
7
+ * to be shared by both.
8
+ */
9
+ /**
10
+ * An incremental scale with no distinct labels beyond position: the
11
+ * first point is "Minimum", the rest "Point 1", "Point 2", … (the
12
+ * devolved training grades). Input is the salary column, top to bottom.
13
+ */
14
+ export const stepped = (salaries) => salaries.map((salary, i) => ({
15
+ label: i === 0 ? 'Minimum' : `Point ${i}`,
16
+ salary,
17
+ }));
18
+ /** One point per row, labelled by the row's printed grade (the GP
19
+ * educator and associate adviser posts). */
20
+ export const byGrade = (rows) => rows.map((r) => ({ label: r.grade, salary: r.salary }));
21
+ /** One point per row, labelled "Point n" from the printed pay point, with
22
+ * its years of service (Northern Ireland's 2022 SAS scales). */
23
+ export const byPayPoint = (rows) => rows.map((r) => ({
24
+ label: `Point ${r.payPoint}`,
25
+ salary: r.salary,
26
+ yearsExperience: r.yearsExperience,
27
+ }));
28
+ /**
29
+ * A scale printed by scale point with years of service (the 2022 specialty
30
+ * doctor and specialist contracts): point 0 is "Minimum", the rest
31
+ * "Point n", and a point's years of experience are its number.
32
+ */
33
+ export const byScalePoint = (rows) => rows.map((r) => ({
34
+ label: r.scalePoint === 0 ? 'Minimum' : `Point ${r.scalePoint}`,
35
+ salary: r.salary,
36
+ yearsExperience: r.scalePoint,
37
+ }));
38
+ /** A two-point salary range (salaried GP), min then max. */
39
+ export const range = (r) => [
40
+ { label: 'Range minimum', salary: r.min },
41
+ { label: 'Range maximum', salary: r.max },
42
+ ];
43
+ /** Plain "Point 1", "Point 2"… labelling (1-based). */
44
+ export const numbered = (salaries) => salaries.map((salary, i) => ({ label: `Point ${i + 1}`, salary }));
45
+ /**
46
+ * One point per row, labelled by the row's `stage` (training grades).
47
+ * Carries the row's `nodalPoint` onto the point where the source lists one
48
+ * (the 2016-contract resident scales); rows without it stay stage-only.
49
+ */
50
+ export const byStage = (rows) => rows.map((r) => ({
51
+ label: r.stage,
52
+ salary: r.salary,
53
+ ...(r.nodalPoint !== undefined ? { nodalPoint: r.nodalPoint } : {}),
54
+ }));
55
+ /**
56
+ * One point per row, labelled by the row's pay-scale `code`. Carries
57
+ * whichever axis the source lists beside the code, because the code
58
+ * alone is opaque: `yearsExperience` for the SAS scales, `nodalPoint`
59
+ * for locally employed doctors, whose codes England publishes against
60
+ * the 2016-contract points and NOT in code order. Rows with neither
61
+ * (GP educators, closed grades) stay code-only.
62
+ */
63
+ export const byCode = (rows) => rows.map((r) => ({
64
+ label: r.code,
65
+ salary: r.salary,
66
+ ...(r.yearsExperience !== undefined
67
+ ? { yearsExperience: r.yearsExperience }
68
+ : {}),
69
+ ...(r.nodalPoint !== undefined
70
+ ? { nodalPoint: r.nodalPoint }
71
+ : {}),
72
+ }));
73
+ /** One point per row, labelled "Band {band} Point {point}" (dental spine). */
74
+ export const bySpine = (rows) => rows.map((r) => ({
75
+ label: `Band ${r.band} Point ${r.point}`,
76
+ salary: r.salary,
77
+ }));
78
+ /**
79
+ * The `salaries` of the named incremental scale in a circular's list.
80
+ * Fails loud (at module load) on a mapping key that doesn't match a
81
+ * source scale — a translation-layer typo can't ship silently.
82
+ */
83
+ export const scaleSalaries = (rows, match, key) => {
84
+ const found = rows.find(match);
85
+ if (!found) {
86
+ throw new Error(`scale-translators: no source scale for "${key}"`);
87
+ }
88
+ return found.salaries;
89
+ };
90
+ /**
91
+ * The salaries of the row a circular prints under pay-scale `code`, the
92
+ * way the translation layer selects most rows. Throws where no row carries
93
+ * it, which happens at module load, so a code the circular does not print
94
+ * fails every test rather than serving an empty scale.
95
+ */
96
+ export const salariesOfCode = (rows, code) => scaleSalaries(rows, (r) => r.code === code, `code ${code}`);
97
+ //# sourceMappingURL=scale-translators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale-translators.js","sourceRoot":"","sources":["../src/scale-translators.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,QAA2B,EACJ,EAAE,CACzB,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;IACzC,MAAM;CACP,CAAC,CAAC,CAAC;AAEN;6CAC6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,IAAkE,EAC3C,EAAE,CACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAC,CAAC,CAAC,CAAC;AAExD;iEACiE;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAIG,EACoB,EAAE,CACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACf,KAAK,EAAE,SAAS,CAAC,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,eAAe,EAAE,CAAC,CAAC,eAAe;CACnC,CAAC,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAuE,EAChD,EAAE,CACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EA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