chore: file generation cleanup (#1736)

This PR does too many things :( 

1. Major refactoring of the dev/scripts and dev/code-generation folders. 

Primarily this was removing duplicate code and cleaning up some poorly written code snippets as well as making them more idempotent so then can be re-run over and over again but still maintain the same results. This is working on my machine, but I've been having problems in CI and comparing diffs so running generators in CI will have to wait. 

2. Re-Implement using the generated api routes for testing

This was a _huge_ refactor that touched damn near every test file but now we have auto-generated typed routes with inline hints and it's used for nearly every test excluding a few that use classes for better parameterization. This should greatly reduce errors when writing new tests. 

3. Minor Perf improvements for the All Recipes endpoint

  A. Removed redundant loops
  B. Uses orjson to do the encoding directly and returns a byte response instead of relying on the default 
       jsonable_encoder.

4. Fix some TS type errors that cropped up for seemingly no reason half way through the PR.

See this issue https://github.com/phillipdupuis/pydantic-to-typescript/issues/28

Basically, the generated TS type is not-correct since Pydantic will automatically fill in null fields. The resulting TS type is generated with a ? to indicate it can be null even though we _know_ that i can't be.
This commit is contained in:
Hayden
2022-10-18 14:49:41 -08:00
committed by GitHub
parent a8f0fb14a7
commit 9ecef4c25f
107 changed files with 2520 additions and 1948 deletions

View File

@@ -1,3 +1,6 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .mealie_model import *
from .types import *
# This file is auto-generated by gen_schema_exports.py
from .mealie_model import MealieModel
__all__ = [
"MealieModel",
]

View File

@@ -1,8 +1,50 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .about import *
from .backup import *
from .email import *
from .maintenance import *
from .migration import *
from .restore import *
from .settings import *
# This file is auto-generated by gen_schema_exports.py
from .about import AdminAboutInfo, AppInfo, AppStatistics, CheckAppConfig, DockerVolumeText
from .backup import AllBackups, BackupFile, BackupOptions, CreateBackup, ImportJob
from .email import EmailReady, EmailSuccess, EmailTest
from .maintenance import MaintenanceLogs, MaintenanceStorageDetails, MaintenanceSummary
from .migration import ChowdownURL, MigrationFile, MigrationImport, Migrations
from .restore import (
CommentImport,
CustomPageImport,
GroupImport,
ImportBase,
NotificationImport,
RecipeImport,
SettingsImport,
UserImport,
)
from .settings import CustomPageBase, CustomPageOut
__all__ = [
"AllBackups",
"BackupFile",
"BackupOptions",
"CreateBackup",
"ImportJob",
"MaintenanceLogs",
"MaintenanceStorageDetails",
"MaintenanceSummary",
"AdminAboutInfo",
"AppInfo",
"AppStatistics",
"CheckAppConfig",
"DockerVolumeText",
"EmailReady",
"EmailSuccess",
"EmailTest",
"CustomPageBase",
"CustomPageOut",
"ChowdownURL",
"MigrationFile",
"MigrationImport",
"Migrations",
"CommentImport",
"CustomPageImport",
"GroupImport",
"ImportBase",
"NotificationImport",
"RecipeImport",
"SettingsImport",
"UserImport",
]

View File

@@ -1,2 +1,6 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .analytics import *
# This file is auto-generated by gen_schema_exports.py
from .analytics import MealieAnalytics
__all__ = [
"MealieAnalytics",
]

View File

@@ -1,2 +1,11 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .cookbook import *
# This file is auto-generated by gen_schema_exports.py
from .cookbook import CookBookPagination, CreateCookBook, ReadCookBook, RecipeCookBook, SaveCookBook, UpdateCookBook
__all__ = [
"CookBookPagination",
"CreateCookBook",
"ReadCookBook",
"RecipeCookBook",
"SaveCookBook",
"UpdateCookBook",
]

View File

@@ -1,12 +1,80 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .group import *
from .group_events import *
from .group_exports import *
from .group_migration import *
from .group_permissions import *
from .group_preferences import *
from .group_seeder import *
from .group_shopping_list import *
from .group_statistics import *
from .invite_token import *
from .webhook import * # type: ignore
# This file is auto-generated by gen_schema_exports.py
from .group import GroupAdminUpdate
from .group_events import (
GroupEventNotifierCreate,
GroupEventNotifierOptions,
GroupEventNotifierOptionsOut,
GroupEventNotifierOptionsSave,
GroupEventNotifierOut,
GroupEventNotifierPrivate,
GroupEventNotifierSave,
GroupEventNotifierUpdate,
GroupEventPagination,
)
from .group_exports import GroupDataExport
from .group_migration import DataMigrationCreate, SupportedMigrations
from .group_permissions import SetPermissions
from .group_preferences import CreateGroupPreferences, ReadGroupPreferences, UpdateGroupPreferences
from .group_seeder import SeederConfig
from .group_shopping_list import (
ShoppingListCreate,
ShoppingListItemCreate,
ShoppingListItemOut,
ShoppingListItemRecipeRef,
ShoppingListItemRecipeRefOut,
ShoppingListItemUpdate,
ShoppingListOut,
ShoppingListPagination,
ShoppingListRecipeRefOut,
ShoppingListSave,
ShoppingListSummary,
ShoppingListUpdate,
)
from .group_statistics import GroupStatistics, GroupStorage
from .invite_token import CreateInviteToken, EmailInitationResponse, EmailInvitation, ReadInviteToken, SaveInviteToken
from .webhook import CreateWebhook, ReadWebhook, SaveWebhook, WebhookPagination, WebhookType
__all__ = [
"CreateGroupPreferences",
"ReadGroupPreferences",
"UpdateGroupPreferences",
"GroupDataExport",
"CreateWebhook",
"ReadWebhook",
"SaveWebhook",
"WebhookPagination",
"WebhookType",
"GroupEventNotifierCreate",
"GroupEventNotifierOptions",
"GroupEventNotifierOptionsOut",
"GroupEventNotifierOptionsSave",
"GroupEventNotifierOut",
"GroupEventNotifierPrivate",
"GroupEventNotifierSave",
"GroupEventNotifierUpdate",
"GroupEventPagination",
"DataMigrationCreate",
"SupportedMigrations",
"SeederConfig",
"ShoppingListCreate",
"ShoppingListItemCreate",
"ShoppingListItemOut",
"ShoppingListItemRecipeRef",
"ShoppingListItemRecipeRefOut",
"ShoppingListItemUpdate",
"ShoppingListOut",
"ShoppingListPagination",
"ShoppingListRecipeRefOut",
"ShoppingListSave",
"ShoppingListSummary",
"ShoppingListUpdate",
"GroupAdminUpdate",
"SetPermissions",
"GroupStatistics",
"GroupStorage",
"CreateInviteToken",
"EmailInitationResponse",
"EmailInvitation",
"ReadInviteToken",
"SaveInviteToken",
]

View File

@@ -1,2 +1,18 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .multi_purpose_label import *
# This file is auto-generated by gen_schema_exports.py
from .multi_purpose_label import (
MultiPurposeLabelCreate,
MultiPurposeLabelOut,
MultiPurposeLabelPagination,
MultiPurposeLabelSave,
MultiPurposeLabelSummary,
MultiPurposeLabelUpdate,
)
__all__ = [
"MultiPurposeLabelCreate",
"MultiPurposeLabelOut",
"MultiPurposeLabelPagination",
"MultiPurposeLabelSave",
"MultiPurposeLabelSummary",
"MultiPurposeLabelUpdate",
]

View File

@@ -1,5 +1,48 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .meal import *
from .new_meal import *
from .plan_rules import *
from .shopping_list import *
# This file is auto-generated by gen_schema_exports.py
from .meal import MealDayIn, MealDayOut, MealIn, MealPlanIn, MealPlanOut
from .new_meal import (
CreatePlanEntry,
CreateRandomEntry,
PlanEntryPagination,
PlanEntryType,
ReadPlanEntry,
SavePlanEntry,
UpdatePlanEntry,
)
from .plan_rules import (
Category,
PlanRulesCreate,
PlanRulesDay,
PlanRulesOut,
PlanRulesPagination,
PlanRulesSave,
PlanRulesType,
Tag,
)
from .shopping_list import ListItem, ShoppingListIn, ShoppingListOut
__all__ = [
"CreatePlanEntry",
"CreateRandomEntry",
"PlanEntryPagination",
"PlanEntryType",
"ReadPlanEntry",
"SavePlanEntry",
"UpdatePlanEntry",
"MealDayIn",
"MealDayOut",
"MealIn",
"MealPlanIn",
"MealPlanOut",
"Category",
"PlanRulesCreate",
"PlanRulesDay",
"PlanRulesOut",
"PlanRulesPagination",
"PlanRulesSave",
"PlanRulesType",
"Tag",
"ListItem",
"ShoppingListIn",
"ShoppingListOut",
]

View File

@@ -0,0 +1,7 @@
# This file is auto-generated by gen_schema_exports.py
from .ocr import OcrAssetReq, OcrTsvResponse
__all__ = [
"OcrAssetReq",
"OcrTsvResponse",
]

View File

@@ -1,16 +1,151 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .recipe import *
from .recipe_asset import *
from .recipe_bulk_actions import *
from .recipe_category import *
from .recipe_comments import * # type: ignore
from .recipe_image_types import *
from .recipe_ingredient import *
from .recipe_notes import *
from .recipe_nutrition import *
from .recipe_scraper import *
from .recipe_settings import *
from .recipe_share_token import * # type: ignore
from .recipe_step import *
from .recipe_tool import * # type: ignore
from .request_helpers import *
# This file is auto-generated by gen_schema_exports.py
from .recipe import (
CreateRecipe,
CreateRecipeBulk,
CreateRecipeByUrlBulk,
Recipe,
RecipeCategory,
RecipeCategoryPagination,
RecipePagination,
RecipePaginationQuery,
RecipeSummary,
RecipeTag,
RecipeTagPagination,
RecipeTool,
RecipeToolPagination,
)
from .recipe_asset import RecipeAsset
from .recipe_bulk_actions import (
AssignCategories,
AssignSettings,
AssignTags,
DeleteRecipes,
ExportBase,
ExportRecipes,
ExportTypes,
)
from .recipe_category import (
CategoryBase,
CategoryIn,
CategoryOut,
CategorySave,
RecipeCategoryResponse,
RecipeTagResponse,
TagBase,
TagIn,
TagOut,
TagSave,
)
from .recipe_comments import (
RecipeCommentCreate,
RecipeCommentOut,
RecipeCommentPagination,
RecipeCommentSave,
RecipeCommentUpdate,
UserBase,
)
from .recipe_image_types import RecipeImageTypes
from .recipe_ingredient import (
CreateIngredientFood,
CreateIngredientUnit,
IngredientConfidence,
IngredientFood,
IngredientFoodPagination,
IngredientRequest,
IngredientsRequest,
IngredientUnit,
IngredientUnitPagination,
MergeFood,
MergeUnit,
ParsedIngredient,
RecipeIngredient,
RegisteredParser,
SaveIngredientFood,
SaveIngredientUnit,
UnitFoodBase,
)
from .recipe_notes import RecipeNote
from .recipe_nutrition import Nutrition
from .recipe_scraper import ScrapeRecipe, ScrapeRecipeTest
from .recipe_settings import RecipeSettings
from .recipe_share_token import RecipeShareToken, RecipeShareTokenCreate, RecipeShareTokenSave, RecipeShareTokenSummary
from .recipe_step import IngredientReferences, RecipeStep
from .recipe_tool import RecipeToolCreate, RecipeToolOut, RecipeToolResponse, RecipeToolSave
from .request_helpers import RecipeSlug, RecipeZipTokenResponse, SlugResponse, UpdateImageResponse
__all__ = [
"RecipeToolCreate",
"RecipeToolOut",
"RecipeToolResponse",
"RecipeToolSave",
"RecipeAsset",
"RecipeSettings",
"RecipeShareToken",
"RecipeShareTokenCreate",
"RecipeShareTokenSave",
"RecipeShareTokenSummary",
"RecipeSlug",
"RecipeZipTokenResponse",
"SlugResponse",
"UpdateImageResponse",
"RecipeNote",
"CategoryBase",
"CategoryIn",
"CategoryOut",
"CategorySave",
"RecipeCategoryResponse",
"RecipeTagResponse",
"TagBase",
"TagIn",
"TagOut",
"TagSave",
"RecipeCommentCreate",
"RecipeCommentOut",
"RecipeCommentPagination",
"RecipeCommentSave",
"RecipeCommentUpdate",
"UserBase",
"AssignCategories",
"AssignSettings",
"AssignTags",
"DeleteRecipes",
"ExportBase",
"ExportRecipes",
"ExportTypes",
"IngredientReferences",
"RecipeStep",
"RecipeImageTypes",
"Nutrition",
"CreateIngredientFood",
"CreateIngredientUnit",
"IngredientConfidence",
"IngredientFood",
"IngredientFoodPagination",
"IngredientRequest",
"IngredientUnit",
"IngredientUnitPagination",
"IngredientsRequest",
"MergeFood",
"MergeUnit",
"ParsedIngredient",
"RecipeIngredient",
"RegisteredParser",
"SaveIngredientFood",
"SaveIngredientUnit",
"UnitFoodBase",
"CreateRecipe",
"CreateRecipeBulk",
"CreateRecipeByUrlBulk",
"Recipe",
"RecipeCategory",
"RecipeCategoryPagination",
"RecipePagination",
"RecipePaginationQuery",
"RecipeSummary",
"RecipeTag",
"RecipeTagPagination",
"RecipeTool",
"RecipeToolPagination",
"ScrapeRecipe",
"ScrapeRecipeTest",
]

View File

@@ -14,7 +14,7 @@ class RecipeToolSave(RecipeToolCreate):
group_id: UUID4
class RecipeTool(RecipeToolCreate):
class RecipeToolOut(RecipeToolCreate):
id: UUID4
slug: str
@@ -22,13 +22,13 @@ class RecipeTool(RecipeToolCreate):
orm_mode = True
class RecipeToolResponse(RecipeTool):
class RecipeToolResponse(RecipeToolOut):
recipes: typing.List["Recipe"] = []
class Config:
orm_mode = True
from .recipe import Recipe
from .recipe import Recipe # noqa: E402
RecipeToolResponse.update_forward_refs()

View File

@@ -1,2 +1,20 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .reports import *
# This file is auto-generated by gen_schema_exports.py
from .reports import (
ReportCategory,
ReportCreate,
ReportEntryCreate,
ReportEntryOut,
ReportOut,
ReportSummary,
ReportSummaryStatus,
)
__all__ = [
"ReportCategory",
"ReportCreate",
"ReportEntryCreate",
"ReportEntryOut",
"ReportOut",
"ReportSummary",
"ReportSummaryStatus",
]

View File

@@ -1,3 +1,19 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .responses import *
from .validation import *
# This file is auto-generated by gen_schema_exports.py
from .pagination import OrderDirection, PaginationBase, PaginationQuery
from .query_filter import LogicalOperator, QueryFilter, QueryFilterComponent, RelationalOperator
from .responses import ErrorResponse, FileTokenResponse, SuccessResponse
from .validation import ValidationResponse
__all__ = [
"ErrorResponse",
"FileTokenResponse",
"SuccessResponse",
"LogicalOperator",
"QueryFilter",
"QueryFilterComponent",
"RelationalOperator",
"OrderDirection",
"PaginationBase",
"PaginationQuery",
"ValidationResponse",
]

View File

@@ -1,2 +1,10 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .tasks import *
# This file is auto-generated by gen_schema_exports.py
from .tasks import ServerTask, ServerTaskCreate, ServerTaskNames, ServerTaskPagination, ServerTaskStatus
__all__ = [
"ServerTask",
"ServerTaskCreate",
"ServerTaskNames",
"ServerTaskPagination",
"ServerTaskStatus",
]

View File

@@ -1,5 +1,56 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .auth import *
from .registration import *
from .user import *
from .user_passwords import *
# This file is auto-generated by gen_schema_exports.py
from .auth import Token, TokenData, UnlockResults
from .registration import CreateUserRegistration
from .user import (
ChangePassword,
CreateToken,
DeleteTokenResponse,
GroupBase,
GroupInDB,
GroupPagination,
LongLiveTokenIn,
LongLiveTokenInDB,
LongLiveTokenOut,
PrivateUser,
UpdateGroup,
UserBase,
UserFavorites,
UserIn,
UserOut,
UserPagination,
)
from .user_passwords import (
ForgotPassword,
PrivatePasswordResetToken,
ResetPassword,
SavePasswordResetToken,
ValidateResetToken,
)
__all__ = [
"CreateUserRegistration",
"Token",
"TokenData",
"UnlockResults",
"ChangePassword",
"CreateToken",
"DeleteTokenResponse",
"GroupBase",
"GroupInDB",
"GroupPagination",
"LongLiveTokenIn",
"LongLiveTokenInDB",
"LongLiveTokenOut",
"PrivateUser",
"UpdateGroup",
"UserBase",
"UserFavorites",
"UserIn",
"UserOut",
"UserPagination",
"ForgotPassword",
"PrivatePasswordResetToken",
"ResetPassword",
"SavePasswordResetToken",
"ValidateResetToken",
]