Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

refactor(utils): removed lodash-es (#552)

Corentin Thomasset8aabd28168fe
diff --git a/.changeset/great-hounds-talk.md b/.changeset/great-hounds-talk.md
new file mode 100644
index 00000000..4b9e1810
--- /dev/null
+++ b/.changeset/great-hounds-talk.md
@@ -0,0 +1,5 @@
+---
+"@papra/docker": patch
+---
+
+Lighten the client bundle by removing lodash dep
diff --git a/apps/papra-client/package.json b/apps/papra-client/package.json
index 0a4c3458..e324c588 100644
--- a/apps/papra-client/package.json
+++ b/apps/papra-client/package.json
@@ -44,7 +44,6 @@
"clsx": "^2.1.1",
"cmdk-solid": "^1.1.2",
"date-fns": "^4.1.0",
- "lodash-es": "^4.17.21",
"ofetch": "^1.4.1",
"posthog-js": "^1.255.1",
"radix3": "^1.1.2",
@@ -60,7 +59,6 @@
"@antfu/eslint-config": "catalog:",
"@iconify-json/tabler": "^1.2.19",
"@playwright/test": "^1.53.1",
- "@types/lodash-es": "^4.17.12",
"@types/node": "catalog:",
"eslint": "catalog:",
"jsdom": "^25.0.1",
diff --git a/apps/papra-client/src/modules/auth/auth.models.ts b/apps/papra-client/src/modules/auth/auth.models.ts
index dfebbe8b..e98d70b5 100644
--- a/apps/papra-client/src/modules/auth/auth.models.ts
+++ b/apps/papra-client/src/modules/auth/auth.models.ts
@@ -1,17 +1,17 @@
import type { Config } from '../config/config';
import type { SsoProviderConfig } from './auth.types';
-import { get } from 'lodash-es';
+import { get } from '../shared/utils/get';
import { ssoProviders } from './auth.constants';
export function isAuthErrorWithCode({ error, code }: { error: unknown; code: string }) {
- return get(error, 'code') === code;
+ return get(error, ['code']) === code;
}
export const isEmailVerificationRequiredError = ({ error }: { error: unknown }) => isAuthErrorWithCode({ error, code: 'EMAIL_NOT_VERIFIED' });
export function getEnabledSsoProviderConfigs({ config }: { config: Config }): SsoProviderConfig[] {
const enabledSsoProviders: SsoProviderConfig[] = [
- ...ssoProviders.filter(({ key }) => get(config, `auth.providers.${key}.isEnabled`)),
+ ...ssoProviders.filter(({ key }) => config.auth.providers[key]?.isEnabled),
...config.auth.providers.customs.map(({ providerId, providerName, providerIconUrl }) => ({
key: providerId,
name: providerName,
diff --git a/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx b/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx
index 20f00366..e0da2161 100644
--- a/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx
+++ b/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx
@@ -2,12 +2,12 @@ import type { Accessor, ParentComponent } from 'solid-js';
import type { Document } from '../documents/documents.types';
import { safely } from '@corentinth/chisels';
import { useNavigate, useParams } from '@solidjs/router';
-import { debounce } from 'lodash-es';
import { createContext, createEffect, createSignal, For, on, onCleanup, onMount, Show, useContext } from 'solid-js';
import { getDocumentIcon } from '../documents/document.models';
import { searchDocuments } from '../documents/documents.services';
import { useI18n } from '../i18n/i18n.provider';
import { cn } from '../shared/style/cn';
+import { debounce } from '../shared/utils/timing';
import { useThemeStore } from '../theme/theme.store';
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading } from '../ui/components/command';
diff --git a/apps/papra-client/src/modules/config/config.provider.tsx b/apps/papra-client/src/modules/config/config.provider.tsx
index 69082201..49b94999 100644
--- a/apps/papra-client/src/modules/config/config.provider.tsx
+++ b/apps/papra-client/src/modules/config/config.provider.tsx
@@ -1,8 +1,8 @@
import type { ParentComponent } from 'solid-js';
import type { Config, RuntimePublicConfig } from './config';
import { useQuery } from '@tanstack/solid-query';
-import { merge } from 'lodash-es';
import { createContext, Match, Switch, useContext } from 'solid-js';
+import { deepMerge } from '../shared/utils/object';
import { Button } from '../ui/components/button';
import { EmptyState } from '../ui/components/empty';
import { createToast } from '../ui/components/sonner';
@@ -31,7 +31,7 @@ export const ConfigProvider: ParentComponent = (props) => {
}));
const mergeConfigs = (runtimeConfig: RuntimePublicConfig): Config => {
- return merge({}, buildTimeConfig, runtimeConfig);
+ return deepMerge(buildTimeConfig, runtimeConfig);
};
const retry = async () => {
diff --git a/apps/papra-client/src/modules/demo/demo-api-mock.ts b/apps/papra-client/src/modules/demo/demo-api-mock.ts
index f774a446..e8140da9 100644
--- a/apps/papra-client/src/modules/demo/demo-api-mock.ts
+++ b/apps/papra-client/src/modules/demo/demo-api-mock.ts
@@ -1,9 +1,9 @@
import type { ApiKey } from '../api-keys/api-keys.types';
import type { Document } from '../documents/documents.types';
import type { Webhook } from '../webhooks/webhooks.types';
-import { get } from 'lodash-es';
import { FetchError } from 'ofetch';
import { createRouter } from 'radix3';
+import { get } from '../shared/utils/get';
import { defineHandler } from './demo-api-mock.models';
import {
apiKeyStorage,
@@ -341,9 +341,9 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
const tag = {
id: createId({ prefix: 'tag' }),
organizationId,
- name: get(body, 'name'),
- color: get(body, 'color'),
- description: get(body, 'description'),
+ name: get(body, ['name']) as string,
+ color: get(body, ['color']) as string,
+ description: (get(body, ['description']) ?? null) as string | null,
createdAt: new Date(),
updatedAt: new Date(),
};
@@ -396,7 +396,7 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
assert(organization, { status: 403 });
- const tagId = get(body, 'tagId');
+ const tagId = get(body, ['tagId']) as string;
assert(tagId, { status: 400 });
@@ -441,7 +441,7 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
handler: async ({ body }) => {
const organization = {
id: createId({ prefix: 'org' }),
- name: get(body, 'name'),
+ name: get(body, ['name']) as string,
createdAt: new Date(),
updatedAt: new Date(),
};
@@ -480,7 +480,7 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
assert(organization, { status: 403 });
- organization.name = get(body, 'name');
+ organization.name = get(body, ['name']) as string;
organization.updatedAt = new Date();
await organizationStorage.setItem(organizationId, organization);
@@ -506,10 +506,10 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
const taggingRule = {
id: createId({ prefix: 'tr' }),
organizationId,
- name: get(body, 'name'),
- description: get(body, 'description'),
- conditions: get(body, 'conditions'),
- actions: get(body, 'tagIds').map((tagId: string) => ({ tagId })),
+ name: get(body, ['name']) as string,
+ description: (get(body, ['description']) ?? '') as string,
+ conditions: get(body, ['conditions']) as any,
+ actions: (get(body, ['tagIds']) as string[]).map((tagId: string) => ({ tagId })),
createdAt: new Date(),
updatedAt: new Date(),
};
@@ -641,11 +641,11 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
const apiKey = {
id: createId({ prefix: 'apiKey' }),
- name: get(body, 'name'),
- permissions: get(body, 'permissions'),
- organizationIds: get(body, 'organizationIds'),
- allOrganizations: get(body, 'allOrganizations'),
- expiresAt: get(body, 'expiresAt'),
+ name: get(body, ['name']),
+ permissions: get(body, ['permissions']),
+ organizationIds: get(body, ['organizationIds']),
+ allOrganizations: get(body, ['allOrganizations']),
+ expiresAt: get(body, ['expiresAt']),
createdAt: new Date(),
updatedAt: new Date(),
prefix: token.slice(0, 11),
@@ -694,10 +694,10 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
const webhook: Webhook = {
id: createId({ prefix: 'webhook' }),
organizationId,
- name: get(body, 'name'),
- url: get(body, 'url'),
+ name: get(body, ['name']) as string,
+ url: get(body, ['url']) as string,
enabled: true,
- events: get(body, 'events'),
+ events: get(body, ['events']) as Webhook['events'],
createdAt: new Date(),
updatedAt: new Date(),
};
diff --git a/apps/papra-client/src/modules/documents/components/document-import-status.component.tsx b/apps/papra-client/src/modules/documents/components/document-import-status.component.tsx
index 76f5932b..0093a719 100644
--- a/apps/papra-client/src/modules/documents/components/document-import-status.component.tsx
+++ b/apps/papra-client/src/modules/documents/components/document-import-status.component.tsx
@@ -2,7 +2,6 @@ import type { ParentComponent } from 'solid-js';
import type { Document } from '../documents.types';
import { safely } from '@corentinth/chisels';
import { A } from '@solidjs/router';
-import { throttle } from 'lodash-es';
import { createContext, createSignal, For, Match, Show, Switch, useContext } from 'solid-js';
import { Portal } from 'solid-js/web';
import { useConfig } from '@/modules/config/config.provider';
@@ -10,6 +9,7 @@ import { useI18n } from '@/modules/i18n/i18n.provider';
import { promptUploadFiles } from '@/modules/shared/files/upload';
import { useI18nApiErrors } from '@/modules/shared/http/composables/i18n-api-errors';
import { cn } from '@/modules/shared/style/cn';
+import { throttle } from '@/modules/shared/utils/timing';
import { Button } from '@/modules/ui/components/button';
import { invalidateOrganizationDocumentsQuery } from '../documents.composables';
import { uploadDocument } from '../documents.services';
@@ -90,7 +90,7 @@ export const DocumentUploadProvider: ParentComponent = (props) => {
updateTaskStatus({ file, status: 'success', document });
}
- await throttledInvalidateOrganizationDocumentsQuery({ organizationId });
+ throttledInvalidateOrganizationDocumentsQuery({ organizationId });
}));
};
diff --git a/apps/papra-client/src/modules/documents/document.models.test.ts b/apps/papra-client/src/modules/documents/document.models.test.ts
index fa107381..d5adcb9d 100644
--- a/apps/papra-client/src/modules/documents/document.models.test.ts
+++ b/apps/papra-client/src/modules/documents/document.models.test.ts
@@ -1,11 +1,10 @@
import { icons as tablerIconSet } from '@iconify-json/tabler';
-import { values } from 'lodash-es';
import { describe, expect, test } from 'vitest';
import { getDaysBeforePermanentDeletion, getDocumentIcon, getDocumentNameExtension, getDocumentNameWithoutExtension, iconByFileType } from './document.models';
describe('files models', () => {
describe('iconByFileType', () => {
- const icons = values(iconByFileType);
+ const icons = Object.values(iconByFileType);
test('they must at least have the default icon', () => {
expect(iconByFileType['*']).toBeDefined();
diff --git a/apps/papra-client/src/modules/documents/pages/documents.page.tsx b/apps/papra-client/src/modules/documents/pages/documents.page.tsx
index 856591be..485d31eb 100644
--- a/apps/papra-client/src/modules/documents/pages/documents.page.tsx
+++ b/apps/papra-client/src/modules/documents/pages/documents.page.tsx
@@ -1,9 +1,9 @@
import type { Component } from 'solid-js';
import { useParams, useSearchParams } from '@solidjs/router';
import { keepPreviousData, useQuery } from '@tanstack/solid-query';
-import { castArray } from 'lodash-es';
import { createSignal, For, Show, Suspense } from 'solid-js';
import { useI18n } from '@/modules/i18n/i18n.provider';
+import { castArray } from '@/modules/shared/utils/array';
import { Tag } from '@/modules/tags/components/tag.component';
import { fetchTags } from '@/modules/tags/tags.services';
import { DocumentUploadArea } from '../components/document-upload-area.component';
diff --git a/apps/papra-client/src/modules/shared/http/api-client.models.ts b/apps/papra-client/src/modules/shared/http/api-client.models.ts
index 60ea5cf2..e5ec8f30 100644
--- a/apps/papra-client/src/modules/shared/http/api-client.models.ts
+++ b/apps/papra-client/src/modules/shared/http/api-client.models.ts
@@ -1,12 +1,12 @@
import type { FetchError } from 'ofetch';
-import { get } from 'lodash-es';
+import { getErrorStatus } from '../utils/errors';
export function shouldRefreshAuthTokens({ error }: { error: FetchError | unknown | undefined }) {
if (!error) {
return false;
}
- return get(error, 'status') === 401;
+ return getErrorStatus(error) === 401;
}
export function buildAuthHeader({ accessToken }: { accessToken?: string | null | undefined } = {}): Record<string, string> {
diff --git a/apps/papra-client/src/modules/shared/http/composables/i18n-api-errors.ts b/apps/papra-client/src/modules/shared/http/composables/i18n-api-errors.ts
index 87854575..4c5fcb49 100644
--- a/apps/papra-client/src/modules/shared/http/composables/i18n-api-errors.ts
+++ b/apps/papra-client/src/modules/shared/http/composables/i18n-api-errors.ts
@@ -1,7 +1,8 @@
import type { TranslationKeys } from '@/modules/i18n/locales.types';
-import { get } from 'lodash-es';
+import { castError } from '@corentinth/chisels';
import { FetchError } from 'ofetch';
import { useI18n } from '@/modules/i18n/i18n.provider';
+import { get } from '@/modules/shared/utils/get';
function codeToKey(code: string): TranslationKeys {
// Better auth may returns different error codes like INVALID_ORIGIN, INVALID_CALLBACKURL when the origin is invalid
@@ -23,9 +24,9 @@ export function useI18nApiErrors({ t = useI18n().t }: { t?: ReturnType<typeof us
}
if ('error' in args) {
- const { error } = args;
- const code = get(error, 'data.error.code') ?? get(error, 'code');
- const translation = code ? t(codeToKey(code)) : undefined;
+ const error = castError(args.error);
+ const code = get(error, ['data', 'error', 'code'], ['code']);
+ const translation = code && typeof code === 'string' ? t(codeToKey(code)) : undefined;
if (translation) {
return translation;
diff --git a/apps/papra-client/src/modules/shared/http/http-errors.ts b/apps/papra-client/src/modules/shared/http/http-errors.ts
index 1777f808..d62f5777 100644
--- a/apps/papra-client/src/modules/shared/http/http-errors.ts
+++ b/apps/papra-client/src/modules/shared/http/http-errors.ts
@@ -1,13 +1,13 @@
-import { get } from 'lodash-es';
+import { get } from '../utils/get';
export { isHttpErrorWithCode, isHttpErrorWithStatusCode, isRateLimitError };
function isHttpErrorWithCode({ error, code }: { error: unknown; code: string }) {
- return get(error, 'data.error.code') === code;
+ return get(error, ['data', 'error', 'code']) === code;
}
function isHttpErrorWithStatusCode({ error, statusCode }: { error: unknown; statusCode: number }) {
- return get(error, 'status') === statusCode;
+ return get(error, ['status']) === statusCode;
}
function isRateLimitError({ error }: { error: unknown }) {
diff --git a/apps/papra-client/src/modules/shared/signals/async-state.ts b/apps/papra-client/src/modules/shared/signals/async-state.ts
deleted file mode 100644
index b6bf0f17..00000000
--- a/apps/papra-client/src/modules/shared/signals/async-state.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import { castError } from '@corentinth/chisels';
-import { identity } from 'lodash-es';
-import { createSignal } from 'solid-js';
-import { createHook } from '../hooks/hooks';
-
-export { useAsyncState };
-
-function useAsyncState<Args, Return, ReturnFormatted = Return>(
- getter: (args: Args) => Promise<Return>,
- { initialData, formatValue = identity, immediate = false }: { initialData?: ReturnFormatted; formatValue?: (value: Return) => ReturnFormatted; immediate?: boolean } = {},
-) {
- const [getIsLoading, setIsLoading] = createSignal(false);
- const [getError, setError] = createSignal<Error | undefined>(undefined);
- const [getData, setData] = createSignal<ReturnFormatted | undefined>(initialData);
- const [getStatus, setStatus] = createSignal<'idle' | 'loading' | 'success' | 'error'>('idle');
-
- const successHook = createHook<{ data: Return; args: Args }>();
- const errorHook = createHook<{ error: Error; args: Args }>();
- const finishHook = createHook<{ data: ReturnFormatted | undefined; error: Error | undefined; args: Args }>();
-
- const execute = async (args: Args) => {
- setIsLoading(true);
- setStatus('loading');
-
- try {
- const data = await getter(args);
-
- // eslint-disable-next-line ts/no-unsafe-function-type
- setData(formatValue(data) as Exclude<ReturnFormatted, Function>);
- setError(undefined);
- setStatus('success');
- successHook.trigger({ data, args });
- return data;
- } catch (err) {
- const error = castError(err);
-
- console.error(error);
-
- setData(undefined);
- setError(error);
- setStatus('error');
- errorHook.trigger({ error, args });
- } finally {
- setIsLoading(false);
- finishHook.trigger({ data: getData(), error: getError(), args });
- }
- };
-
- if (immediate) {
- execute({} as Args);
- }
-
- return {
- getIsLoading,
- getError,
- getData,
- getStatus,
- execute,
- onSuccess: successHook.on,
- onError: errorHook.on,
- onFinish: finishHook.on,
- };
-}
diff --git a/apps/papra-client/src/modules/shared/utils/array.test.ts b/apps/papra-client/src/modules/shared/utils/array.test.ts
new file mode 100644
index 00000000..93a28e23
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/array.test.ts
@@ -0,0 +1,21 @@
+import { describe, expect, test } from 'vitest';
+import { castArray } from './array';
+
+describe('array', () => {
+ describe('castArray', () => {
+ test('wraps non-array values in an array', () => {
+ expect(castArray(5)).toEqual([5]);
+ expect(castArray('hello')).toEqual(['hello']);
+ expect(castArray({ key: 'value' })).toEqual([{ key: 'value' }]);
+ });
+
+ test('returns the same array if an array is provided', () => {
+ expect(castArray([1, 2, 3])).toEqual([1, 2, 3]);
+ expect(castArray(['a', 'b', 'c'])).toEqual(['a', 'b', 'c']);
+ expect(castArray([])).toEqual([]);
+
+ const objArray = [{ key: 'value1' }, { key: 'value2' }];
+ expect(castArray(objArray)).toEqual(objArray);
+ });
+ });
+});
diff --git a/apps/papra-client/src/modules/shared/utils/array.ts b/apps/papra-client/src/modules/shared/utils/array.ts
new file mode 100644
index 00000000..1b267d15
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/array.ts
@@ -0,0 +1,3 @@
+export function castArray<T>(value: T | T[]): T[] {
+ return Array.isArray(value) ? value : [value];
+}
diff --git a/apps/papra-client/src/modules/shared/utils/errors.ts b/apps/papra-client/src/modules/shared/utils/errors.ts
new file mode 100644
index 00000000..04611281
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/errors.ts
@@ -0,0 +1,9 @@
+import { isRecord } from './object';
+
+export function getErrorStatus(error: unknown): number | undefined {
+ if (isRecord(error) && 'status' in error && typeof error.status === 'number') {
+ return error.status;
+ }
+
+ return undefined;
+}
diff --git a/apps/papra-client/src/modules/shared/utils/get.test.ts b/apps/papra-client/src/modules/shared/utils/get.test.ts
new file mode 100644
index 00000000..c0430ce7
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/get.test.ts
@@ -0,0 +1,160 @@
+import { describe, expect, test } from 'vitest';
+import { get } from './get';
+
+describe('get', () => {
+ test('gets value from simple path', () => {
+ const obj = { user: { name: 'John', age: 30 } };
+
+ expect(get(obj, ['user', 'name'])).toBe('John');
+ expect(get(obj, ['user', 'age'])).toBe(30);
+ });
+
+ test('returns undefined for missing path', () => {
+ const obj = { user: { name: 'John' } };
+
+ expect(get(obj, ['user', 'missing'])).toBeUndefined();
+ expect(get(obj, ['missing', 'path'])).toBeUndefined();
+ });
+
+ test('returns undefined for null/undefined objects', () => {
+ expect(get(null, ['any'])).toBeUndefined();
+ expect(get(undefined, ['any'])).toBeUndefined();
+ });
+
+ test('returns undefined for non-object values', () => {
+ expect(get('string', ['any'])).toBeUndefined();
+ expect(get(123, ['any'])).toBeUndefined();
+ expect(get(true, ['any'])).toBeUndefined();
+ });
+
+ test('handles deeply nested paths', () => {
+ const obj = {
+ level1: {
+ level2: {
+ level3: {
+ value: 'deep',
+ },
+ },
+ },
+ };
+
+ expect(get(obj, ['level1', 'level2', 'level3', 'value'])).toBe('deep');
+ });
+
+ test('returns first non-undefined value from multiple paths', () => {
+ const obj = {
+ primary: undefined,
+ secondary: 'fallback',
+ tertiary: 'another',
+ };
+
+ expect(get(obj, ['missing'], ['secondary'])).toBe('fallback');
+ expect(get(obj, ['primary'], ['secondary'])).toBe('fallback');
+ expect(get(obj, ['missing'], ['another-missing'], ['tertiary'])).toBe('another');
+ });
+
+ test('returns undefined if all paths are undefined', () => {
+ const obj = { a: 1, b: 2 };
+
+ expect(get(obj, ['x'], ['y'], ['z'])).toBeUndefined();
+ });
+
+ test('handles paths with undefined intermediate values', () => {
+ const obj = {
+ user: {
+ profile: undefined,
+ },
+ };
+
+ expect(get(obj, ['user', 'profile', 'name'])).toBeUndefined();
+ });
+
+ test('handles arrays in paths', () => {
+ const obj = {
+ users: [
+ { name: 'John' },
+ { name: 'Jane' },
+ ],
+ };
+
+ expect(get(obj, ['users', '0', 'name'])).toBe('John');
+ expect(get(obj, ['users', '1', 'name'])).toBe('Jane');
+ });
+
+ test('handles empty path array', () => {
+ const obj = { value: 'test' };
+
+ expect(get(obj, [])).toBe(obj);
+ });
+
+ test('works with numeric keys', () => {
+ const obj = {
+ 123: { value: 'numeric key' },
+ };
+
+ expect(get(obj, ['123', 'value'])).toBe('numeric key');
+ });
+
+ test('handles objects with null prototype', () => {
+ const obj = Object.create(null);
+ obj.key = 'value';
+
+ expect(get(obj, ['key'])).toBe('value');
+ });
+
+ test('returns value even if it is falsy (but not undefined)', () => {
+ const obj = {
+ zero: 0,
+ emptyString: '',
+ false: false,
+ null: null,
+ };
+
+ expect(get(obj, ['zero'])).toBe(0);
+ expect(get(obj, ['emptyString'])).toBe('');
+ expect(get(obj, ['false'])).toBe(false);
+ expect(get(obj, ['null'])).toBe(null);
+ });
+
+ test('stops at first non-undefined value in fallback chain', () => {
+ const obj = {
+ first: undefined,
+ second: null, // null is not undefined
+ third: 'value',
+ };
+
+ expect(get(obj, ['first'], ['second'], ['third'])).toBe(null);
+ });
+
+ test('handles complex real-world scenario', () => {
+ const apiResponse = {
+ data: {
+ user: {
+ profile: {
+ contact: {
+ email: '[email protected]',
+ },
+ },
+ },
+ },
+ meta: {
+ fallbackEmail: '[email protected]',
+ },
+ };
+
+ // Try to get user email, fallback to admin email
+ expect(
+ get(apiResponse, ['data', 'user', 'profile', 'contact', 'email'], ['meta', 'fallbackEmail']),
+ ).toBe('[email protected]');
+
+ // If user email is missing, get admin email
+ const apiResponseWithoutUserEmail = {
+ data: { user: {} },
+ meta: { fallbackEmail: '[email protected]' },
+ };
+
+ expect(
+ get(apiResponseWithoutUserEmail, ['data', 'user', 'profile', 'contact', 'email'], ['meta', 'fallbackEmail']),
+ ).toBe('[email protected]');
+ });
+});
diff --git a/apps/papra-client/src/modules/shared/utils/get.ts b/apps/papra-client/src/modules/shared/utils/get.ts
new file mode 100644
index 00000000..cb83e70a
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/get.ts
@@ -0,0 +1,42 @@
+import { isObject } from './object';
+
+/**
+ * Gets a value from an object at the specified path.
+ * If multiple paths are provided, returns the first non-undefined value.
+ *
+ * @param obj - The object to query
+ * @param paths - One or more paths as string arrays (e.g., ['user', 'name'])
+ * @returns The value at the path, or undefined if not found
+ *
+ * @example
+ * const obj = { user: { name: 'John', age: 30 }, fallback: 'default' };
+ *
+ * get(obj, ['user', 'name']); // 'John'
+ * get(obj, ['user', 'missing']); // undefined
+ * get(obj, ['missing'], ['fallback']); // 'default' (first non-undefined)
+ * get(obj, ['a', 'b', 'c']); // undefined
+ */
+export function get(obj: unknown, ...paths: string[][]): unknown {
+ if (!isObject(obj)) {
+ return undefined;
+ }
+
+ for (const path of paths) {
+ let current: any = obj;
+
+ for (const key of path) {
+ if (isObject(current) && key in current) {
+ current = (current as Record<string, any>)[key];
+ } else {
+ current = undefined;
+ break;
+ }
+ }
+
+ if (current !== undefined) {
+ return current;
+ }
+ }
+
+ return undefined;
+}
diff --git a/apps/papra-client/src/modules/shared/utils/object.test.ts b/apps/papra-client/src/modules/shared/utils/object.test.ts
new file mode 100644
index 00000000..1fe11d4f
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/object.test.ts
@@ -0,0 +1,231 @@
+import { describe, expect, test } from 'vitest';
+import { deepMerge } from './object';
+
+describe('object utilities', () => {
+ describe('deepMerge', () => {
+ test('merges two flat objects', () => {
+ const a = { x: 1, y: 2 };
+ const b = { y: 3, z: 4 };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ x: 1, y: 3, z: 4 });
+ });
+
+ test('does not mutate original objects', () => {
+ const a = { x: 1, y: 2 };
+ const b = { y: 3, z: 4 };
+
+ deepMerge(a, b);
+
+ expect(a).toEqual({ x: 1, y: 2 });
+ expect(b).toEqual({ y: 3, z: 4 });
+ });
+
+ test('creates deep copies without shared references', () => {
+ const a = { nested: { value: 1 }, arr: [1, 2, 3] };
+ const b = { other: 'test' };
+
+ const result = deepMerge(a, b);
+
+ // Mutate the result
+ result.nested.value = 999;
+ result.arr.push(4);
+
+ // Original should be unchanged
+ expect(a.nested.value).toBe(1);
+ expect(a.arr).toEqual([1, 2, 3]);
+ });
+
+ test('deeply merges nested objects', () => {
+ const a = { nested: { a: 1, b: 2 }, x: 1 };
+ const b = { nested: { b: 3, c: 4 }, y: 2 };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({
+ x: 1,
+ y: 2,
+ nested: { a: 1, b: 3, c: 4 },
+ });
+ });
+
+ test('handles multiple levels of nesting', () => {
+ const a = {
+ level1: {
+ level2: {
+ a: 1,
+ b: 2,
+ },
+ x: 1,
+ },
+ };
+ const b = {
+ level1: {
+ level2: {
+ b: 3,
+ c: 4,
+ },
+ y: 2,
+ },
+ };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({
+ level1: {
+ level2: {
+ a: 1,
+ b: 3,
+ c: 4,
+ },
+ x: 1,
+ y: 2,
+ },
+ });
+ });
+
+ test('replaces arrays instead of merging them', () => {
+ const a = { arr: [1, 2, 3] };
+ const b = { arr: [4, 5] };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ arr: [4, 5] });
+ });
+
+ test('replaces primitives with objects', () => {
+ const a = { value: 'string' };
+ const b = { value: { nested: 'object' } };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ value: { nested: 'object' } });
+ });
+
+ test('replaces objects with primitives', () => {
+ const a = { value: { nested: 'object' } };
+ const b = { value: 'string' };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ value: 'string' });
+ });
+
+ test('handles null values', () => {
+ const a = { value: { nested: 'object' } };
+ const b = { value: null };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ value: null });
+ });
+
+ test('handles undefined values', () => {
+ const a = { x: 1, y: 2 };
+ const b = { y: undefined, z: 3 };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ x: 1, y: undefined, z: 3 });
+ });
+
+ test('handles empty objects', () => {
+ const a = { x: 1 };
+ const b = {};
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ x: 1 });
+ });
+
+ test('merges into empty object', () => {
+ const a = {};
+ const b = { x: 1, y: 2 };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({ x: 1, y: 2 });
+ });
+
+ test('does not merge Date objects', () => {
+ const date1 = new Date('2024-01-01');
+ const date2 = new Date('2024-12-31');
+
+ const a = { date: date1 };
+ const b = { date: date2 };
+
+ const result = deepMerge(a, b);
+
+ expect(result.date).toBe(date2);
+ });
+
+ test('merges class instances as plain objects', () => {
+ class MyClass {
+ constructor(public value: number) {}
+ }
+
+ const a = { instance: new MyClass(1) };
+ const b = { instance: new MyClass(2) };
+
+ const result = deepMerge(a, b);
+
+ // Class instances that look like plain objects get merged
+ expect(result.instance.value).toBe(2);
+ });
+
+ test('preserves type information', () => {
+ const a = { x: 1 as number };
+ const b = { y: 'hello' as string };
+
+ const result = deepMerge(a, b);
+
+ // Type assertion to verify TypeScript types
+ const x: number = result.x;
+ const y: string = result.y;
+
+ expect(x).toBe(1);
+ expect(y).toBe('hello');
+ });
+
+ test('handles complex nested structure', () => {
+ const a = {
+ config: {
+ api: {
+ baseUrl: 'https://old.com',
+ timeout: 5000,
+ },
+ features: {
+ darkMode: false,
+ },
+ },
+ };
+
+ const b = {
+ config: {
+ api: {
+ baseUrl: 'https://new.com',
+ },
+ features: {
+ experimental: true,
+ },
+ },
+ };
+
+ const result = deepMerge(a, b);
+
+ expect(result).toEqual({
+ config: {
+ api: {
+ baseUrl: 'https://new.com',
+ timeout: 5000,
+ },
+ features: {
+ darkMode: false,
+ experimental: true,
+ },
+ },
+ });
+ });
+ });
+});
diff --git a/apps/papra-client/src/modules/shared/utils/object.ts b/apps/papra-client/src/modules/shared/utils/object.ts
new file mode 100644
index 00000000..64ef7847
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/object.ts
@@ -0,0 +1,66 @@
+import type { Expand } from '@corentinth/chisels';
+
+export function isObject(value: unknown): value is object {
+ return typeof value === 'object' && value !== null;
+}
+
+/**
+ * Type guard to check if a value is a plain record object (not a Date, Array, or other special object)
+ */
+export function isRecord(obj: unknown): obj is Record<string, unknown> {
+ return (
+ isObject(obj)
+ && !Array.isArray(obj)
+ // Exclude Date objects and RegExp objects, and other built-in types
+ && Object.prototype.toString.call(obj) === '[object Object]'
+ );
+}
+
+/**
+ * Deep merges multiple objects into a new object.
+ * Later objects override properties from earlier objects.
+ * Only plain objects are merged recursively - arrays and other types are replaced.
+ *
+ * @param objects - Objects to merge
+ * @returns A new merged object
+ *
+ * @example
+ * const a = { x: 1, nested: { a: 1 } };
+ * const b = { y: 2, nested: { b: 2 } };
+ * const c = { z: 3, nested: { c: 3 } };
+ * const result = deepMerge(a, b, c);
+ * // { x: 1, y: 2, z: 3, nested: { a: 1, b: 2, c: 3 } }
+ */
+export function deepMerge<T extends Record<string, any>[]>(
+ ...objects: T
+): T extends [infer First, ...infer Rest]
+ ? Rest extends Record<string, any>[]
+ ? Expand<First & DeepMergeAll<Rest>>
+ : First
+ : Record<string, unknown> {
+ return objects.reduce((prev, obj) => {
+ const result = { ...prev };
+
+ Object.keys(obj).forEach((key) => {
+ const pVal = result[key];
+ const oVal = obj[key];
+
+ if (isRecord(pVal) && isRecord(oVal)) {
+ result[key] = deepMerge(pVal, oVal);
+ } else if (isRecord(oVal)) {
+ result[key] = deepMerge({}, oVal);
+ } else if (Array.isArray(oVal)) {
+ result[key] = [...oVal];
+ } else {
+ result[key] = oVal;
+ }
+ });
+
+ return result;
+ }, {}) as any;
+}
+
+// Helper type for merging multiple objects
+type DeepMergeAll<T extends readonly any[]> = T extends [infer First, ...infer Rest]
+ ? First & DeepMergeAll<Rest>
+ : unknown;
diff --git a/apps/papra-client/src/modules/shared/utils/timing.test.ts b/apps/papra-client/src/modules/shared/utils/timing.test.ts
new file mode 100644
index 00000000..cbab6a52
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/timing.test.ts
@@ -0,0 +1,312 @@
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import { debounce, throttle } from './timing';
+
+describe('debounce', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ test('delays function execution until after wait time', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 100);
+
+ debouncedFunc();
+
+ expect(func).not.toHaveBeenCalled();
+
+ vi.advanceTimersByTime(150);
+
+ expect(func).toHaveBeenCalledTimes(1);
+ });
+
+ test('only executes the last call when invoked multiple times rapidly', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 100);
+
+ debouncedFunc('first');
+ debouncedFunc('second');
+ debouncedFunc('third');
+
+ expect(func).not.toHaveBeenCalled();
+
+ vi.advanceTimersByTime(150);
+
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith('third');
+ });
+
+ test('executes multiple times if calls are spaced out beyond wait time', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 60);
+
+ debouncedFunc('first');
+ vi.advanceTimersByTime(100);
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith('first');
+
+ debouncedFunc('second');
+ vi.advanceTimersByTime(100);
+ expect(func).toHaveBeenCalledTimes(2);
+ expect(func).toHaveBeenCalledWith('second');
+ });
+
+ test('preserves function arguments correctly', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 100);
+
+ debouncedFunc('arg1', 'arg2', 'arg3');
+
+ vi.advanceTimersByTime(150);
+
+ expect(func).toHaveBeenCalledWith('arg1', 'arg2', 'arg3');
+ });
+
+ test('works with async functions', () => {
+ const asyncFunc = vi.fn(async (value: string) => {
+ return `processed-${value}`;
+ });
+
+ const debouncedFunc = debounce(asyncFunc, 100);
+
+ debouncedFunc('test');
+
+ vi.advanceTimersByTime(150);
+
+ expect(asyncFunc).toHaveBeenCalledTimes(1);
+ expect(asyncFunc).toHaveBeenCalledWith('test');
+ });
+
+ test('works with functions that have multiple parameter types', () => {
+ const func = vi.fn((str: string, num: number, obj: { key: string }) => {
+ return { str, num, obj };
+ });
+
+ const debouncedFunc = debounce(func, 100);
+
+ debouncedFunc('hello', 42, { key: 'value' });
+
+ vi.advanceTimersByTime(150);
+
+ expect(func).toHaveBeenCalledWith('hello', 42, { key: 'value' });
+ });
+
+ test('handles zero wait time', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 0);
+
+ debouncedFunc('test');
+
+ expect(func).not.toHaveBeenCalled();
+
+ vi.advanceTimersByTime(10);
+
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith('test');
+ });
+
+ test('cancels previous timeout when called again before wait time', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 100);
+
+ debouncedFunc('first');
+ vi.advanceTimersByTime(50);
+
+ debouncedFunc('second');
+ vi.advanceTimersByTime(50);
+
+ // First call should be cancelled
+ expect(func).not.toHaveBeenCalled();
+
+ vi.advanceTimersByTime(60);
+
+ // Only second call should execute
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith('second');
+ });
+
+ test('works with no arguments', () => {
+ const func = vi.fn();
+ const debouncedFunc = debounce(func, 100);
+
+ debouncedFunc();
+
+ vi.advanceTimersByTime(150);
+
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith();
+ });
+
+ test('preserves type safety for function parameters', () => {
+ // Type-only test - this will fail TypeScript compilation if types are wrong
+ const typedFunc = (name: string, age: number) => ({ name, age });
+ const debouncedTypedFunc = debounce(typedFunc, 100);
+
+ // This should compile without errors
+ debouncedTypedFunc('John', 30);
+
+ // These should cause TypeScript errors (commented out):
+ // debouncedTypedFunc(123, 'wrong'); // Wrong argument types
+ // debouncedTypedFunc('John'); // Missing argument
+
+ vi.advanceTimersByTime(150);
+ });
+});
+
+describe('throttle', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ test('invokes function immediately on first call', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc('test');
+
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith('test');
+ });
+
+ test('ignores rapid calls within wait period', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc('first');
+ throttledFunc('second');
+ throttledFunc('third');
+
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith('first');
+ });
+
+ test('invokes function again after wait period', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc('first');
+ expect(func).toHaveBeenCalledTimes(1);
+
+ vi.advanceTimersByTime(150);
+
+ throttledFunc('second');
+ expect(func).toHaveBeenCalledTimes(2);
+ expect(func).toHaveBeenCalledWith('second');
+ });
+
+ test('schedules trailing call if invoked during wait period', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc('first');
+ expect(func).toHaveBeenCalledTimes(1);
+
+ vi.advanceTimersByTime(50);
+ throttledFunc('second');
+ expect(func).toHaveBeenCalledTimes(1);
+
+ // Should invoke after remaining wait time
+ vi.advanceTimersByTime(50);
+ expect(func).toHaveBeenCalledTimes(2);
+ expect(func).toHaveBeenCalledWith('second');
+ });
+
+ test('uses latest arguments for trailing call', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc('first');
+ expect(func).toHaveBeenCalledTimes(1);
+
+ vi.advanceTimersByTime(30);
+ throttledFunc('second');
+
+ vi.advanceTimersByTime(30);
+ throttledFunc('third');
+
+ vi.advanceTimersByTime(40);
+ expect(func).toHaveBeenCalledTimes(2);
+ expect(func).toHaveBeenCalledWith('third');
+ });
+
+ test('works with multiple parameter types', () => {
+ const func = vi.fn((str: string, num: number, obj: { key: string }) => {
+ return { str, num, obj };
+ });
+
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc('hello', 42, { key: 'value' });
+
+ expect(func).toHaveBeenCalledWith('hello', 42, { key: 'value' });
+ });
+
+ test('works with async functions', () => {
+ const asyncFunc = vi.fn(async (value: string) => {
+ return `processed-${value}`;
+ });
+
+ const throttledFunc = throttle(asyncFunc, 100);
+
+ throttledFunc('test');
+
+ expect(asyncFunc).toHaveBeenCalledTimes(1);
+ expect(asyncFunc).toHaveBeenCalledWith('test');
+ });
+
+ test('works with no arguments', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ throttledFunc();
+
+ expect(func).toHaveBeenCalledTimes(1);
+ expect(func).toHaveBeenCalledWith();
+ });
+
+ test('preserves type safety for function parameters', () => {
+ // Type-only test - this will fail TypeScript compilation if types are wrong
+ const typedFunc = (name: string, age: number) => ({ name, age });
+ const throttledTypedFunc = throttle(typedFunc, 100);
+
+ // This should compile without errors
+ throttledTypedFunc('John', 30);
+
+ // These should cause TypeScript errors (commented out):
+ // throttledTypedFunc(123, 'wrong'); // Wrong argument types
+ // throttledTypedFunc('John'); // Missing argument
+
+ expect(true).toBe(true);
+ });
+
+ test('handles multiple invocations over time correctly', () => {
+ const func = vi.fn();
+ const throttledFunc = throttle(func, 100);
+
+ // First call - immediate
+ throttledFunc('call1');
+ expect(func).toHaveBeenCalledTimes(1);
+
+ // Within wait period - scheduled
+ vi.advanceTimersByTime(50);
+ throttledFunc('call2');
+ expect(func).toHaveBeenCalledTimes(1);
+
+ // Complete wait period - trailing call executes
+ vi.advanceTimersByTime(50);
+ expect(func).toHaveBeenCalledTimes(2);
+
+ // Wait full period before next call
+ vi.advanceTimersByTime(100);
+ throttledFunc('call3');
+ expect(func).toHaveBeenCalledTimes(3);
+ expect(func).toHaveBeenCalledWith('call3');
+ });
+});
diff --git a/apps/papra-client/src/modules/shared/utils/timing.ts b/apps/papra-client/src/modules/shared/utils/timing.ts
new file mode 100644
index 00000000..782933b1
--- /dev/null
+++ b/apps/papra-client/src/modules/shared/utils/timing.ts
@@ -0,0 +1,87 @@
+/**
+ * Creates a debounced function that delays invoking func until after wait milliseconds
+ * have elapsed since the last time the debounced function was invoked.
+ *
+ * @param func - The function to debounce
+ * @param waitMs - The number of milliseconds to delay
+ * @returns The debounced function
+ *
+ * @example
+ * const search = debounce(async (query: string) => {
+ * const results = await searchAPI(query);
+ * return results;
+ * }, 300);
+ *
+ * search('hello'); // Only the last call within 300ms will execute
+ */
+export function debounce<Args extends unknown[], Return>(
+ func: (...args: Args) => Return,
+ waitMs: number = 500,
+): (...args: Args) => void {
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
+
+ return (...args: Args): void => {
+ if (timeoutId !== undefined) {
+ clearTimeout(timeoutId);
+ }
+
+ timeoutId = setTimeout(() => {
+ func(...args);
+ timeoutId = undefined;
+ }, waitMs);
+ };
+}
+
+/**
+ * Creates a throttled function that only invokes func at most once per every wait milliseconds.
+ * The throttled function will invoke func on the leading edge of the timeout.
+ *
+ * @param func - The function to throttle
+ * @param waitMs - The number of milliseconds to throttle invocations to
+ * @returns The throttled function
+ *
+ * @example
+ * const handleScroll = throttle(() => {
+ * console.log('Scroll event');
+ * }, 100);
+ *
+ * window.addEventListener('scroll', handleScroll);
+ */
+export function throttle<Args extends unknown[], Return>(
+ func: (...args: Args) => Return,
+ waitMs: number = 500,
+): (...args: Args) => void {
+ let lastCallTime: number | undefined;
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
+
+ return (...args: Args): void => {
+ const now = Date.now();
+
+ if (lastCallTime === undefined) {
+ // First call - invoke immediately
+ func(...args);
+ lastCallTime = now;
+ return;
+ }
+
+ const timeSinceLastCall = now - lastCallTime;
+
+ if (timeSinceLastCall >= waitMs) {
+ // Enough time has passed - invoke immediately
+ func(...args);
+ lastCallTime = now;
+ return;
+ }
+
+ // Schedule invocation for when the wait period ends
+ if (timeoutId !== undefined) {
+ clearTimeout(timeoutId);
+ }
+
+ timeoutId = setTimeout(() => {
+ func(...args);
+ lastCallTime = Date.now();
+ timeoutId = undefined;
+ }, waitMs - timeSinceLastCall);
+ };
+}
diff --git a/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx b/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
index d174040b..5ec2d4df 100644
--- a/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
+++ b/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
@@ -4,12 +4,12 @@ import type { Organization } from '@/modules/organizations/organizations.types';
import { useNavigate, useParams } from '@solidjs/router';
import { useQuery } from '@tanstack/solid-query';
-import { get } from 'lodash-es';
import { createEffect, on, Show } from 'solid-js';
import { useConfig } from '@/modules/config/config.provider';
import { DocumentUploadProvider } from '@/modules/documents/components/document-import-status.component';
import { useI18n } from '@/modules/i18n/i18n.provider';
import { fetchOrganization, fetchOrganizations } from '@/modules/organizations/organizations.services';
+import { getErrorStatus } from '@/modules/shared/utils/errors';
import { UpgradeDialog } from '@/modules/subscriptions/components/upgrade-dialog.component';
import { fetchOrganizationSubscription } from '@/modules/subscriptions/subscriptions.services';
import { Button } from '../components/button';
@@ -125,7 +125,7 @@ const OrganizationLayoutSideNav: Component = () => {
() => organizationQuery.error,
(error) => {
if (error) {
- const status = get(error, 'status');
+ const status = getErrorStatus(error);
if (status && [
400, // when the id of the organization is not valid
@@ -201,7 +201,7 @@ export const OrganizationLayout: ParentComponent = (props) => {
() => query.error,
(error) => {
if (error) {
- const status = get(error, 'status');
+ const status = getErrorStatus(error);
if (status && [401, 403].includes(status)) {
navigate('/');
diff --git a/apps/papra-client/uno.config.ts b/apps/papra-client/uno.config.ts
index aa19b97f..3702f2b0 100644
--- a/apps/papra-client/uno.config.ts
+++ b/apps/papra-client/uno.config.ts
@@ -1,4 +1,3 @@
-import { uniq, values } from 'lodash-es';
import {
defineConfig,
presetIcons,
@@ -113,9 +112,9 @@ export default defineConfig({
},
},
safelist: [
- ...uniq([
- ...values(iconByFileType),
- ...values(documentActivityIcon),
+ ...new Set([
+ ...Object.values(iconByFileType),
+ ...Object.values(documentActivityIcon),
...(ssoProviders.map(p => p.icon)),
]),
],
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 517da9e9..b8e1a295 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,18 +12,12 @@ catalogs:
'@types/node':
specifier: ^22.15.21
version: 22.16.0
- '@vitest/coverage-v8':
- specifier: ^3.0.2
- version: 3.2.4
better-auth:
specifier: 1.3.4
version: 1.3.4
eslint:
specifier: ^9.30.1
version: 9.30.1
- tsdown:
- specifier: ^0.13.4
- version: 0.13.4
typescript:
specifier: ^5.6.2
version: 5.8.3
@@ -168,9 +162,6 @@ importers:
date-fns:
specifier: ^4.1.0
version: 4.1.0
- lodash-es:
- specifier: ^4.17.21
- version: 4.17.21
ofetch:
specifier: ^1.4.1
version: 1.4.1
@@ -211,9 +202,6 @@ importers:
'@playwright/test':
specifier: ^1.53.1
version: 1.53.1
- '@types/lodash-es':
- specifier: ^4.17.12
- version: 4.17.12
'@types/node':
specifier: 'catalog:'
version: 22.16.0
@@ -10700,12 +10688,6 @@ snapshots:
eslint: 9.27.0([email protected])
eslint-visitor-keys: 3.4.3
- dependencies:
- eslint: 9.30.1([email protected])
- eslint-visitor-keys: 3.4.3
- optional: true
-
dependencies:
eslint: 9.27.0([email protected])
@@ -13276,14 +13258,14 @@ snapshots:
'@typescript-eslint/types': 8.35.1
'@typescript-eslint/typescript-estree': 8.35.1([email protected])
astrojs-compiler-sync: 1.0.1(@astrojs/[email protected])
- debug: 4.4.1
+ debug: 4.4.3
entities: 4.5.0
eslint-scope: 8.4.0
eslint-visitor-keys: 4.2.1
espree: 10.4.0
globby: 11.1.0
is-glob: 4.0.3
- semver: 7.7.2
+ semver: 7.7.3
transitivePeerDependencies:
- supports-color
- typescript
@@ -14430,14 +14412,14 @@ snapshots:
dependencies:
- '@eslint-community/eslint-utils': 4.5.1([email protected]([email protected]))
- '@jridgewell/sourcemap-codec': 1.5.0
- '@typescript-eslint/types': 8.26.1
+ '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))
+ '@jridgewell/sourcemap-codec': 1.5.5
+ '@typescript-eslint/types': 8.35.1
astro-eslint-parser: 1.1.0([email protected])
eslint: 9.30.1([email protected])
- eslint-compat-utils: 0.6.4([email protected]([email protected]))
+ eslint-compat-utils: 0.6.5([email protected]([email protected]))
globals: 15.15.0
- postcss: 8.5.3
+ postcss: 8.5.6
postcss-selector-parser: 7.0.0
transitivePeerDependencies:
- supports-color
@@ -17092,7 +17074,7 @@ snapshots:
dependencies:
inherits: 2.0.4
- string_decoder: 1.1.1
+ string_decoder: 1.3.0
util-deprecate: 1.0.2
@@ -17478,8 +17460,7 @@ snapshots:
- optional: true
dependencies: