1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-25 08:09:41 +02:00

feature: proper multi-tenant-support (#969)(WIP)

* update naming

* refactor tests to use shared structure

* shorten names

* add tools test case

* refactor to support multi-tenant

* set group_id on creation

* initial refactor for multitenant tags/cats

* spelling

* additional test case for same valued resources

* fix recipe update tests

* apply indexes to foreign keys

* fix performance regressions

* handle unknown exception

* utility decorator for function debugging

* migrate recipe_id to UUID

* GUID for recipes

* remove unused import

* move image functions into package

* move utilities to packages dir

* update import

* linter

* image image and asset routes

* update assets and images to use UUIDs

* fix migration base

* image asset test coverage

* use ids for categories and tag crud functions

* refactor recipe organizer test suite to reduce duplication

* add uuid serlization utility

* organizer base router

* slug routes testing and fixes

* fix postgres error

* adopt UUIDs

* move tags, categories, and tools under "organizers" umbrella

* update composite label

* generate ts types

* fix import error

* update frontend types

* fix type errors

* fix postgres errors

* fix #978

* add null check for title validation

* add note in docs on multi-tenancy
This commit is contained in:
Hayden 2022-02-13 12:23:42 -09:00 committed by GitHub
parent 9a82a172cb
commit c617251f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
157 changed files with 1866 additions and 1578 deletions

View file

@ -72,12 +72,12 @@ export interface CustomPageBase {
}
export interface RecipeCategoryResponse {
name: string;
id: number;
id: string;
slug: string;
recipes?: Recipe[];
recipes?: RecipeSummary[];
}
export interface Recipe {
id?: number;
export interface RecipeSummary {
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -97,28 +97,19 @@ export interface Recipe {
recipeIngredient?: RecipeIngredient[];
dateAdded?: string;
dateUpdated?: string;
recipeInstructions?: RecipeStep[];
nutrition?: Nutrition;
settings?: RecipeSettings;
assets?: RecipeAsset[];
notes?: RecipeNote[];
extras?: {
[k: string]: unknown;
};
comments?: RecipeCommentOut[];
}
export interface RecipeCategory {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTag {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTool {
id?: number;
id: string;
name: string;
slug: string;
onHand?: boolean;
@ -137,7 +128,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
id: number;
id: string;
}
export interface CreateIngredientUnit {
name: string;
@ -149,7 +140,7 @@ export interface IngredientFood {
name: string;
description?: string;
labelId?: string;
id: number;
id: string;
label?: MultiPurposeLabelSummary;
}
export interface MultiPurposeLabelSummary {
@ -163,59 +154,6 @@ export interface CreateIngredientFood {
description?: string;
labelId?: string;
}
export interface RecipeStep {
id?: string;
title?: string;
text: string;
ingredientReferences?: IngredientReferences[];
}
/**
* A list of ingredient references.
*/
export interface IngredientReferences {
referenceId?: string;
}
export interface Nutrition {
calories?: string;
fatContent?: string;
proteinContent?: string;
carbohydrateContent?: string;
fiberContent?: string;
sodiumContent?: string;
sugarContent?: string;
}
export interface RecipeSettings {
public?: boolean;
showNutrition?: boolean;
showAssets?: boolean;
landscapeView?: boolean;
disableComments?: boolean;
disableAmount?: boolean;
locked?: boolean;
}
export interface RecipeAsset {
name: string;
icon: string;
fileName?: string;
}
export interface RecipeNote {
title: string;
text: string;
}
export interface RecipeCommentOut {
recipeId: number;
text: string;
id: string;
createdAt: string;
updateAt: string;
userId: string;
user: UserBase;
}
export interface UserBase {
id: number;
username?: string;
admin: boolean;
}
export interface CustomPageImport {
name: string;
status: boolean;

View file

@ -7,7 +7,7 @@
export interface CategoryBase {
name: string;
id: number;
id: string;
slug: string;
}
export interface CreateCookBook {
@ -28,12 +28,12 @@ export interface ReadCookBook {
}
export interface RecipeCategoryResponse {
name: string;
id: number;
id: string;
slug: string;
recipes?: Recipe[];
recipes?: RecipeSummary[];
}
export interface Recipe {
id?: number;
export interface RecipeSummary {
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -53,28 +53,19 @@ export interface Recipe {
recipeIngredient?: RecipeIngredient[];
dateAdded?: string;
dateUpdated?: string;
recipeInstructions?: RecipeStep[];
nutrition?: Nutrition;
settings?: RecipeSettings;
assets?: RecipeAsset[];
notes?: RecipeNote[];
extras?: {
[k: string]: unknown;
};
comments?: RecipeCommentOut[];
}
export interface RecipeCategory {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTag {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTool {
id?: number;
id: string;
name: string;
slug: string;
onHand?: boolean;
@ -93,7 +84,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
id: number;
id: string;
}
export interface CreateIngredientUnit {
name: string;
@ -105,7 +96,7 @@ export interface IngredientFood {
name: string;
description?: string;
labelId?: string;
id: number;
id: string;
label?: MultiPurposeLabelSummary;
}
export interface MultiPurposeLabelSummary {
@ -119,59 +110,6 @@ export interface CreateIngredientFood {
description?: string;
labelId?: string;
}
export interface RecipeStep {
id?: string;
title?: string;
text: string;
ingredientReferences?: IngredientReferences[];
}
/**
* A list of ingredient references.
*/
export interface IngredientReferences {
referenceId?: string;
}
export interface Nutrition {
calories?: string;
fatContent?: string;
proteinContent?: string;
carbohydrateContent?: string;
fiberContent?: string;
sodiumContent?: string;
sugarContent?: string;
}
export interface RecipeSettings {
public?: boolean;
showNutrition?: boolean;
showAssets?: boolean;
landscapeView?: boolean;
disableComments?: boolean;
disableAmount?: boolean;
locked?: boolean;
}
export interface RecipeAsset {
name: string;
icon: string;
fileName?: string;
}
export interface RecipeNote {
title: string;
text: string;
}
export interface RecipeCommentOut {
recipeId: number;
text: string;
id: string;
createdAt: string;
updateAt: string;
userId: string;
user: UserBase;
}
export interface UserBase {
id: number;
username?: string;
admin: boolean;
}
export interface RecipeCookBook {
name: string;
description?: string;

View file

@ -180,7 +180,7 @@ export interface IngredientFood {
name: string;
description?: string;
labelId?: string;
id: number;
id: string;
label?: MultiPurposeLabelSummary;
}
export interface MultiPurposeLabelSummary {
@ -194,7 +194,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
id: number;
id: string;
}
export interface ReadGroupPreferences {
privateGroup?: boolean;
@ -222,7 +222,7 @@ export interface ReadWebhook {
id: number;
}
export interface RecipeSummary {
id?: number;
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -244,17 +244,17 @@ export interface RecipeSummary {
dateUpdated?: string;
}
export interface RecipeCategory {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTag {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTool {
id?: number;
id: string;
name: string;
slug: string;
onHand?: boolean;
@ -307,15 +307,15 @@ export interface ShoppingListItemCreate {
isFood?: boolean;
note?: string;
quantity?: number;
unitId?: number;
unitId?: string;
unit?: IngredientUnit;
foodId?: number;
foodId?: string;
food?: IngredientFood;
labelId?: string;
recipeReferences?: ShoppingListItemRecipeRef[];
}
export interface ShoppingListItemRecipeRef {
recipeId: number;
recipeId: string;
recipeQuantity: number;
}
export interface ShoppingListItemOut {
@ -325,9 +325,9 @@ export interface ShoppingListItemOut {
isFood?: boolean;
note?: string;
quantity?: number;
unitId?: number;
unitId?: string;
unit?: IngredientUnit;
foodId?: number;
foodId?: string;
food?: IngredientFood;
labelId?: string;
recipeReferences?: ShoppingListItemRecipeRefOut[];
@ -335,7 +335,7 @@ export interface ShoppingListItemOut {
label?: MultiPurposeLabelSummary;
}
export interface ShoppingListItemRecipeRefOut {
recipeId: number;
recipeId: string;
recipeQuantity: number;
id: string;
shoppingListItemId: string;
@ -347,9 +347,9 @@ export interface ShoppingListItemUpdate {
isFood?: boolean;
note?: string;
quantity?: number;
unitId?: number;
unitId?: string;
unit?: IngredientUnit;
foodId?: number;
foodId?: string;
food?: IngredientFood;
labelId?: string;
recipeReferences?: ShoppingListItemRecipeRef[];
@ -365,7 +365,7 @@ export interface ShoppingListOut {
export interface ShoppingListRecipeRefOut {
id: string;
shoppingListId: string;
recipeId: number;
recipeId: string;
recipeQuantity: number;
recipe: RecipeSummary;
}

View file

@ -10,7 +10,7 @@ export type PlanRulesDay = "monday" | "tuesday" | "wednesday" | "thursday" | "fr
export type PlanRulesType = "breakfast" | "lunch" | "dinner" | "unset";
export interface Category {
id: number;
id: string;
name: string;
slug: string;
}
@ -23,7 +23,7 @@ export interface CreatePlanEntry {
entryType?: PlanEntryType & string;
title?: string;
text?: string;
recipeId?: number;
recipeId?: string;
}
export interface ListItem {
title?: string;
@ -66,7 +66,7 @@ export interface PlanRulesCreate {
tags?: Tag[];
}
export interface Tag {
id: number;
id: string;
name: string;
slug: string;
}
@ -90,13 +90,13 @@ export interface ReadPlanEntry {
entryType?: PlanEntryType & string;
title?: string;
text?: string;
recipeId?: number;
recipeId?: string;
id: number;
groupId: string;
recipe?: RecipeSummary;
}
export interface RecipeSummary {
id?: number;
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -118,17 +118,17 @@ export interface RecipeSummary {
dateUpdated?: string;
}
export interface RecipeCategory {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTag {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTool {
id?: number;
id: string;
name: string;
slug: string;
onHand?: boolean;
@ -147,7 +147,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
id: number;
id: string;
}
export interface CreateIngredientUnit {
name: string;
@ -159,7 +159,7 @@ export interface IngredientFood {
name: string;
description?: string;
labelId?: string;
id: number;
id: string;
label?: MultiPurposeLabelSummary;
}
export interface MultiPurposeLabelSummary {
@ -178,7 +178,7 @@ export interface SavePlanEntry {
entryType?: PlanEntryType & string;
title?: string;
text?: string;
recipeId?: number;
recipeId?: string;
groupId: string;
}
export interface ShoppingListIn {
@ -197,7 +197,7 @@ export interface UpdatePlanEntry {
entryType?: PlanEntryType & string;
title?: string;
text?: string;
recipeId?: number;
recipeId?: string;
id: number;
groupId: string;
}

View file

@ -14,7 +14,7 @@ export interface AssignCategories {
}
export interface CategoryBase {
name: string;
id: number;
id: string;
slug: string;
}
export interface AssignTags {
@ -23,7 +23,7 @@ export interface AssignTags {
}
export interface TagBase {
name: string;
id: number;
id: string;
slug: string;
}
export interface BulkActionError {
@ -38,6 +38,15 @@ export interface BulkActionsResponse {
export interface CategoryIn {
name: string;
}
export interface CategoryOut {
name: string;
id: string;
slug: string;
}
export interface CategorySave {
name: string;
groupId: string;
}
export interface CreateIngredientFood {
name: string;
description?: string;
@ -58,12 +67,12 @@ export interface CreateRecipeBulk {
tags?: RecipeTag[];
}
export interface RecipeCategory {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTag {
id?: number;
id: string;
name: string;
slug: string;
}
@ -95,7 +104,7 @@ export interface IngredientFood {
name: string;
description?: string;
labelId?: string;
id: number;
id: string;
label?: MultiPurposeLabelSummary;
}
export interface MultiPurposeLabelSummary {
@ -119,7 +128,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
id: number;
id: string;
}
export interface IngredientsRequest {
parser?: RegisteredParser & string;
@ -149,7 +158,7 @@ export interface RecipeIngredient {
referenceId?: string;
}
export interface Recipe {
id?: number;
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -180,7 +189,7 @@ export interface Recipe {
comments?: RecipeCommentOut[];
}
export interface RecipeTool {
id?: number;
id: string;
name: string;
slug: string;
onHand?: boolean;
@ -210,7 +219,7 @@ export interface RecipeNote {
text: string;
}
export interface RecipeCommentOut {
recipeId: number;
recipeId: string;
text: string;
id: string;
createdAt: string;
@ -225,52 +234,12 @@ export interface UserBase {
}
export interface RecipeCategoryResponse {
name: string;
id: number;
slug: string;
recipes?: Recipe[];
}
export interface RecipeCommentCreate {
recipeId: number;
text: string;
}
export interface RecipeCommentSave {
recipeId: number;
text: string;
userId: string;
}
export interface RecipeCommentUpdate {
id: string;
text: string;
}
export interface RecipeShareToken {
recipeId: number;
expiresAt?: string;
groupId: string;
id: string;
createdAt: string;
recipe: Recipe;
}
export interface RecipeShareTokenCreate {
recipeId: number;
expiresAt?: string;
}
export interface RecipeShareTokenSave {
recipeId: number;
expiresAt?: string;
groupId: string;
}
export interface RecipeShareTokenSummary {
recipeId: number;
expiresAt?: string;
groupId: string;
id: string;
createdAt: string;
}
export interface RecipeSlug {
id: string;
slug: string;
recipes?: RecipeSummary[];
}
export interface RecipeSummary {
id?: number;
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -291,16 +260,56 @@ export interface RecipeSummary {
dateAdded?: string;
dateUpdated?: string;
}
export interface RecipeCommentCreate {
recipeId: string;
text: string;
}
export interface RecipeCommentSave {
recipeId: string;
text: string;
userId: string;
}
export interface RecipeCommentUpdate {
id: string;
text: string;
}
export interface RecipeShareToken {
recipeId: string;
expiresAt?: string;
groupId: string;
id: string;
createdAt: string;
recipe: Recipe;
}
export interface RecipeShareTokenCreate {
recipeId: string;
expiresAt?: string;
}
export interface RecipeShareTokenSave {
recipeId: string;
expiresAt?: string;
groupId: string;
}
export interface RecipeShareTokenSummary {
recipeId: string;
expiresAt?: string;
groupId: string;
id: string;
createdAt: string;
}
export interface RecipeSlug {
slug: string;
}
export interface RecipeTagResponse {
name: string;
id: number;
id: string;
slug: string;
recipes?: Recipe[];
recipes?: RecipeSummary[];
}
export interface RecipeTool1 {
name: string;
onHand?: boolean;
id: number;
id: string;
slug: string;
}
export interface RecipeToolCreate {
@ -310,14 +319,42 @@ export interface RecipeToolCreate {
export interface RecipeToolResponse {
name: string;
onHand?: boolean;
id: number;
id: string;
slug: string;
recipes?: Recipe[];
}
export interface RecipeToolSave {
name: string;
onHand?: boolean;
groupId: string;
}
export interface SaveIngredientFood {
name: string;
description?: string;
labelId?: string;
groupId: string;
}
export interface SaveIngredientUnit {
name: string;
description?: string;
fraction?: boolean;
abbreviation?: string;
groupId: string;
}
export interface SlugResponse {}
export interface TagIn {
name: string;
}
export interface TagOut {
name: string;
groupId: string;
id: string;
slug: string;
}
export interface TagSave {
name: string;
groupId: string;
}
export interface UnitFoodBase {
name: string;
description?: string;

View file

@ -7,7 +7,7 @@
export interface CategoryBase {
name: string;
id: number;
id: string;
slug: string;
}
export interface ChangePassword {
@ -109,7 +109,7 @@ export interface PrivatePasswordResetToken {
user: PrivateUser;
}
export interface RecipeSummary {
id?: number;
id?: string;
userId?: string;
groupId?: string;
name?: string;
@ -131,17 +131,17 @@ export interface RecipeSummary {
dateUpdated?: string;
}
export interface RecipeCategory {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTag {
id?: number;
id: string;
name: string;
slug: string;
}
export interface RecipeTool {
id?: number;
id: string;
name: string;
slug: string;
onHand?: boolean;
@ -160,7 +160,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
id: number;
id: string;
}
export interface CreateIngredientUnit {
name: string;
@ -172,7 +172,7 @@ export interface IngredientFood {
name: string;
description?: string;
labelId?: string;
id: number;
id: string;
label?: MultiPurposeLabelSummary;
}
export interface MultiPurposeLabelSummary {