mcp-recipes 1.0.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/CHANGELOG.md +147 -0
- package/LICENSE +21 -0
- package/README.md +684 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3037 -0
- package/dist/index.js.map +1 -0
- package/dist/language-BgfmjwtF.d.ts +14 -0
- package/dist/recipe/scale.d.ts +86 -0
- package/dist/recipe/scale.js +1367 -0
- package/dist/recipe/scale.js.map +1 -0
- package/dist/sources/client.d.ts +448 -0
- package/dist/sources/client.js +697 -0
- package/dist/sources/client.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which language an ingredient line is written in.
|
|
3
|
+
*
|
|
4
|
+
* A list can hold French lines and English lines at once, because a cook
|
|
5
|
+
* comparing two versions of a dish keeps both in front of them. The language
|
|
6
|
+
* decides how a number is written, how a noun agrees with it, and which
|
|
7
|
+
* vocabulary of measures applies, so it is settled per line rather than once
|
|
8
|
+
* for a whole list.
|
|
9
|
+
*/
|
|
10
|
+
type Language = "fr" | "en";
|
|
11
|
+
/** What a caller may ask for: a language, or a reading taken per line. */
|
|
12
|
+
type LanguageChoice = Language | "auto";
|
|
13
|
+
|
|
14
|
+
export type { LanguageChoice as L, Language as a };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { L as LanguageChoice, a as Language } from '../language-BgfmjwtF.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scaling ingredient quantities, in French and in English.
|
|
5
|
+
*
|
|
6
|
+
* The guiding rule is that a scaled quantity must be something a cook can act
|
|
7
|
+
* on. Multiplying every number by the factor is arithmetically correct and
|
|
8
|
+
* practically useless: it produces "2,4 oeufs" and "0.67 pinch of salt" with
|
|
9
|
+
* the same confidence as "267 g flour". Each line is therefore classified by
|
|
10
|
+
* what its measure allows, and the classification travels with the result so
|
|
11
|
+
* the caller can see what was computed and what was left alone.
|
|
12
|
+
*
|
|
13
|
+
* Leaving a line alone is a decision of the same weight. A quantity a recipe
|
|
14
|
+
* states loosely still holds a share of the dish, and a leavening agent left at
|
|
15
|
+
* one pinch for twenty-five servings is a recipe that does not rise.
|
|
16
|
+
*
|
|
17
|
+
* The two languages are read by one set of rules. A list holding French lines
|
|
18
|
+
* and English lines comes back scaled by the same arithmetic, with each line
|
|
19
|
+
* written the way its own language writes numbers, plurals and measures.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
type ScalingKind =
|
|
23
|
+
/** The arithmetic was exact. */
|
|
24
|
+
"scaled"
|
|
25
|
+
/**
|
|
26
|
+
* A countable item was moved to a whole or half unit, or a measurement was
|
|
27
|
+
* demoted to a smaller unit to stay usable.
|
|
28
|
+
*/
|
|
29
|
+
| "rounded"
|
|
30
|
+
/** The line carries nothing that can be multiplied. */
|
|
31
|
+
| "unscaled";
|
|
32
|
+
interface ScaledIngredient {
|
|
33
|
+
/** The line after scaling, identical to `original` when unscaled. */
|
|
34
|
+
text: string;
|
|
35
|
+
/** The line as published. */
|
|
36
|
+
original: string;
|
|
37
|
+
scaling: ScalingKind;
|
|
38
|
+
/**
|
|
39
|
+
* The scaled quantity, expressed in `unit`, and the lower bound when the line
|
|
40
|
+
* gives a range.
|
|
41
|
+
*
|
|
42
|
+
* Read it together with `unit`, never on its own: a large result is moved to
|
|
43
|
+
* a bigger unit, so scaling "200 g" by ten gives an amount of 2 with a unit
|
|
44
|
+
* of "kg". The bare number can therefore shrink while the quantity grows.
|
|
45
|
+
*/
|
|
46
|
+
amount: number | null;
|
|
47
|
+
/** Upper bound when the line gives a range, null otherwise. */
|
|
48
|
+
amountMax: number | null;
|
|
49
|
+
/** The unit `amount` is in, which may differ from the one the recipe used. */
|
|
50
|
+
unit: string | null;
|
|
51
|
+
/** The language the line was read and rewritten in. */
|
|
52
|
+
language: Language;
|
|
53
|
+
/** Why the line was rounded, clamped or left alone. */
|
|
54
|
+
note?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ScaleOptions {
|
|
57
|
+
/** Multiplier applied to the quantities. */
|
|
58
|
+
factor: number;
|
|
59
|
+
/**
|
|
60
|
+
* Which language to read the lines in. Left out, each line is read on its
|
|
61
|
+
* own, so a list holding both comes back written the way each line was.
|
|
62
|
+
*/
|
|
63
|
+
language?: LanguageChoice;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Scale one ingredient line.
|
|
67
|
+
*
|
|
68
|
+
* Countable items are rounded to something a kitchen can measure, ranges are
|
|
69
|
+
* scaled at both ends, equivalents and alternatives are scaled with the amount
|
|
70
|
+
* they stand beside, and an approximate measure such as a pinch has its count
|
|
71
|
+
* scaled with a note saying how loosely one of them is defined.
|
|
72
|
+
*/
|
|
73
|
+
declare function scaleIngredient(line: string, options: ScaleOptions): ScaledIngredient;
|
|
74
|
+
declare function scaleIngredients(lines: string[], options: ScaleOptions): ScaledIngredient[];
|
|
75
|
+
/**
|
|
76
|
+
* A line returned as published, with whatever quantity could be read off it.
|
|
77
|
+
*
|
|
78
|
+
* A line that carries a readable amount is `scaled`, because leaving it alone
|
|
79
|
+
* is what multiplying by one does. A line with no amount at all is `unscaled`
|
|
80
|
+
* and says why.
|
|
81
|
+
*/
|
|
82
|
+
declare function passthroughIngredient(line: string, language?: LanguageChoice): ScaledIngredient;
|
|
83
|
+
/** An ingredient list returned unchanged, for when no scaling was requested. */
|
|
84
|
+
declare function passthroughIngredients(lines: string[], language?: LanguageChoice): ScaledIngredient[];
|
|
85
|
+
|
|
86
|
+
export { Language, LanguageChoice, type ScaleOptions, type ScaledIngredient, type ScalingKind, passthroughIngredient, passthroughIngredients, scaleIngredient, scaleIngredients };
|