mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 15:26:41 +02:00
fix lint
This commit is contained in:
parent
16cb8e753b
commit
e9caa4a217
46 changed files with 1784 additions and 728 deletions
|
|
@ -21,6 +21,8 @@ export const typescriptConfig = [
|
|||
parserOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
||||
import { createParamDecorator, type ExecutionContext } from '@nestjs/common';
|
||||
|
||||
export interface JwtPayload {
|
||||
sub: string;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ModuleMetadata, Type } from '@nestjs/common';
|
||||
import { type ModuleMetadata, type Type } from '@nestjs/common';
|
||||
|
||||
export interface ManaCoreModuleOptions {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -106,12 +106,17 @@ export class CreditClientService {
|
|||
return this.getDefaultBalance();
|
||||
}
|
||||
|
||||
const data = (await response.json()) as CreditBalance;
|
||||
const {
|
||||
balance = 0,
|
||||
freeCreditsRemaining = 0,
|
||||
totalEarned = 0,
|
||||
totalSpent = 0,
|
||||
} = (await response.json()) as CreditBalance;
|
||||
return {
|
||||
balance: data.balance || 0,
|
||||
freeCreditsRemaining: data.freeCreditsRemaining || 0,
|
||||
totalEarned: data.totalEarned || 0,
|
||||
totalSpent: data.totalSpent || 0,
|
||||
balance,
|
||||
freeCreditsRemaining,
|
||||
totalEarned,
|
||||
totalSpent,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to get balance for user ${userId}:`, error);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { drizzle, PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
||||
import { drizzle, type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
import * as schema from './schema';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
* Generic types for creating auth stores with custom user types
|
||||
*/
|
||||
|
||||
import type { AuthResult as BaseAuthResult } from '@manacore/shared-types';
|
||||
|
||||
/**
|
||||
* Base user interface that all app-specific user types must extend
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -106,10 +106,6 @@ export function createAuthService(config: AuthServiceConfig) {
|
|||
*/
|
||||
async signUp(email: string, password: string): Promise<AuthResult> {
|
||||
try {
|
||||
const storage = getStorageAdapter();
|
||||
const deviceAdapter = getDeviceAdapter();
|
||||
const deviceInfo = await deviceAdapter.getDeviceInfo();
|
||||
|
||||
const response = await fetch(`${baseUrl}${endpoints.signUp}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
|
@ -128,7 +124,8 @@ export function createAuthService(config: AuthServiceConfig) {
|
|||
return { success: false, error: errorData.message || 'Sign up failed' };
|
||||
}
|
||||
|
||||
const responseData = await response.json();
|
||||
// Consume response to avoid unhandled promise
|
||||
await response.json();
|
||||
|
||||
// Mana Core Auth returns user data immediately on registration
|
||||
// User needs to sign in separately to get tokens
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function decodeToken(token: string): DecodedToken | null {
|
|||
/**
|
||||
* Check if a token is valid locally (not expired)
|
||||
*/
|
||||
export function isTokenValidLocally(token: string, bufferSeconds: number = 10): boolean {
|
||||
export function isTokenValidLocally(token: string, bufferSeconds = 10): boolean {
|
||||
try {
|
||||
const payload = decodeToken(token);
|
||||
if (!payload || !payload.exp) {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export function getEnv(
|
|||
*/
|
||||
export function getBoolEnv(
|
||||
key: string,
|
||||
defaultValue: boolean = false,
|
||||
defaultValue = false,
|
||||
env: NodeJS.ProcessEnv = process.env
|
||||
): boolean {
|
||||
const value = env[key];
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ export function createFeatureFlags<T extends Record<string, FeatureFlag>>(
|
|||
*/
|
||||
export function isFeatureEnabled(
|
||||
featureName: string,
|
||||
defaultValue: boolean = false,
|
||||
defaultValue = false,
|
||||
env: NodeJS.ProcessEnv = process.env
|
||||
): boolean {
|
||||
const envVar = `FEATURE_${featureName.toUpperCase().replace(/[^A-Z0-9]/g, '_')}`;
|
||||
|
|
|
|||
|
|
@ -230,10 +230,7 @@ export function createCreditService(config: CreditServiceConfig) {
|
|||
/**
|
||||
* Calculate cost for multiple units of an operation
|
||||
*/
|
||||
async function calculateCost(
|
||||
operation: StandardOperationType,
|
||||
quantity: number = 1
|
||||
): Promise<number> {
|
||||
async function calculateCost(operation: StandardOperationType, quantity = 1): Promise<number> {
|
||||
const unitCost = await getOperationCost(operation);
|
||||
return unitCost * quantity;
|
||||
}
|
||||
|
|
@ -241,7 +238,7 @@ export function createCreditService(config: CreditServiceConfig) {
|
|||
/**
|
||||
* Calculate cost synchronously (uses cached values)
|
||||
*/
|
||||
function calculateCostSync(operation: StandardOperationType, quantity: number = 1): number {
|
||||
function calculateCostSync(operation: StandardOperationType, quantity = 1): number {
|
||||
const unitCost = getOperationCostSync(operation);
|
||||
return unitCost * quantity;
|
||||
}
|
||||
|
|
@ -288,7 +285,7 @@ export function createCreditService(config: CreditServiceConfig) {
|
|||
/**
|
||||
* Format credit amount for display
|
||||
*/
|
||||
function formatCredits(amount: number, locale: string = 'en-US'): string {
|
||||
function formatCredits(amount: number, locale = 'en-US'): string {
|
||||
return new Intl.NumberFormat(locale).format(amount);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
* Types for credit/mana operations across all apps
|
||||
*/
|
||||
|
||||
import type { OperationPricing, ManaBalance } from '@manacore/shared-subscription-types';
|
||||
|
||||
/**
|
||||
* Credit balance with additional metadata
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import { ErrorCode, ERROR_CODE_TO_HTTP_STATUS, ERROR_CODE_RETRYABLE } from '../types/error-codes';
|
||||
import {
|
||||
type ErrorCode,
|
||||
ERROR_CODE_TO_HTTP_STATUS,
|
||||
ERROR_CODE_RETRYABLE,
|
||||
} from '../types/error-codes';
|
||||
|
||||
/**
|
||||
* Additional context that can be attached to errors.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import type { Request, Response } from 'express';
|
||||
import { AppError } from '../errors/app-error';
|
||||
import { type AppError } from '../errors/app-error';
|
||||
import { isAppError, isCreditError, isRateLimitError } from '../guards/type-guards';
|
||||
import { ErrorCode } from '../types/error-codes';
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
import type {
|
||||
Feedback,
|
||||
CreateFeedbackInput,
|
||||
FeedbackQueryParams,
|
||||
FeedbackResponse,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
||||
import { CurrentUserData } from '../types';
|
||||
import { createParamDecorator, type ExecutionContext } from '@nestjs/common';
|
||||
import { type CurrentUserData } from '../types';
|
||||
|
||||
/**
|
||||
* Parameter decorator to extract the current user from the request.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This package provides a unified Supabase client and common database utilities.
|
||||
*/
|
||||
|
||||
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
||||
import { createClient, type SupabaseClient } from '@supabase/supabase-js';
|
||||
import type { SupabaseConfig } from '@manacore/shared-types';
|
||||
|
||||
export { SupabaseClient } from '@supabase/supabase-js';
|
||||
|
|
|
|||
|
|
@ -111,11 +111,7 @@ export function createUserSettingsStore(config: UserSettingsStoreConfig): UserSe
|
|||
/**
|
||||
* Make an API request to the settings endpoint
|
||||
*/
|
||||
async function apiRequest<T>(
|
||||
method: string,
|
||||
path: string,
|
||||
body?: object
|
||||
): Promise<T | null> {
|
||||
async function apiRequest<T>(method: string, path: string, body?: object): Promise<T | null> {
|
||||
const token = await getAccessToken();
|
||||
if (!token) {
|
||||
console.warn('No access token available for settings API');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export type LocaleKey = keyof typeof locales;
|
|||
*/
|
||||
export function formatDate(
|
||||
date: string | Date,
|
||||
formatStr: string = 'PPP',
|
||||
formatStr = 'PPP',
|
||||
locale: LocaleKey = 'de'
|
||||
): string {
|
||||
const dateObj = typeof date === 'string' ? parseISO(date) : date;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ export function formatDurationHumanReadable(seconds: number, locale: 'en' | 'de'
|
|||
/**
|
||||
* Format file size from bytes to human readable string
|
||||
*/
|
||||
export function formatFileSize(bytes: number, decimals: number = 1): string {
|
||||
export function formatFileSize(bytes: number, decimals = 1): string {
|
||||
if (bytes === 0) return '0 B';
|
||||
if (!Number.isFinite(bytes) || bytes < 0) return '--';
|
||||
|
||||
|
|
@ -107,18 +107,14 @@ export function formatFileSize(bytes: number, decimals: number = 1): string {
|
|||
/**
|
||||
* Format number with thousands separator
|
||||
*/
|
||||
export function formatNumber(num: number, locale: string = 'de-DE'): string {
|
||||
export function formatNumber(num: number, locale = 'de-DE'): string {
|
||||
return num.toLocaleString(locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format currency
|
||||
*/
|
||||
export function formatCurrency(
|
||||
amount: number,
|
||||
currency: string = 'EUR',
|
||||
locale: string = 'de-DE'
|
||||
): string {
|
||||
export function formatCurrency(amount: number, currency = 'EUR', locale = 'de-DE'): string {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency,
|
||||
|
|
@ -128,11 +124,7 @@ export function formatCurrency(
|
|||
/**
|
||||
* Format percentage
|
||||
*/
|
||||
export function formatPercent(
|
||||
value: number,
|
||||
decimals: number = 0,
|
||||
locale: string = 'de-DE'
|
||||
): string {
|
||||
export function formatPercent(value: number, decimals = 0, locale = 'de-DE'): string {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'percent',
|
||||
minimumFractionDigits: decimals,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export function capitalize(str: string): string {
|
|||
/**
|
||||
* Generate a random string ID
|
||||
*/
|
||||
export function generateId(length: number = 8): string {
|
||||
export function generateId(length = 8): string {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue