Skip to content

Commit

Permalink
Merge pull request #6 from gw2efficiency/add-multipe-recipe-count
Browse files Browse the repository at this point in the history
Add `multipleRecipeCount` property
  • Loading branch information
queicherius authored Nov 4, 2024
2 parents 2c3d50b + d446adc commit 07fde37
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ export interface API_Recipes_Entry {
id: number
chat_link: string
}

export interface API_Recipes_Entry_Next extends API_Recipes_Entry {
multipleRecipeCount: number
}
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { omit, compact, toMap } from '@devoxa/flocky'
import { API_Recipes_Entry } from './api'
import { API_Recipes_Entry_Next } from './api'

export type BasicItemComponent = { id: number; type: 'Item'; quantity: number }
export type BasicCurrencyComponent = { id: number; type: 'Currency'; quantity: number }
Expand All @@ -22,6 +22,7 @@ interface TransformedRecipe {
achievement_id?: number
merchant?: { name: string; locations: Array<string> }
prerequisites: Prerequisites
multipleRecipeCount: number
}

interface TransformedRecipeInternal extends TransformedRecipe {
Expand All @@ -35,7 +36,7 @@ interface TransformedRecipeInternal extends TransformedRecipe {
}

export function nestRecipes(
apiRecipes: Array<API_Recipes_Entry>,
apiRecipes: Array<API_Recipes_Entry_Next>,
decorationMap: Record<string, number> = {}
): Array<NestedRecipe> {
const recipes = apiRecipes.map(transformRecipe)
Expand All @@ -59,7 +60,7 @@ export function nestRecipes(
.filter((recipe) => recipe.components) as Array<NestedRecipe>
}

function transformRecipe(recipe: API_Recipes_Entry): TransformedRecipeInternal {
function transformRecipe(recipe: API_Recipes_Entry_Next): TransformedRecipeInternal {
const components = recipe.ingredients.map((ingredient) => ({
id: ingredient.id,
type: ingredient.type,
Expand All @@ -80,6 +81,7 @@ function transformRecipe(recipe: API_Recipes_Entry): TransformedRecipeInternal {
output_range: recipe.output_item_count_range,
achievement_id: recipe.achievement_id,
merchant: recipe.merchant,
multipleRecipeCount: recipe.multipleRecipeCount,
}
}

Expand Down
32 changes: 32 additions & 0 deletions tests/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Object {
"id": 19712,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": "1-10",
"prerequisites": Array [
Expand Down Expand Up @@ -52,6 +53,7 @@ Object {
"id": 19112,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 5,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -88,6 +90,7 @@ Object {
"id": 19712,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": "1-10",
"prerequisites": Array [
Expand Down Expand Up @@ -120,6 +123,7 @@ Object {
"id": 19685,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -152,6 +156,7 @@ Object {
"id": 12988,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -188,6 +193,7 @@ Object {
"id": 19710,
"merchant": undefined,
"min_rating": 0,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -224,6 +230,7 @@ Object {
"id": 19679,
"merchant": undefined,
"min_rating": 0,
"multipleRecipeCount": 1,
"output": 5,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -245,6 +252,7 @@ Object {
"id": 12990,
"merchant": undefined,
"min_rating": 50,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -284,6 +292,7 @@ Object {
"id": 19679,
"merchant": undefined,
"min_rating": 0,
"multipleRecipeCount": 1,
"output": 5,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -323,6 +332,7 @@ Array [
"id": 1002,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -342,6 +352,7 @@ Array [
"id": 1001,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -374,6 +385,7 @@ Array [
"id": 1002,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -425,6 +437,7 @@ Object {
"id": 19679,
"merchant": undefined,
"min_rating": 0,
"multipleRecipeCount": 1,
"output": 5,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -444,6 +457,7 @@ Object {
"id": 77749,
"merchant": undefined,
"min_rating": 250,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -465,6 +479,7 @@ Object {
"id": 1234,
"merchant": undefined,
"min_rating": 175,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -517,6 +532,7 @@ Object {
"id": 88772,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -539,6 +555,7 @@ Object {
"id": 88774,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -577,6 +594,7 @@ Object {
"id": 88772,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -601,6 +619,7 @@ Object {
"id": 88775,
"merchant": undefined,
"min_rating": 250,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -623,6 +642,7 @@ Object {
"id": 88773,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -645,6 +665,7 @@ Object {
"id": 88772,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -683,6 +704,7 @@ Object {
"id": 88771,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -724,6 +746,7 @@ Object {
"id": 19742,
"merchant": undefined,
"min_rating": 150,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -755,6 +778,7 @@ Object {
"id": 19814,
"merchant": undefined,
"min_rating": 175,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -791,6 +815,7 @@ Object {
"id": 99994,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -824,6 +849,7 @@ Object {
"id": 99994,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -846,6 +872,7 @@ Object {
"id": 99991,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -879,6 +906,7 @@ Object {
"id": 99994,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -901,6 +929,7 @@ Object {
"id": 99992,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down Expand Up @@ -934,6 +963,7 @@ Object {
"id": 99994,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -956,6 +986,7 @@ Object {
"id": 99993,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand All @@ -978,6 +1009,7 @@ Object {
"id": 99990,
"merchant": undefined,
"min_rating": 400,
"multipleRecipeCount": 1,
"output": 1,
"output_range": undefined,
"prerequisites": Array [
Expand Down
Loading

0 comments on commit 07fde37

Please sign in to comment.