@adeficior/data-modifier 1.0.0-rc.12 → 1.0.0-rc.14
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/common/id.d.ts +1 -0
- package/dist/common/id.js +4 -0
- package/dist/common/id.js.map +1 -1
- package/dist/common/ingredient/filter.d.ts +6 -0
- package/dist/common/ingredient/filter.js +97 -0
- package/dist/common/ingredient/filter.js.map +1 -0
- package/dist/common/ingredient/index.d.ts +74 -0
- package/dist/common/ingredient/index.js +112 -0
- package/dist/common/ingredient/index.js.map +1 -0
- package/dist/common/ingredient/input.d.ts +3 -0
- package/dist/common/ingredient/input.js +1 -0
- package/dist/common/ingredient/input.js.map +1 -0
- package/dist/common/ingredient/serializer.d.ts +17 -0
- package/dist/common/ingredient/serializer.js +112 -0
- package/dist/common/ingredient/serializer.js.map +1 -0
- package/dist/common/predicates.d.ts +2 -1
- package/dist/common/predicates.js.map +1 -1
- package/dist/common/result/filter.d.ts +6 -0
- package/dist/common/result/filter.js +68 -0
- package/dist/common/result/filter.js.map +1 -0
- package/dist/common/result/index.d.ts +41 -0
- package/dist/common/result/index.js +59 -0
- package/dist/common/result/index.js.map +1 -0
- package/dist/common/result/input.d.ts +3 -0
- package/dist/common/result/input.js +1 -0
- package/dist/common/result/input.js.map +1 -0
- package/dist/common/result/serializer.d.ts +15 -0
- package/dist/common/result/serializer.js +81 -0
- package/dist/common/result/serializer.js.map +1 -0
- package/dist/common/serializable.d.ts +6 -0
- package/dist/common/serializable.js +1 -0
- package/dist/common/serializable.js.map +1 -0
- package/dist/common/units.d.ts +1 -0
- package/dist/common/units.js +2 -0
- package/dist/common/units.js.map +1 -0
- package/dist/emit/blacklist.d.ts +4 -6
- package/dist/emit/blacklist.js +19 -21
- package/dist/emit/blacklist.js.map +1 -1
- package/dist/emit/data/loot.d.ts +6 -8
- package/dist/emit/data/loot.js +11 -13
- package/dist/emit/data/loot.js.map +1 -1
- package/dist/emit/data/recipe.d.ts +20 -18
- package/dist/emit/data/recipe.js +40 -29
- package/dist/emit/data/recipe.js.map +1 -1
- package/dist/emit/data/tags.d.ts +1 -1
- package/dist/emit/data/tags.js.map +1 -1
- package/dist/emit/polytoneTabs.d.ts +1 -1
- package/dist/emit/polytoneTabs.js +1 -2
- package/dist/emit/polytoneTabs.js.map +1 -1
- package/dist/emit/rule/lootTable.d.ts +2 -1
- package/dist/emit/rule/lootTable.js +4 -2
- package/dist/emit/rule/lootTable.js.map +1 -1
- package/dist/emit/rule/recipe.d.ts +7 -5
- package/dist/emit/rule/recipe.js.map +1 -1
- package/dist/emit/ruled.d.ts +2 -1
- package/dist/emit/ruled.js +5 -2
- package/dist/emit/ruled.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/loader/context.d.ts +12 -0
- package/dist/loader/context.js +1 -0
- package/dist/loader/context.js.map +1 -0
- package/dist/loader/pack.d.ts +13 -7
- package/dist/loader/pack.js +43 -25
- package/dist/loader/pack.js.map +1 -1
- package/dist/loader/recipe.d.ts +9 -5
- package/dist/loader/recipe.js +39 -48
- package/dist/loader/recipe.js.map +1 -1
- package/dist/loader/registry/dump.d.ts +0 -2
- package/dist/loader/registry/dump.js +0 -11
- package/dist/loader/registry/dump.js.map +1 -1
- package/dist/loader/registry/index.d.ts +0 -2
- package/dist/loader/registry/wrapped.d.ts +13 -0
- package/dist/loader/registry/wrapped.js +26 -0
- package/dist/loader/registry/wrapped.js.map +1 -0
- package/dist/loader/tags.d.ts +1 -1
- package/dist/loader/tags.js.map +1 -1
- package/dist/parser/adAstra.d.ts +5 -11
- package/dist/parser/adAstra.js +5 -5
- package/dist/parser/adAstra.js.map +1 -1
- package/dist/parser/botania.d.ts +10 -20
- package/dist/parser/botania.js +10 -10
- package/dist/parser/botania.js.map +1 -1
- package/dist/parser/create.d.ts +2 -4
- package/dist/parser/create.js +2 -2
- package/dist/parser/create.js.map +1 -1
- package/dist/parser/index.d.ts +7 -13
- package/dist/parser/index.js +7 -7
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/lootTable.d.ts +7 -6
- package/dist/parser/lootTable.js +25 -23
- package/dist/parser/lootTable.js.map +1 -1
- package/dist/parser/recipe/adAstra/conversion.d.ts +15 -14
- package/dist/parser/recipe/adAstra/conversion.js +27 -20
- package/dist/parser/recipe/adAstra/conversion.js.map +1 -1
- package/dist/parser/recipe/adAstra/hammering.d.ts +3 -17
- package/dist/parser/recipe/adAstra/hammering.js +2 -25
- package/dist/parser/recipe/adAstra/hammering.js.map +1 -1
- package/dist/parser/recipe/adAstra/inputOutput.d.ts +16 -19
- package/dist/parser/recipe/adAstra/inputOutput.js +37 -29
- package/dist/parser/recipe/adAstra/inputOutput.js.map +1 -1
- package/dist/parser/recipe/adAstra/nasaWorkbench.d.ts +3 -19
- package/dist/parser/recipe/adAstra/nasaWorkbench.js +2 -28
- package/dist/parser/recipe/adAstra/nasaWorkbench.js.map +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.d.ts +15 -14
- package/dist/parser/recipe/adAstra/spaceStation.js +33 -14
- package/dist/parser/recipe/adAstra/spaceStation.js.map +1 -1
- package/dist/parser/recipe/botania/apothecary.d.ts +17 -14
- package/dist/parser/recipe/botania/apothecary.js +26 -17
- package/dist/parser/recipe/botania/apothecary.js.map +1 -1
- package/dist/parser/recipe/botania/blocks.d.ts +21 -0
- package/dist/parser/recipe/botania/blocks.js +77 -0
- package/dist/parser/recipe/botania/blocks.js.map +1 -0
- package/dist/parser/recipe/botania/brew.d.ts +13 -12
- package/dist/parser/recipe/botania/brew.js +16 -11
- package/dist/parser/recipe/botania/brew.js.map +1 -1
- package/dist/parser/recipe/botania/elvenTrade.d.ts +8 -13
- package/dist/parser/recipe/botania/elvenTrade.js +11 -22
- package/dist/parser/recipe/botania/elvenTrade.js.map +1 -1
- package/dist/parser/recipe/botania/gogWrapper.d.ts +12 -12
- package/dist/parser/recipe/botania/gogWrapper.js +14 -15
- package/dist/parser/recipe/botania/gogWrapper.js.map +1 -1
- package/dist/parser/recipe/botania/manaInfusion.d.ts +18 -15
- package/dist/parser/recipe/botania/manaInfusion.js +29 -21
- package/dist/parser/recipe/botania/manaInfusion.js.map +1 -1
- package/dist/parser/recipe/botania/nbtWrapper.d.ts +12 -12
- package/dist/parser/recipe/botania/nbtWrapper.js +12 -13
- package/dist/parser/recipe/botania/nbtWrapper.js.map +1 -1
- package/dist/parser/recipe/botania/orechid.d.ts +3 -30
- package/dist/parser/recipe/botania/orechid.js +2 -72
- package/dist/parser/recipe/botania/orechid.js.map +1 -1
- package/dist/parser/recipe/botania/pureDaisy.d.ts +3 -18
- package/dist/parser/recipe/botania/pureDaisy.js +2 -28
- package/dist/parser/recipe/botania/pureDaisy.js.map +1 -1
- package/dist/parser/recipe/botania/runicAltar.d.ts +8 -13
- package/dist/parser/recipe/botania/runicAltar.js +11 -22
- package/dist/parser/recipe/botania/runicAltar.js.map +1 -1
- package/dist/parser/recipe/botania/terraPlate.d.ts +4 -16
- package/dist/parser/recipe/botania/terraPlate.js +2 -25
- package/dist/parser/recipe/botania/terraPlate.js.map +1 -1
- package/dist/parser/recipe/create/assembly.d.ts +18 -17
- package/dist/parser/recipe/create/assembly.js +28 -28
- package/dist/parser/recipe/create/assembly.js.map +1 -1
- package/dist/parser/recipe/create/processing.d.ts +4 -16
- package/dist/parser/recipe/create/processing.js +2 -25
- package/dist/parser/recipe/create/processing.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cooking.d.ts +16 -12
- package/dist/parser/recipe/farmersdelight/cooking.js +27 -15
- package/dist/parser/recipe/farmersdelight/cooking.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cutting.d.ts +14 -15
- package/dist/parser/recipe/farmersdelight/cutting.js +32 -29
- package/dist/parser/recipe/farmersdelight/cutting.js.map +1 -1
- package/dist/parser/recipe/forge/conditional.d.ts +11 -11
- package/dist/parser/recipe/forge/conditional.js +17 -21
- package/dist/parser/recipe/forge/conditional.js.map +1 -1
- package/dist/parser/recipe/index.d.ts +36 -13
- package/dist/parser/recipe/index.js +38 -5
- package/dist/parser/recipe/index.js.map +1 -1
- package/dist/parser/recipe/ingredientMap.d.ts +12 -0
- package/dist/parser/recipe/ingredientMap.js +17 -0
- package/dist/parser/recipe/ingredientMap.js.map +1 -0
- package/dist/parser/recipe/manyToMany.d.ts +20 -0
- package/dist/parser/recipe/manyToMany.js +33 -0
- package/dist/parser/recipe/manyToMany.js.map +1 -0
- package/dist/parser/recipe/manyToOne.d.ts +20 -0
- package/dist/parser/recipe/manyToOne.js +33 -0
- package/dist/parser/recipe/manyToOne.js.map +1 -0
- package/dist/parser/recipe/oneToOne.d.ts +20 -0
- package/dist/parser/recipe/oneToOne.js +33 -0
- package/dist/parser/recipe/oneToOne.js.map +1 -0
- package/dist/parser/recipe/roots/component.d.ts +13 -12
- package/dist/parser/recipe/roots/component.js +16 -11
- package/dist/parser/recipe/roots/component.js.map +1 -1
- package/dist/parser/recipe/roots/ritual.d.ts +14 -16
- package/dist/parser/recipe/roots/ritual.js +18 -25
- package/dist/parser/recipe/roots/ritual.js.map +1 -1
- package/dist/parser/recipe/sullys/polishing.d.ts +4 -16
- package/dist/parser/recipe/sullys/polishing.js +2 -25
- package/dist/parser/recipe/sullys/polishing.js.map +1 -1
- package/dist/parser/recipe/thermal/catalyst.d.ts +13 -12
- package/dist/parser/recipe/thermal/catalyst.js +16 -11
- package/dist/parser/recipe/thermal/catalyst.js.map +1 -1
- package/dist/parser/recipe/thermal/fuel.d.ts +13 -12
- package/dist/parser/recipe/thermal/fuel.js +17 -11
- package/dist/parser/recipe/thermal/fuel.js.map +1 -1
- package/dist/parser/recipe/thermal/index.d.ts +16 -14
- package/dist/parser/recipe/thermal/index.js +35 -24
- package/dist/parser/recipe/thermal/index.js.map +1 -1
- package/dist/parser/recipe/thermal/ingredient.d.ts +4 -21
- package/dist/parser/recipe/thermal/ingredient.js +40 -33
- package/dist/parser/recipe/thermal/ingredient.js.map +1 -1
- package/dist/parser/recipe/thermal/treeExtraction.d.ts +17 -17
- package/dist/parser/recipe/thermal/treeExtraction.js +30 -31
- package/dist/parser/recipe/thermal/treeExtraction.js.map +1 -1
- package/dist/parser/recipe/vanilla/shaped.d.ts +17 -13
- package/dist/parser/recipe/vanilla/shaped.js +21 -16
- package/dist/parser/recipe/vanilla/shaped.js.map +1 -1
- package/dist/parser/recipe/vanilla/shapeless.d.ts +3 -17
- package/dist/parser/recipe/vanilla/shapeless.js +2 -25
- package/dist/parser/recipe/vanilla/shapeless.js.map +1 -1
- package/dist/parser/recipe/vanilla/smelting.d.ts +16 -13
- package/dist/parser/recipe/vanilla/smelting.js +21 -15
- package/dist/parser/recipe/vanilla/smelting.js.map +1 -1
- package/dist/parser/recipe/vanilla/smithing.d.ts +18 -14
- package/dist/parser/recipe/vanilla/smithing.js +25 -16
- package/dist/parser/recipe/vanilla/smithing.js.map +1 -1
- package/dist/parser/recipe/vanilla/stonecutting.d.ts +15 -13
- package/dist/parser/recipe/vanilla/stonecutting.js +22 -24
- package/dist/parser/recipe/vanilla/stonecutting.js.map +1 -1
- package/dist/parser/roots.d.ts +2 -4
- package/dist/parser/roots.js +2 -2
- package/dist/parser/roots.js.map +1 -1
- package/dist/parser/thermal.d.ts +4 -10
- package/dist/parser/thermal.js +4 -5
- package/dist/parser/thermal.js.map +1 -1
- package/dist/schema/data/recipe.d.ts +2 -1
- package/package.json +2 -1
- package/dist/common/ingredient.d.ts +0 -49
- package/dist/common/ingredient.js +0 -108
- package/dist/common/ingredient.js.map +0 -1
- package/dist/common/result.d.ts +0 -48
- package/dist/common/result.js +0 -37
- package/dist/common/result.js.map +0 -1
- package/dist/parser/recipe/adAstra/index.d.ts +0 -5
- package/dist/parser/recipe/adAstra/index.js +0 -1
- package/dist/parser/recipe/adAstra/index.js.map +0 -1
- package/dist/parser/recipe/ignored.d.ts +0 -10
- package/dist/parser/recipe/ignored.js +0 -16
- package/dist/parser/recipe/ignored.js.map +0 -1
- package/dist/parser/recipe/quark/exclusion.d.ts +0 -20
- package/dist/parser/recipe/quark/exclusion.js +0 -32
- package/dist/parser/recipe/quark/exclusion.js.map +0 -1
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
import { exists } from "@adeficior/pack-resolver";
|
|
2
2
|
import RecipeParser, { Recipe } from "../index.js";
|
|
3
3
|
export class CookingRecipe extends Recipe {
|
|
4
|
+
ingredients;
|
|
5
|
+
result;
|
|
6
|
+
container;
|
|
7
|
+
constructor(ingredients, result, container) {
|
|
8
|
+
super();
|
|
9
|
+
this.ingredients = ingredients;
|
|
10
|
+
this.result = result;
|
|
11
|
+
this.container = container;
|
|
12
|
+
}
|
|
4
13
|
getIngredients() {
|
|
5
|
-
return [this.
|
|
14
|
+
return [this.container, ...this.ingredients].filter(exists);
|
|
6
15
|
}
|
|
7
16
|
getResults() {
|
|
8
|
-
return [this.
|
|
17
|
+
return [this.result];
|
|
9
18
|
}
|
|
10
|
-
|
|
11
|
-
return new CookingRecipe(
|
|
12
|
-
...this.definition,
|
|
13
|
-
container: this.definition.container && replace(this.definition.container),
|
|
14
|
-
ingredients: this.definition.ingredients.map(replace),
|
|
15
|
-
});
|
|
19
|
+
replace(ingredientReplacer, resultReplacer) {
|
|
20
|
+
return new CookingRecipe(this.ingredients.map(ingredientReplacer), resultReplacer(this.result), this.container && ingredientReplacer(this.container));
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
result:
|
|
21
|
-
|
|
22
|
+
serialize(context) {
|
|
23
|
+
return {
|
|
24
|
+
ingredients: context.ingredients.serializeList(this.ingredients),
|
|
25
|
+
result: context.results.serialize(this.result),
|
|
26
|
+
container: this.container && context.ingredients.serialize(this.container),
|
|
27
|
+
};
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
export default class CookingRecipeParser extends RecipeParser {
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
deserialize(definition, context) {
|
|
32
|
+
const ingredients = context.ingredients.createList(definition.ingredients);
|
|
33
|
+
const result = context.results.create(definition.result);
|
|
34
|
+
// TODO optional serialize & deserialize?
|
|
35
|
+
const container = definition.container === undefined
|
|
36
|
+
? undefined
|
|
37
|
+
: context.ingredients.create(definition.container);
|
|
38
|
+
return new CookingRecipe(ingredients, result, container);
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
41
|
//# sourceMappingURL=cooking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cooking.js","sourceRoot":"","sources":["../../../../src/parser/recipe/farmersdelight/cooking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cooking.js","sourceRoot":"","sources":["../../../../src/parser/recipe/farmersdelight/cooking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAKlD,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAYnD,MAAM,OAAO,aAAc,SAAQ,MAAM;IAEpB;IACA;IACA;IAHnB,YACmB,WAAyB,EACzB,MAAc,EACd,SAAsB;QAEvC,KAAK,EAAE,CAAC;QAJS,gBAAW,GAAX,WAAW,CAAc;QACzB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAa;IAGzC,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAEQ,OAAO,CACd,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,aAAa,CACtB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,EACxC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAC3B,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CACrD,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;YAChE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9C,SAAS,EACP,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;SAClE,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAGhD;IACC,WAAW,CACT,UAAmC,EACnC,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,yCAAyC;QACzC,MAAM,SAAS,GACb,UAAU,CAAC,SAAS,KAAK,SAAS;YAChC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO,IAAI,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type
|
|
5
|
-
import type { Result, ResultInput } from "../../../common/result.js";
|
|
1
|
+
import type { Ingredient } from "../../../common/ingredient/index.js";
|
|
2
|
+
import type { Result } from "../../../common/result/index.js";
|
|
3
|
+
import RecipeParser, { type RecipeParseContext, type Replacer } from "../index.js";
|
|
4
|
+
import { ManyToManyRecipe, type ManyToManyRecipeDefinition } from "../manyToMany.js";
|
|
6
5
|
export type ToolInput = Readonly<{
|
|
7
6
|
type: "farmersdelight:tool_action";
|
|
8
7
|
action: string;
|
|
9
8
|
}>;
|
|
10
|
-
export type CuttingRecipeDefinition =
|
|
11
|
-
|
|
12
|
-
result:
|
|
13
|
-
tool: Ingredient | ToolInput;
|
|
9
|
+
export type CuttingRecipeDefinition = Omit<ManyToManyRecipeDefinition, "results"> & Readonly<{
|
|
10
|
+
tool: unknown;
|
|
11
|
+
result: ManyToManyRecipeDefinition["results"];
|
|
14
12
|
}>;
|
|
15
|
-
export declare class CuttingRecipe extends
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
export declare class CuttingRecipe extends ManyToManyRecipe {
|
|
14
|
+
private readonly tool;
|
|
15
|
+
constructor(ingredients: Ingredient[], results: Result[], tool: Ingredient);
|
|
16
|
+
getIngredients(): Ingredient[];
|
|
17
|
+
replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): CuttingRecipe;
|
|
18
|
+
serialize(context: RecipeParseContext): Partial<CuttingRecipeDefinition>;
|
|
20
19
|
}
|
|
21
20
|
export default class CuttingRecipeParser extends RecipeParser<CuttingRecipeDefinition, CuttingRecipe> {
|
|
22
|
-
|
|
21
|
+
deserialize(definition: CuttingRecipeDefinition, context: RecipeParseContext): CuttingRecipe;
|
|
23
22
|
}
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import RecipeParser, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import RecipeParser, {} from "../index.js";
|
|
2
|
+
import { ManyToManyRecipe, } from "../manyToMany.js";
|
|
3
|
+
// TODO create actual input
|
|
4
|
+
// function isToolInput<T>(input: T | ToolInput): input is ToolInput {
|
|
5
|
+
// return (
|
|
6
|
+
// !!input &&
|
|
7
|
+
// typeof input === "object" &&
|
|
8
|
+
// "type" in input &&
|
|
9
|
+
// input.type === "farmersdelight:tool_action"
|
|
10
|
+
// );
|
|
11
|
+
// }
|
|
12
|
+
export class CuttingRecipe extends ManyToManyRecipe {
|
|
13
|
+
tool;
|
|
14
|
+
constructor(ingredients, results, tool) {
|
|
15
|
+
super(ingredients, results);
|
|
16
|
+
this.tool = tool;
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
return this.
|
|
18
|
+
getIngredients() {
|
|
19
|
+
return [...super.getIngredients(), this.tool];
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
return new CuttingRecipe(
|
|
19
|
-
...this.definition,
|
|
20
|
-
ingredients: this.definition.ingredients.map(replace),
|
|
21
|
-
tool: isToolInput(this.definition.tool)
|
|
22
|
-
? this.definition.tool
|
|
23
|
-
: replace(this.definition.tool),
|
|
24
|
-
});
|
|
21
|
+
replace(ingredientReplacer, resultReplacer) {
|
|
22
|
+
return new CuttingRecipe(this.ingredients.map(ingredientReplacer), this.results.map(resultReplacer), ingredientReplacer(this.tool));
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
serialize(context) {
|
|
25
|
+
const { results, ...rest } = super.serialize(context);
|
|
26
|
+
return {
|
|
27
|
+
...rest,
|
|
28
|
+
result: results,
|
|
29
|
+
tool: context.ingredients.serialize(this.tool),
|
|
30
|
+
};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
export default class CuttingRecipeParser extends RecipeParser {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
deserialize(definition, context) {
|
|
35
|
+
const ingredients = context.ingredients.createList(definition.ingredients);
|
|
36
|
+
const result = context.results.createList(definition.result);
|
|
37
|
+
const tool = context.ingredients.create(definition.tool);
|
|
38
|
+
return new CuttingRecipe(ingredients, result, tool);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
//# sourceMappingURL=cutting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cutting.js","sourceRoot":"","sources":["../../../../src/parser/recipe/farmersdelight/cutting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cutting.js","sourceRoot":"","sources":["../../../../src/parser/recipe/farmersdelight/cutting.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,EAAE,EAGpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAgB1B,2BAA2B;AAC3B,sEAAsE;AACtE,aAAa;AACb,iBAAiB;AACjB,mCAAmC;AACnC,yBAAyB;AACzB,kDAAkD;AAClD,OAAO;AACP,IAAI;AAEJ,MAAM,OAAO,aAAc,SAAQ,gBAAgB;IAI9B;IAHnB,YACE,WAAyB,EACzB,OAAiB,EACA,IAAgB;QAEjC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAFX,SAAI,GAAJ,IAAI,CAAY;IAGnC,CAAC;IAEQ,cAAc;QACrB,OAAO,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAEQ,OAAO,CACd,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,aAAa,CACtB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,EACxC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAChC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAC9B,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO;YACL,GAAG,IAAI;YACP,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/C,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAGhD;IACC,WAAW,CACT,UAAmC,EACnC,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzD,OAAO,IAAI,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Ingredient
|
|
2
|
-
import type { Result
|
|
1
|
+
import type { Ingredient } from "../../../common/ingredient/index.js";
|
|
2
|
+
import type { Result } from "../../../common/result/index.js";
|
|
3
3
|
import type { RecipeDefinition } from "../../../schema/data/recipe.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { RecipeHolder, RecipeParseContext, Replacer } from "../index.js";
|
|
5
5
|
import RecipeParser, { Recipe } from "../index.js";
|
|
6
6
|
type WithConditions<T> = {
|
|
7
7
|
conditions: unknown[];
|
|
@@ -10,16 +10,16 @@ type WithConditions<T> = {
|
|
|
10
10
|
export type ForgeConditionalRecipeDefinition = RecipeDefinition & Readonly<{
|
|
11
11
|
recipes: WithConditions<RecipeDefinition>[];
|
|
12
12
|
}>;
|
|
13
|
-
export declare class ForgeConditionalRecipe extends Recipe
|
|
13
|
+
export declare class ForgeConditionalRecipe extends Recipe {
|
|
14
14
|
private readonly recipes;
|
|
15
|
-
constructor(
|
|
16
|
-
getIngredients():
|
|
17
|
-
getResults():
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
constructor(recipes: WithConditions<RecipeHolder>[]);
|
|
16
|
+
getIngredients(): Ingredient[];
|
|
17
|
+
getResults(): Result[];
|
|
18
|
+
replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): ForgeConditionalRecipe;
|
|
19
|
+
serialize(context: RecipeParseContext): Partial<ForgeConditionalRecipeDefinition>;
|
|
20
|
+
additionalTypes(): `${string}:${string}`[];
|
|
21
21
|
}
|
|
22
22
|
export default class ForgeConditionalRecipeParser extends RecipeParser<ForgeConditionalRecipeDefinition, ForgeConditionalRecipe> {
|
|
23
|
-
|
|
23
|
+
deserialize(definition: ForgeConditionalRecipeDefinition, context: RecipeParseContext): ForgeConditionalRecipe;
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import RecipeParser, { Recipe } from "../index.js";
|
|
2
2
|
export class ForgeConditionalRecipe extends Recipe {
|
|
3
3
|
recipes;
|
|
4
|
-
constructor(
|
|
5
|
-
super(
|
|
6
|
-
...definition,
|
|
7
|
-
recipes: recipes.map((it) => ({
|
|
8
|
-
conditions: it.conditions,
|
|
9
|
-
recipe: it.recipe.toJSON(),
|
|
10
|
-
})),
|
|
11
|
-
});
|
|
4
|
+
constructor(recipes) {
|
|
5
|
+
super();
|
|
12
6
|
this.recipes = recipes;
|
|
13
7
|
}
|
|
14
8
|
getIngredients() {
|
|
@@ -17,29 +11,31 @@ export class ForgeConditionalRecipe extends Recipe {
|
|
|
17
11
|
getResults() {
|
|
18
12
|
return this.recipes.flatMap((it) => it.recipe.getResults());
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
return new ForgeConditionalRecipe(this.
|
|
14
|
+
replace(ingredientReplacer, resultReplacer) {
|
|
15
|
+
return new ForgeConditionalRecipe(this.recipes.map((it) => ({
|
|
22
16
|
...it,
|
|
23
|
-
recipe: it.recipe.
|
|
17
|
+
recipe: it.recipe.replace(ingredientReplacer, resultReplacer),
|
|
24
18
|
})));
|
|
25
19
|
}
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
serialize(context) {
|
|
21
|
+
return {
|
|
22
|
+
recipes: this.recipes.map((it) => ({
|
|
23
|
+
...it,
|
|
24
|
+
recipe: context.recipes.serialize(it.recipe),
|
|
25
|
+
})),
|
|
26
|
+
};
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
return this.
|
|
28
|
+
additionalTypes() {
|
|
29
|
+
return this.recipes.flatMap((it) => it.recipe.getTypes());
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
export default class ForgeConditionalRecipeParser extends RecipeParser {
|
|
37
|
-
|
|
33
|
+
deserialize(definition, context) {
|
|
38
34
|
const recipes = definition.recipes.map((it) => ({
|
|
39
35
|
conditions: it.conditions,
|
|
40
|
-
recipe:
|
|
36
|
+
recipe: context.recipes.deserialize(it.recipe),
|
|
41
37
|
}));
|
|
42
|
-
return new ForgeConditionalRecipe(
|
|
38
|
+
return new ForgeConditionalRecipe(recipes);
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
//# sourceMappingURL=conditional.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../src/parser/recipe/forge/conditional.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../src/parser/recipe/forge/conditional.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAYnD,MAAM,OAAO,sBAAuB,SAAQ,MAAM;IACnB;IAA7B,YAA6B,OAAuC;QAClE,KAAK,EAAE,CAAC;QADmB,YAAO,GAAP,OAAO,CAAgC;IAEpE,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;IAEQ,OAAO,CACd,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,sBAAsB,CAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACxB,GAAG,EAAE;YACL,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,cAAc,CAAC;SAC9D,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACjC,GAAG,EAAE;gBACL,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC;aAC7C,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;IAEQ,eAAe;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,4BAA6B,SAAQ,YAGzD;IACU,WAAW,CAClB,UAA4C,EAC5C,OAA2B;QAE3B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CACpC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACP,UAAU,EAAE,EAAE,CAAC,UAAU;YACzB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC;SAC/C,CAAC,CACH,CAAC;QAEF,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { type NormalizedId } from "../../common/id.js";
|
|
2
|
+
import type { Ingredient } from "../../common/ingredient/index.js";
|
|
3
|
+
import type { Predicate } from "../../common/predicates.js";
|
|
4
|
+
import type { Result } from "../../common/result/index.js";
|
|
5
|
+
import type { PackContext } from "../../loader/context.js";
|
|
3
6
|
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
4
7
|
export type Replacer<T> = (value: T) => T;
|
|
5
8
|
export declare function createReplacer<T>(from: Predicate<T>, to: T): Replacer<T>;
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export declare class RecipeHolder {
|
|
10
|
+
private readonly definition;
|
|
11
|
+
private readonly recipe;
|
|
12
|
+
private readonly type;
|
|
13
|
+
constructor(definition: RecipeDefinition, recipe: Recipe);
|
|
14
|
+
serialize(context: RecipeParseContext): {
|
|
15
|
+
type: import("@adeficior/data-modifier/generated").RecipeSerializerId;
|
|
16
|
+
conditions?: import("../../index.js").ForgeCondition[];
|
|
17
|
+
"fabric:load_conditions"?: import("../../index.js").FabricCondition[];
|
|
18
|
+
};
|
|
19
|
+
getIngredients(): Ingredient[];
|
|
20
|
+
getResults(): Result[];
|
|
21
|
+
replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): RecipeHolder;
|
|
22
|
+
replaceIngredient(replace: Replacer<Ingredient>): RecipeHolder;
|
|
23
|
+
replaceResult(replace: Replacer<Result>): RecipeHolder;
|
|
24
|
+
getTypes(): NormalizedId[];
|
|
15
25
|
}
|
|
16
|
-
export
|
|
26
|
+
export declare abstract class Recipe {
|
|
27
|
+
abstract getIngredients(): Ingredient[];
|
|
28
|
+
abstract getResults(): Result[];
|
|
29
|
+
abstract replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): Recipe;
|
|
30
|
+
additionalTypes(): NormalizedId[];
|
|
31
|
+
abstract serialize(context: RecipeParseContext): Partial<RecipeDefinition>;
|
|
32
|
+
}
|
|
33
|
+
export type RecipeSerializer = {
|
|
34
|
+
deserialize(definition: RecipeDefinition): RecipeHolder;
|
|
35
|
+
serialize(recipe: RecipeHolder): RecipeDefinition;
|
|
36
|
+
};
|
|
37
|
+
export type RecipeParseContext = Pick<PackContext, "ingredients" | "results"> & {
|
|
38
|
+
recipes: RecipeSerializer;
|
|
39
|
+
};
|
|
17
40
|
export default abstract class RecipeParser<TDefinition extends RecipeDefinition, TRecipe extends Recipe> {
|
|
18
|
-
abstract
|
|
41
|
+
abstract deserialize(definition: TDefinition, context: RecipeParseContext): TRecipe;
|
|
19
42
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { encodeId } from "../../common/id.js";
|
|
1
2
|
export function createReplacer(from, to) {
|
|
2
3
|
return (it) => {
|
|
3
4
|
if (from(it))
|
|
@@ -5,16 +6,48 @@ export function createReplacer(from, to) {
|
|
|
5
6
|
return it;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
function keep() {
|
|
10
|
+
return (t) => t;
|
|
11
|
+
}
|
|
12
|
+
export class RecipeHolder {
|
|
9
13
|
definition;
|
|
10
|
-
|
|
14
|
+
recipe;
|
|
15
|
+
type;
|
|
16
|
+
constructor(definition, recipe) {
|
|
11
17
|
this.definition = definition;
|
|
18
|
+
this.recipe = recipe;
|
|
19
|
+
this.type = encodeId(definition.type);
|
|
20
|
+
}
|
|
21
|
+
serialize(context) {
|
|
22
|
+
return {
|
|
23
|
+
...this.definition,
|
|
24
|
+
...this.recipe.serialize(context),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getIngredients() {
|
|
28
|
+
return this.recipe.getIngredients();
|
|
29
|
+
}
|
|
30
|
+
getResults() {
|
|
31
|
+
return this.recipe.getResults();
|
|
12
32
|
}
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
// TODO rename modifiy & add modifier object
|
|
34
|
+
replace(ingredientReplacer, resultReplacer) {
|
|
35
|
+
const modified = this.recipe.replace(ingredientReplacer, resultReplacer);
|
|
36
|
+
return new RecipeHolder(this.definition, modified);
|
|
37
|
+
}
|
|
38
|
+
replaceIngredient(replace) {
|
|
39
|
+
return this.replace(replace, keep());
|
|
40
|
+
}
|
|
41
|
+
replaceResult(replace) {
|
|
42
|
+
return this.replace(keep(), replace);
|
|
15
43
|
}
|
|
16
44
|
getTypes() {
|
|
17
|
-
return [this.
|
|
45
|
+
return [this.type, ...this.recipe.additionalTypes()];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class Recipe {
|
|
49
|
+
additionalTypes() {
|
|
50
|
+
return [];
|
|
18
51
|
}
|
|
19
52
|
}
|
|
20
53
|
export default class RecipeParser {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/parser/recipe/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/parser/recipe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqB,MAAM,oBAAoB,CAAC;AASjE,MAAM,UAAU,cAAc,CAAI,IAAkB,EAAE,EAAK;IACzD,OAAO,CAAC,EAAK,EAAE,EAAE;QACf,IAAI,IAAI,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,IAAI;IACX,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,OAAO,YAAY;IAIJ;IACA;IAJF,IAAI,CAAe;IAEpC,YACmB,UAA4B,EAC5B,MAAc;QADd,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAQ;QAE/B,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,SAAS,CAAC,OAA2B;QACnC,OAAO;YACL,GAAG,IAAI,CAAC,UAAU;YAClB,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;SAClC,CAAC;IACJ,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IACtC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED,4CAA4C;IAC5C,OAAO,CACL,kBAAwC,EACxC,cAAgC;QAEhC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,aAAa,CAAC,OAAyB;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAED,MAAM,OAAgB,MAAM;IAU1B,eAAe;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;CAGF;AAcD,MAAM,CAAC,OAAO,OAAgB,YAAY;CAQzC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RecipeParseContext, Replacer } from ".";
|
|
2
|
+
import type { Ingredient } from "../../common/ingredient";
|
|
3
|
+
export type IngredientMapInput = Record<string, unknown>;
|
|
4
|
+
export declare class IngredientMap {
|
|
5
|
+
private readonly ingredients;
|
|
6
|
+
constructor(ingredients: Record<string, Ingredient>);
|
|
7
|
+
list(): Ingredient[];
|
|
8
|
+
replace(replace: Replacer<Ingredient>): IngredientMap;
|
|
9
|
+
serialize(context: RecipeParseContext): {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { mapValues } from "lodash-es";
|
|
2
|
+
export class IngredientMap {
|
|
3
|
+
ingredients;
|
|
4
|
+
constructor(ingredients) {
|
|
5
|
+
this.ingredients = ingredients;
|
|
6
|
+
}
|
|
7
|
+
list() {
|
|
8
|
+
return Object.values(this.ingredients);
|
|
9
|
+
}
|
|
10
|
+
replace(replace) {
|
|
11
|
+
return new IngredientMap(mapValues(this.ingredients, replace));
|
|
12
|
+
}
|
|
13
|
+
serialize(context) {
|
|
14
|
+
return mapValues(this.ingredients, (it) => context.ingredients.serialize(it));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ingredientMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingredientMap.js","sourceRoot":"","sources":["../../../src/parser/recipe/ingredientMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMtC,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,WAAuC;QAAvC,gBAAW,GAAX,WAAW,CAA4B;IAAG,CAAC;IAExE,IAAI;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,SAAS,CAAC,OAA2B;QACnC,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CACxC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ingredient } from "../../common/ingredient/index.js";
|
|
2
|
+
import type { Result } from "../../common/result/index.js";
|
|
3
|
+
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
4
|
+
import RecipeParser, { Recipe, type RecipeParseContext, type Replacer } from "./index.js";
|
|
5
|
+
export type ManyToManyRecipeDefinition = RecipeDefinition & Readonly<{
|
|
6
|
+
ingredients: unknown[];
|
|
7
|
+
results: unknown[];
|
|
8
|
+
}>;
|
|
9
|
+
export declare class ManyToManyRecipe extends Recipe {
|
|
10
|
+
protected readonly ingredients: Ingredient[];
|
|
11
|
+
protected readonly results: Result[];
|
|
12
|
+
constructor(ingredients: Ingredient[], results: Result[]);
|
|
13
|
+
getIngredients(): Ingredient[];
|
|
14
|
+
getResults(): Result[];
|
|
15
|
+
replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): ManyToManyRecipe;
|
|
16
|
+
serialize(context: RecipeParseContext): Partial<ManyToManyRecipeDefinition>;
|
|
17
|
+
}
|
|
18
|
+
export declare class ManyToManyRecipeParser<TDefinition extends ManyToManyRecipeDefinition> extends RecipeParser<TDefinition, ManyToManyRecipe> {
|
|
19
|
+
deserialize(definition: TDefinition, context: RecipeParseContext): ManyToManyRecipe;
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import RecipeParser, { Recipe, } from "./index.js";
|
|
2
|
+
export class ManyToManyRecipe extends Recipe {
|
|
3
|
+
ingredients;
|
|
4
|
+
results;
|
|
5
|
+
constructor(ingredients, results) {
|
|
6
|
+
super();
|
|
7
|
+
this.ingredients = ingredients;
|
|
8
|
+
this.results = results;
|
|
9
|
+
}
|
|
10
|
+
getIngredients() {
|
|
11
|
+
return this.ingredients;
|
|
12
|
+
}
|
|
13
|
+
getResults() {
|
|
14
|
+
return this.results;
|
|
15
|
+
}
|
|
16
|
+
replace(ingredientReplacer, resultReplacer) {
|
|
17
|
+
return new ManyToManyRecipe(this.ingredients.map(ingredientReplacer), this.results.map(resultReplacer));
|
|
18
|
+
}
|
|
19
|
+
serialize(context) {
|
|
20
|
+
return {
|
|
21
|
+
results: context.results.serializeList(this.results),
|
|
22
|
+
ingredients: context.ingredients.serializeList(this.ingredients),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class ManyToManyRecipeParser extends RecipeParser {
|
|
27
|
+
deserialize(definition, context) {
|
|
28
|
+
const ingredients = context.ingredients.createList(definition.ingredients);
|
|
29
|
+
const results = context.results.createList(definition.results);
|
|
30
|
+
return new ManyToManyRecipe(ingredients, results);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=manyToMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manyToMany.js","sourceRoot":"","sources":["../../../src/parser/recipe/manyToMany.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,EAAE,EACnB,MAAM,GAGP,MAAM,YAAY,CAAC;AAQpB,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IAErB;IACA;IAFrB,YACqB,WAAyB,EACzB,OAAiB;QAEpC,KAAK,EAAE,CAAC;QAHW,gBAAW,GAAX,WAAW,CAAc;QACzB,YAAO,GAAP,OAAO,CAAU;IAGtC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEQ,OAAO,CACd,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,gBAAgB,CACzB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,EACxC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CACjC,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YACpD,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;SACjE,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,sBAEX,SAAQ,YAA2C;IACnD,WAAW,CACT,UAAuB,EACvB,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,IAAI,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ingredient } from "../../common/ingredient/index.js";
|
|
2
|
+
import type { Result } from "../../common/result/index.js";
|
|
3
|
+
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
4
|
+
import RecipeParser, { Recipe, type RecipeParseContext, type Replacer } from "./index.js";
|
|
5
|
+
export type ManyToOneRecipeDefinition = RecipeDefinition & Readonly<{
|
|
6
|
+
ingredients: unknown[];
|
|
7
|
+
result: unknown;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class ManyToOneRecipe extends Recipe {
|
|
10
|
+
protected readonly ingredients: Ingredient[];
|
|
11
|
+
protected readonly result: Result;
|
|
12
|
+
constructor(ingredients: Ingredient[], result: Result);
|
|
13
|
+
getIngredients(): Ingredient[];
|
|
14
|
+
getResults(): Result[];
|
|
15
|
+
replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): ManyToOneRecipe;
|
|
16
|
+
serialize(context: RecipeParseContext): Partial<ManyToOneRecipeDefinition>;
|
|
17
|
+
}
|
|
18
|
+
export declare class ManyToOneRecipeParser<TDefinition extends ManyToOneRecipeDefinition> extends RecipeParser<TDefinition, ManyToOneRecipe> {
|
|
19
|
+
deserialize(definition: TDefinition, context: RecipeParseContext): ManyToOneRecipe;
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import RecipeParser, { Recipe, } from "./index.js";
|
|
2
|
+
export class ManyToOneRecipe extends Recipe {
|
|
3
|
+
ingredients;
|
|
4
|
+
result;
|
|
5
|
+
constructor(ingredients, result) {
|
|
6
|
+
super();
|
|
7
|
+
this.ingredients = ingredients;
|
|
8
|
+
this.result = result;
|
|
9
|
+
}
|
|
10
|
+
getIngredients() {
|
|
11
|
+
return this.ingredients;
|
|
12
|
+
}
|
|
13
|
+
getResults() {
|
|
14
|
+
return [this.result];
|
|
15
|
+
}
|
|
16
|
+
replace(ingredientReplacer, resultReplacer) {
|
|
17
|
+
return new ManyToOneRecipe(this.ingredients.map(ingredientReplacer), resultReplacer(this.result));
|
|
18
|
+
}
|
|
19
|
+
serialize(context) {
|
|
20
|
+
return {
|
|
21
|
+
result: context.results.serialize(this.result),
|
|
22
|
+
ingredients: context.ingredients.serializeList(this.ingredients),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class ManyToOneRecipeParser extends RecipeParser {
|
|
27
|
+
deserialize(definition, context) {
|
|
28
|
+
const ingredients = context.ingredients.createList(definition.ingredients);
|
|
29
|
+
const result = context.results.create(definition.result);
|
|
30
|
+
return new ManyToOneRecipe(ingredients, result);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=manyToOne.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manyToOne.js","sourceRoot":"","sources":["../../../src/parser/recipe/manyToOne.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,EAAE,EACnB,MAAM,GAGP,MAAM,YAAY,CAAC;AAQpB,MAAM,OAAO,eAAgB,SAAQ,MAAM;IAEpB;IACA;IAFrB,YACqB,WAAyB,EACzB,MAAc;QAEjC,KAAK,EAAE,CAAC;QAHW,gBAAW,GAAX,WAAW,CAAc;QACzB,WAAM,GAAN,MAAM,CAAQ;IAGnC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAEQ,OAAO,CACd,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,eAAe,CACxB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,EACxC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAC5B,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9C,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;SACjE,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,qBAEX,SAAQ,YAA0C;IAClD,WAAW,CACT,UAAuB,EACvB,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,IAAI,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ingredient } from "../../common/ingredient/index.js";
|
|
2
|
+
import type { Result } from "../../common/result/index.js";
|
|
3
|
+
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
4
|
+
import RecipeParser, { Recipe, type RecipeParseContext, type Replacer } from "./index.js";
|
|
5
|
+
export type OneToOneRecipeDefinition = RecipeDefinition & Readonly<{
|
|
6
|
+
ingredient: unknown;
|
|
7
|
+
result: unknown;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class OneToOneRecipe extends Recipe {
|
|
10
|
+
protected readonly ingredient: Ingredient;
|
|
11
|
+
protected readonly result: Result;
|
|
12
|
+
constructor(ingredient: Ingredient, result: Result);
|
|
13
|
+
getIngredients(): Ingredient[];
|
|
14
|
+
getResults(): Result[];
|
|
15
|
+
replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): OneToOneRecipe;
|
|
16
|
+
serialize(context: RecipeParseContext): Partial<OneToOneRecipeDefinition>;
|
|
17
|
+
}
|
|
18
|
+
export declare class OneToOneRecipeParser<TDefinition extends OneToOneRecipeDefinition> extends RecipeParser<TDefinition, OneToOneRecipe> {
|
|
19
|
+
deserialize(definition: TDefinition, context: RecipeParseContext): OneToOneRecipe;
|
|
20
|
+
}
|