@adeficior/data-modifier 1.0.0-rc.35 → 1.0.0-rc.37
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/class.d.ts +4 -0
- package/dist/common/class.js +1 -0
- package/dist/common/class.js.map +1 -0
- package/dist/common/fields.d.ts +1 -1
- package/dist/common/fields.js +1 -1
- package/dist/common/fields.js.map +1 -1
- package/dist/common/filters.d.ts +2 -3
- package/dist/common/filters.js +8 -10
- package/dist/common/filters.js.map +1 -1
- package/dist/common/id.d.ts +0 -2
- package/dist/common/id.js +2 -9
- package/dist/common/id.js.map +1 -1
- package/dist/common/ingredient/filter.js +10 -24
- package/dist/common/ingredient/filter.js.map +1 -1
- package/dist/common/ingredient/index.d.ts +4 -30
- package/dist/common/ingredient/index.js +1 -34
- package/dist/common/ingredient/index.js.map +1 -1
- package/dist/common/ingredient/serializer.d.ts +2 -10
- package/dist/common/ingredient/serializer.js +39 -106
- package/dist/common/ingredient/serializer.js.map +1 -1
- package/dist/common/{serializable.d.ts → inputOutput.d.ts} +1 -3
- package/dist/common/inputOutput.js +1 -0
- package/dist/common/inputOutput.js.map +1 -0
- package/dist/common/result/index.d.ts +2 -17
- package/dist/common/result/index.js +0 -15
- package/dist/common/result/index.js.map +1 -1
- package/dist/common/result/serializer.d.ts +2 -10
- package/dist/common/result/serializer.js +20 -75
- package/dist/common/result/serializer.js.map +1 -1
- package/dist/common/serializer.d.ts +32 -0
- package/dist/common/serializer.js +95 -0
- package/dist/common/serializer.js.map +1 -0
- package/dist/emit/assets/models.js +0 -1
- package/dist/emit/assets/models.js.map +1 -1
- package/dist/emit/blacklist.d.ts +2 -3
- package/dist/emit/blacklist.js +3 -5
- package/dist/emit/blacklist.js.map +1 -1
- package/dist/emit/data/loot.d.ts +2 -3
- package/dist/emit/data/loot.js +2 -4
- package/dist/emit/data/loot.js.map +1 -1
- package/dist/emit/data/recipe.js +2 -2
- package/dist/emit/data/recipe.js.map +1 -1
- package/dist/emit/data/tags.d.ts +2 -3
- package/dist/emit/data/tags.js +2 -4
- package/dist/emit/data/tags.js.map +1 -1
- package/dist/emit/rule/lootTable.js +9 -10
- package/dist/emit/rule/lootTable.js.map +1 -1
- package/dist/emit/rule/recipe.d.ts +1 -1
- package/dist/emit/rule/recipe.js +4 -4
- package/dist/emit/rule/recipe.js.map +1 -1
- package/dist/error.d.ts +1 -1
- package/dist/error.js +6 -20
- package/dist/error.js.map +1 -1
- package/dist/loader/index.d.ts +0 -2
- package/dist/loader/index.js +0 -4
- package/dist/loader/index.js.map +1 -1
- package/dist/loader/loot.d.ts +1 -2
- package/dist/loader/loot.js +2 -6
- package/dist/loader/loot.js.map +1 -1
- package/dist/loader/pack.d.ts +2 -8
- package/dist/loader/pack.js +10 -19
- package/dist/loader/pack.js.map +1 -1
- package/dist/loader/recipe.d.ts +1 -2
- package/dist/loader/recipe.js +2 -8
- package/dist/loader/recipe.js.map +1 -1
- package/dist/loader/tags.d.ts +2 -3
- package/dist/loader/tags.js +21 -8
- package/dist/loader/tags.js.map +1 -1
- package/dist/parser/recipe/adAstra/conversion.d.ts +1 -1
- package/dist/parser/recipe/adAstra/conversion.js +2 -2
- package/dist/parser/recipe/adAstra/conversion.js.map +1 -1
- package/dist/parser/recipe/adAstra/inputOutput.d.ts +1 -1
- package/dist/parser/recipe/adAstra/inputOutput.js +2 -2
- package/dist/parser/recipe/adAstra/inputOutput.js.map +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.d.ts +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.js +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.js.map +1 -1
- package/dist/parser/recipe/botania/apothecary.d.ts +1 -1
- package/dist/parser/recipe/botania/apothecary.js +3 -3
- package/dist/parser/recipe/botania/apothecary.js.map +1 -1
- package/dist/parser/recipe/botania/blocks.js +1 -1
- package/dist/parser/recipe/botania/blocks.js.map +1 -1
- package/dist/parser/recipe/botania/brew.d.ts +1 -1
- package/dist/parser/recipe/botania/brew.js +1 -1
- package/dist/parser/recipe/botania/brew.js.map +1 -1
- package/dist/parser/recipe/botania/gogWrapper.d.ts +1 -1
- package/dist/parser/recipe/botania/gogWrapper.js +2 -2
- package/dist/parser/recipe/botania/gogWrapper.js.map +1 -1
- package/dist/parser/recipe/botania/manaInfusion.d.ts +1 -1
- package/dist/parser/recipe/botania/manaInfusion.js +3 -3
- package/dist/parser/recipe/botania/manaInfusion.js.map +1 -1
- package/dist/parser/recipe/botania/nbtWrapper.d.ts +1 -1
- package/dist/parser/recipe/botania/nbtWrapper.js +2 -2
- package/dist/parser/recipe/botania/nbtWrapper.js.map +1 -1
- package/dist/parser/recipe/botania/runicAltar.js +1 -1
- package/dist/parser/recipe/botania/runicAltar.js.map +1 -1
- package/dist/parser/recipe/create/assembly.d.ts +1 -1
- package/dist/parser/recipe/create/assembly.js +4 -4
- package/dist/parser/recipe/create/assembly.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cooking.d.ts +1 -1
- package/dist/parser/recipe/farmersdelight/cooking.js +3 -3
- package/dist/parser/recipe/farmersdelight/cooking.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cutting.d.ts +1 -1
- package/dist/parser/recipe/farmersdelight/cutting.js +2 -2
- package/dist/parser/recipe/farmersdelight/cutting.js.map +1 -1
- package/dist/parser/recipe/forge/conditional.d.ts +1 -1
- package/dist/parser/recipe/forge/conditional.js +2 -2
- package/dist/parser/recipe/forge/conditional.js.map +1 -1
- package/dist/parser/recipe/index.d.ts +2 -2
- package/dist/parser/recipe/index.js +4 -5
- package/dist/parser/recipe/index.js.map +1 -1
- package/dist/parser/recipe/manyToMany.d.ts +1 -1
- package/dist/parser/recipe/manyToMany.js +1 -1
- package/dist/parser/recipe/manyToMany.js.map +1 -1
- package/dist/parser/recipe/manyToOne.d.ts +1 -1
- package/dist/parser/recipe/manyToOne.js +2 -2
- package/dist/parser/recipe/manyToOne.js.map +1 -1
- package/dist/parser/recipe/oneToOne.d.ts +1 -1
- package/dist/parser/recipe/oneToOne.js +3 -3
- package/dist/parser/recipe/oneToOne.js.map +1 -1
- package/dist/parser/recipe/roots/component.d.ts +1 -1
- package/dist/parser/recipe/roots/component.js +1 -1
- package/dist/parser/recipe/roots/component.js.map +1 -1
- package/dist/parser/recipe/roots/ritual.d.ts +1 -1
- package/dist/parser/recipe/roots/ritual.js +2 -2
- package/dist/parser/recipe/roots/ritual.js.map +1 -1
- package/dist/parser/recipe/thermal/catalyst.d.ts +1 -1
- package/dist/parser/recipe/thermal/catalyst.js +2 -2
- package/dist/parser/recipe/thermal/catalyst.js.map +1 -1
- package/dist/parser/recipe/thermal/fuel.d.ts +1 -1
- package/dist/parser/recipe/thermal/fuel.js +2 -2
- package/dist/parser/recipe/thermal/fuel.js.map +1 -1
- package/dist/parser/recipe/thermal/index.d.ts +1 -1
- package/dist/parser/recipe/thermal/index.js +3 -3
- package/dist/parser/recipe/thermal/index.js.map +1 -1
- package/dist/parser/recipe/thermal/ingredient.js +1 -1
- package/dist/parser/recipe/thermal/ingredient.js.map +1 -1
- package/dist/parser/recipe/thermal/treeExtraction.d.ts +1 -1
- package/dist/parser/recipe/thermal/treeExtraction.js +4 -4
- package/dist/parser/recipe/thermal/treeExtraction.js.map +1 -1
- package/dist/parser/recipe/vanilla/shaped.d.ts +1 -1
- package/dist/parser/recipe/vanilla/shaped.js +2 -2
- package/dist/parser/recipe/vanilla/shaped.js.map +1 -1
- package/dist/parser/recipe/vanilla/smelting.d.ts +1 -1
- package/dist/parser/recipe/vanilla/smelting.js +3 -3
- package/dist/parser/recipe/vanilla/smelting.js.map +1 -1
- package/dist/parser/recipe/vanilla/smithing.d.ts +1 -1
- package/dist/parser/recipe/vanilla/smithing.js +4 -4
- package/dist/parser/recipe/vanilla/smithing.js.map +1 -1
- package/dist/parser/recipe/vanilla/stonecutting.d.ts +1 -1
- package/dist/parser/recipe/vanilla/stonecutting.js +3 -3
- package/dist/parser/recipe/vanilla/stonecutting.js.map +1 -1
- package/dist/schema/data/loot.d.ts +60 -1086
- package/dist/textHelper.js +1 -10
- package/dist/textHelper.js.map +1 -1
- package/package.json +2 -2
- package/dist/common/serializable.js +0 -1
- package/dist/common/serializable.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/common/class.ts"],"names":[],"mappings":""}
|
package/dist/common/fields.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
export declare const CountSchema: z.
|
|
2
|
+
export declare const CountSchema: z.ZodCodec<z.ZodOptional<z.ZodNumber>, z.ZodNumber>;
|
|
3
3
|
export declare const AmountSchema: z.ZodNumber;
|
|
4
4
|
export declare const ChanceSchema: z.ZodOptional<z.ZodNumber>;
|
package/dist/common/fields.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
export const CountSchema = z.number().int().positive().
|
|
2
|
+
export const CountSchema = z.codec(z.number().int().positive().optional(), z.number(), { decode: (it) => it ?? 1, encode: (it) => (it === 1 ? undefined : it) });
|
|
3
3
|
export const AmountSchema = z.number().positive();
|
|
4
4
|
export const ChanceSchema = z.number().max(1).positive().optional();
|
|
5
5
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/common/fields.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/common/fields.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAChC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EACtC,CAAC,CAAC,MAAM,EAAE,EACV,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CACzE,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAClD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC"}
|
package/dist/common/filters.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { InferIds, RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
|
-
import type { Logger } from "@adeficior/pack-resolver";
|
|
3
2
|
import type { TagRegistry } from "../loader/tags.js";
|
|
4
3
|
import type { IdInput, NormalizedId } from "./id.js";
|
|
5
|
-
export type Predicate<T> = (value: T
|
|
4
|
+
export type Predicate<T> = (value: T) => boolean;
|
|
6
5
|
export type CommonFilter<T> = RegExp | Predicate<T> | T;
|
|
7
|
-
export declare function createIdPredicate<TEntry, TId extends string>(test: CommonFilter<TId>, resolve: (value: TEntry
|
|
6
|
+
export declare function createIdPredicate<TEntry, TId extends string>(test: CommonFilter<TId>, resolve: (value: TEntry) => NormalizedId<TId>[], tags?: TagRegistry<RegistryId>): Predicate<TEntry>;
|
|
8
7
|
export declare function resolveIDTest<T extends RegistryId>(test: CommonFilter<NormalizedId<InferIds<T>>>, tags?: TagRegistry<T>): Predicate<IdInput<InferIds<T>>>;
|
package/dist/common/filters.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { encodeId } from "./id.js";
|
|
2
|
-
export function createIdPredicate(test, resolve,
|
|
3
|
-
// TODO required?
|
|
4
|
-
tags) {
|
|
2
|
+
export function createIdPredicate(test, resolve, tags) {
|
|
5
3
|
if (typeof test === "function") {
|
|
6
|
-
return (entry
|
|
4
|
+
return (entry) => resolve(entry).some((id) => test(id));
|
|
7
5
|
}
|
|
8
6
|
else if (test instanceof RegExp) {
|
|
9
|
-
return (ingredient
|
|
10
|
-
return resolve(ingredient
|
|
7
|
+
return (ingredient) => {
|
|
8
|
+
return resolve(ingredient).some((it) => test.test(it));
|
|
11
9
|
};
|
|
12
10
|
}
|
|
13
11
|
else if (test.startsWith("#")) {
|
|
14
|
-
return (ingredient
|
|
15
|
-
return resolve(ingredient
|
|
12
|
+
return (ingredient) => {
|
|
13
|
+
return resolve(ingredient).some((id) => {
|
|
16
14
|
if (id.startsWith("#") && test === id)
|
|
17
15
|
return true;
|
|
18
16
|
else if (tags)
|
|
@@ -23,8 +21,8 @@ tags) {
|
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
else {
|
|
26
|
-
return (ingredient
|
|
27
|
-
return resolve(ingredient
|
|
24
|
+
return (ingredient) => {
|
|
25
|
+
return resolve(ingredient).includes(encodeId(test));
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/common/filters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/common/filters.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC,MAAM,UAAU,iBAAiB,CAC/B,IAAuB,EACvB,OAA+C,EAC/C,IAA8B;IAE9B,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,EAA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}
|
package/dist/common/id.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ export type NormalizedId<T extends string = string> = T extends `${string}:${str
|
|
|
9
9
|
export type TagId = NormalizedId<`#${string}`>;
|
|
10
10
|
export type TagInput = IdInput<`#${string}`>;
|
|
11
11
|
export declare const IdSchema: zod.ZodString;
|
|
12
|
-
export declare const TagSchema: zod.ZodType<`#${string}`>;
|
|
13
|
-
export declare const IdOrTagSchema: zod.ZodString;
|
|
14
12
|
export declare function createId(from: IdInput): Id;
|
|
15
13
|
export declare function encodeId<T extends string>(from: IdInput<T>): NormalizedId<T>;
|
|
16
14
|
export declare function toTag(from: IdInput): TagId;
|
package/dist/common/id.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import zod from "zod";
|
|
2
2
|
export const IdSchema = zod
|
|
3
3
|
.string()
|
|
4
|
-
.regex(
|
|
4
|
+
.regex(/^#?([a-z0-9_.-]+:)?[a-z0-9_.-/]+$/i, "ID may only include letters, numbers, dashes and underscores")
|
|
5
|
+
.refine((val) => !val.startsWith("#"), "IDs may not start with a hashtag")
|
|
5
6
|
.describe("Valid ID");
|
|
6
|
-
export const TagSchema = zod
|
|
7
|
-
.string()
|
|
8
|
-
.regex(/^#([a-z0-9_.-]+:)?[a-z0-9/._-]+$/i)
|
|
9
|
-
.describe("Valid Tag-ID");
|
|
10
|
-
export const IdOrTagSchema = zod
|
|
11
|
-
.string()
|
|
12
|
-
.regex(/^#?([a-z0-9_.-]+:)?[a-z0-9/._-]+$/i)
|
|
13
|
-
.describe("Valid ID or Tag-ID");
|
|
14
7
|
export function createId(from) {
|
|
15
8
|
if (typeof from !== "string")
|
|
16
9
|
return from;
|
package/dist/common/id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/common/id.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB,MAAM,CAAC,MAAM,QAAQ,GAAG,G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CAAC,SAAS,CAAC,CAAC,CAAC,EAAqB,CAAC;QAC9D,OAAO,aAAa,IAAI,EAAqB,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,EAAqB,CAAC;IAC5E,OAAO,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,EAAqB,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,IAAa;IACjC,OAAO,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAU,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAW,EAAE,MAAc;IAChD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAW,EAAE,MAAc;IAChD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ingredient, ItemIngredient, ItemTagIngredient, ListIngredient, RegistryEntryIngredient, TagIngredient, } from ".";
|
|
2
|
+
import { IllegalShapeError } from "../../error";
|
|
2
3
|
import { createIdPredicate, } from "../filters";
|
|
3
4
|
import {} from "../id";
|
|
4
5
|
export default function createIngredientPredicate(test, context) {
|
|
@@ -16,40 +17,25 @@ function createUnvalidatedFilter(test, context) {
|
|
|
16
17
|
return filterByRegistry(test, context, "minecraft:item");
|
|
17
18
|
}
|
|
18
19
|
if (typeof test === "function") {
|
|
19
|
-
// ingredients.create not needed if function wrapped
|
|
20
|
-
return (it
|
|
20
|
+
// TODO ingredients.create not needed if function wrapped
|
|
21
|
+
return (it) => test(context.ingredients.deserialize(it));
|
|
21
22
|
}
|
|
22
23
|
if (test instanceof Ingredient) {
|
|
23
24
|
test.validate(context.lookup);
|
|
24
25
|
}
|
|
25
|
-
if (test instanceof
|
|
26
|
-
return filterByRegistry(test.tag, context,
|
|
26
|
+
if (test instanceof TagIngredient) {
|
|
27
|
+
return filterByRegistry(test.tag, context, test.registry);
|
|
27
28
|
}
|
|
28
|
-
if (test instanceof
|
|
29
|
-
return filterByRegistry(test.id, context,
|
|
30
|
-
}
|
|
31
|
-
if (test instanceof FluidTagIngredient) {
|
|
32
|
-
return filterByRegistry(test.tag, context, "minecraft:fluid");
|
|
33
|
-
}
|
|
34
|
-
if (test instanceof FluidIngredient) {
|
|
35
|
-
return filterByRegistry(test.id, context, "minecraft:fluid");
|
|
36
|
-
}
|
|
37
|
-
if (test instanceof BlockTagIngredient) {
|
|
38
|
-
return filterByRegistry(test.tag, context, "minecraft:block");
|
|
39
|
-
}
|
|
40
|
-
if (test instanceof BlockIngredient) {
|
|
41
|
-
return filterByRegistry(test.id, context, "minecraft:block");
|
|
29
|
+
if (test instanceof RegistryEntryIngredient) {
|
|
30
|
+
return filterByRegistry(test.id, context, test.registry);
|
|
42
31
|
}
|
|
43
32
|
if (test instanceof ListIngredient) {
|
|
44
33
|
const predicates = test.entries.map((it) => createIngredientPredicate(it, context));
|
|
45
34
|
return (it) => predicates.some((predicate) => predicate(it));
|
|
46
35
|
}
|
|
47
|
-
|
|
48
|
-
return () => false;
|
|
36
|
+
throw new IllegalShapeError("cannot filter by unknown ingredient type", test);
|
|
49
37
|
}
|
|
50
38
|
function filterByRegistry(test, context, registry) {
|
|
51
|
-
return createIdPredicate(test,
|
|
52
|
-
// TODO remove logger
|
|
53
|
-
(it, _logger) => it.idsFor(registry), context.tags.registry(registry));
|
|
39
|
+
return createIdPredicate(test, (it) => it.idsFor(registry), context.tags.registry(registry));
|
|
54
40
|
}
|
|
55
41
|
//# sourceMappingURL=filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/common/ingredient/filter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/common/ingredient/filter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,aAAa,GACd,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,iBAAiB,GAGlB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAqB,MAAM,OAAO,CAAC;AAQ1C,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,IAAsB,EACtB,OAA6D;IAE7D,MAAM,WAAW,GAAG,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,uBAAuB,CAC9B,IAAsB,EACtB,OAA6D;IAE7D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,yBAAyB,CAC9B,IAAI,iBAAiB,CAAC,IAAI,C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AI,iBAAiB,CAAC,0CAA0C,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,gBAAgB,CACvB,IAA2B,EAC3B,OAA6D,EAC7D,QAAkC;IAElC,OAAO,iBAAiB,CACtB,IAAI,EACJ,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC3B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAChC,CAAC;AACJ,CAAC"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import type { BlockId, FluidId, ItemId, RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type RegistryLookup from "../../loader/registry";
|
|
3
|
-
import type { SemVerInput } from "../../packFormat";
|
|
4
3
|
import { type IdInput, type NormalizedId, type TagId } from "../id";
|
|
4
|
+
import type { InputOutput } from "../inputOutput";
|
|
5
5
|
import { BlockResult, FluidResult, ItemResult, type Result } from "../result";
|
|
6
|
-
|
|
7
|
-
export declare abstract class Ingredient implements Serializable {
|
|
6
|
+
export declare abstract class Ingredient implements InputOutput {
|
|
8
7
|
validate(_: RegistryLookup): void;
|
|
9
|
-
abstract serialize(packFormat: SemVerInput): unknown;
|
|
10
8
|
abstract idsFor(registry: NormalizedId<RegistryId>): NormalizedId<RegistryId>[];
|
|
11
9
|
abstract asResult(): Result;
|
|
12
10
|
}
|
|
13
11
|
export declare abstract class TagIngredient extends Ingredient {
|
|
14
|
-
|
|
12
|
+
readonly registry: NormalizedId<RegistryId>;
|
|
15
13
|
readonly tag: TagId;
|
|
16
14
|
constructor(input: IdInput, registry: NormalizedId<RegistryId>);
|
|
17
15
|
idsFor(registry: NormalizedId<RegistryId>): `#${string}:${string}`[];
|
|
@@ -20,27 +18,16 @@ export declare abstract class TagIngredient extends Ingredient {
|
|
|
20
18
|
export declare class ItemTagIngredient extends TagIngredient {
|
|
21
19
|
readonly count: number;
|
|
22
20
|
constructor(tag: IdInput, count?: number);
|
|
23
|
-
serialize(_packFormat: SemVerInput): {
|
|
24
|
-
tag: `${string}:${string}`;
|
|
25
|
-
count: number | undefined;
|
|
26
|
-
};
|
|
27
21
|
}
|
|
28
22
|
export declare class FluidTagIngredient extends TagIngredient {
|
|
29
23
|
readonly amount: number;
|
|
30
24
|
constructor(tag: IdInput, amount?: number);
|
|
31
|
-
serialize(_packFormat: SemVerInput): {
|
|
32
|
-
fluidTag: `${string}:${string}`;
|
|
33
|
-
amount: number;
|
|
34
|
-
};
|
|
35
25
|
}
|
|
36
26
|
export declare class BlockTagIngredient extends TagIngredient {
|
|
37
27
|
constructor(tag: IdInput);
|
|
38
|
-
serialize(_packFormat: SemVerInput): {
|
|
39
|
-
blockTag: `${string}:${string}`;
|
|
40
|
-
};
|
|
41
28
|
}
|
|
42
29
|
export declare abstract class RegistryEntryIngredient<T extends string> extends Ingredient {
|
|
43
|
-
|
|
30
|
+
readonly registry: NormalizedId<RegistryId>;
|
|
44
31
|
readonly id: NormalizedId<T>;
|
|
45
32
|
constructor(input: IdInput<T>, registry: NormalizedId<RegistryId>);
|
|
46
33
|
idsFor(registry: NormalizedId<RegistryId>): NormalizedId<T>[];
|
|
@@ -48,10 +35,6 @@ export declare abstract class RegistryEntryIngredient<T extends string> extends
|
|
|
48
35
|
export declare class ItemIngredient extends RegistryEntryIngredient<ItemId> {
|
|
49
36
|
readonly count: number;
|
|
50
37
|
constructor(id: IdInput<ItemId>, count?: number);
|
|
51
|
-
serialize(_packFormat: SemVerInput): {
|
|
52
|
-
item: `${string}:${string}`;
|
|
53
|
-
count: number | undefined;
|
|
54
|
-
};
|
|
55
38
|
validate(lookup: RegistryLookup): void;
|
|
56
39
|
asResult(): ItemResult;
|
|
57
40
|
}
|
|
@@ -59,27 +42,18 @@ export declare class FluidIngredient extends RegistryEntryIngredient<FluidId> {
|
|
|
59
42
|
readonly amount: number;
|
|
60
43
|
readonly chance?: number | undefined;
|
|
61
44
|
constructor(id: IdInput<FluidId>, amount?: number, chance?: number | undefined);
|
|
62
|
-
serialize(_packFormat: SemVerInput): {
|
|
63
|
-
fluid: `${string}:${string}`;
|
|
64
|
-
amount: number;
|
|
65
|
-
};
|
|
66
45
|
validate(lookup: RegistryLookup): void;
|
|
67
46
|
asResult(): FluidResult;
|
|
68
47
|
}
|
|
69
48
|
export declare class BlockIngredient extends RegistryEntryIngredient<BlockId> {
|
|
70
49
|
readonly weight?: number | undefined;
|
|
71
50
|
constructor(id: IdInput<BlockId>, weight?: number | undefined);
|
|
72
|
-
serialize(_packFormat: SemVerInput): {
|
|
73
|
-
block: `${string}:${string}`;
|
|
74
|
-
weight: number | undefined;
|
|
75
|
-
};
|
|
76
51
|
validate(lookup: RegistryLookup): void;
|
|
77
52
|
asResult(): BlockResult;
|
|
78
53
|
}
|
|
79
54
|
export declare class ListIngredient extends Ingredient {
|
|
80
55
|
readonly entries: Ingredient[];
|
|
81
56
|
constructor(entries: Ingredient[]);
|
|
82
|
-
serialize(packFormat: SemVerInput): unknown[];
|
|
83
57
|
validate(lookup: RegistryLookup): void;
|
|
84
58
|
idsFor(registry: NormalizedId<RegistryId>): `${string}:${string}`[];
|
|
85
59
|
asResult(): Result;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { encodeId,
|
|
1
|
+
import { encodeId, toTag, } from "../id";
|
|
2
2
|
import { BlockResult, FluidResult, ItemResult } from "../result";
|
|
3
3
|
import { BUCKET } from "../units";
|
|
4
4
|
export class Ingredient {
|
|
5
|
-
// TODO make required
|
|
6
5
|
validate(_) { }
|
|
7
6
|
}
|
|
8
7
|
export class TagIngredient extends Ingredient {
|
|
@@ -29,11 +28,6 @@ export class ItemTagIngredient extends TagIngredient {
|
|
|
29
28
|
super(tag, "minecraft:item");
|
|
30
29
|
this.count = count;
|
|
31
30
|
}
|
|
32
|
-
serialize(_packFormat) {
|
|
33
|
-
const count = this.count === 1 ? undefined : this.count;
|
|
34
|
-
const tag = stripTag(this.tag);
|
|
35
|
-
return { tag, count };
|
|
36
|
-
}
|
|
37
31
|
}
|
|
38
32
|
export class FluidTagIngredient extends TagIngredient {
|
|
39
33
|
amount;
|
|
@@ -41,20 +35,11 @@ export class FluidTagIngredient extends TagIngredient {
|
|
|
41
35
|
super(tag, "minecraft:fluid");
|
|
42
36
|
this.amount = amount;
|
|
43
37
|
}
|
|
44
|
-
serialize(_packFormat) {
|
|
45
|
-
const { amount } = this;
|
|
46
|
-
const tag = stripTag(this.tag);
|
|
47
|
-
return { fluidTag: tag, amount };
|
|
48
|
-
}
|
|
49
38
|
}
|
|
50
39
|
export class BlockTagIngredient extends TagIngredient {
|
|
51
40
|
constructor(tag) {
|
|
52
41
|
super(tag, "minecraft:block");
|
|
53
42
|
}
|
|
54
|
-
serialize(_packFormat) {
|
|
55
|
-
const tag = stripTag(this.tag);
|
|
56
|
-
return { blockTag: tag };
|
|
57
|
-
}
|
|
58
43
|
}
|
|
59
44
|
export class RegistryEntryIngredient extends Ingredient {
|
|
60
45
|
registry;
|
|
@@ -76,11 +61,6 @@ export class ItemIngredient extends RegistryEntryIngredient {
|
|
|
76
61
|
super(id, "minecraft:item");
|
|
77
62
|
this.count = count;
|
|
78
63
|
}
|
|
79
|
-
serialize(_packFormat) {
|
|
80
|
-
const count = this.count === 1 ? undefined : this.count;
|
|
81
|
-
const id = encodeId(this.id);
|
|
82
|
-
return { item: id, count };
|
|
83
|
-
}
|
|
84
64
|
validate(lookup) {
|
|
85
65
|
lookup.validateEntry("minecraft:item", this.id);
|
|
86
66
|
}
|
|
@@ -96,11 +76,6 @@ export class FluidIngredient extends RegistryEntryIngredient {
|
|
|
96
76
|
this.amount = amount;
|
|
97
77
|
this.chance = chance;
|
|
98
78
|
}
|
|
99
|
-
serialize(_packFormat) {
|
|
100
|
-
const { amount } = this;
|
|
101
|
-
const id = encodeId(this.id);
|
|
102
|
-
return { fluid: id, amount };
|
|
103
|
-
}
|
|
104
79
|
validate(lookup) {
|
|
105
80
|
lookup.validateEntry("minecraft:fluid", this.id);
|
|
106
81
|
}
|
|
@@ -114,11 +89,6 @@ export class BlockIngredient extends RegistryEntryIngredient {
|
|
|
114
89
|
super(id, "minecraft:block");
|
|
115
90
|
this.weight = weight;
|
|
116
91
|
}
|
|
117
|
-
serialize(_packFormat) {
|
|
118
|
-
const { weight } = this;
|
|
119
|
-
const id = encodeId(this.id);
|
|
120
|
-
return { block: id, weight };
|
|
121
|
-
}
|
|
122
92
|
validate(lookup) {
|
|
123
93
|
lookup.validateEntry("minecraft:block", this.id);
|
|
124
94
|
}
|
|
@@ -132,9 +102,6 @@ export class ListIngredient extends Ingredient {
|
|
|
132
102
|
super();
|
|
133
103
|
this.entries = entries;
|
|
134
104
|
}
|
|
135
|
-
serialize(packFormat) {
|
|
136
|
-
return this.entries.map((it) => it.serialize(packFormat));
|
|
137
|
-
}
|
|
138
105
|
validate(lookup) {
|
|
139
106
|
this.entries.forEach((it) => it.validate(lookup));
|
|
140
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/ingredient/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/ingredient/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EACR,KAAK,GAIN,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAe,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAgB,UAAU;IAC9B,QAAQ,CAAC,CAAiB,IAAS,CAAC;CAKrC;AAED,MAAM,OAAgB,aAAc,SAAQ,UAAU;IAKlC;IAJF,GAAG,CAAQ;IAE3B,YACE,KAAc,EACE,QAAkC;QAElD,KAAK,EAAE,CAAC;QAFQ,aAAQ,GAAR,QAAQ,CAA0B;QAGlD,2CAA2C;QAC3C,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC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GAAP,OAAO,CAAc;IAEjD,CAAC;IAEQ,QAAQ,CAAC,MAAsB;QACtC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;IAEQ,MAAM,CAAC,QAAkC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAEQ,QAAQ;QACf,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -2,16 +2,8 @@ import { Ingredient } from ".";
|
|
|
2
2
|
import type RegistryLookup from "../../loader/registry";
|
|
3
3
|
import type { SemVerInput } from "../../packFormat";
|
|
4
4
|
import { IngredientMap, type IngredientMapInput } from "../../parser/recipe/ingredientMap";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
private readonly lookup;
|
|
8
|
-
private readonly deserializer;
|
|
5
|
+
import { VersionedSerializer } from "../serializer";
|
|
6
|
+
export default class IngredientSerializer extends VersionedSerializer<Ingredient> {
|
|
9
7
|
constructor(packFormat: SemVerInput, lookup: RegistryLookup);
|
|
10
|
-
serialize(ingredient: Ingredient): unknown;
|
|
11
|
-
serializeList(ingredients: Ingredient[]): unknown[];
|
|
12
|
-
private deserialize;
|
|
13
|
-
create(input: unknown): Ingredient;
|
|
14
|
-
validated<T extends Ingredient>(ingredient: T): T;
|
|
15
|
-
createList(input: unknown[]): Ingredient[];
|
|
16
8
|
ingredientMap(input: IngredientMapInput): IngredientMap;
|
|
17
9
|
}
|
|
@@ -1,118 +1,51 @@
|
|
|
1
1
|
import { mapValues } from "lodash-es";
|
|
2
2
|
import z from "zod";
|
|
3
3
|
import { BlockIngredient, BlockTagIngredient, FluidIngredient, FluidTagIngredient, Ingredient, ItemIngredient, ItemTagIngredient, ListIngredient, } from ".";
|
|
4
|
-
import { IllegalShapeError, transformErrors } from "../../error";
|
|
5
4
|
import { IngredientMap, } from "../../parser/recipe/ingredientMap";
|
|
6
5
|
import { AmountSchema, CountSchema } from "../fields";
|
|
7
|
-
import { IdSchema } from "../id";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if ("fluidTag" in input) {
|
|
44
|
-
const parsed = this.schemas.fluidTag.parse(input);
|
|
45
|
-
return new FluidTagIngredient(parsed.fluidTag, parsed.amount);
|
|
46
|
-
}
|
|
47
|
-
if ("block" in input) {
|
|
48
|
-
const parsed = this.schemas.block.parse(input);
|
|
49
|
-
return new BlockIngredient(parsed.block);
|
|
50
|
-
}
|
|
51
|
-
if ("item" in input) {
|
|
52
|
-
const parsed = this.schemas.itemStack.parse(input);
|
|
53
|
-
return new ItemIngredient(parsed.item, parsed.count);
|
|
54
|
-
}
|
|
55
|
-
if ("fluid" in input) {
|
|
56
|
-
const parsed = this.schemas.fluidStack.parse(input);
|
|
57
|
-
return new FluidIngredient(parsed.fluid, parsed.amount);
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export default class IngredientSerializer {
|
|
63
|
-
packFormat;
|
|
64
|
-
lookup;
|
|
65
|
-
deserializer;
|
|
6
|
+
import { IdSchema, stripTag } from "../id";
|
|
7
|
+
import { createSerializer, isObjectWith, VersionedSerializer, } from "../serializer";
|
|
8
|
+
const serializer15 = createSerializer((builder) => {
|
|
9
|
+
builder.deserializer((it) => typeof it === "string", (input) => {
|
|
10
|
+
if (input.startsWith("#")) {
|
|
11
|
+
return new ItemTagIngredient(input);
|
|
12
|
+
}
|
|
13
|
+
return new ItemIngredient(input);
|
|
14
|
+
});
|
|
15
|
+
builder.serializer(ListIngredient, (it, serialize) => it.entries.flatMap(serialize));
|
|
16
|
+
builder.deserializer(Array.isArray, (it, deserialize) => new ListIngredient(it.map(deserialize)));
|
|
17
|
+
builder.register(ItemTagIngredient, isObjectWith("tag"), z.object({
|
|
18
|
+
tag: IdSchema,
|
|
19
|
+
count: CountSchema,
|
|
20
|
+
}), (it) => new ItemTagIngredient(it.tag, it.count), ({ count, tag }) => ({ tag: stripTag(tag), count }));
|
|
21
|
+
builder.register(FluidTagIngredient, isObjectWith("fluidTag"), z.object({
|
|
22
|
+
fluidTag: IdSchema,
|
|
23
|
+
amount: AmountSchema,
|
|
24
|
+
}), (it) => new FluidTagIngredient(it.fluidTag, it.amount), ({ amount, tag }) => ({ fluidTag: stripTag(tag), amount }));
|
|
25
|
+
builder.register(BlockTagIngredient, isObjectWith("blockTag"), z.object({
|
|
26
|
+
blockTag: IdSchema,
|
|
27
|
+
weight: z.number().optional(),
|
|
28
|
+
}), (it) => new BlockTagIngredient(it.blockTag), ({ tag }) => ({ blockTag: stripTag(tag) }));
|
|
29
|
+
builder.register(ItemIngredient, isObjectWith("item"), z.object({
|
|
30
|
+
item: IdSchema,
|
|
31
|
+
count: CountSchema,
|
|
32
|
+
}), (it) => new ItemIngredient(it.item, it.count), ({ id, ...rest }) => ({ item: id, ...rest }));
|
|
33
|
+
builder.register(FluidIngredient, isObjectWith("fluid"), z.object({
|
|
34
|
+
fluid: IdSchema,
|
|
35
|
+
amount: AmountSchema,
|
|
36
|
+
}), (it) => new FluidIngredient(it.fluid, it.amount), ({ id, ...rest }) => ({ fluid: id, ...rest }));
|
|
37
|
+
builder.register(BlockIngredient, isObjectWith("block"), z.object({
|
|
38
|
+
block: IdSchema,
|
|
39
|
+
}), (it) => new BlockIngredient(it.block), ({ id }) => ({ block: id }));
|
|
40
|
+
});
|
|
41
|
+
export default class IngredientSerializer extends VersionedSerializer {
|
|
66
42
|
constructor(packFormat, lookup) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.deserializer = new OldDeserializer();
|
|
70
|
-
}
|
|
71
|
-
serialize(ingredient) {
|
|
72
|
-
return ingredient.serialize(this.packFormat);
|
|
73
|
-
}
|
|
74
|
-
serializeList(ingredients) {
|
|
75
|
-
return ingredients.map((it) => this.serialize(it));
|
|
76
|
-
}
|
|
77
|
-
deserialize(input) {
|
|
78
|
-
if (input instanceof Ingredient)
|
|
79
|
-
return input;
|
|
80
|
-
if (!input)
|
|
81
|
-
throw new IllegalShapeError("ingredient input may not be null");
|
|
82
|
-
if (typeof input === "string") {
|
|
83
|
-
if (input.startsWith("#")) {
|
|
84
|
-
return this.deserialize(new ItemTagIngredient(input));
|
|
85
|
-
}
|
|
86
|
-
this.lookup.validateEntry("minecraft:item", input);
|
|
87
|
-
return new ItemIngredient(input);
|
|
88
|
-
}
|
|
89
|
-
if (Array.isArray(input)) {
|
|
90
|
-
return new ListIngredient(input.map((it) => this.deserialize(it)));
|
|
91
|
-
}
|
|
92
|
-
if (typeof input === "object") {
|
|
93
|
-
const deserialized = this.deserializer.deserialize(input);
|
|
94
|
-
if (deserialized)
|
|
95
|
-
return deserialized;
|
|
96
|
-
}
|
|
97
|
-
throw new IllegalShapeError(`unknown ingredient shape`, input);
|
|
98
|
-
}
|
|
99
|
-
// TODO rename deserialize
|
|
100
|
-
create(input) {
|
|
101
|
-
return transformErrors(() => {
|
|
102
|
-
const deserialized = this.deserialize(input);
|
|
103
|
-
deserialized.validate(this.lookup);
|
|
104
|
-
return deserialized;
|
|
43
|
+
super(packFormat, lookup, Ingredient, {
|
|
44
|
+
15: serializer15,
|
|
105
45
|
});
|
|
106
46
|
}
|
|
107
|
-
validated(ingredient) {
|
|
108
|
-
ingredient.validate(this.lookup);
|
|
109
|
-
return ingredient;
|
|
110
|
-
}
|
|
111
|
-
createList(input) {
|
|
112
|
-
return input.map((it) => this.create(it));
|
|
113
|
-
}
|
|
114
47
|
ingredientMap(input) {
|
|
115
|
-
return new IngredientMap(mapValues(input, (it) => this.
|
|
48
|
+
return new IngredientMap(mapValues(input, (it) => this.deserialize(it)));
|
|
116
49
|
}
|
|
117
50
|
}
|
|
118
51
|
//# sourceMappingURL=serializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/common/ingredient/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/common/ingredient/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,GAAG,CAAC;AAGX,OAAO,EACL,aAAa,GAEd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,mBAAmB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EAAE,YAAY;KACrB,CAAC,EACF,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,EAChD,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAC9C,CAAC;IAEF,OAAO,CAAC,QAAQ,CACd,eAAe,EACf,YAAY,CAAC,OAAO,CAAC,EACrB,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,QAAQ;KAChB,CAAC,EACF,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,CAAC,KAAK,CAAC,EACrC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,mBAA+B;IAC/E,YAAY,UAAuB,EAAE,MAAsB;QACzD,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;YACpC,EAAE,EAAE,YAAY;SACjB,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAyB;QACrC,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type RegistryLookup from "../loader/registry";
|
|
3
|
-
import type { SemVerInput } from "../packFormat";
|
|
4
3
|
import type { NormalizedId } from "./id";
|
|
5
|
-
export interface
|
|
6
|
-
serialize(packFormat: SemVerInput): unknown;
|
|
4
|
+
export interface InputOutput {
|
|
7
5
|
validate(lookup: RegistryLookup): void;
|
|
8
6
|
idsFor(registry: NormalizedId<RegistryId>): NormalizedId<RegistryId>[];
|
|
9
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=inputOutput.js.map
|