The minimalistic document archiving platform.
feat(cli): paperless-ngx exports import command (#622)
Corentin Thomasset432a192b94d0
diff --git a/.changeset/eight-cities-win.md b/.changeset/eight-cities-win.mdnew file mode 100644index 00000000..2600ef5e--- /dev/null+++ b/.changeset/eight-cities-win.md@@ -0,0 +1,5 @@+---+"@papra/api-sdk": patch+---++Added listOrganizations, listTags, createTag, addTagToDocument method in papra sdkdiff --git a/.changeset/mean-pugs-move.md b/.changeset/mean-pugs-move.mdnew file mode 100644index 00000000..c3a56ae4--- /dev/null+++ b/.changeset/mean-pugs-move.md@@ -0,0 +1,5 @@+---+"@papra/cli": minor+---++Added a paperless export importerdiff --git a/package.json b/package.jsonindex 735537d9..f9e03d46 100644--- a/package.json+++ b/package.json@@ -11,6 +11,7 @@"version": "changeset version && pnpm install --no-frozen-lockfile","changeset": "changeset","build:packages": "pnpm --filter './packages/*' --stream build",+ "build:packages:watch": "pnpm --filter './packages/*' --stream build:watch","test": "vitest run","test:watch": "vitest watch"},diff --git a/packages/api-sdk/src/api-client.ts b/packages/api-sdk/src/api-client.tsindex 928beb23..e183560d 100644--- a/packages/api-sdk/src/api-client.ts+++ b/packages/api-sdk/src/api-client.ts@@ -1,16 +1,22 @@-import type { PapraDocument } from './api-client.types';+import type { PapraDocument, PapraTag } from './api-client.types';import type { ApiClient } from './http-client';import { injectArguments } from '@corentinth/chisels';import { createApiClient } from './http-client';export const PAPRA_API_URL = 'https://api.papra.app';+export type Client = ReturnType<typeof createClient>;+export function createClient({ apiKey, apiBaseUrl = PAPRA_API_URL }: { apiKey: string; apiBaseUrl?: string }) {const { apiClient } = createApiClient({ apiKey, apiBaseUrl });const methods = injectArguments({uploadDocument,+ listOrganizations,+ listTags,+ createTag,+ addTagToDocument,},{ apiClient },);@@ -34,3 +40,54 @@ async function uploadDocument({body: formData,});}++async function listOrganizations({ apiClient }: { apiClient: ApiClient }) {+ return await apiClient<{ organizations: { id: string; name: string }[] }>('/api/organizations', {+ method: 'GET',+ });+}++async function listTags({+ organizationId,+ apiClient,+}: { organizationId: string; apiClient: ApiClient }) {+ return await apiClient<{ tags: PapraTag[] }>(`/api/organizations/${organizationId}/tags`, {+ method: 'GET',+ });+}++async function createTag({+ organizationId,+ name,+ color,+ description,+ apiClient,+}: {+ organizationId: string;+ name: string;+ color: string;+ description?: string;+ apiClient: ApiClient;+}) {+ return await apiClient<{ tag: PapraTag }>(`/api/organizations/${organizationId}/tags`, {+ method: 'POST',+ body: { name, color, description },+ });+}++async function addTagToDocument({+ organizationId,+ documentId,+ tagId,+ apiClient,+}: {+ organizationId: string;+ documentId: string;+ tagId: string;+ apiClient: ApiClient;+}) {+ return await apiClient<void>(`/api/organizations/${organizationId}/documents/${documentId}/tags`, {+ method: 'POST',+ body: { tagId },+ });+}diff --git a/packages/api-sdk/src/api-client.types.ts b/packages/api-sdk/src/api-client.types.tsindex bfaf4ff4..f12263e8 100644--- a/packages/api-sdk/src/api-client.types.ts+++ b/packages/api-sdk/src/api-client.types.ts@@ -15,3 +15,13 @@ export type PapraDocument = {isDeleted: boolean;content: string;};++export type PapraTag = {+ id: string;+ name: string;+ color: string;+ description?: string;+ organizationId: string;+ createdAt: string;+ updatedAt: string;+};diff --git a/packages/api-sdk/src/index.ts b/packages/api-sdk/src/index.tsindex a371d4ee..a3a9a5d8 100644--- a/packages/api-sdk/src/index.ts+++ b/packages/api-sdk/src/index.ts@@ -1 +1,3 @@export { createClient, PAPRA_API_URL } from './api-client';++export type { Client } from './api-client';diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 16ec772c..7e41f0a1 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -45,13 +45,15 @@"build:watch": "tsdown --watch"},"dependencies": {- "@clack/prompts": "^0.10.1",+ "@clack/prompts": "^1.0.0-alpha.6","@corentinth/chisels": "catalog:","@papra/api-sdk": "workspace:*","citty": "^0.1.6","conf": "^13.1.0",+ "jszip": "^3.10.1","mime-types": "^3.0.1","ofetch": "^1.4.1",+ "picocolors": "^1.1.1","valibot": "1.0.0-beta.10"},"devDependencies": {diff --git a/packages/cli/papra b/packages/cli/papranew file mode 100755index 00000000..ed212a0f--- /dev/null+++ b/packages/cli/papra@@ -0,0 +1,6 @@+#! /usr/bin/env sh++# Simple command to run the papra cli for better dx+# pass all args to the cli++pnpm --silent dev $@\ No newline at end of filediff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.tsindex f60a59d2..f44d2ace 100644--- a/packages/cli/src/cli.ts+++ b/packages/cli/src/cli.ts@@ -2,6 +2,7 @@ import { defineCommand, runMain } from 'citty';import { description, version } from '../package.json';import { configCommand } from './commands/config/config.command';import { documentsCommand } from './commands/documents/documents.command';+import { importCommand } from './commands/import/documents.command';import { cliName } from './config';const main = defineCommand({@@ -13,6 +14,7 @@ const main = defineCommand({subCommands: {documents: documentsCommand,config: configCommand,+ import: importCommand,},});diff --git a/packages/cli/src/commands/config/config.schemas.ts b/packages/cli/src/commands/config/config.schemas.tsindex dfa3f1fa..74881d91 100644--- a/packages/cli/src/commands/config/config.schemas.ts+++ b/packages/cli/src/commands/config/config.schemas.ts@@ -2,12 +2,10 @@ import * as v from 'valibot';export const apiUrlSchema = v.pipe(v.string(), v.url());export const apiKeySchema = v.string();-export const defaultOrganizationIdSchema = v.string();export const cliConfigSchema = v.object({apiUrl: v.optional(apiUrlSchema),apiKey: v.optional(apiKeySchema),- defaultOrganizationId: v.optional(defaultOrganizationIdSchema),});export type CliConfig = v.InferOutput<typeof cliConfigSchema>;diff --git a/packages/cli/src/commands/documents/documents.arguments.ts b/packages/cli/src/commands/documents/documents.arguments.tsindex d88a4c1c..3c5cadf1 100644--- a/packages/cli/src/commands/documents/documents.arguments.ts+++ b/packages/cli/src/commands/documents/documents.arguments.ts@@ -1,6 +1,6 @@export const organizationIdArgument = {type: 'string',- description: 'The organization ID',+ description: 'The organization ID. If not set, and you belong to multiple organizations, you\'ll be prompted to choose one.',alias: 'o',valueHint: 'organization-id',} as const;diff --git a/packages/cli/src/commands/documents/import/import.command.ts b/packages/cli/src/commands/documents/import/import.command.tsindex ed8932a2..8d172e90 100644--- a/packages/cli/src/commands/documents/import/import.command.ts+++ b/packages/cli/src/commands/documents/import/import.command.ts@@ -7,6 +7,7 @@ import { createClient } from '@papra/api-sdk';import { defineCommand } from 'citty';import mime from 'mime-types';import { reportClientError } from '../../../client.models';+import { getOrganizationId } from '../../../organizations/organizations.usecases';import { getConfig } from '../../config/config.services';import { organizationIdArgument } from '../documents.arguments';@@ -24,15 +25,7 @@ export const importCommand = defineCommand({organizationId: organizationIdArgument,},run: async ({ args }) => {- const { apiKey, apiUrl, defaultOrganizationId } = await getConfig();-- const orgId = args.organizationId ?? defaultOrganizationId;-- if (!orgId) {- prompts.cancel('No organization ID provided');-- process.exit(1);- }+ const { apiKey, apiUrl } = await getConfig();if (!apiKey) {prompts.cancel('No API key provided');@@ -40,11 +33,13 @@ export const importCommand = defineCommand({process.exit(1);}- const client = createClient({+ const apiClient = createClient({apiKey,apiBaseUrl: apiUrl,});+ const { organizationId } = await getOrganizationId({ apiClient, argOrganizationId: args.organizationId });+await prompts.tasks([{title: 'Importing document',@@ -55,8 +50,8 @@ export const importCommand = defineCommand({const file = new File([fileBuffer], fileName, { type: mimeType });- const [, error] = await safely(client.uploadDocument({- organizationId: orgId,+ const [, error] = await safely(apiClient.uploadDocument({+ organizationId,file,}));diff --git a/packages/cli/src/commands/import/documents.command.ts b/packages/cli/src/commands/import/documents.command.tsnew file mode 100644index 00000000..23f9efc5--- /dev/null+++ b/packages/cli/src/commands/import/documents.command.ts@@ -0,0 +1,12 @@+import { defineCommand } from 'citty';+import { paperlessCommand } from './paperless/paperless.command';++export const importCommand = defineCommand({+ meta: {+ name: 'import',+ description: 'Import documents from external sources',+ },+ subCommands: {+ paperless: paperlessCommand,+ },+});diff --git a/packages/cli/src/commands/import/paperless/paperless.command.ts b/packages/cli/src/commands/import/paperless/paperless.command.tsnew file mode 100644index 00000000..4b68b1be--- /dev/null+++ b/packages/cli/src/commands/import/paperless/paperless.command.ts@@ -0,0 +1,82 @@+import * as prompts from '@clack/prompts';+import { createClient } from '@papra/api-sdk';+import { defineCommand } from 'citty';+import pc from 'picocolors';+import { fileExists } from '../../../fs';+import { getOrganizationId } from '../../../organizations/organizations.usecases';+import { exit } from '../../../prompts/utils';+import { getConfig } from '../../config/config.services';+import { organizationIdArgument } from '../../documents/documents.arguments';+import { analyzeAndHandleTags, analyzeExport, displayImportSummary, importDocuments, selectDocumentStrategy } from './paperless.wizard';++export const paperlessCommand = defineCommand({+ meta: {+ name: 'paperless',+ description: 'Import documents from a Paperless NGX export',+ },+ args: {+ organizationId: organizationIdArgument,+ archivePath: {+ type: 'positional',+ description: 'The path to the Paperless NGX export archive',+ valueHint: './export.zip',+ required: true,+ },+ },+ run: async ({ args }) => {+ const { apiKey, apiUrl } = await getConfig();++ if (!apiKey) {+ exit(`API key not found. Please create an api key in your Papra account and set it using the ${pc.bold('papra config init')} command.`);+ }++ if (!fileExists(args.archivePath)) {+ exit(`Archive file not found: ${args.archivePath}`);+ }++ const apiClient = createClient({+ apiKey,+ apiBaseUrl: apiUrl,+ });++ prompts.intro('Paperless NGX Import');++ const { manifest, analysis } = await analyzeExport({ archivePath: args.archivePath });++ if (analysis.documentCount === 0) {+ prompts.outro('No documents found in export');+ return;+ }++ const { organizationId } = await getOrganizationId({+ apiClient,+ argOrganizationId: args.organizationId,+ });++ const { tagMapping } = await analyzeAndHandleTags({+ manifest,+ organizationId,+ apiClient,+ });++ const documentStrategy = await selectDocumentStrategy();++ if (documentStrategy === 'skip') {+ prompts.outro('Import cancelled');+ return;+ }++ const stats = await importDocuments({+ manifest,+ archivePath: args.archivePath,+ organizationId,+ apiClient,+ tagMapping,+ applyTags: documentStrategy === 'import-with-tags',+ });++ displayImportSummary({ stats });++ prompts.outro('Import finished');+ },+});diff --git a/packages/cli/src/commands/import/paperless/paperless.types.ts b/packages/cli/src/commands/import/paperless/paperless.types.tsnew file mode 100644index 00000000..4543c71d--- /dev/null+++ b/packages/cli/src/commands/import/paperless/paperless.types.ts@@ -0,0 +1,75 @@+export type PaperlessManifest = PaperlessManifestItem[];++export type PaperlessManifestItem+ = | PaperlessDocumentItem+ | PaperlessTagItem+ | PaperlessManifestOtherItem;++export type PaperlessDocumentItem = {+ model: 'documents.document';+ pk: number;+ fields: {+ title: string;+ content: string;+ created: string;+ modified: string;+ added: string;+ original_filename: string;+ tags: number[];+ correspondent: number | null;+ document_type: number | null;+ mime_type: string;+ };+ __exported_file_name__: string;+};++export type PaperlessTagItem = {+ model: 'documents.tag';+ pk: number;+ fields: {+ name: string;+ color: string;+ match?: string;+ matching_algorithm?: number;+ is_insensitive?: boolean;+ is_inbox_tag?: boolean;+ };+};++export type PaperlessCorrespondentItem = {+ model: 'documents.correspondent';+ pk: number;+ fields: {+ name: string;+ };+};++export type PaperlessDocumentTypeItem = {+ model: 'documents.documenttype';+ pk: number;+ fields: {+ name: string;+ };+};++export type PaperlessManifestOtherItem = {+ model: string;+ pk: number;+ fields: Record<string, unknown>;+};++export type ImportPreview = {+ documents: PaperlessDocumentItem[];+ tags: PaperlessTagItem[];+ correspondents: PaperlessCorrespondentItem[];+ documentTypes: PaperlessDocumentTypeItem[];+};++export type ImportResult = {+ success: boolean;+ documentsImported: number;+ documentsSkipped: number;+ documentsFailed: number;+ tagsCreated: number;+ errors: Array<{ fileName: string; error: string }>;+};diff --git a/packages/cli/src/commands/import/paperless/paperless.usecases.ts b/packages/cli/src/commands/import/paperless/paperless.usecases.tsnew file mode 100644index 00000000..e1db89d7--- /dev/null+++ b/packages/cli/src/commands/import/paperless/paperless.usecases.ts@@ -0,0 +1,67 @@+import type { Buffer } from 'node:buffer';+import type { ImportPreview, PaperlessCorrespondentItem, PaperlessDocumentItem, PaperlessDocumentTypeItem, PaperlessManifest, PaperlessTagItem } from './paperless.types';+import { readFile } from 'node:fs/promises';+import JSZip from 'jszip';++export async function extractManifest({ archivePath }: { archivePath: string }): Promise<PaperlessManifest> {+ const zipData = await readFile(archivePath);+ const zip = await JSZip.loadAsync(zipData);++ const manifestFile = zip.file('manifest.json');++ if (!manifestFile) {+ throw new Error('Invalid Paperless export: manifest.json not found');+ }++ const manifestContent = await manifestFile.async('text');+ const manifest = JSON.parse(manifestContent) as PaperlessManifest;++ return manifest;+}++export async function readArchive({ archivePath }: { archivePath: string }): Promise<JSZip> {+ const zipData = await readFile(archivePath);+ return await JSZip.loadAsync(zipData);+}++export async function extractFileFromArchive({+ archive,+ filePath,+}: {+ archive: JSZip;+ filePath: string;+}): Promise<Buffer> {+ const file = archive.file(filePath);++ if (!file) {+ throw new Error(`File not found in archive: ${filePath}`);+ }++ return await file.async('nodebuffer');+}++export function parseManifest({ manifest }: { manifest: PaperlessManifest }): ImportPreview {+ const documents: PaperlessDocumentItem[] = [];+ const tags: PaperlessTagItem[] = [];+ const correspondents: PaperlessCorrespondentItem[] = [];+ const documentTypes: PaperlessDocumentTypeItem[] = [];++ for (const item of manifest) {+ if (item.model === 'documents.document') {+ documents.push(item as PaperlessDocumentItem);+ } else if (item.model === 'documents.tag') {+ tags.push(item as PaperlessTagItem);+ } else if (item.model === 'documents.correspondent') {+ correspondents.push(item as PaperlessCorrespondentItem);+ } else if (item.model === 'documents.documenttype') {+ documentTypes.push(item as PaperlessDocumentTypeItem);+ }+ }++ return {+ documents,+ tags,+ correspondents,+ documentTypes,+ };+}diff --git a/packages/cli/src/commands/import/paperless/paperless.wizard.ts b/packages/cli/src/commands/import/paperless/paperless.wizard.tsnew file mode 100644index 00000000..f7aff0ce--- /dev/null+++ b/packages/cli/src/commands/import/paperless/paperless.wizard.ts@@ -0,0 +1,412 @@+import type { Client } from '@papra/api-sdk';+import type JSZip from 'jszip';+import type { PaperlessDocumentItem, PaperlessTagItem } from './paperless.types';+import * as prompts from '@clack/prompts';+import { safely } from '@corentinth/chisels';+import mime from 'mime-types';+import pc from 'picocolors';+import { getErrorMessage } from '../../../errors/errors.models';+import { exit, exitOnCancel } from '../../../prompts/utils';+import { extractFileFromArchive, extractManifest, parseManifest, readArchive } from './paperless.usecases';++function pluralize(count: number, singular: string, plural?: string): string {+ if (count === 1) {+ return `${count} ${singular}`;+ }+ return `${count} ${plural ?? `${singular}s`}`;+}++type TagStrategy = 'create-and-map' | 'create-all' | 'skip';+type DocumentStrategy = 'import-with-tags' | 'import-without-tags' | 'skip';++type ExportAnalysis = {+ documentCount: number;+ tagCount: number;+};++type TagAnalysis = {+ existingTags: Array<{ id: string; name: string }>;+ missingTags: PaperlessTagItem[];+ tagMapping: Map<number, string>;+};++type ImportStats = {+ documentsImported: number;+ documentsSkipped: number;+ documentsFailed: number;+ tagsCreated: number;+ errors: Array<{ fileName: string; error: string }>;+};++export async function analyzeExport({ archivePath }: { archivePath: string }): Promise<{+ manifest: Awaited<ReturnType<typeof extractManifest>>;+ analysis: ExportAnalysis;+}> {+ const [manifest, error] = await safely(extractManifest({ archivePath }));++ if (error) {+ exit(`Failed to extract manifest:\n${getErrorMessage(error)}`);+ }++ if (!manifest) {+ exit('Failed to extract manifest');+ }++ const preview = parseManifest({ manifest });++ const analysis: ExportAnalysis = {+ documentCount: preview.documents.length,+ tagCount: preview.tags.length,+ };++ prompts.note(+ [+ `${pc.green('✓')} Valid Paperless NGX export detected`,+ `${pc.green('✓')} Found ${pluralize(analysis.documentCount, 'document')}`,+ `${pc.green('✓')} Found ${pluralize(analysis.tagCount, 'tag')}`,+ ].join('\n'),+ 'Export file analysis',+ );++ return { manifest, analysis };+}++export async function analyzeAndHandleTags({+ manifest,+ organizationId,+ apiClient,+}: {+ manifest: Awaited<ReturnType<typeof extractManifest>>;+ organizationId: string;+ apiClient: Client;+}): Promise<TagAnalysis> {+ const preview = parseManifest({ manifest });++ const { tags: existingTags } = await apiClient.listTags({ organizationId });+ const missingTags = preview.tags.filter(+ tag => !existingTags.some(existingTag => existingTag.name === tag.fields.name),+ );++ prompts.note(+ preview.tags.length === 0+ ? 'No tags found in export'+ : [+ `${pluralize(preview.tags.length, 'tag')} found in export`,+ ` - ${pluralize(existingTags.length, 'tag')} have the same name in the Papra organization`,+ ` - ${pluralize(missingTags.length, 'tag')} need to be created`,+ ].join('\n'),+ 'Tags analysis',+ );++ if (preview.tags.length === 0) {+ return {+ existingTags,+ missingTags: [],+ tagMapping: new Map(),+ };+ }++ const tagStrategy = await selectTagStrategy({ hasMissingTags: missingTags.length > 0 });++ const tagMapping = await executeTagStrategy({+ strategy: tagStrategy,+ missingTags,+ existingTags,+ allTags: preview.tags,+ organizationId,+ apiClient,+ });++ return {+ existingTags,+ missingTags,+ tagMapping,+ };+}++async function selectTagStrategy({ hasMissingTags }: { hasMissingTags: boolean }): Promise<TagStrategy> {+ if (!hasMissingTags) {+ return 'create-and-map';+ }++ const strategy = await exitOnCancel(+ prompts.select({+ message: 'How should we handle tags?',+ options: [+ {+ value: 'create-and-map' as const,+ label: 'Create missing tags and map existing ones',+ hint: 'Recommended',+ },+ {+ value: 'create-all' as const,+ label: 'Create all tags from export',+ hint: 'Will create duplicate tags if names match',+ },+ {+ value: 'skip' as const,+ label: 'Skip tag import',+ hint: 'Documents will be imported without tags',+ },+ ],+ initialValue: 'create-and-map' as const,+ }),+ );++ return strategy;+}++async function executeTagStrategy({+ strategy,+ missingTags,+ existingTags,+ allTags,+ organizationId,+ apiClient,+}: {+ strategy: TagStrategy;+ missingTags: PaperlessTagItem[];+ existingTags: Array<{ id: string; name: string }>;+ allTags: PaperlessTagItem[];+ organizationId: string;+ apiClient: Client;+}): Promise<Map<number, string>> {+ const tagMapping = new Map<number, string>();++ if (strategy === 'skip') {+ return tagMapping;+ }++ const tagsToCreate = strategy === 'create-all' ? allTags : missingTags;++ if (tagsToCreate.length > 0) {+ const prog = prompts.progress({ max: tagsToCreate.length });+ prog.start(`Creating ${pluralize(tagsToCreate.length, 'tag')}`);++ let createdCount = 0;++ for (const [index, tag] of tagsToCreate.entries()) {+ prog.message(`Creating tag ${index + 1}/${tagsToCreate.length}: ${tag.fields.name}`);+ const [result, error] = await safely(+ apiClient.createTag({+ organizationId,+ name: tag.fields.name,+ color: tag.fields.color,+ }),+ );++ if (error) {+ prog.message(`Failed to create tag "${tag.fields.name}": ${getErrorMessage(error)}`);+ prompts.log.warn(`Failed to create tag "${tag.fields.name}": ${getErrorMessage(error)}`);+ } else if (result) {+ prog.message(`Created tag "${tag.fields.name}": ${result.tag.id}`);+ tagMapping.set(tag.pk, result.tag.id);+ createdCount++;+ }++ prog.advance(1);+ }++ prog.stop(`Created ${pluralize(createdCount, 'tag')} ✓`);+ }++ if (strategy === 'create-and-map') {+ for (const existingTag of existingTags) {+ const paperlessTag = allTags.find(tag => tag.fields.name === existingTag.name);+ if (paperlessTag && !tagMapping.has(paperlessTag.pk)) {+ tagMapping.set(paperlessTag.pk, existingTag.id);+ }+ }+ }++ return tagMapping;+}++export async function selectDocumentStrategy(): Promise<DocumentStrategy> {+ const strategy = await exitOnCancel(+ prompts.select({+ message: 'How should we import documents?',+ options: [+ {+ value: 'import-with-tags' as const,+ label: 'Import documents and apply tags',+ hint: 'Recommended',+ },+ {+ value: 'import-without-tags' as const,+ label: 'Import documents without tags',+ },+ {+ value: 'skip' as const,+ label: 'Skip document import',+ },+ ],+ initialValue: 'import-with-tags' as const,+ }),+ );++ return strategy;+}++export async function importDocuments({+ manifest,+ archivePath,+ organizationId,+ apiClient,+ tagMapping,+ applyTags,+}: {+ manifest: Awaited<ReturnType<typeof extractManifest>>;+ archivePath: string;+ organizationId: string;+ apiClient: Client;+ tagMapping: Map<number, string>;+ applyTags: boolean;+}): Promise<ImportStats> {+ const preview = parseManifest({ manifest });+ const documents = preview.documents;++ const stats: ImportStats = {+ documentsImported: 0,+ documentsSkipped: 0,+ documentsFailed: 0,+ tagsCreated: tagMapping.size,+ errors: [],+ };++ const prog = prompts.progress({ max: documents.length });+ prog.start(`Importing ${pluralize(documents.length, 'document')}`);++ const archive = await readArchive({ archivePath });++ for (const [index, document] of documents.entries()) {+ prog.message(`Importing document ${index + 1}/${documents.length}: ${document.fields.title}`);+ const [, error] = await safely(+ importSingleDocument({+ document,+ archive,+ organizationId,+ apiClient,+ tagMapping: applyTags ? tagMapping : new Map(),+ }),+ );++ if (error) {+ const isDuplicate = isDocumentAlreadyExistsError(error);++ if (isDuplicate) {+ stats.documentsSkipped++;+ } else {+ const errorMessage = getErrorMessage(error);+ stats.documentsFailed++;+ stats.errors.push({+ fileName: document.fields.original_filename,+ error: errorMessage,+ });++ prog.message(`Failed to import document "${document.fields.title}"`);+ }+ } else {+ prog.message(`Imported document "${document.fields.title}"`);+ stats.documentsImported++;+ }++ prog.advance(1);+ }++ prog.stop(`Import completed ✓`);++ return stats;+}++async function importSingleDocument({+ document,+ archive,+ organizationId,+ apiClient,+ tagMapping,+}: {+ document: PaperlessDocumentItem;+ archive: JSZip;+ organizationId: string;+ apiClient: Client;+ tagMapping: Map<number, string>;+}) {+ const file = await createFileFromDocument({ document, archive });++ const { document: uploadedDocument } = await apiClient.uploadDocument({+ organizationId,+ file,+ });++ const documentTags = document.fields.tags+ .map(tagPk => tagMapping.get(tagPk))+ .filter((tagId): tagId is string => tagId !== undefined);++ for (const tagId of documentTags) {+ const [, error] = await safely(+ apiClient.addTagToDocument({+ organizationId,+ documentId: uploadedDocument.id,+ tagId,+ }),+ );++ if (error) {+ prompts.log.warn(+ `Failed to add tag (ID: ${tagId}) to document "${document.fields.title}": ${getErrorMessage(error)}`,+ );+ }+ }++ return uploadedDocument;+}++async function createFileFromDocument({+ document,+ archive,+}: {+ document: PaperlessDocumentItem;+ archive: JSZip;+}): Promise<File> {+ const filePath = document.__exported_file_name__;+ const fileName = document.fields.original_filename ?? document.__exported_file_name__ ?? document.fields.title ?? 'untitled';++ const fileBuffer = await extractFileFromArchive({+ archive,+ filePath,+ });++ const mimeType = document.fields.mime_type ?? mime.lookup(fileName) ?? 'application/octet-stream';++ return new File([fileBuffer as BlobPart], fileName, { type: mimeType });+}++export function displayImportSummary({ stats }: { stats: ImportStats }): void {+ const summaryLines = [+ stats.tagsCreated > 0 ? `${pc.green('✓')} ${pluralize(stats.tagsCreated, 'tag')} created` : null,+ `${pc.green('✓')} ${pluralize(stats.documentsImported, 'document')} imported`,+ stats.documentsSkipped > 0 ? `${pc.yellow('⊘')} ${pluralize(stats.documentsSkipped, 'document')} skipped (already exist)` : null,+ stats.documentsFailed > 0 ? `${pc.red('✗')} ${pluralize(stats.documentsFailed, 'document')} failed` : null,+ ].filter(Boolean);++ prompts.note(summaryLines.join('\n'), 'Import summary');++ if (stats.errors.length > 0) {+ prompts.note(+ stats.errors.map(({ fileName, error }) => ` - ${fileName}: ${error}`).join('\n'),+ `Errors (${stats.errors.length})`,+ );+ }+}++function isDocumentAlreadyExistsError(error: unknown): boolean {+ if (!error || typeof error !== 'object') {+ return false;+ }++ const err = error as Record<string, unknown>;+ const status = err.status ?? err.statusCode;++ return status === 409;+}diff --git a/packages/cli/src/errors/errors.models.ts b/packages/cli/src/errors/errors.models.tsnew file mode 100644index 00000000..d367cda4--- /dev/null+++ b/packages/cli/src/errors/errors.models.ts@@ -0,0 +1,19 @@+import type { FetchError } from 'ofetch';++export function getErrorMessage(error: unknown): string {+ if (!(error instanceof Error)) {+ return String(error);+ }++ if (error.name === 'FetchError') {+ const fetchError = error as FetchError;++ if (fetchError.response) {+ return `API request failed with status ${fetchError.status} ${fetchError.statusText}`;+ }++ return `Network error, server unreachable.\n${fetchError.message}`;+ }++ return error.message;+}diff --git a/packages/cli/src/fs.ts b/packages/cli/src/fs.tsnew file mode 100644index 00000000..5fbe7f90--- /dev/null+++ b/packages/cli/src/fs.ts@@ -0,0 +1,5 @@+import fs from 'node:fs';++export function fileExists(path: string): boolean {+ return fs.existsSync(path);+}diff --git a/packages/cli/src/organizations/organizations.usecases.ts b/packages/cli/src/organizations/organizations.usecases.tsnew file mode 100644index 00000000..eb8eb3fa--- /dev/null+++ b/packages/cli/src/organizations/organizations.usecases.ts@@ -0,0 +1,43 @@+import type { Client } from '@papra/api-sdk';+import * as p from '@clack/prompts';+import pc from 'picocolors';+import { exit, exitOnCancel, exitOnError } from '../prompts/utils';++export async function promptForOrganization({ organizations }: { apiClient: Client; organizations: { id: string; name: string }[] }) {+ if (organizations.length === 0) {+ exit('No organizations found. Please create one in the Papra dashboard first.');+ }++ if (organizations.length === 1) {+ const { name, id } = organizations[0]!;+ p.log.info(`One organization found.\n${pc.bold(name)} (${pc.dim(id)})`);++ return { organizationId: id };+ }++ const selectedOrgId = await exitOnCancel(p.select({+ message: 'Select an organization to import stuff into:',+ options: organizations.map(org => ({+ value: org.id,+ label: `${pc.bold(org.name)} ${pc.dim(`(${org.id})`)}`,+ })),+ }));++ return { organizationId: selectedOrgId };+}++export async function getOrganizationId({ apiClient, argOrganizationId }: { apiClient: Client; argOrganizationId?: string }) {+ const { organizations } = await exitOnError(apiClient.listOrganizations(), { errorContext: 'Failed to fetch organizations.' });++ if (argOrganizationId) {+ const org = organizations.find(org => org.id === argOrganizationId);++ if (!org) {+ exit(`No organization found with ID ${pc.bold(argOrganizationId)}.`);+ }++ return { organizationId: org.id };+ }++ return promptForOrganization({ apiClient, organizations });+}diff --git a/packages/cli/src/prompts/utils.ts b/packages/cli/src/prompts/utils.tsnew file mode 100644index 00000000..42340f39--- /dev/null+++ b/packages/cli/src/prompts/utils.ts@@ -0,0 +1,41 @@+import process from 'node:process';+import { cancel, isCancel } from '@clack/prompts';+import { getErrorMessage } from '../errors/errors.models';++export async function exitOnCancel<T>(promise: Promise<T | symbol>): Promise<T> {+ const value = await promise;++ if (isCancel(value)) {+ exit('Operation cancelled');+ }++ if (typeof value === 'symbol') {+ // should never happen, but for type safety+ throw new TypeError('Unexpected symbol value');+ }+ return value;+}++export function exit(message: string): never {+ // There is a small indentation for the first line, so we adjust all lines to have the same style+ cancel(message.split('\n').join('\n '));+ process.exit(1);+}++export async function exitOnError<T>(+ promise: Promise<T>,+ {+ errorContext,+ }: {+ /**+ * Additional context to display with the error message.+ */+ errorContext?: string;+ } = { },+): Promise<T> {+ try {+ return await promise;+ } catch (error) {+ exit([errorContext, getErrorMessage(error)].filter(Boolean).join('\n'));+ }+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex bfa13c52..4ebf75eb 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -463,8 +463,8 @@ importers:packages/cli:dependencies:'@clack/prompts':- specifier: ^0.10.1- version: 0.10.1+ specifier: ^1.0.0-alpha.6+ version: 1.0.0-alpha.6'@corentinth/chisels':specifier: 'catalog:'version: 2.1.0@@ -477,12 +477,18 @@ importers:conf:specifier: ^13.1.0version: 13.1.0+ jszip:+ specifier: ^3.10.1+ version: 3.10.1mime-types:specifier: ^3.0.1version: 3.0.1ofetch:specifier: ^1.4.1version: 1.4.1+ picocolors:+ specifier: ^1.1.1+ version: 1.1.1valibot:specifier: 1.0.0-beta.10version: 1.0.0-beta.10([email protected])@@ -1156,18 +1162,18 @@ packages:'@changesets/[email protected]':resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==}- '@clack/[email protected]':- resolution: {integrity: sha512-NYQfcEy8MWIxrT5Fj8nIVchfRFA26yYKJcvBS7WlUIlw2OmQOY9DhGGXMovyI5J5PpxrCPGkgUi207EBrjpBvg==}-'@clack/[email protected]':resolution: {integrity: sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow==}- '@clack/[email protected]':- resolution: {integrity: sha512-Q0T02vx8ZM9XSv9/Yde0jTmmBQufZhPJfYAg2XrrrxWWaZgq1rr8nU8Hv710BQ1dhoP8rtY7YUdpGej2Qza/cw==}+ '@clack/[email protected]':+ resolution: {integrity: sha512-eG5P45+oShFG17u9I1DJzLkXYB1hpUgTLi32EfsMjSHLEqJUR8BOBCVFkdbUX2g08eh/HCi6UxNGpPhaac1LAA==}'@clack/[email protected]':resolution: {integrity: sha512-pMN5FcrEw9hUkZA4f+zLlzivQSeQf5dRGJjSUbvVYDLvpKCdQx5OaknvKzgbtXOizhP+SJJJjqEbOe55uKKfAw==}+ '@clack/[email protected]':+ resolution: {integrity: sha512-75NCtYOgDHVBE2nLdKPTDYOaESxO0GLAKC7INREp5VbS988Xua1u+588VaGlcvXiLc/kSwc25Cd+4PeTSpY6QQ==}+'@corentinth/[email protected]':resolution: {integrity: sha512-Tnk3NqeyP4WUMCn/o3DNj8IYmkn6u6ilsB71+OLnRSfgKPfUUHV9XJLXra9h/SA9H+c/X1A4oSjKQBviV5qmFw==}@@ -1256,11 +1262,9 @@ packages:'@esbuild-kit/[email protected]':resolution: {integrity: sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ==}- deprecated: 'Merged into tsx: https://tsx.is''@esbuild-kit/[email protected]':resolution: {integrity: sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA==}- deprecated: 'Merged into tsx: https://tsx.is''@esbuild/[email protected]':resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==}@@ -2138,12 +2142,6 @@ packages:peerDependencies:eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0- '@eslint-community/[email protected]':- resolution: {integrity: sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==}- engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}- peerDependencies:- eslint: ^6.0.0 || ^7.0.0 || >=8.0.0-'@eslint-community/[email protected]':resolution: {integrity: sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==}engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}@@ -2739,9 +2737,6 @@ packages:'@peculiar/[email protected]':resolution: {integrity: sha512-ioigvA6WSYN9h/YssMmmoIwgl3RvZlAYx4A/9jD2qaqXZwGcNlAxaw54eSx2QG1Yu7YyBC5Rku3nNoHrQ16YsQ==}- '@peculiar/[email protected]':- resolution: {integrity: sha512-/HtR91dvgog7z/WhCVdxZJ/jitJuIu8iTqiyWVgRE9Ac5imt2sT/E4obqIVGKQw7PIy+X6i8lVBoT6wC73XUgA==}-'@peculiar/[email protected]':resolution: {integrity: sha512-t4eYGNhXtLRxaP50h3sfO6aJebUCDGQACoeexcelL4roMFRRVgB20yBIu2LxsPh/tdW9I282gNgMOyg3ywg/mg==}@@ -2754,24 +2749,15 @@ packages:'@peculiar/[email protected]':resolution: {integrity: sha512-UgqSMBLNLR5TzEZ5ZzxR45Nk6VJrammxd60WMSkofyNzd3DQLSNycGWSK5Xg3UTYbXcDFyG8pA/7/y/ztVCa6A==}- '@peculiar/[email protected]':- resolution: {integrity: sha512-p6hsanvPhexRtYSOHihLvUUgrJ8y0FtOM97N5UEpC+VifFYyZa0iZ5cXjTkZoDwxJ/TTJ1IJo3HVTB2JJTpXvg==}-'@peculiar/[email protected]':resolution: {integrity: sha512-qMZ/vweiTHy9syrkkqWFvbT3eLoedvamcUdnnvwyyUNv5FgFXA3KP8td+ATibnlZ0EANW5PYRm8E6MJzEB/72Q==}- '@peculiar/[email protected]':- resolution: {integrity: sha512-QPeD8UA8axQREpgR5UTAfu2mqQmm97oUqahDtNdBcfj3qAnoXzFdQW+aNf/tD2WVXF8Fhmftxoj0eMIT++gX2w==}-'@peculiar/[email protected]':resolution: {integrity: sha512-YM/nFfskFJSlHqv59ed6dZlLZqtZQwjRVJ4bBAiWV08Oc+1rSd5lDZcBEx0lGDHfSoH3UziI2pXt2UM33KerPQ==}'@peculiar/[email protected]':resolution: {integrity: sha512-9f0hPOxiJDoG/bfNLAFven+Bd4gwz/VzrCIIWc1025LEI4BXO0U5fOCTNDPbbp2ll+UzqKsZ3g61mpBp74gk9A==}- '@peculiar/[email protected]':- resolution: {integrity: sha512-0dK5xqTqSLaxv1FHXIcd4Q/BZNuopg+u1l23hT9rOmQ1g4dNtw0g/RnEi+TboB0gOwGtrWn269v27cMgchFIIg==}-'@peculiar/[email protected]':resolution: {integrity: sha512-CpwtMCTJvfvYTFMuiME5IH+8qmDe3yEWzKHe7OOADbGfq7ohxeLaXwQo0q4du3qs0AII3UbLCvb9NF/6q0oTKQ==}@@ -3715,10 +3701,6 @@ packages:eslint: ^8.57.0 || ^9.0.0typescript: '>=4.8.4 <6.0.0'- '@typescript-eslint/[email protected]':- resolution: {integrity: sha512-q/O04vVnKHfrrhNAscndAn1tuQhIkwqnaW+eu5waD5IPts2eX1dgJxgqcPx5BX109/qAz7IG6VrEPTOYKCNfRQ==}- engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}-'@typescript-eslint/[email protected]':resolution: {integrity: sha512-lNCWCbq7rpg7qDsQrd3D6NyWYu+gkTENkG5IKYhUIcxSb59SQC/hEQ+MrG4sTgBVghTonNWq42bA/d4yYumldQ==}engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}@@ -4095,10 +4077,6 @@ packages:resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==}- resolution: {integrity: sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==}- engines: {node: '>=12.0.0'}-resolution: {integrity: sha512-UOCGPYbl0tv8+006qks/dTgV9ajs97X2p0FAbyS2iyCRrmLSRolDaHdp+v/CLgnzHc3fVB+CwYiUmei7ndFcgA==}engines: {node: '>=12.0.0'}@@ -6008,9 +5986,6 @@ packages:resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}- resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==}-resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}@@ -6357,7 +6332,6 @@ packages:resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}engines: {node: '>=10.5.0'}- deprecated: Use your platform's native DOMException insteadresolution: {integrity: sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==}@@ -7080,7 +7054,6 @@ packages:resolution: {integrity: sha512-+AbdxhM9kJsHtruUF39bwS/B0Fytw6Fr1o4ZAIAEqA6cke2xcoO2GleBw9Zw7nRzILVEgz7zBM5GiTJjie1G9A==}engines: {node: '>=14.0.0', npm: '>=6.0.0'}- deprecated: 'SECURITY: Multiple vulnerabilities fixed in 8.0.1 (XML injection, path traversal, command injection, protocol injection). Upgrade immediately: npm install [email protected]'hasBin: true@@ -9085,7 +9058,7 @@ snapshots:'@babel/[email protected]':dependencies:- '@babel/types': 7.28.0+ '@babel/types': 7.28.5'@babel/[email protected]':dependencies:@@ -9137,7 +9110,7 @@ snapshots:'@babel/[email protected]':dependencies:'@babel/helper-string-parser': 7.27.1- '@babel/helper-validator-identifier': 7.27.1+ '@babel/helper-validator-identifier': 7.28.5'@babel/[email protected]':dependencies:@@ -9361,25 +9334,25 @@ snapshots:human-id: 4.1.1prettier: 2.8.8- '@clack/[email protected]':+ '@clack/[email protected]':dependencies:picocolors: 1.1.1sisteransi: 1.0.5- '@clack/[email protected]':+ '@clack/[email protected]':dependencies:picocolors: 1.1.1sisteransi: 1.0.5- '@clack/[email protected]':+ '@clack/[email protected]':dependencies:- '@clack/core': 0.4.2+ '@clack/core': 0.5.0picocolors: 1.1.1sisteransi: 1.0.5- '@clack/[email protected]':+ '@clack/[email protected]':dependencies:- '@clack/core': 0.5.0+ '@clack/core': 1.0.0-alpha.6picocolors: 1.1.1sisteransi: 1.0.5@@ -9921,11 +9894,6 @@ snapshots:eslint: 9.38.0([email protected])ignore: 5.3.2- dependencies:- eslint: 9.38.0([email protected])- eslint-visitor-keys: 3.4.3-dependencies:eslint: 9.38.0([email protected])@@ -10549,8 +10517,8 @@ snapshots:'@peculiar/[email protected]':dependencies:- '@peculiar/asn1-schema': 2.3.15- asn1js: 3.0.5+ '@peculiar/asn1-schema': 2.5.0+ asn1js: 3.0.6tslib: 2.8.1'@peculiar/[email protected]':@@ -10568,13 +10536,6 @@ snapshots:asn1js: 3.0.6tslib: 2.8.1- '@peculiar/[email protected]':- dependencies:- '@peculiar/asn1-schema': 2.3.15- '@peculiar/asn1-x509': 2.3.15- asn1js: 3.0.5- tslib: 2.8.1-'@peculiar/[email protected]':dependencies:'@peculiar/asn1-schema': 2.5.0@@ -10609,13 +10570,6 @@ snapshots:asn1js: 3.0.6tslib: 2.8.1- '@peculiar/[email protected]':- dependencies:- '@peculiar/asn1-schema': 2.3.15- '@peculiar/asn1-x509': 2.3.15- asn1js: 3.0.5- tslib: 2.8.1-'@peculiar/[email protected]':dependencies:'@peculiar/asn1-schema': 2.5.0@@ -10623,12 +10577,6 @@ snapshots:asn1js: 3.0.6tslib: 2.8.1- '@peculiar/[email protected]':- dependencies:- asn1js: 3.0.5- pvtsutils: 1.3.6- tslib: 2.8.1-'@peculiar/[email protected]':dependencies:asn1js: 3.0.6@@ -10642,13 +10590,6 @@ snapshots:asn1js: 3.0.6tslib: 2.8.1- '@peculiar/[email protected]':- dependencies:- '@peculiar/asn1-schema': 2.3.15- asn1js: 3.0.5- pvtsutils: 1.3.6- tslib: 2.8.1-'@peculiar/[email protected]':dependencies:'@peculiar/asn1-schema': 2.5.0@@ -10772,9 +10713,9 @@ snapshots:'@rollup/[email protected]([email protected])':dependencies:- '@types/estree': 1.0.7+ '@types/estree': 1.0.8estree-walker: 2.0.2- picomatch: 4.0.2+ picomatch: 4.0.3optionalDependencies:rollup: 4.52.4@@ -10949,10 +10890,10 @@ snapshots:'@hexagon/base64': 1.1.28'@levischuck/tiny-cbor': 0.2.11'@peculiar/asn1-android': 2.3.15- '@peculiar/asn1-ecc': 2.3.15- '@peculiar/asn1-rsa': 2.3.15- '@peculiar/asn1-schema': 2.3.15- '@peculiar/asn1-x509': 2.3.15+ '@peculiar/asn1-ecc': 2.5.0+ '@peculiar/asn1-rsa': 2.5.0+ '@peculiar/asn1-schema': 2.5.0+ '@peculiar/asn1-x509': 2.5.0'@peculiar/x509': 1.14.0'@sindresorhus/[email protected]': {}@@ -11659,8 +11600,6 @@ snapshots:transitivePeerDependencies:- supports-color- '@typescript-eslint/[email protected]': {}-'@typescript-eslint/[email protected]': {}'@typescript-eslint/[email protected]([email protected])':@@ -12058,19 +11997,11 @@ snapshots:chai: 6.2.0tinyrainbow: 3.0.3- '@vitest/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':- dependencies:- '@vitest/spy': 4.0.3- estree-walker: 3.0.3- magic-string: 0.30.19- optionalDependencies:-'@vitest/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':dependencies:'@vitest/spy': 4.0.3estree-walker: 3.0.3- magic-string: 0.30.19+ magic-string: 0.30.21optionalDependencies:@@ -12078,7 +12009,7 @@ snapshots:dependencies:'@vitest/spy': 4.0.3estree-walker: 3.0.3- magic-string: 0.30.19+ magic-string: 0.30.21optionalDependencies:@@ -12094,7 +12025,7 @@ snapshots:'@vitest/[email protected]':dependencies:'@vitest/pretty-format': 4.0.3- magic-string: 0.30.19+ magic-string: 0.30.21pathe: 2.0.3'@vitest/[email protected]': {}@@ -12257,12 +12188,6 @@ snapshots:dependencies:safer-buffer: 2.1.2- dependencies:- pvtsutils: 1.3.6- pvutils: 1.1.3- tslib: 2.8.1-dependencies:pvtsutils: 1.3.6@@ -13343,8 +13268,8 @@ snapshots:dependencies:- '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))- '@typescript-eslint/types': 8.35.1+ '@eslint-community/eslint-utils': 4.9.0([email protected]([email protected]))+ '@typescript-eslint/types': 8.46.2eslint: 9.38.0([email protected])optionalDependencies:typescript: 5.8.3@@ -13371,7 +13296,7 @@ snapshots:dependencies:- '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))+ '@eslint-community/eslint-utils': 4.9.0([email protected]([email protected]))diff-sequences: 27.5.1eslint: 9.38.0([email protected])eslint-compat-utils: 0.6.5([email protected]([email protected]))@@ -13386,7 +13311,7 @@ snapshots:dependencies:- '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))+ '@eslint-community/eslint-utils': 4.9.0([email protected]([email protected]))enhanced-resolve: 5.18.2eslint: 9.38.0([email protected])eslint-plugin-es-x: 7.8.0([email protected]([email protected]))@@ -13423,7 +13348,7 @@ snapshots:dependencies:- '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))+ '@eslint-community/eslint-utils': 4.9.0([email protected]([email protected]))'@eslint-community/regexpp': 4.12.1comment-parser: 1.4.1eslint: 9.38.0([email protected])@@ -13458,7 +13383,7 @@ snapshots:dependencies:'@babel/helper-validator-identifier': 7.28.5- '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))+ '@eslint-community/eslint-utils': 4.9.0([email protected]([email protected]))'@eslint/plugin-kit': 0.3.3change-case: 5.4.4ci-info: 4.3.1@@ -13485,7 +13410,7 @@ snapshots:[email protected](@stylistic/[email protected]([email protected]([email protected])))(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))):dependencies:- '@eslint-community/eslint-utils': 4.7.0([email protected]([email protected]))+ '@eslint-community/eslint-utils': 4.9.0([email protected]([email protected]))eslint: 9.38.0([email protected])natural-compare: 1.4.0nth-check: 2.1.1@@ -13621,7 +13546,7 @@ snapshots:dependencies:- '@types/estree': 1.0.7+ '@types/estree': 1.0.8@@ -13698,6 +13623,10 @@ snapshots:optionalDependencies:picomatch: 4.0.2+ optionalDependencies:+ picomatch: 4.0.3+optionalDependencies:picomatch: 4.0.3@@ -14526,10 +14455,6 @@ snapshots:dependencies:'@jridgewell/sourcemap-codec': 1.5.0- dependencies:- '@jridgewell/sourcemap-codec': 1.5.5-dependencies:'@jridgewell/sourcemap-codec': 1.5.5@@ -16400,8 +16325,8 @@ snapshots:dependencies:- fdir: 6.4.4([email protected])- picomatch: 4.0.2+ fdir: 6.4.4([email protected])+ picomatch: 4.0.3dependencies:@@ -16883,7 +16808,7 @@ snapshots:[email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected]):dependencies:'@vitest/expect': 4.0.3- '@vitest/mocker': 4.0.3([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ '@vitest/mocker': 4.0.3([email protected](@types/[email protected])([email protected])([email protected])([email protected]))'@vitest/pretty-format': 4.0.3'@vitest/runner': 4.0.3'@vitest/snapshot': 4.0.3@@ -16892,7 +16817,7 @@ snapshots:debug: 4.4.3es-module-lexer: 1.7.0expect-type: 1.2.2- magic-string: 0.30.19+ magic-string: 0.30.21pathe: 2.0.3picomatch: 4.0.3std-env: 3.9.0@@ -16932,7 +16857,7 @@ snapshots:debug: 4.4.3es-module-lexer: 1.7.0expect-type: 1.2.2- magic-string: 0.30.19+ magic-string: 0.30.21pathe: 2.0.3picomatch: 4.0.3std-env: 3.9.0@@ -16972,7 +16897,7 @@ snapshots:debug: 4.4.3es-module-lexer: 1.7.0expect-type: 1.2.2- magic-string: 0.30.19+ magic-string: 0.30.21pathe: 2.0.3picomatch: 4.0.3std-env: 3.9.0@@ -17128,7 +17053,7 @@ snapshots:dependencies:eslint-visitor-keys: 3.4.3- yaml: 2.8.0+ yaml: 2.8.1