@toolpath/tool-scraper 2.2.0 → 2.3.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.
@@ -40,9 +40,19 @@
40
40
  * confidently wrong rather than obviously broken. See `records.GEOMETRY_FIELDS`
41
41
  * for the canonical side of that line.
42
42
  */
43
+ import type { UnitSystem } from '@toolpath/tool-support';
43
44
  import type { BrandName } from './identity.js';
44
- /** Which unit system a family's dimensional columns are published in. */
45
- export type UnitSystem = 'millimeters' | 'inches';
45
+ /**
46
+ * Which unit system a family's dimensional columns are published in.
47
+ *
48
+ * `@toolpath/tool-support`'s, re-exported under the name this package has
49
+ * always published. The same two strings were declared here and spelled two
50
+ * other ways downstream — `'metric' | 'inch'`, and a display unit `'mm' | 'in'`
51
+ * — with a lookup table between them on ingest, which is where a metric family
52
+ * quietly becomes an inch one. This spelling won because a scrape originates
53
+ * the fact.
54
+ */
55
+ export type { UnitSystem } from '@toolpath/tool-support';
46
56
  /**
47
57
  * The suffix a dimensional column carries, per unit system.
48
58
  *
package/dist/measure.d.ts CHANGED
@@ -41,16 +41,22 @@
41
41
  * writes `1 1/2` and admits no hyphen at all. What it hands here is
42
42
  * {@link Measured}, which is the part they have in common.
43
43
  *
44
- * **`MM_PER_INCH` lives here and not in a vendor.** It was declared and
45
- * exported twice `vendors/harvey/value.ts` and `vendors/regofix/scrape.ts`
46
- * — so `@toolpath/tool-scraper/vendors/harvey` and `.../vendors/regofix` each
47
- * published their own copy of 25.4. That is exactly what `conventions.CAD_COLUMN`
48
- * was moved up for, and what `tests/vendor-boundary.test.ts` now refuses by name.
44
+ * **`MM_PER_INCH` and `convertLength` are `@toolpath/tool-support`'s**, and are
45
+ * re-exported here under the names this package has always published.
46
+ *
47
+ * They were declared and exported twice inside this package alone
48
+ * `vendors/harvey/value.ts` and `vendors/regofix/scrape.ts` so
49
+ * `@toolpath/tool-scraper/vendors/harvey` and `.../vendors/regofix` each
50
+ * published their own copy of 25.4. `tests/vendor-boundary.test.ts` refuses that
51
+ * by name and moving the constant up here fixed it *within* this package, while
52
+ * a third copy went on standing in the application downstream. The domain
53
+ * package is where a constant every consumer shares can only be declared once,
54
+ * and `@toolpath/tool-support`'s own boundary test now holds the whole tree to
55
+ * one `25.4`.
49
56
  */
50
- import type { UnitSystem } from './conventions.js';
57
+ import { convertLength, MM_PER_INCH, type UnitSystem } from '@toolpath/tool-support';
51
58
  import { type Warn } from './scrape.js';
52
- /** Exact by definition: the inch has been 25.4 mm since 1959. */
53
- export declare const MM_PER_INCH = 25.4;
59
+ export { convertLength, MM_PER_INCH };
54
60
  /**
55
61
  * `.250` -> 0.25, `3/4` -> 0.75, `1-1/2` -> 1.5, `2` -> 2.
56
62
  *
@@ -63,8 +69,6 @@ export declare const MM_PER_INCH = 25.4;
63
69
  * that guessed would be the mistake `conventions.UNIT_SUFFIX` exists to prevent.
64
70
  */
65
71
  export declare function fractionValue(token: string): number | null;
66
- /** `value`, converted from `from` to `to`. A no-op when they agree. */
67
- export declare function convertLength(value: number, from: UnitSystem, to: UnitSystem): number;
68
72
  /**
69
73
  * What a value states about itself: a length system, or degrees.
70
74
  *
package/dist/measure.js CHANGED
@@ -41,15 +41,22 @@
41
41
  * writes `1 1/2` and admits no hyphen at all. What it hands here is
42
42
  * {@link Measured}, which is the part they have in common.
43
43
  *
44
- * **`MM_PER_INCH` lives here and not in a vendor.** It was declared and
45
- * exported twice `vendors/harvey/value.ts` and `vendors/regofix/scrape.ts`
46
- * — so `@toolpath/tool-scraper/vendors/harvey` and `.../vendors/regofix` each
47
- * published their own copy of 25.4. That is exactly what `conventions.CAD_COLUMN`
48
- * was moved up for, and what `tests/vendor-boundary.test.ts` now refuses by name.
44
+ * **`MM_PER_INCH` and `convertLength` are `@toolpath/tool-support`'s**, and are
45
+ * re-exported here under the names this package has always published.
46
+ *
47
+ * They were declared and exported twice inside this package alone
48
+ * `vendors/harvey/value.ts` and `vendors/regofix/scrape.ts` so
49
+ * `@toolpath/tool-scraper/vendors/harvey` and `.../vendors/regofix` each
50
+ * published their own copy of 25.4. `tests/vendor-boundary.test.ts` refuses that
51
+ * by name and moving the constant up here fixed it *within* this package, while
52
+ * a third copy went on standing in the application downstream. The domain
53
+ * package is where a constant every consumer shares can only be declared once,
54
+ * and `@toolpath/tool-support`'s own boundary test now holds the whole tree to
55
+ * one `25.4`.
49
56
  */
57
+ import { convertLength, MM_PER_INCH } from '@toolpath/tool-support';
50
58
  import { consoleWarn } from './scrape.js';
51
- /** Exact by definition: the inch has been 25.4 mm since 1959. */
52
- export const MM_PER_INCH = 25.4;
59
+ export { convertLength, MM_PER_INCH };
53
60
  /**
54
61
  * A decimal, a simple fraction or a mixed number — and nothing else.
55
62
  *
@@ -80,12 +87,6 @@ export function fractionValue(token) {
80
87
  const value = (whole === undefined ? 0 : Number(whole)) + part;
81
88
  return Number.isFinite(value) ? value : null;
82
89
  }
83
- /** `value`, converted from `from` to `to`. A no-op when they agree. */
84
- export function convertLength(value, from, to) {
85
- if (from === to)
86
- return value;
87
- return to === 'inches' ? value / MM_PER_INCH : value * MM_PER_INCH;
88
- }
89
90
  /**
90
91
  * A read cell as a length in `unit`, or null where it publishes none.
91
92
  *
@@ -34,6 +34,7 @@
34
34
  * **Collets get no profile.** They publish no CAD model and are not drawn: a
35
35
  * collet sits inside the nut, which the holder's own envelope already includes.
36
36
  */
37
+ import type { ProfileDatum, ProfilePoint } from '@toolpath/tool-support';
37
38
  import type { HolderRecord } from './holding.js';
38
39
  import type { BrandName } from './identity.js';
39
40
  /** Bumped when {@link ProfilesDocument}'s shape changes in a way a consumer must handle. */
@@ -117,8 +118,12 @@ export interface MeasuredHolder {
117
118
  readonly kernelVersion: string;
118
119
  readonly options: ImportOptions;
119
120
  }
120
- /** One vertex of a silhouette: `[z, r]`, both in millimetres. */
121
- export type ProfilePoint = readonly [z: number, r: number];
121
+ /**
122
+ * One vertex of a silhouette: `[z, r]`, both in millimetres.
123
+ *
124
+ * `@toolpath/tool-support`'s, re-exported under this package's own name.
125
+ */
126
+ export type { ProfilePoint } from '@toolpath/tool-support';
122
127
  /**
123
128
  * What `z = 0` means on a profile.
124
129
  *
@@ -132,8 +137,13 @@ export type ProfilePoint = readonly [z: number, r: number];
132
137
  * implementation put it. One `datum` over a batch is only true while every
133
138
  * holder in it has a taper, and the first Capto or straight-shank holder makes
134
139
  * the document's own header wrong about some of its entries.
140
+ *
141
+ * `@toolpath/tool-support`'s, re-exported under this package's own name. It was
142
+ * declared here, in the drawing package, and in the application between them —
143
+ * three copies of two strings, one of which decides whether a consumer may
144
+ * print a gauge length at all.
135
145
  */
136
- export type ProfileDatum = 'gage-line' | 'nose';
146
+ export type { ProfileDatum } from '@toolpath/tool-support';
137
147
  /** One holder's measured silhouette, and how far it agrees with the vendor. */
138
148
  export interface HolderProfile {
139
149
  readonly catalogNumber: string;
@@ -44,6 +44,7 @@
44
44
  * is shaped `YYYY-MM-DD` — and `cite: ''` would otherwise satisfy the
45
45
  * compiler while citing nothing.
46
46
  */
47
+ import { type Provenance } from '@toolpath/tool-support';
47
48
  /** What a per-family constant can be. */
48
49
  export type FactValue = string | number | boolean;
49
50
  /**
@@ -53,9 +54,16 @@ export type FactValue = string | number | boolean;
53
54
  * before the guesses and finishes on the ones only a person stands behind —
54
55
  * `derived` first, then `assumed`. (`vendor-stated` leads the order but is
55
56
  * filtered out of that document entirely; see {@link assumptions}.)
57
+ *
58
+ * **`@toolpath/tool-support`'s `PROVENANCE`**, re-exported under this package's
59
+ * own name. The order is load-bearing here and is the shared list's, so the
60
+ * ordering that document is read in cannot drift from the vocabulary a drawing
61
+ * marks a derived dimension by. Three identical declarations of these three
62
+ * strings stood before it — this one, the drawing's `Provenance`, and the
63
+ * application's.
56
64
  */
57
65
  export declare const SOURCES: readonly ["vendor-stated", "derived", "assumed"];
58
- export type FactSource = (typeof SOURCES)[number];
66
+ export type FactSource = Provenance;
59
67
  /**
60
68
  * One per-family constant, with its provenance.
61
69
  *
@@ -44,6 +44,7 @@
44
44
  * is shaped `YYYY-MM-DD` — and `cite: ''` would otherwise satisfy the
45
45
  * compiler while citing nothing.
46
46
  */
47
+ import { PROVENANCE } from '@toolpath/tool-support';
47
48
  import { ScraperConfigError } from './errors.js';
48
49
  import { compare } from './order.js';
49
50
  /**
@@ -53,8 +54,15 @@ import { compare } from './order.js';
53
54
  * before the guesses and finishes on the ones only a person stands behind —
54
55
  * `derived` first, then `assumed`. (`vendor-stated` leads the order but is
55
56
  * filtered out of that document entirely; see {@link assumptions}.)
57
+ *
58
+ * **`@toolpath/tool-support`'s `PROVENANCE`**, re-exported under this package's
59
+ * own name. The order is load-bearing here and is the shared list's, so the
60
+ * ordering that document is read in cannot drift from the vocabulary a drawing
61
+ * marks a derived dimension by. Three identical declarations of these three
62
+ * strings stood before it — this one, the drawing's `Provenance`, and the
63
+ * application's.
56
64
  */
57
- export const SOURCES = ['vendor-stated', 'derived', 'assumed'];
65
+ export const SOURCES = PROVENANCE;
58
66
  const DATE = /^\d{4}-\d{2}-\d{2}$/;
59
67
  /** What a note has to say, per source kind. */
60
68
  const WANTED = {
package/dist/records.d.ts CHANGED
@@ -42,9 +42,33 @@
42
42
  * always a copy is not a second measurement. An adapter that could supply them
43
43
  * separately could supply a tool that claims a holder it does not have.
44
44
  */
45
- import { type UnitSystem } from './conventions.js';
45
+ import { type UnitSystem } from '@toolpath/tool-support';
46
46
  import { type BrandName } from './identity.js';
47
47
  import type { FactSource } from './provenance.js';
48
+ /**
49
+ * One canonical geometry name: what it measures, and whose name it is.
50
+ *
51
+ * **Declared here rather than re-exported from `@toolpath/tool-support`**, even
52
+ * though the dictionary's entries are the shared ones. The shared
53
+ * `GeometryField` carries a required `unit` and is `readonly` throughout, and
54
+ * this type has been published since 1.0: adopting it outright would stop a
55
+ * consumer that builds one of these — `{ definition, iso }` — from compiling,
56
+ * for no gain the values below do not already give. The entries *satisfy* the
57
+ * shared shape, so a field renamed upstream is still a compile error here.
58
+ */
59
+ export interface GeometryField {
60
+ /**
61
+ * What the field measures, phrased so it can be quoted back at whoever
62
+ * mapped a column to the wrong one.
63
+ */
64
+ definition: string;
65
+ /**
66
+ * The ISO 13399 code for this measurement, or `null` where the standard's
67
+ * counterpart has not been pinned against the dictionary. Equal to the
68
+ * canonical name itself on every field that *is* the standard's code.
69
+ */
70
+ iso: string | null;
71
+ }
48
72
  /** The kinds of cutting tool this package maps. */
49
73
  export type ToolKind = 'drill' | 'tap' | 'endmill';
50
74
  /**
@@ -87,20 +111,6 @@ export declare const UNSPECIFIED = "unspecified";
87
111
  * type so that the vocabularies cannot drift apart.
88
112
  */
89
113
  export type MaterialGroupsSource = FactSource | typeof UNSPECIFIED;
90
- /** One canonical geometry name: what it measures, and whose name it is. */
91
- export interface GeometryField {
92
- /**
93
- * What the field measures, phrased so it can be quoted back at whoever
94
- * mapped a column to the wrong one.
95
- */
96
- definition: string;
97
- /**
98
- * The ISO 13399 code for this measurement, or `null` where the standard's
99
- * counterpart has not been pinned against the dictionary. Equal to the
100
- * canonical name itself on every field that *is* the standard's code.
101
- */
102
- iso: string | null;
103
- }
104
114
  /**
105
115
  * Canonical geometry fields an adapter may supply, and what each means.
106
116
  *
@@ -109,6 +119,26 @@ export interface GeometryField {
109
119
  * so the vocabulary's source is readable from the code rather than from a plan
110
120
  * document.
111
121
  *
122
+ * ## What each entry says, and what this table says
123
+ *
124
+ * The definitions and ISO codes are `@toolpath/tool-support`'s — that is the
125
+ * dictionary, and it is shared because a code has to mean one thing in every
126
+ * package that reads one. **This is not that dictionary.** It is the narrower
127
+ * question only a scraper asks: which of those names an *adapter may map a
128
+ * vendor column to*.
129
+ *
130
+ * The two are not the same list and must not become one. The dictionary knows
131
+ * `LBH` and `LD`, which are derived from a tool and a holder downstream and
132
+ * which no vendor publishes; an adapter permitted to map a column to `LBH`
133
+ * could supply a tool that claims a stickout nobody set. It also knows `LSCN`,
134
+ * ISO's clamping-length minimum, which is a real vendor column the day a vendor
135
+ * prints one — and which is deliberately absent below until that day, because
136
+ * the load-time check's job is to refuse a name no scrape can fill.
137
+ *
138
+ * So each entry is an explicit pick out of the shared table rather than a
139
+ * spread of it: a name dropped from the dictionary is a compile error here, and
140
+ * a name added to the dictionary does not silently become mappable.
141
+ *
112
142
  * **Seven of the ten are the standard's codes with the standard's meanings.**
113
143
  * The three that are not are Autodesk's, and each has an ISO counterpart
114
144
  * Autodesk did not use:
@@ -127,43 +157,53 @@ export interface GeometryField {
127
157
  */
128
158
  export declare const GEOMETRY_FIELDS: {
129
159
  readonly DC: {
160
+ readonly unit: "mm";
130
161
  readonly definition: "cutting diameter";
131
162
  readonly iso: "DC";
132
163
  };
133
164
  readonly SFDM: {
134
- readonly definition: "shank diameter";
165
+ readonly unit: "mm";
166
+ readonly definition: "shank diameter \u2014 what the holder grips";
135
167
  readonly iso: "DMM";
136
168
  };
137
169
  readonly OAL: {
138
- readonly definition: "overall length";
170
+ readonly unit: "mm";
171
+ readonly definition: "overall length, tip to the end of the shank";
139
172
  readonly iso: "OAL";
140
173
  };
141
174
  readonly LCF: {
142
- readonly definition: "flute length — the length of the cutting edge";
175
+ readonly unit: "mm";
176
+ readonly definition: "flute length \u2014 the length of the cutting edge";
143
177
  readonly iso: "LCF";
144
178
  };
145
179
  readonly RE: {
180
+ readonly unit: "mm";
146
181
  readonly definition: "corner radius; 0 on a square-end tool";
147
182
  readonly iso: "RE";
148
183
  };
149
184
  readonly TP: {
150
- readonly definition: "thread pitch, in the tool’s own unit system";
185
+ readonly unit: "mm";
186
+ readonly definition: "thread pitch, in the tool\u2019s own unit system";
151
187
  readonly iso: "TP";
152
188
  };
153
189
  readonly NOF: {
190
+ readonly unit: "count";
154
191
  readonly definition: "number of flutes";
155
192
  readonly iso: "NOF";
156
193
  };
157
194
  readonly SIG: {
195
+ readonly unit: "deg";
158
196
  readonly definition: "point angle, degrees included";
159
197
  readonly iso: "SIG";
160
198
  };
161
199
  readonly 'shoulder-length': {
200
+ readonly unit: "mm";
162
201
  readonly definition: "usable length below the full shank";
163
202
  readonly iso: null;
164
203
  };
165
204
  readonly 'shoulder-diameter': {
166
- readonly definition: "diameter at the shoulder — the neck, where necked";
205
+ readonly unit: "mm";
206
+ readonly definition: "diameter at the shoulder \u2014 the neck, where necked";
167
207
  readonly iso: null;
168
208
  };
169
209
  };
package/dist/records.js CHANGED
@@ -42,6 +42,7 @@
42
42
  * always a copy is not a second measurement. An adapter that could supply them
43
43
  * separately could supply a tool that claims a holder it does not have.
44
44
  */
45
+ import { GEOMETRY_FIELDS as DICTIONARY } from '@toolpath/tool-support';
45
46
  import { dimensionalColumn } from './conventions.js';
46
47
  import { ScraperConfigError } from './errors.js';
47
48
  import { recordGuid } from './identity.js';
@@ -81,6 +82,26 @@ export const UNSPECIFIED = 'unspecified';
81
82
  * so the vocabulary's source is readable from the code rather than from a plan
82
83
  * document.
83
84
  *
85
+ * ## What each entry says, and what this table says
86
+ *
87
+ * The definitions and ISO codes are `@toolpath/tool-support`'s — that is the
88
+ * dictionary, and it is shared because a code has to mean one thing in every
89
+ * package that reads one. **This is not that dictionary.** It is the narrower
90
+ * question only a scraper asks: which of those names an *adapter may map a
91
+ * vendor column to*.
92
+ *
93
+ * The two are not the same list and must not become one. The dictionary knows
94
+ * `LBH` and `LD`, which are derived from a tool and a holder downstream and
95
+ * which no vendor publishes; an adapter permitted to map a column to `LBH`
96
+ * could supply a tool that claims a stickout nobody set. It also knows `LSCN`,
97
+ * ISO's clamping-length minimum, which is a real vendor column the day a vendor
98
+ * prints one — and which is deliberately absent below until that day, because
99
+ * the load-time check's job is to refuse a name no scrape can fill.
100
+ *
101
+ * So each entry is an explicit pick out of the shared table rather than a
102
+ * spread of it: a name dropped from the dictionary is a compile error here, and
103
+ * a name added to the dictionary does not silently become mappable.
104
+ *
84
105
  * **Seven of the ten are the standard's codes with the standard's meanings.**
85
106
  * The three that are not are Autodesk's, and each has an ISO counterpart
86
107
  * Autodesk did not use:
@@ -98,25 +119,16 @@ export const UNSPECIFIED = 'unspecified';
98
119
  * recognises it.
99
120
  */
100
121
  export const GEOMETRY_FIELDS = {
101
- DC: { definition: 'cutting diameter', iso: 'DC' },
102
- SFDM: { definition: 'shank diameter', iso: 'DMM' },
103
- OAL: { definition: 'overall length', iso: 'OAL' },
104
- LCF: {
105
- definition: 'flute length — the length of the cutting edge',
106
- iso: 'LCF',
107
- },
108
- RE: { definition: 'corner radius; 0 on a square-end tool', iso: 'RE' },
109
- TP: { definition: 'thread pitch, in the tool’s own unit system', iso: 'TP' },
110
- NOF: { definition: 'number of flutes', iso: 'NOF' },
111
- SIG: { definition: 'point angle, degrees included', iso: 'SIG' },
112
- 'shoulder-length': {
113
- definition: 'usable length below the full shank',
114
- iso: null,
115
- },
116
- 'shoulder-diameter': {
117
- definition: 'diameter at the shoulder — the neck, where necked',
118
- iso: null,
119
- },
122
+ DC: DICTIONARY.DC,
123
+ SFDM: DICTIONARY.SFDM,
124
+ OAL: DICTIONARY.OAL,
125
+ LCF: DICTIONARY.LCF,
126
+ RE: DICTIONARY.RE,
127
+ TP: DICTIONARY.TP,
128
+ NOF: DICTIONARY.NOF,
129
+ SIG: DICTIONARY.SIG,
130
+ 'shoulder-length': DICTIONARY['shoulder-length'],
131
+ 'shoulder-diameter': DICTIONARY['shoulder-diameter'],
120
132
  };
121
133
  /**
122
134
  * The canonical names that are **not** ISO 13399's own codes, derived rather
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolpath/tool-scraper",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Scrape cutting-tool geometry from vendor catalogs into records and CSVs",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -82,7 +82,8 @@
82
82
  "README.md"
83
83
  ],
84
84
  "dependencies": {
85
- "htmlparser2": "12.0.0"
85
+ "htmlparser2": "12.0.0",
86
+ "@toolpath/tool-support": "^0.1.0"
86
87
  },
87
88
  "devDependencies": {
88
89
  "@types/node": "24.10.1",