Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AnyList extends EventEmitter {
const url = response.request.options.url.href;
console.error(`Endpoint ${url} returned uncaught status code ${response.statusCode}`);
}

return error;
},
],
Expand Down
41 changes: 41 additions & 0 deletions lib/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const OP_MAPPING = {
* @property {string} manualSortIndex
* @property {string} userId
* @property {string} categoryMatchId
* @property {string} recipeId
* @property {string} rawIngredient
* @property {Array<{recipeId: string, recipeName: string, eventId: string, eventDate: string}>} ingredients
*/
class Item {
/**
Expand All @@ -41,6 +44,14 @@ class Item {
this._manualSortIndex = i.manualSortIndex;
this._userId = i.userId;
this._categoryMatchId = i.categoryMatchId || 'other';
this._recipeId = i.recipeId || null;
this._rawIngredient = i.rawIngredient || null;
this._ingredients = (i.ingredients || []).map(ing => ({
recipeId: ing.recipeId || null,
recipeName: ing.recipeName || null,
eventId: ing.eventId || null,
eventDate: ing.eventDate || null,
}));

this._client = client;
this._protobuf = protobuf;
Expand All @@ -60,6 +71,9 @@ class Item {
manualSortIndex: this._manualSortIndex,
userId: this._userId,
categoryMatchId: this._categoryMatchId,
recipeId: this._recipeId,
rawIngredient: this._rawIngredient,
ingredients: this._ingredients,
};
}

Expand All @@ -75,6 +89,9 @@ class Item {
userId: this._userId,
categoryMatchId: this._categoryMatchId,
manualSortIndex: this._manualSortIndex,
recipeId: this._recipeId,
rawIngredient: this._rawIngredient,
ingredients: this._ingredients,
});
}

Expand Down Expand Up @@ -160,6 +177,30 @@ class Item {
this._fieldsToUpdate.push('categoryMatchId');
}

get recipeId() {
return this._recipeId;
}

set recipeId(_) {
throw new Error('Recipe ID is read-only.');
}

get rawIngredient() {
return this._rawIngredient;
}

set rawIngredient(_) {
throw new Error('Raw ingredient is read-only.');
}

get ingredients() {
return this._ingredients;
}

set ingredients(_) {
throw new Error('Ingredients is read-only.');
}

get manualSortIndex() {
return this._manualSortIndex;
}
Expand Down