@rangefoundry/catalog 0.0.0 → 0.1.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/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from './catalogue.js';
2
+ export * from './coverage.js';
3
+ export * from './data-set.js';
4
+ export * from './data-set-rule.js';
5
+ export * from './load-tables.js';
6
+ export * from './maker-rows.js';
7
+ export * from './plausibility.js';
8
+ export * from './published-loads.js';
9
+ export * from './records.js';
10
+ export * from './sources.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ /** Whether `v` is a JSON object (or an array), whose properties a check may read. */
2
+ export declare const isObject: (v: unknown) => v is Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ /** Whether `v` is a JSON object (or an array), whose properties a check may read. */
2
+ export const isObject = (v) => typeof v === 'object' && v !== null;
3
+ //# sourceMappingURL=json-object.js.map
@@ -0,0 +1,12 @@
1
+ import type { LoadTables, Powder } from '@rangefoundry/schema';
2
+ export type { LoadTable, LoadTables } from '@rangefoundry/schema';
3
+ /**
4
+ * Provenance gate of the powder model. A source that is `fitted`, or supports `interior` of a
5
+ * powder that has one, must be a `fitted` source whose `fields` list only `interior`, on a powder
6
+ * with `interior`. With `loadTables` (a records root read has a `load-tables.json`) it must name a
7
+ * listed load table (title, URL, retrieval date) and the fit run (model version, report); without
8
+ * them (the public catalog) a title, a retrieval date and the model version of the fit run, and no
9
+ * report. A source under an open license (`origin: public` with a `license`) is exempt. A powder
10
+ * with `interior` needs at least one fitted source. Returns one message per broken rule.
11
+ */
12
+ export declare function checkFittedSources(powder: Powder, loadTables: LoadTables | undefined): string[];
@@ -0,0 +1,73 @@
1
+ /** Whether `loadTables` lists a table with the source's title, URL and retrieval date. */
2
+ function isListedLoadTable(source, loadTables) {
3
+ const table = Object.values(loadTables).find((t) => t.title === source.title);
4
+ return !!table && table.url === source.url && table.retrieved === source.retrieved;
5
+ }
6
+ const isInterior = (f) => f === 'interior' || f.startsWith('interior.');
7
+ /** The findings of one source that supports `interior` or is fitted, of `powder`. */
8
+ function checkInteriorSource(s, at, kind, { powder, loadTables }) {
9
+ const errors = [];
10
+ if (kind !== 'fitted')
11
+ errors.push(`${at} supports interior but is not fitted`);
12
+ else if (!s.fields?.every(isInterior))
13
+ errors.push(`${at}: a fitted source supports only interior`);
14
+ else if (!powder.interior)
15
+ errors.push(`${at}: fitted source without interior`);
16
+ if (kind !== 'fitted')
17
+ return errors;
18
+ if (!loadTables)
19
+ return [...errors, ...publicFitFindings(s, at)];
20
+ if (!isListedLoadTable(s, loadTables))
21
+ errors.push(`${at} is not a listed load table`);
22
+ if (!s.run?.report)
23
+ errors.push(`${at} names no fit run (version, report)`);
24
+ return errors;
25
+ }
26
+ /** The findings of the fitted source `s` when no records root has load tables (the public catalog): it names its document, the retrieval date and the model version, and no fit report. */
27
+ function publicFitFindings(s, at) {
28
+ const errors = [];
29
+ if (s.title === undefined)
30
+ errors.push(`${at} names no title`);
31
+ if (s.retrieved === undefined)
32
+ errors.push(`${at} names no retrieval date`);
33
+ if (!s.run)
34
+ errors.push(`${at} names no fit run (version)`);
35
+ if (s.run?.report !== undefined)
36
+ errors.push(`${at} names a fit report, which stays private`);
37
+ return errors;
38
+ }
39
+ /**
40
+ * Provenance gate of the powder model. A source that is `fitted`, or supports `interior` of a
41
+ * powder that has one, must be a `fitted` source whose `fields` list only `interior`, on a powder
42
+ * with `interior`. With `loadTables` (a records root read has a `load-tables.json`) it must name a
43
+ * listed load table (title, URL, retrieval date) and the fit run (model version, report); without
44
+ * them (the public catalog) a title, a retrieval date and the model version of the fit run, and no
45
+ * report. A source under an open license (`origin: public` with a `license`) is exempt. A powder
46
+ * with `interior` needs at least one fitted source. Returns one message per broken rule.
47
+ */
48
+ export function checkFittedSources(powder, loadTables) {
49
+ const { provenance } = powder;
50
+ if (!provenance)
51
+ return powder.interior ? ['interior without a fitted source'] : [];
52
+ const errors = [];
53
+ let fitted = 0;
54
+ provenance.sources.forEach((s, i) => {
55
+ const kind = s.kind ?? provenance.kind;
56
+ const covers = !s.fields || s.fields.some(isInterior);
57
+ // a source under an open license needs no listed manufacturer load table (a test fixture powder)
58
+ if (s.origin === 'public' && s.license) {
59
+ if (kind === 'fitted')
60
+ fitted++;
61
+ return;
62
+ }
63
+ if (kind !== 'fitted' && !(covers && powder.interior))
64
+ return;
65
+ if (kind === 'fitted')
66
+ fitted++;
67
+ errors.push(...checkInteriorSource(s, `source ${i} ("${s.title}")`, kind, { powder, loadTables }));
68
+ });
69
+ if (powder.interior && fitted === 0)
70
+ errors.push('interior without a fitted source');
71
+ return errors;
72
+ }
73
+ //# sourceMappingURL=load-tables.js.map
@@ -0,0 +1,37 @@
1
+ import type { Bundle } from './records.ts';
2
+ import type { SourceIndex } from './sources.ts';
3
+ /** Dot paths of the bullet and powder fields a listed source may name, a path covering the fields below it, and whether it may stand in a load. */
4
+ export interface ListedSourceFields {
5
+ readonly bullet: readonly string[];
6
+ readonly powder: readonly string[];
7
+ /** Dot paths of bullet fields it may name as written only, not the fields below them. */
8
+ readonly bulletExact?: readonly string[];
9
+ readonly load: boolean;
10
+ }
11
+ /**
12
+ * The source records that are not a maker's, by id, each with the fields it may name and whether it
13
+ * may stand in a load: our thermochemistry solver, our map of the makers' construction wording, and
14
+ * the invented data of the test fixtures. Every other source a bullet, powder or load cites counts
15
+ * as a maker's, whatever its `origin` or `publisher` says; only a community list of the bullet
16
+ * length is not asked for a terms URL. An id or a field added here changes the guard of the public
17
+ * catalog, and its pull request is reviewed as one. The solver and the wording map have no source
18
+ * record yet; the importer change that first cites one adds its record under the id listed here.
19
+ * Until then a mismatched id fails closed.
20
+ */
21
+ export declare const nonMakerSources: Readonly<Record<string, ListedSourceFields>>;
22
+ /** A record the public catalog may not hold, with what keeps it out. */
23
+ export interface MakerRow {
24
+ id: string;
25
+ findings: string[];
26
+ }
27
+ /**
28
+ * The records of `bundle` the public catalog may not hold, by kind, in the order of the bundle;
29
+ * kinds without one are left out. `citations` gives the cited source ids of each record file. A
30
+ * bullet or powder may cite a maker's published source for the fields of `makerSourceFields`
31
+ * only, a powder a fitted maker source for `interior` only, and a listed source for the fields of its {@link nonMakerSources} entry only, named unless
32
+ * it is `synthetic-test-data`; a catalogue load or a published-load file (`publishedLoads`, by
33
+ * `<cartridge>/<id>`) no maker source and only a listed source that may stand in a load, and a
34
+ * record of another kind no manufacturer-origin source or fitted source without an origin.
35
+ * Manufacturer records are identity records and may cite their maker.
36
+ */
37
+ export declare function makerRows(bundle: Bundle, citations: SourceIndex['citations']): Record<string, MakerRow[]>;
@@ -0,0 +1,201 @@
1
+ import { detailedFields, isWebLink, makerSourceFields } from '@rangefoundry/schema';
2
+ /**
3
+ * The source records that are not a maker's, by id, each with the fields it may name and whether it
4
+ * may stand in a load: our thermochemistry solver, our map of the makers' construction wording, and
5
+ * the invented data of the test fixtures. Every other source a bullet, powder or load cites counts
6
+ * as a maker's, whatever its `origin` or `publisher` says; only a community list of the bullet
7
+ * length is not asked for a terms URL. An id or a field added here changes the guard of the public
8
+ * catalog, and its pull request is reviewed as one. The solver and the wording map have no source
9
+ * record yet; the importer change that first cites one adds its record under the id listed here.
10
+ * Until then a mismatched id fails closed.
11
+ */
12
+ export const nonMakerSources = {
13
+ 'rangefoundry-constant-volume-equilibrium-solver': {
14
+ bullet: [],
15
+ powder: ['thermochemistry'],
16
+ load: false,
17
+ },
18
+ 'mapping-of-the-maker-wording-tools-src-bullets': {
19
+ bullet: [
20
+ 'construction.raw',
21
+ 'construction.structure',
22
+ 'construction.core',
23
+ 'construction.jacket.material',
24
+ 'construction.surface',
25
+ 'construction.gasCheck',
26
+ 'construction.drivingBands',
27
+ 'construction.unmapped',
28
+ ],
29
+ powder: [],
30
+ // an empty jacket states only that the bullet has one, which the maker's wording gives
31
+ bulletExact: ['construction.jacket'],
32
+ load: false,
33
+ },
34
+ 'synthetic-test-data': {
35
+ bullet: [
36
+ 'manufacturer',
37
+ 'productNumber',
38
+ 'name',
39
+ 'country',
40
+ 'productLine',
41
+ 'caliber',
42
+ 'diameter',
43
+ 'mass',
44
+ 'length',
45
+ 'base',
46
+ 'ogive',
47
+ 'cannelure',
48
+ 'tip',
49
+ 'meplatDiameter',
50
+ 'noseLength',
51
+ 'baseToOgive',
52
+ 'bearingLength',
53
+ 'construction',
54
+ 'ballisticCoefficients',
55
+ 'recommendedTwist',
56
+ 'slowestTwist',
57
+ 'note',
58
+ 'nameOnly',
59
+ ],
60
+ powder: [
61
+ 'manufacturer',
62
+ 'name',
63
+ 'aliases',
64
+ 'country',
65
+ 'grainForm',
66
+ 'propellantBase',
67
+ 'bulkDensity',
68
+ 'composition',
69
+ 'thermochemistry',
70
+ 'interior',
71
+ 'temperatureSensitivity',
72
+ 'listedCartridges',
73
+ 'note',
74
+ ],
75
+ load: true,
76
+ },
77
+ };
78
+ // own keys only, so an id such as `constructor` stays a maker's
79
+ const isMakerId = (id) => id === undefined || !Object.hasOwn(nonMakerSources, id);
80
+ /** The sources of `record` that count as a maker's: an embedded one, or one whose id `ids` gives outside {@link nonMakerSources}. */
81
+ const makerSources = (record, ids) => (record.provenance?.sources ?? []).filter((_, i) => isMakerId(ids?.[i]));
82
+ const overlaps = (path, field) => path === field || path.startsWith(`${field}.`) || field.startsWith(`${path}.`);
83
+ /** True when `source` states the community origin and names only the bullet `length`: a basic field the public catalog holds without a source, so trusting the stated origin admits nothing it would refuse. */
84
+ const isCommunityLengthList = (kind, source) => kind === 'bullet' &&
85
+ source.origin === 'community' &&
86
+ source.fields?.every((f) => f === 'length') === true;
87
+ /** True when the maker source `source` has no terms URL and is not a {@link isCommunityLengthList}. */
88
+ const lacksTermsUrl = (kind, source) => (!source.terms || !isWebLink(source.terms)) && !isCommunityLengthList(kind, source);
89
+ /** True when `source` is a powder's `fitted` source (its own kind or the record's) that names only `interior`: the fit to a maker's load table. */
90
+ const isFittedInterior = (kind, record, source) => kind === 'powder' &&
91
+ (source.kind ?? record.provenance?.kind) === 'fitted' &&
92
+ !!source.fields?.length &&
93
+ source.fields.every((f) => f === 'interior' || f.startsWith('interior.'));
94
+ /** Why the maker source `source` may not stand as published: no URL and no title and publisher of a document cited by title, a missing field list or terms URL (none asked of a community list, {@link isCommunityLengthList}), or a license. */
95
+ function publicationFindings(kind, source, name) {
96
+ // a source without an address that is no document cited by title is data a maker sent us, which has no rules yet
97
+ if (source.url === undefined && (source.title === undefined || source.publisher === undefined))
98
+ return [
99
+ `source "${source.title}" is not a listed non-maker source and has no URL: it counts as data received directly from a maker, which is not yet supported`,
100
+ ];
101
+ const findings = [];
102
+ if (!source.fields)
103
+ findings.push(`${name}: names no fields`);
104
+ if (lacksTermsUrl(kind, source))
105
+ findings.push(`${name}: needs a terms URL`);
106
+ if (source.license !== undefined)
107
+ findings.push(`${name}: carries a license`);
108
+ return findings;
109
+ }
110
+ /** Why the maker source `source` may not stand in a bullet or powder record: the {@link publicationFindings}, or a detailed field outside {@link makerSourceFields} and, for a {@link isFittedInterior} source, `interior`. */
111
+ function makerSourceFindings(kind, record, source) {
112
+ const name = `source "${source.title}" (not a listed non-maker source)`;
113
+ const findings = publicationFindings(kind, source, name);
114
+ const allowed = isFittedInterior(kind, record, source)
115
+ ? [...makerSourceFields[kind], 'interior']
116
+ : makerSourceFields[kind];
117
+ for (const path of detailedFields(kind, record)) {
118
+ const covered = !source.fields || source.fields.some((f) => overlaps(path, f));
119
+ if (covered && !allowed.some((a) => path === a || path.startsWith(`${a}.`)))
120
+ findings.push(`${name}: covers ${path}, which no maker source may supply`);
121
+ }
122
+ return findings;
123
+ }
124
+ /** Whether the listed source `id` may name `field` of a record of `kind`. */
125
+ function listedMayName(id, kind, field) {
126
+ const entry = nonMakerSources[id];
127
+ if (kind === 'bullet' && entry?.bulletExact?.includes(field))
128
+ return true;
129
+ return (entry?.[kind] ?? []).some((a) => field === a || field.startsWith(`${a}.`));
130
+ }
131
+ /** A listed source names only fields of its {@link nonMakerSources} entry, and names them unless it is `synthetic-test-data`. */
132
+ function listedSourceFindings(kind, record, ids) {
133
+ return (record.provenance?.sources ?? []).flatMap((source, i) => {
134
+ const id = ids?.[i];
135
+ if (id === undefined || isMakerId(id))
136
+ return [];
137
+ if (!source.fields)
138
+ return id === 'synthetic-test-data' ? [] : [`listed source "${id}" names no fields`];
139
+ return source.fields
140
+ .filter((f) => !listedMayName(id, kind, f))
141
+ .map((f) => `listed source "${id}" names ${f}, which it may not supply`);
142
+ });
143
+ }
144
+ /** Why the source `id` may not stand in a load or a published-load file: a maker's, or a listed source without standing for loads. */
145
+ const loadFindings = (id) => {
146
+ if (id === undefined)
147
+ return ["cites an embedded source, which counts as a maker's"];
148
+ if (isMakerId(id))
149
+ return [`cites source "${id}", which counts as a maker's`];
150
+ return nonMakerSources[id]?.load
151
+ ? []
152
+ : [`cites listed source "${id}", which supplies no load field`];
153
+ };
154
+ /** True when `record` cites a manufacturer-origin source, or a fitted source that does not say whose data it was fitted to. */
155
+ const mayHoldMakerData = (record) => (record.provenance?.sources ?? []).some((s) => s.origin === 'manufacturer' ||
156
+ (s.origin === undefined && (s.kind ?? record.provenance?.kind) === 'fitted'));
157
+ /** The findings of one record of `kind`, its file's source ids `ids`. */
158
+ function findingsOf(kind, record, ids) {
159
+ if (kind === 'bullets' || kind === 'powders') {
160
+ const fieldKind = kind === 'bullets' ? 'bullet' : 'powder';
161
+ return [
162
+ ...listedSourceFindings(fieldKind, record, ids),
163
+ ...makerSources(record, ids).flatMap((s) => makerSourceFindings(fieldKind, record, s)),
164
+ ];
165
+ }
166
+ if (kind === 'loads')
167
+ return (record.provenance?.sources ?? []).flatMap((_, i) => loadFindings(ids?.[i]));
168
+ return mayHoldMakerData(record)
169
+ ? ['cites a manufacturer-origin source or a fitted source without an origin']
170
+ : [];
171
+ }
172
+ /**
173
+ * The records of `bundle` the public catalog may not hold, by kind, in the order of the bundle;
174
+ * kinds without one are left out. `citations` gives the cited source ids of each record file. A
175
+ * bullet or powder may cite a maker's published source for the fields of `makerSourceFields`
176
+ * only, a powder a fitted maker source for `interior` only, and a listed source for the fields of its {@link nonMakerSources} entry only, named unless
177
+ * it is `synthetic-test-data`; a catalogue load or a published-load file (`publishedLoads`, by
178
+ * `<cartridge>/<id>`) no maker source and only a listed source that may stand in a load, and a
179
+ * record of another kind no manufacturer-origin source or fitted source without an origin.
180
+ * Manufacturer records are identity records and may cite their maker.
181
+ */
182
+ export function makerRows(bundle, citations) {
183
+ const out = {};
184
+ const add = (kind, id, findings) => {
185
+ if (findings.length > 0)
186
+ (out[kind] ??= []).push({ id, findings });
187
+ };
188
+ for (const [kind, records] of Object.entries(bundle)) {
189
+ if (kind === 'manufacturers' || !Array.isArray(records))
190
+ continue;
191
+ for (const record of records)
192
+ add(kind, record.id, findingsOf(kind, record, citations.get(`${kind}/${record.id}.json`)));
193
+ }
194
+ for (const [file, ids] of citations) {
195
+ const published = /^loads\/([^/]+\/[^/]+)\.json$/.exec(file)?.[1];
196
+ if (published)
197
+ add('publishedLoads', published, ids.flatMap(loadFindings));
198
+ }
199
+ return out;
200
+ }
201
+ //# sourceMappingURL=maker-rows.js.map
@@ -0,0 +1,10 @@
1
+ import type { Finding } from './plausibility.ts';
2
+ import type { Bundle } from './records.ts';
3
+ /** A finding with the record file it was found in (`<dir>/<id>.json`). */
4
+ export type LocatedFinding = Finding & {
5
+ file: string;
6
+ };
7
+ /** Lower-case letters and digits only, accents removed, so `P-140` and `p140` are one name; a decimal point between digits stays, so `6.5x55` and `65x55` differ. */
8
+ export declare function normaliseName(name: string): string;
9
+ /** Exactly or after `normaliseName`, against an earlier record of their kind and scope: none for cartridges, manufacturers and powder aliases, the manufacturer id for powders, primers and bullets, manufacturer and cartridge for cases, the report for range records, the federation id for target faces. */
10
+ export declare function checkNames(bundle: Pick<Bundle, 'cartridges' | 'manufacturers' | 'powders' | 'primers' | 'bullets' | 'cases' | 'rangeFirings' | 'targetFaces'>): LocatedFinding[];
package/dist/names.js ADDED
@@ -0,0 +1,121 @@
1
+ /** Lower-case letters and digits only, accents removed, so `P-140` and `p140` are one name; a decimal point between digits stays, so `6.5x55` and `65x55` differ. */
2
+ export function normaliseName(name) {
3
+ return name
4
+ .normalize('NFKD')
5
+ .toLowerCase()
6
+ .replace(/[^a-z0-9.]|(?<!\d)\.|\.(?!\d)/g, '');
7
+ }
8
+ /** The finding for one name of a record, if an earlier record has it; adds the name to `seen`. */
9
+ function duplicateOf(seen, { file, scope }, name, reported) {
10
+ const norm = normaliseName(name);
11
+ const same = seen.exact.get(`${scope}\n${name}`);
12
+ const similar = seen.normalised.get(`${scope}\n${norm}`);
13
+ let found;
14
+ if (same && same !== file) {
15
+ found = {
16
+ file,
17
+ finding: `duplicate-name:${name}`,
18
+ message: `"${name}" is also a name of ${same}`,
19
+ };
20
+ reported.add(norm);
21
+ }
22
+ else if (norm !== '' && similar && similar !== file && !reported.has(norm)) {
23
+ found = {
24
+ file,
25
+ finding: `duplicate-normalised-name:${norm}`,
26
+ message: `"${name}" normalizes like a name of ${similar}`,
27
+ };
28
+ reported.add(norm);
29
+ }
30
+ if (!same)
31
+ seen.exact.set(`${scope}\n${name}`, file);
32
+ if (!similar && norm !== '')
33
+ seen.normalised.set(`${scope}\n${norm}`, file);
34
+ return found;
35
+ }
36
+ /** Reports each record that shares a name with an earlier record (by file name, code-unit order as `readKind` reads them) of its kind and scope. */
37
+ function duplicates(records) {
38
+ const findings = [];
39
+ const seen = { exact: new Map(), normalised: new Map() };
40
+ for (const record of records.toSorted((a, b) => (a.file < b.file ? -1 : 1))) {
41
+ const reported = new Set();
42
+ for (const name of new Set(record.names)) {
43
+ const found = duplicateOf(seen, record, name, reported);
44
+ if (found)
45
+ findings.push(found);
46
+ }
47
+ }
48
+ return findings;
49
+ }
50
+ /** The record file of `id` in directory `dir`. */
51
+ const fileOf = (dir, id) => `${dir}/${id}.json`;
52
+ /** The names of cartridges, manufacturers, powders, primers and bullets, one group per comparison. */
53
+ function componentNames(bundle) {
54
+ return [
55
+ bundle.cartridges.map((c) => ({
56
+ file: fileOf('cartridges', c.id),
57
+ scope: '',
58
+ names: [c.name, ...(c.aliases ?? [])],
59
+ })),
60
+ bundle.manufacturers.map((m) => ({
61
+ file: fileOf('manufacturers', m.id),
62
+ scope: '',
63
+ names: [m.name, ...(m.aliases ?? [])],
64
+ })),
65
+ bundle.powders.map((p) => ({
66
+ file: fileOf('powders', p.id),
67
+ scope: p.manufacturer,
68
+ names: [p.name],
69
+ })),
70
+ // An alias names a brand and name of another manufacturer, so aliases are compared with aliases only.
71
+ bundle.powders.map((p) => ({
72
+ file: fileOf('powders', p.id),
73
+ scope: '',
74
+ names: p.aliases ?? [],
75
+ })),
76
+ bundle.primers.map((p) => ({
77
+ file: fileOf('primers', p.id),
78
+ scope: p.manufacturer,
79
+ names: [p.name],
80
+ })),
81
+ bundle.bullets.map((b) => ({
82
+ file: fileOf('bullets', b.id),
83
+ scope: b.manufacturer,
84
+ names: [b.name],
85
+ })),
86
+ ];
87
+ }
88
+ /** The names of cases, range records and target faces, one group per comparison. */
89
+ function otherNames(bundle) {
90
+ return [
91
+ // A case is named per cartridge, as the same product line serves several.
92
+ bundle.cases.map((c) => ({
93
+ file: fileOf('cases', c.id),
94
+ scope: `${c.manufacturer} ${c.cartridge}`,
95
+ names: [c.name],
96
+ })),
97
+ // One projectile may appear in several reports.
98
+ bundle.rangeFirings.flatMap((r) => {
99
+ const [source] = r.provenance?.sources ?? [];
100
+ if (!source)
101
+ return [];
102
+ return [
103
+ {
104
+ file: fileOf('range', r.id),
105
+ scope: source.sha256 ?? source.url ?? source.title ?? r.id,
106
+ names: [r.projectile],
107
+ },
108
+ ];
109
+ }),
110
+ bundle.targetFaces.map((f) => ({
111
+ file: fileOf('target-faces', f.id),
112
+ scope: f.federation ?? '',
113
+ names: [f.name],
114
+ })),
115
+ ];
116
+ }
117
+ /** Exactly or after `normaliseName`, against an earlier record of their kind and scope: none for cartridges, manufacturers and powder aliases, the manufacturer id for powders, primers and bullets, manufacturer and cartridge for cases, the report for range records, the federation id for target faces. */
118
+ export function checkNames(bundle) {
119
+ return [...componentNames(bundle), ...otherNames(bundle)].flatMap((group) => duplicates(group));
120
+ }
121
+ //# sourceMappingURL=names.js.map
@@ -0,0 +1,47 @@
1
+ import type { Bullet, Cartridge, CatalogueCase, CatalogueSession, Powder } from '@rangefoundry/schema';
2
+ /** A rule violation, identified by `finding` so that a record can acknowledge it. */
3
+ export type Finding = {
4
+ finding: string;
5
+ message: string;
6
+ };
7
+ /** Checks the values of one sheet; every finding must be fixed or acknowledged in `exceptions`. */
8
+ export declare function checkSpec(spec: Pick<Cartridge, 'values'>): Finding[];
9
+ /** Twist per turn in mm, 1:4 to about 1:70 in: pistol and muzzleloader bullets list twists such as 1:48. */
10
+ export declare const twistRange: Readonly<{
11
+ min: number;
12
+ max: number;
13
+ }>;
14
+ /** A finite twist inside the range; NaN is not a misprint but a value that was not read. */
15
+ export declare const twistPlausible: (mm: number) => boolean;
16
+ /**
17
+ * Checks one bullet record against physical ranges: small-arms diameters and masses, BCs, length
18
+ * against diameter, twist. A finding means a misread or mistyped value; it must be fixed.
19
+ */
20
+ export declare function checkBullet(bullet: Bullet): Finding[];
21
+ /**
22
+ * Checks one capacity: positive, and at most the water filling the cylinder that encloses the case
23
+ * (the larger of cartridge P1 and R1, times L3, of `spec`, the cartridge's sheet) at
24
+ * 1 g/cm3, the highest density of water.
25
+ */
26
+ export declare function checkCapacity(capacity: {
27
+ waterCapacity: {
28
+ value: number;
29
+ };
30
+ }, spec: Pick<Cartridge, 'values'> | undefined): Finding[];
31
+ /**
32
+ * Checks one case: the flash hole and the empty mass inside small-arms ranges, and the stated water
33
+ * capacity as {@link checkCapacity} checks a measured one against the cartridge's sheet.
34
+ */
35
+ export declare function checkCase(record: Pick<CatalogueCase, 'flashHole' | 'mass' | 'waterCapacity'>, spec: Pick<Cartridge, 'values'> | undefined): Finding[];
36
+ /**
37
+ * Checks one powder: bulk and loading density below the solid density, thermochemistry inside the
38
+ * solver's temperature bracket, above the lightest species and against the ideal gas.
39
+ */
40
+ export declare function checkPowder(powder: Powder): Finding[];
41
+ /** World air temperature extremes, degC (WMO 2025). */
42
+ export declare const airTemperatureRange: Readonly<{
43
+ min: number;
44
+ max: number;
45
+ }>;
46
+ /** Checks one chronograph session against physical limits and the world temperature extremes. */
47
+ export declare function checkChronoSession(session: CatalogueSession): Finding[];