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

feat: Migrate to Nuxt 3 framework (#5184)

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
Hoa (Kyle) Trinh 2025-06-20 00:09:12 +07:00 committed by GitHub
parent 89ab7fac25
commit c24d532608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
403 changed files with 23959 additions and 19557 deletions

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { AdminAboutInfo, CheckAppConfig } from "~/lib/api/types/admin";
import type { AdminAboutInfo, CheckAppConfig } from "~/lib/api/types/admin";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { MealieAnalytics } from "~/lib/api/types/analytics";
import type { MealieAnalytics } from "~/lib/api/types/analytics";
const prefix = "/api";

View file

@ -1,6 +1,6 @@
import { BaseAPI } from "../base/base-clients";
import { AllBackups } from "~/lib/api/types/admin";
import { ErrorResponse, FileTokenResponse, SuccessResponse } from "~/lib/api/types/response";
import type { AllBackups } from "~/lib/api/types/admin";
import type { ErrorResponse, FileTokenResponse, SuccessResponse } from "~/lib/api/types/response";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { DebugResponse } from "~/lib/api/types/admin";
import type { DebugResponse } from "~/lib/api/types/admin";
const prefix = "/api";

View file

@ -1,6 +1,7 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { GroupBase, GroupInDB } from "~/lib/api/types/user";
import { GroupAdminUpdate } from "~/lib/api/types/group";
import type { GroupBase, GroupInDB } from "~/lib/api/types/user";
import type { GroupAdminUpdate } from "~/lib/api/types/group";
const prefix = "/api";
const routes = {

View file

@ -1,5 +1,6 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { HouseholdCreate, HouseholdInDB, UpdateHouseholdAdmin } from "~/lib/api/types/household";
import type { HouseholdCreate, HouseholdInDB, UpdateHouseholdAdmin } from "~/lib/api/types/household";
const prefix = "/api";
const routes = {

View file

@ -1,6 +1,6 @@
import { BaseAPI } from "../base/base-clients";
import { SuccessResponse } from "~/lib/api/types/response";
import { MaintenanceLogs, MaintenanceStorageDetails, MaintenanceSummary } from "~/lib/api/types/admin";
import type { SuccessResponse } from "~/lib/api/types/response";
import type { MaintenanceLogs, MaintenanceStorageDetails, MaintenanceSummary } from "~/lib/api/types/admin";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { ForgotPassword, PasswordResetToken, UnlockResults, UserIn, UserOut } from "~/lib/api/types/user";
import type { ForgotPassword, PasswordResetToken, UnlockResults, UserIn, UserOut } from "~/lib/api/types/user";
const prefix = "/api";

View file

@ -1,6 +1,6 @@
import { Recipe } from "../types/recipe";
import { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
import { QueryValue, route } from "~/lib/api/base/route";
import type { Recipe } from "../types/recipe";
import type { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
import { type QueryValue, route } from "~/lib/api/base/route";
export interface CrudAPIInterface {
requests: ApiRequestInstance;
@ -23,8 +23,26 @@ export abstract class BaseAPI {
export abstract class BaseCRUDAPIReadOnly<ReadType>
extends BaseAPI
implements CrudAPIInterface {
abstract baseRoute: (string);
abstract itemRoute(itemId: string | number): string;
public baseRoute: string;
public itemRouteFn: (itemId: string | number) => string;
constructor(
requests: ApiRequestInstance,
baseRoute: string,
itemRoute: (itemId: string | number) => string,
) {
super(requests);
this.baseRoute = baseRoute;
this.itemRouteFn = itemRoute;
}
get baseRouteValue() {
return this.baseRoute;
}
itemRoute(itemId: string | number): string {
return this.itemRouteFn(itemId);
}
async getAll(page = 1, perPage = -1, params = {} as Record<string, QueryValue>) {
params = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== null && v !== undefined));

View file

@ -27,7 +27,8 @@ export function route(rest: string, params: Record<string, QueryValue> | null =
for (const item of value) {
url.searchParams.append(key, String(item));
}
} else {
}
else {
url.searchParams.append(key, String(value));
}
}

View file

@ -6,7 +6,7 @@ import { AdminBackupsApi } from "./admin/admin-backups";
import { AdminMaintenanceApi } from "./admin/admin-maintenance";
import { AdminAnalyticsApi } from "./admin/admin-analytics";
import { AdminDebugAPI } from "./admin/admin-debug";
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
import type { ApiRequestInstance } from "~/lib/api/types/non-generated";
export class AdminAPI {
public about: AdminAboutAPI;

View file

@ -1,7 +1,7 @@
import { ValidatorsApi } from "./public/validators";
import { ExploreApi } from "./public/explore";
import { SharedApi } from "./public/shared";
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
import type { ApiRequestInstance } from "~/lib/api/types/non-generated";
export class PublicApi {
public validators: ValidatorsApi;

View file

@ -24,7 +24,7 @@ import { MultiPurposeLabelsApi } from "./user/group-multiple-purpose-labels";
import { GroupEventNotifierApi } from "./user/group-event-notifier";
import { MealPlanRulesApi } from "./user/group-mealplan-rules";
import { GroupDataSeederApi } from "./user/group-seeder";
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
import type { ApiRequestInstance } from "~/lib/api/types/non-generated";
export class UserApiClient {
public recipes: RecipeAPI;

View file

@ -11,10 +11,11 @@ const routes = {
};
export class PublicCookbooksApi extends BaseCRUDAPIReadOnly<RecipeCookBook> {
baseRoute = routes.cookbooksGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.cookbooksGroupSlugCookbookId(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
constructor(requests: ApiRequestInstance, groupSlug: string) {
super(
requests,
routes.cookbooksGroupSlug(groupSlug),
(itemId: string | number) => routes.cookbooksGroupSlugCookbookId(groupSlug, itemId)
);
}
}

View file

@ -11,10 +11,11 @@ const routes = {
};
export class PublicFoodsApi extends BaseCRUDAPIReadOnly<IngredientFood> {
baseRoute = routes.foodsGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.foodsGroupSlugFoodId(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
constructor(requests: ApiRequestInstance, groupSlug: string) {
super(
requests,
routes.foodsGroupSlug(groupSlug),
(itemId: string | number) => routes.foodsGroupSlugFoodId(groupSlug, itemId)
);
}
}

View file

@ -11,10 +11,11 @@ const routes = {
};
export class PublicHouseholdApi extends BaseCRUDAPIReadOnly<HouseholdSummary> {
baseRoute = routes.householdsGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.householdsGroupSlugHouseholdSlug(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
constructor(requests: ApiRequestInstance, groupSlug: string) {
super(
requests,
routes.householdsGroupSlug(groupSlug),
(itemId: string | number) => routes.householdsGroupSlugHouseholdSlug(groupSlug, itemId)
);
}
}

View file

@ -15,28 +15,31 @@ const routes = {
};
export class PublicCategoriesApi extends BaseCRUDAPIReadOnly<RecipeCategory> {
baseRoute = routes.categoriesGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.categoriesGroupSlugCategoryId(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
constructor(requests: ApiRequestInstance, groupSlug: string) {
super(
requests,
routes.categoriesGroupSlug(groupSlug),
(itemId: string | number) => routes.categoriesGroupSlugCategoryId(groupSlug, itemId)
);
}
}
export class PublicTagsApi extends BaseCRUDAPIReadOnly<RecipeTag> {
baseRoute = routes.tagsGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.tagsGroupSlugTagId(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
constructor(requests: ApiRequestInstance, groupSlug: string) {
super(
requests,
routes.tagsGroupSlug(groupSlug),
(itemId: string | number) => routes.tagsGroupSlugTagId(groupSlug, itemId)
);
}
}
export class PublicToolsApi extends BaseCRUDAPIReadOnly<RecipeTool> {
baseRoute = routes.toolsGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.toolsGroupSlugToolId(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
constructor(requests: ApiRequestInstance, groupSlug: string) {
super(
requests,
routes.toolsGroupSlug(groupSlug),
(itemId: string | number) => routes.toolsGroupSlugToolId(groupSlug, itemId)
);
}
}

View file

@ -13,11 +13,12 @@ const routes = {
};
export class PublicRecipeApi extends BaseCRUDAPIReadOnly<Recipe> {
baseRoute = routes.recipesGroupSlug(this.groupSlug);
itemRoute = (itemId: string | number) => routes.recipesGroupSlugRecipeSlug(this.groupSlug, itemId);
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
super(requests);
super(
requests,
routes.recipesGroupSlug(groupSlug),
(itemId: string | number) => routes.recipesGroupSlugRecipeSlug(groupSlug, itemId)
);
}
async search(rsq: RecipeSearchQuery) {
@ -26,7 +27,7 @@ export class PublicRecipeApi extends BaseCRUDAPIReadOnly<Recipe> {
async getSuggestions(q: RecipeSuggestionQuery, foods: string[] | null = null, tools: string[]| null = null) {
return await this.requests.get<RecipeSuggestionResponse>(
route(`${this.baseRoute}/suggestions`, { ...q, foods, tools })
route(`${routes.recipesGroupSlug(this.groupSlug)}/suggestions`, { ...q, foods, tools })
);
}
}

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,10 +1,12 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script
*/
import type { HouseholdSummary } from "./household";
export type PlanEntryType = "breakfast" | "lunch" | "dinner" | "side";
export type PlanRulesDay = "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday" | "unset";
export type PlanRulesType = "breakfast" | "lunch" | "dinner" | "side" | "unset";
@ -42,6 +44,9 @@ export interface PlanRulesOut {
householdId: string;
id: string;
queryFilter?: QueryFilterJSON;
categories?: RecipeCategory[];
tags?: RecipeTag[];
households?: HouseholdSummary[];
}
export interface QueryFilterJSON {
parts?: QueryFilterJSONPart[];

View file

@ -1,4 +1,4 @@
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
export type NoUndefinedField<T> = { [P in keyof T]-?: NoUndefinedField<NonNullable<T[P]>> };

View file

@ -226,7 +226,7 @@ export interface Recipe {
groupId?: string;
name?: string | null;
slug?: string;
image?: unknown;
image?: string;
recipeServings?: number;
recipeYieldQuantity?: number;
recipeYield?: string | null;
@ -512,7 +512,7 @@ export interface ScrapeRecipeTest {
url: string;
useOpenAI?: boolean;
}
export interface SlugResponse {}
export interface SlugResponse { }
export interface TagIn {
name: string;
}

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script

View file

@ -1,5 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script
@ -197,6 +197,7 @@ export interface UserBase {
canManage?: boolean;
canManageHousehold?: boolean;
canOrganize?: boolean;
advancedOptions?: boolean;
}
export interface UserIn {
id?: string | null;

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { AllBackups, BackupOptions, CreateBackup } from "~/lib/api/types/admin";
import type { AllBackups, BackupOptions, CreateBackup } from "~/lib/api/types/admin";
const prefix = "/api";

View file

@ -1,7 +1,7 @@
import { BaseAPI } from "../base/base-clients";
import { EmailInitationResponse, EmailInvitation } from "~/lib/api/types/household";
import { ForgotPassword } from "~/lib/api/types/user";
import { EmailTest } from "~/lib/api/types/admin";
import type { EmailInitationResponse, EmailInvitation } from "~/lib/api/types/household";
import type { ForgotPassword } from "~/lib/api/types/user";
import type { EmailTest } from "~/lib/api/types/admin";
const routes = {
base: "/api/admin/email",

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { CreateCookBook, RecipeCookBook, UpdateCookBook } from "~/lib/api/types/cookbook";
import type { CreateCookBook, RecipeCookBook, UpdateCookBook } from "~/lib/api/types/cookbook";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { GroupEventNotifierCreate, GroupEventNotifierOut, GroupEventNotifierUpdate } from "~/lib/api/types/household";
import type { GroupEventNotifierCreate, GroupEventNotifierOut, GroupEventNotifierUpdate } from "~/lib/api/types/household";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { PlanRulesCreate, PlanRulesOut } from "~/lib/api/types/meal-plan";
import type { PlanRulesCreate, PlanRulesOut } from "~/lib/api/types/meal-plan";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { CreatePlanEntry, CreateRandomEntry, ReadPlanEntry, UpdatePlanEntry } from "~/lib/api/types/meal-plan";
import type { CreatePlanEntry, CreateRandomEntry, ReadPlanEntry, UpdatePlanEntry } from "~/lib/api/types/meal-plan";
const prefix = "/api";

View file

@ -1,6 +1,6 @@
import { BaseAPI } from "../base/base-clients";
import { ReportSummary } from "~/lib/api/types/reports";
import { SupportedMigrations } from "~/lib/api/types/group";
import type { ReportSummary } from "~/lib/api/types/reports";
import type { SupportedMigrations } from "~/lib/api/types/group";
const prefix = "/api";
export interface MigrationPayload {

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { MultiPurposeLabelCreate, MultiPurposeLabelOut, MultiPurposeLabelUpdate } from "~/lib/api/types/labels";
import type { MultiPurposeLabelCreate, MultiPurposeLabelOut, MultiPurposeLabelUpdate } from "~/lib/api/types/labels";
const prefix = "/api";

View file

@ -1,19 +1,19 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { CreateGroupRecipeAction, GroupRecipeActionOut } from "~/lib/api/types/household";
import type { CreateGroupRecipeAction, GroupRecipeActionOut } from "~/lib/api/types/household";
const prefix = "/api";
const routes = {
groupRecipeActions: `${prefix}/households/recipe-actions`,
groupRecipeActionsId: (id: string | number) => `${prefix}/households/recipe-actions/${id}`,
groupRecipeActionsIdTriggerRecipeSlug: (id: string | number, recipeSlug: string) => `${prefix}/households/recipe-actions/${id}/trigger/${recipeSlug}`,
};
groupRecipeActions: `${prefix}/households/recipe-actions`,
groupRecipeActionsId: (id: string | number) => `${prefix}/households/recipe-actions/${id}`,
groupRecipeActionsIdTriggerRecipeSlug: (id: string | number, recipeSlug: string) => `${prefix}/households/recipe-actions/${id}/trigger/${recipeSlug}`,
};
export class GroupRecipeActionsAPI extends BaseCRUDAPI<CreateGroupRecipeAction, GroupRecipeActionOut> {
baseRoute = routes.groupRecipeActions;
itemRoute = routes.groupRecipeActionsId;
export class GroupRecipeActionsAPI extends BaseCRUDAPI<CreateGroupRecipeAction, GroupRecipeActionOut> {
baseRoute = routes.groupRecipeActions;
itemRoute = routes.groupRecipeActionsId;
async triggerAction(id: string | number, recipeSlug: string, scaledAmount: number) {
return await this.requests.post(routes.groupRecipeActionsIdTriggerRecipeSlug(id, recipeSlug), {scaledAmount});
}
async triggerAction(id: string | number, recipeSlug: string, scaledAmount: number) {
return await this.requests.post(routes.groupRecipeActionsIdTriggerRecipeSlug(id, recipeSlug), { scaledAmount });
}
}

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { ReportCategory, ReportOut, ReportSummary } from "~/lib/api/types/reports";
import type { ReportCategory, ReportOut, ReportSummary } from "~/lib/api/types/reports";
const prefix = "/api";

View file

@ -1,6 +1,6 @@
import { BaseAPI } from "../base/base-clients";
import { SuccessResponse } from "~/lib/api/types/response";
import { SeederConfig } from "~/lib/api/types/group";
import type { SuccessResponse } from "~/lib/api/types/response";
import type { SeederConfig } from "~/lib/api/types/group";
const prefix = "/api";

View file

@ -1,6 +1,6 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
import {
import type { ApiRequestInstance } from "~/lib/api/types/non-generated";
import type {
ShoppingListAddRecipeParamsBulk,
ShoppingListCreate,
ShoppingListItemCreate,

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { CreateWebhook, ReadWebhook } from "~/lib/api/types/household";
import type { CreateWebhook, ReadWebhook } from "~/lib/api/types/household";
const prefix = "/api";

View file

@ -1,8 +1,8 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { PaginationData } from "../types/non-generated";
import { QueryValue } from "../base/route";
import { GroupBase, GroupInDB, GroupSummary, UserSummary } from "~/lib/api/types/user";
import {
import type { PaginationData } from "../types/non-generated";
import type { QueryValue } from "../base/route";
import type { GroupBase, GroupInDB, GroupSummary, UserSummary } from "~/lib/api/types/user";
import type {
GroupAdminUpdate,
GroupStorage,
ReadGroupPreferences,

View file

@ -1,8 +1,8 @@
import { BaseCRUDAPIReadOnly } from "../base/base-clients";
import { PaginationData } from "../types/non-generated";
import { QueryValue } from "../base/route";
import { UserOut } from "~/lib/api/types/user";
import {
import type { PaginationData } from "../types/non-generated";
import type { QueryValue } from "../base/route";
import type { UserOut } from "~/lib/api/types/user";
import type {
HouseholdInDB,
HouseholdStatistics,
ReadHouseholdPreferences,
@ -27,7 +27,7 @@ const routes = {
invitation: `${prefix}/households/invitations`,
householdsId: (id: string | number) => `${prefix}/groups/households/${id}`,
householdsSelfRecipesSlug: (recipeSlug: string) => `${prefix}/households/self/recipes/${recipeSlug}`,
householdsSelfRecipesSlug: (recipeSlug: string) => `${prefix}/households/self/recipes/${recipeSlug}`,
};
export class HouseholdAPI extends BaseCRUDAPIReadOnly<HouseholdSummary> {

View file

@ -1,6 +1,6 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { config } from "../config";
import { CategoryIn, RecipeCategoryResponse } from "~/lib/api/types/recipe";
import type { CategoryIn, RecipeCategoryResponse } from "~/lib/api/types/recipe";
const prefix = config.PREFIX + "/organizers";

View file

@ -1,6 +1,6 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { config } from "../config";
import { RecipeTagResponse, TagIn } from "~/lib/api/types/recipe";
import type { RecipeTagResponse, TagIn } from "~/lib/api/types/recipe";
const prefix = config.PREFIX + "/organizers";

View file

@ -1,6 +1,6 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { config } from "../config";
import { RecipeTool, RecipeToolCreate, RecipeToolResponse } from "~/lib/api/types/recipe";
import type { RecipeTool, RecipeToolCreate, RecipeToolResponse } from "~/lib/api/types/recipe";
const prefix = config.PREFIX + "/organizers";

View file

@ -1,10 +1,10 @@
import { BaseAPI } from "../base/base-clients";
import { AssignCategories, AssignSettings, AssignTags, DeleteRecipes, ExportRecipes } from "~/lib/api/types/recipe";
import { GroupDataExport } from "~/lib/api/types/group";
import type { AssignCategories, AssignSettings, AssignTags, DeleteRecipes, ExportRecipes } from "~/lib/api/types/recipe";
import type { GroupDataExport } from "~/lib/api/types/group";
// Many bulk actions return nothing
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface BulkActionResponse {}
type BulkActionResponse = object;
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { CreateIngredientFood, IngredientFood } from "~/lib/api/types/recipe";
import type { CreateIngredientFood, IngredientFood } from "~/lib/api/types/recipe";
const prefix = "/api";
@ -14,7 +14,6 @@ export class FoodAPI extends BaseCRUDAPI<CreateIngredientFood, IngredientFood> {
itemRoute = routes.foodsFood;
merge(fromId: string, toId: string) {
// @ts-ignore TODO: fix this
return this.requests.put<IngredientFood>(routes.merge, { fromFood: fromId, toFood: toId });
}
}

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { CreateIngredientUnit, IngredientUnit } from "~/lib/api/types/recipe";
import type { CreateIngredientUnit, IngredientUnit } from "~/lib/api/types/recipe";
const prefix = "/api";
@ -14,7 +14,6 @@ export class UnitAPI extends BaseCRUDAPI<CreateIngredientUnit, IngredientUnit> {
itemRoute = routes.unitsUnit;
merge(fromId: string, toId: string) {
// @ts-ignore TODO: fix this
return this.requests.put<IngredientUnit>(routes.merge, { fromUnit: fromId, toUnit: toId });
}
}

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../../base/base-clients";
import { RecipeCommentCreate, RecipeCommentOut, RecipeCommentUpdate } from "~/lib/api/types/recipe";
import type { RecipeCommentCreate, RecipeCommentOut, RecipeCommentUpdate } from "~/lib/api/types/recipe";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../../base/base-clients";
import { RecipeShareToken, RecipeShareTokenCreate } from "~/lib/api/types/recipe";
import type { RecipeShareToken, RecipeShareTokenCreate } from "~/lib/api/types/recipe";
const prefix = "/api";

View file

@ -2,7 +2,7 @@ import { BaseCRUDAPI } from "../../base/base-clients";
import { route } from "../../base";
import { CommentsApi } from "./recipe-comments";
import { RecipeShareApi } from "./recipe-share";
import {
import type {
Recipe,
CreateRecipe,
RecipeAsset,
@ -17,7 +17,7 @@ import {
RecipeTimelineEventOut,
RecipeTimelineEventUpdate,
} from "~/lib/api/types/recipe";
import { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
import type { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
export type Parser = "nlp" | "brute" | "openai";
@ -113,9 +113,9 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
});
}
async getSuggestions(q: RecipeSuggestionQuery, foods: string[] | null = null, tools: string[]| null = null) {
async getSuggestions(q: RecipeSuggestionQuery, foods: string[] | null = null, tools: string[] | null = null) {
return await this.requests.get<RecipeSuggestionResponse>(
route(routes.recipesSuggestions, { ...q, foods, tools })
route(routes.recipesSuggestions, { ...q, foods, tools }),
);
}
@ -162,9 +162,9 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
formData.append("images", fileObject);
formData.append("extension", fileName.split(".").pop() ?? "");
let apiRoute = routes.recipesCreateFromImage
let apiRoute = routes.recipesCreateFromImage;
if (translateLanguage) {
apiRoute = `${apiRoute}?translateLanguage=${translateLanguage}`
apiRoute = `${apiRoute}?translateLanguage=${translateLanguage}`;
}
return await this.requests.post<string>(apiRoute, formData);
@ -197,7 +197,7 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
}
async updateLastMade(recipeSlug: string, timestamp: string) {
return await this.requests.patch<Recipe, RecipeLastMade>(routes.recipesSlugLastMade(recipeSlug), { timestamp })
return await this.requests.patch<Recipe, RecipeLastMade>(routes.recipesSlugLastMade(recipeSlug), { timestamp });
}
async createTimelineEvent(payload: RecipeTimelineEventIn) {
@ -207,7 +207,7 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
async updateTimelineEvent(eventId: string, payload: RecipeTimelineEventUpdate) {
return await this.requests.put<RecipeTimelineEventOut, RecipeTimelineEventUpdate>(
routes.recipesTimelineEventId(eventId),
payload
payload,
);
}
@ -220,7 +220,7 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
routes.recipesTimelineEvent,
{
params: { page, perPage, ...params },
}
},
);
}

View file

@ -2,6 +2,8 @@ import { BaseAPI } from "../base/base-clients";
export class UploadFile extends BaseAPI {
file(url: string, fileObject: any) {
return this.requests.post<string>(url, fileObject);
const { $axios } = useNuxtApp();
return $axios.post<string>(url, fileObject, { headers: { "Content-Type": "multipart/form-data" } });
// return this.requests.post<string>(url, fileObject);
}
}

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { CreateUserRegistration } from "~/lib/api/types/user";
import type { CreateUserRegistration } from "~/lib/api/types/user";
const prefix = "/api";

View file

@ -1,5 +1,5 @@
import { BaseCRUDAPI } from "../base/base-clients";
import {
import type {
ChangePassword,
DeleteTokenResponse,
LongLiveTokenIn,

View file

@ -1,5 +1,5 @@
import { BaseAPI } from "../base/base-clients";
import { FileTokenResponse } from "~/lib/api/types/response";
import type { FileTokenResponse } from "~/lib/api/types/response";
const prefix = "/api";