// @generated by FORGE - DO NOT EDIT

import {
  getForgeClient,
  createSubscriptionStore,
  createJobStore,
  createWorkflowStore,
} from "@forge-rs/svelte";
import type {
  AuthResponse,
  ConfirmVerificationInput,
  DemoStats,
  ExportInput,
  ExportOutput,
  IssLocation,
  LoginInput,
  RefreshInput,
  RegisterInput,
  TokenPair,
  Trade,
  User,
  UserRole,
  VerificationInput,
  VerificationOutput,
  WebhookEvent,
} from "./types";

// Queries
export const getDemoStats = (): Promise<DemoStats> =>
  getForgeClient().call("get_demo_stats", null);
export const getIssLocation = (): Promise<IssLocation | null> =>
  getForgeClient().call("get_iss_location", null);
export const getTrades = (): Promise<Trade[]> =>
  getForgeClient().call("get_trades", null);
export const getUser = (args: { id: string }): Promise<User | null> =>
  getForgeClient().call("get_user", args);
export const getUsers = (): Promise<User[]> =>
  getForgeClient().call("get_users", null);
export const getWebhookEvents = (): Promise<WebhookEvent[]> =>
  getForgeClient().call("get_webhook_events", null);

// Subscriptions
export const getDemoStatsStore$ = () =>
  createSubscriptionStore<null, DemoStats>("get_demo_stats", null);
export const getIssLocationStore$ = () =>
  createSubscriptionStore<null, IssLocation | null>("get_iss_location", null);
export const getTradesStore$ = () =>
  createSubscriptionStore<null, Trade[]>("get_trades", null);
export const getUserStore$ = (args: { id: string }) =>
  createSubscriptionStore<{ id: string }, User | null>("get_user", args);
export const getUsersStore$ = () =>
  createSubscriptionStore<null, User[]>("get_users", null);
export const getWebhookEventsStore$ = () =>
  createSubscriptionStore<null, WebhookEvent[]>("get_webhook_events", null);

// Mutations
export const confirmVerification = (
  args: ConfirmVerificationInput,
): Promise<boolean> => getForgeClient().call("confirm_verification", args);
export const createUser = (args: {
  email: string;
  name: string;
  role: UserRole | null;
}): Promise<User> => getForgeClient().call("create_user", args);
export const deleteUser = (args: { id: string }): Promise<boolean> =>
  getForgeClient().call("delete_user", args);
export const login = (args: LoginInput): Promise<AuthResponse> =>
  getForgeClient().call("login", args);
export const refreshToken = (args: RefreshInput): Promise<TokenPair> =>
  getForgeClient().call("refresh_token", args);
export const register = (args: RegisterInput): Promise<AuthResponse> =>
  getForgeClient().call("register", args);
export const updateUser = (args: {
  id: string;
  email: string | null;
  name: string | null;
  role: UserRole | null;
}): Promise<User> => getForgeClient().call("update_user", args);

// Jobs
export const trackExportUsers = (args: ExportInput) =>
  createJobStore<ExportInput, ExportOutput>("export_users", args);

// Workflows
export const trackAccountVerification = (args: VerificationInput) =>
  createWorkflowStore<VerificationInput, VerificationOutput>(
    "account_verification",
    args,
  );
