@finbheara/domain 0.30.0 → 0.32.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/place.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  placesRelation2,
18
18
  probablySamePlace2,
19
19
  sameReading2
20
- } from "./chunks/place-h2s1w0tq.js";
20
+ } from "./chunks/place-6qvca8eg.js";
21
21
  import"./chunks/place-tcgfvemw.js";
22
22
  export {
23
23
  DEFAULT_PLACE_CAPACITY2 as DEFAULT_PLACE_CAPACITY,
@@ -0,0 +1,70 @@
1
+ import"./chunks/place-8k74cr5j.js";
2
+ import {
3
+ compTitle2,
4
+ matchTitle2
5
+ } from "./chunks/place-bhedwqd1.js";
6
+
7
+ function hallKey(hall) {
8
+ return hall.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
9
+ }
10
+ function sameHall(a, b) {
11
+ const x = hallKey(a);
12
+ const y = hallKey(b);
13
+ if (x === "" || y === "")
14
+ return false;
15
+ if (x === y)
16
+ return true;
17
+ const [short, long] = x.length <= y.length ? [x, y] : [y, x];
18
+ return short.length >= 4 && long.endsWith(` ${short}`);
19
+ }
20
+ function scheduleAt(slots, where) {
21
+ const day = where.day ?? null;
22
+ const at = where.at ?? null;
23
+ return slots.filter((s) => sameHall(s.hall, where.hall) && (day === null || s.day === null || s.day === day) && (at === null || (s.start === null || s.start <= at) && (s.end === null || at < s.end)));
24
+ }
25
+ var ROUND_END = /\b(?:r ?\d|rounds? \d)(?: ?(?:&|and|,) ?(?:r ?)?\d)*\b/giu;
26
+ function piecesOf(line) {
27
+ const out = [];
28
+ let from = 0;
29
+ for (const m of line.matchAll(ROUND_END)) {
30
+ const to = (m.index ?? 0) + m[0].length;
31
+ out.push(line.slice(from, to));
32
+ from = to;
33
+ }
34
+ out.push(line.slice(from));
35
+ return out.flatMap((p) => p.split(",")).filter((p) => p.trim() !== "");
36
+ }
37
+ function readRunningOrder(text, entries, where, ctx = {}) {
38
+ const out = [];
39
+ const seen = new Set;
40
+ for (const line of text.split(/[\n;]+/)) {
41
+ let population = "";
42
+ for (const piece of piecesOf(line)) {
43
+ const own = compTitle2(piece, ctx).population;
44
+ if (own !== "")
45
+ population = own;
46
+ const said = own === "" && population !== "" ? `${piece} ${population}` : piece;
47
+ const m = matchTitle2(said, entries, ctx);
48
+ for (const entry of m.entries) {
49
+ const key = `${entries.indexOf(entry)}|${m.round}`;
50
+ if (seen.has(key))
51
+ continue;
52
+ seen.add(key);
53
+ out.push(Object.freeze({
54
+ hall: where.hall,
55
+ day: where.day ?? null,
56
+ start: null,
57
+ end: null,
58
+ entry,
59
+ round: m.round
60
+ }));
61
+ }
62
+ }
63
+ }
64
+ return out;
65
+ }
66
+ export {
67
+ readRunningOrder,
68
+ sameHall,
69
+ scheduleAt
70
+ };
package/dist/school.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  areAllPlaceTokens2,
13
13
  placeRelation2,
14
14
  sameReading2
15
- } from "./chunks/place-h2s1w0tq.js";
15
+ } from "./chunks/place-6qvca8eg.js";
16
16
  import {
17
17
  validity
18
18
  } from "./chunks/place-q9kwsmzd.js";
package/dist/title.js ADDED
@@ -0,0 +1,19 @@
1
+ import {
2
+ populationIn2,
3
+ roundNumbersIn2,
4
+ compTitle2,
5
+ populationRelation2,
6
+ titleRelation2,
7
+ ladderOf2,
8
+ matchTitle2
9
+ } from "./chunks/place-bhedwqd1.js";
10
+ import"./chunks/place-8k74cr5j.js";
11
+ export {
12
+ compTitle2 as compTitle,
13
+ ladderOf2 as ladderOf,
14
+ matchTitle2 as matchTitle,
15
+ populationIn2 as populationIn,
16
+ populationRelation2 as populationRelation,
17
+ roundNumbersIn2 as roundNumbersIn,
18
+ titleRelation2 as titleRelation
19
+ };
@@ -6,6 +6,7 @@ export interface GeocodeTown {
6
6
  readonly name: string;
7
7
  readonly cell: string;
8
8
  readonly geonameid: number;
9
+ readonly areas: readonly string[];
9
10
  }
10
11
  export declare function geocodeTowns(): ReadonlyMap<string, GeocodeTown>;
11
12
  export declare function geocode(print: string, ctx?: string | PlaceContext): Place;
@@ -1,3 +1,3 @@
1
- export declare const PLACE_TOWNS_TREE = "7766f91ef2cbbb099f93d878d1fd33d8b66bf6f3fe1a35590d0b5755f9a6dda6";
1
+ export declare const PLACE_TOWNS_TREE = "f320d266e5d9119559361f4e961ffc2f49ac2158ba221015fa6b35a647471719";
2
2
  export declare const PLACE_TOWNS_SOURCES: Readonly<Record<string, string>>;
3
3
  export declare const PLACE_TOWNS: Readonly<Record<string, string>>;
@@ -1,4 +1,4 @@
1
1
  import type { PlaceWithin } from "./place-types.ts";
2
- export declare const PLACE_WITHIN_TREE = "7766f91ef2cbbb099f93d878d1fd33d8b66bf6f3fe1a35590d0b5755f9a6dda6";
2
+ export declare const PLACE_WITHIN_TREE = "f320d266e5d9119559361f4e961ffc2f49ac2158ba221015fa6b35a647471719";
3
3
  export declare const PLACE_WITHIN_SOURCES: Readonly<Record<string, string>>;
4
4
  export declare const PLACE_WITHIN: Readonly<Record<string, PlaceWithin>>;
@@ -0,0 +1,21 @@
1
+ import { type SyllabusEntry, type TitleContext } from "./title.ts";
2
+ export type { SyllabusEntry, TitleContext } from "./title.ts";
3
+ export interface ScheduleSlot<E> {
4
+ readonly hall: string;
5
+ readonly day: number | null;
6
+ readonly start: number | null;
7
+ readonly end: number | null;
8
+ readonly entry: E;
9
+ readonly round: number | null;
10
+ }
11
+ export interface ScheduleWhere {
12
+ readonly hall: string;
13
+ readonly day?: number | null;
14
+ readonly at?: number | null;
15
+ }
16
+ export declare function sameHall(a: string, b: string): boolean;
17
+ export declare function scheduleAt<E>(slots: readonly ScheduleSlot<E>[], where: ScheduleWhere): ScheduleSlot<E>[];
18
+ export declare function readRunningOrder<E extends SyllabusEntry>(text: string, entries: readonly E[], where: {
19
+ readonly hall: string;
20
+ readonly day?: number | null;
21
+ }, ctx?: Omit<TitleContext, "ladder">): ScheduleSlot<E>[];
@@ -0,0 +1,45 @@
1
+ import type { AgeTitleSpan } from "./age-title.ts";
2
+ import { Age, type AgeComparison, type AgeLadder, type AgeRelation } from "./age.ts";
3
+ import { type Validated } from "./validated.ts";
4
+ export type { EmptyReason, Validated } from "./validated.ts";
5
+ export type { AgeComparison, AgeLadder } from "./age.ts";
6
+ export type Population = "girls" | "boys" | "mixed";
7
+ export declare function populationIn(text: string): Population | "";
8
+ export declare function roundNumbersIn(folded: string, printed: boolean): Set<number>;
9
+ export interface TitleContext {
10
+ readonly year?: number | null;
11
+ readonly ladder?: AgeLadder;
12
+ }
13
+ export type TitleRefusal = "no-age";
14
+ export interface CompTitle extends Validated<TitleRefusal> {
15
+ readonly [Symbol.toStringTag]: "CompTitle";
16
+ readonly print: string;
17
+ readonly age: Age;
18
+ readonly ageSpan: AgeTitleSpan | null;
19
+ readonly population: Population | "";
20
+ readonly round: number | null;
21
+ readonly rounds: readonly number[];
22
+ readonly split: string | null;
23
+ isTitle(): boolean;
24
+ }
25
+ export declare function compTitle(print: string, ctx?: TitleContext): CompTitle;
26
+ export type PopulationRelation = "same" | "disjoint" | "silent";
27
+ export interface TitleComparison {
28
+ readonly relation: AgeRelation;
29
+ readonly age: AgeComparison;
30
+ readonly population: PopulationRelation;
31
+ }
32
+ export declare function populationRelation(a: Population | "", b: Population | ""): PopulationRelation;
33
+ export declare function titleRelation(a: CompTitle, b: CompTitle): TitleComparison;
34
+ export declare function ladderOf(bands: readonly Age[]): AgeLadder;
35
+ export interface SyllabusEntry {
36
+ readonly title: string;
37
+ readonly age?: string;
38
+ }
39
+ export interface TitleMatch<E extends SyllabusEntry> {
40
+ readonly title: CompTitle;
41
+ readonly entries: readonly E[];
42
+ readonly round: number | null;
43
+ isSingular(): boolean;
44
+ }
45
+ export declare function matchTitle<E extends SyllabusEntry>(print: string, entries: readonly E[], ctx?: Omit<TitleContext, "ladder">): TitleMatch<E>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@finbheara/domain",
3
- "version": "0.30.0",
4
- "description": "Places, CLRG regions, school names, ages, dances and a person's print in its role, as they are printed: read, compared and told apart",
3
+ "version": "0.32.0",
4
+ "description": "Places, CLRG regions, school names, ages, dances, competition titles and schedules, and a person's print in its role, as they are printed: read, compared and told apart",
5
5
  "keywords": [
6
6
  "places",
7
7
  "regions",
@@ -65,6 +65,14 @@
65
65
  "types": "./dist/types/person.d.ts",
66
66
  "default": "./dist/person.js"
67
67
  },
68
+ "./title": {
69
+ "types": "./dist/types/title.d.ts",
70
+ "default": "./dist/title.js"
71
+ },
72
+ "./schedule": {
73
+ "types": "./dist/types/schedule.d.ts",
74
+ "default": "./dist/schedule.js"
75
+ },
68
76
  "./package.json": "./package.json"
69
77
  },
70
78
  "files": ["dist/*.js", "dist/chunks/*.js", "dist/types/**/*.d.ts", "README.md", "LICENSE"],