From fefa0a03847075f6e5016135cb38dfcde382a9ce Mon Sep 17 00:00:00 2001 From: Sebastian Krupinski Date: Sat, 14 Feb 2026 11:45:34 -0500 Subject: [PATCH] chore: standardize protocol Signed-off-by: Sebastian Krupinski --- lib/Controllers/DefaultController.php | 41 +- lib/Manager.php | 24 +- package-lock.json | 1500 +++++++++++++++++++++++++ src/composables/useMailSync.ts | 23 +- src/services/collectionService.ts | 111 +- src/services/entityService.ts | 226 ++-- src/services/providerService.ts | 32 +- src/services/serviceService.ts | 61 +- src/stores/collectionsStore.ts | 464 +++++--- src/stores/entitiesStore.ts | 590 ++++++---- src/stores/providersStore.ts | 108 +- src/stores/servicesStore.ts | 296 +++-- src/types/collection.ts | 81 +- src/types/common.ts | 101 +- src/types/entity.ts | 144 +-- src/types/provider.ts | 15 +- src/types/service.ts | 197 ++-- src/utils/serviceHelpers.ts | 315 +----- 18 files changed, 3090 insertions(+), 1239 deletions(-) create mode 100644 package-lock.json diff --git a/lib/Controllers/DefaultController.php b/lib/Controllers/DefaultController.php index 80acb34..3533f98 100644 --- a/lib/Controllers/DefaultController.php +++ b/lib/Controllers/DefaultController.php @@ -226,34 +226,39 @@ class DefaultController extends ControllerAbstract { return match ($operation) { // Provider operations 'provider.list' => $this->providerList($tenantId, $userId, $data), + 'provider.fetch' => $this->providerFetch($tenantId, $userId, $data), 'provider.extant' => $this->providerExtant($tenantId, $userId, $data), // Service operations 'service.list' => $this->serviceList($tenantId, $userId, $data), - 'service.extant' => $this->serviceExtant($tenantId, $userId, $data), 'service.fetch' => $this->serviceFetch($tenantId, $userId, $data), - 'service.discover' => $this->serviceDiscover($tenantId, $userId, $data), - 'service.test' => $this->serviceTest($tenantId, $userId, $data), + 'service.extant' => $this->serviceExtant($tenantId, $userId, $data), 'service.create' => $this->serviceCreate($tenantId, $userId, $data), 'service.update' => $this->serviceUpdate($tenantId, $userId, $data), 'service.delete' => $this->serviceDelete($tenantId, $userId, $data), + 'service.discover' => $this->serviceDiscover($tenantId, $userId, $data), + 'service.test' => $this->serviceTest($tenantId, $userId, $data), // Collection operations 'collection.list' => $this->collectionList($tenantId, $userId, $data), - 'collection.extant' => $this->collectionExtant($tenantId, $userId, $data), 'collection.fetch' => $this->collectionFetch($tenantId, $userId, $data), + 'collection.extant' => $this->collectionExtant($tenantId, $userId, $data), 'collection.create' => $this->collectionCreate($tenantId, $userId, $data), - 'collection.modify' => $this->collectionModify($tenantId, $userId, $data), - 'collection.destroy' => $this->collectionDestroy($tenantId, $userId, $data), + 'collection.update' => $this->collectionUpdate($tenantId, $userId, $data), + 'collection.delete' => $this->collectionDelete($tenantId, $userId, $data), + 'collection.delta' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), + 'collection.move' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), // Entity operations 'entity.list' => $this->entityList($tenantId, $userId, $data), - 'entity.delta' => $this->entityDelta($tenantId, $userId, $data), - 'entity.extant' => $this->entityExtant($tenantId, $userId, $data), 'entity.fetch' => $this->entityFetch($tenantId, $userId, $data), + 'entity.extant' => $this->entityExtant($tenantId, $userId, $data), 'entity.create' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), 'entity.update' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), 'entity.delete' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), + 'entity.delta' => $this->entityDelta($tenantId, $userId, $data), + 'entity.move' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), + 'entity.copy' => throw new InvalidArgumentException('Operation not implemented: ' . $operation), 'entity.transmit' => $this->entityTransmit($tenantId, $userId, $data), default => throw new InvalidArgumentException('Unknown operation: ' . $operation) @@ -289,6 +294,18 @@ class DefaultController extends ControllerAbstract { } + private function providerFetch(string $tenantId, string $userId, array $data): mixed { + + if (!isset($data['identifier'])) { + throw new InvalidArgumentException(self::ERR_MISSING_IDENTIFIER); + } + if (!is_string($data['identifier'])) { + throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); + } + + return $this->mailManager->providerFetch($tenantId, $userId, $data['identifier']); + } + // ==================== Service Operations ===================== private function serviceList(string $tenantId, string $userId, array $data): mixed { @@ -536,7 +553,7 @@ class DefaultController extends ControllerAbstract { ); } - private function collectionModify(string $tenantId, string $userId, array $data): mixed { + private function collectionUpdate(string $tenantId, string $userId, array $data): mixed { if (!isset($data['provider'])) { throw new InvalidArgumentException(self::ERR_MISSING_PROVIDER); } @@ -562,7 +579,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_DATA); } - return $this->mailManager->collectionModify( + return $this->mailManager->collectionUpdate( $tenantId, $userId, $data['provider'], @@ -572,7 +589,7 @@ class DefaultController extends ControllerAbstract { ); } - private function collectionDestroy(string $tenantId, string $userId, array $data): mixed { + private function collectionDelete(string $tenantId, string $userId, array $data): mixed { if (!isset($data['provider'])) { throw new InvalidArgumentException(self::ERR_MISSING_PROVIDER); } @@ -592,7 +609,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); } - return $this->mailManager->collectionDestroy( + return $this->mailManager->collectionDelete( $tenantId, $userId, $data['provider'], diff --git a/lib/Manager.php b/lib/Manager.php index 76f5453..82ce17e 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -621,7 +621,7 @@ class Manager { * @return CollectionBaseInterface * @throws InvalidArgumentException */ - public function collectionModify(string $tenantId, string $userId, string $providerId, string|int $serviceId, string|int $collectionId, CollectionMutableInterface|array $object): CollectionBaseInterface { + public function collectionUpdate(string $tenantId, string $userId, string $providerId, string|int $serviceId, string|int $collectionId, CollectionMutableInterface|array $object): CollectionBaseInterface { // retrieve service $service = $this->serviceFetch($tenantId, $userId, $providerId, $serviceId); @@ -629,8 +629,8 @@ class Manager { if (!($service instanceof ServiceCollectionMutableInterface)) { throw new InvalidArgumentException("Service does not support collection mutations"); } - if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_MODIFY)) { - throw new InvalidArgumentException("Service is not capable of modifying collections"); + if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_UPDATE)) { + throw new InvalidArgumentException("Service is not capable of updating collections"); } if (is_array($object)) { @@ -640,12 +640,12 @@ class Manager { $collection = $object; } - // Modify collection - return $service->collectionModify($collectionId, $collection); + // Update collection + return $service->collectionUpdate($collectionId, $collection); } /** - * Destroy a specific collection + * Delete a specific collection * * @since 2025.05.01 * @@ -657,23 +657,23 @@ class Manager { * * @return CollectionBaseInterface|null */ - public function collectionDestroy(string $tenantId, ?string $userId, string $providerId, string|int $serviceId, string|int $collectionId, array $options = []): bool { + public function collectionDelete(string $tenantId, ?string $userId, string $providerId, string|int $serviceId, string|int $collectionId, array $options = []): bool { // retrieve service $service = $this->serviceFetch($tenantId, $userId, $providerId, $serviceId); - // Check if service supports collection destruction + // Check if service supports collection deletion if (!($service instanceof ServiceCollectionMutableInterface)) { throw new InvalidArgumentException("Service does not support collection mutations"); } - if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_DESTROY)) { - throw new InvalidArgumentException("Service is not capable of destroying collections"); + if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_DELETE)) { + throw new InvalidArgumentException("Service is not capable of deleting collections"); } $force = $options['force'] ?? false; $recursive = $options['recursive'] ?? false; - // destroy collection - return $service->collectionDestroy($collectionId, $force, $recursive); + // delete collection + return $service->collectionDelete($collectionId, $force, $recursive); } // ==================== Message Operations ==================== diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..5c154c3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1500 @@ +{ + "name": "mail_manager", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "mail_manager", + "version": "1.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "pinia": "^2.3.1" + }, + "devDependencies": { + "@vue/tsconfig": "^0.7.0", + "typescript": "~5.8.3", + "vite": "^7.1.2", + "vue-tsc": "^3.0.5" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.0.tgz", + "integrity": "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", + "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz", + "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz", + "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz", + "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz", + "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz", + "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz", + "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz", + "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz", + "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz", + "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz", + "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz", + "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz", + "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz", + "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz", + "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz", + "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz", + "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz", + "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz", + "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz", + "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz", + "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz", + "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz", + "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz", + "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz", + "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz", + "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "license": "MIT", + "peer": true + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", + "integrity": "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.57.1.tgz", + "integrity": "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.57.1.tgz", + "integrity": "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.57.1.tgz", + "integrity": "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.57.1.tgz", + "integrity": "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.57.1.tgz", + "integrity": "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.57.1.tgz", + "integrity": "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.57.1.tgz", + "integrity": "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.57.1.tgz", + "integrity": "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.57.1.tgz", + "integrity": "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.57.1.tgz", + "integrity": "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.57.1.tgz", + "integrity": "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.57.1.tgz", + "integrity": "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.57.1.tgz", + "integrity": "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.57.1.tgz", + "integrity": "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.57.1.tgz", + "integrity": "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.57.1.tgz", + "integrity": "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.57.1.tgz", + "integrity": "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz", + "integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.57.1.tgz", + "integrity": "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.57.1.tgz", + "integrity": "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.57.1.tgz", + "integrity": "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.57.1.tgz", + "integrity": "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.57.1.tgz", + "integrity": "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.57.1.tgz", + "integrity": "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@volar/language-core": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.27.tgz", + "integrity": "sha512-DjmjBWZ4tJKxfNC1F6HyYERNHPYS7L7OPFyCrestykNdUZMFYzI9WTyvwPcaNaHlrEUwESHYsfEw3isInncZxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/source-map": "2.4.27" + } + }, + "node_modules/@volar/source-map": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.27.tgz", + "integrity": "sha512-ynlcBReMgOZj2i6po+qVswtDUeeBRCTgDurjMGShbm8WYZgJ0PA4RmtebBJ0BCYol1qPv3GQF6jK7C9qoVc7lg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@volar/typescript": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.27.tgz", + "integrity": "sha512-eWaYCcl/uAPInSK2Lze6IqVWaBu/itVqR5InXcHXFyles4zO++Mglt3oxdgj75BDcv1Knr9Y93nowS8U3wqhxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.27", + "path-browserify": "^1.0.1", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.28.tgz", + "integrity": "sha512-kviccYxTgoE8n6OCw96BNdYlBg2GOWfBuOW4Vqwrt7mSKWKwFVvI8egdTltqRgITGPsTFYtKYfxIG8ptX2PJHQ==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.0", + "@vue/shared": "3.5.28", + "entities": "^7.0.1", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.28.tgz", + "integrity": "sha512-/1ZepxAb159jKR1btkefDP+J2xuWL5V3WtleRmxaT+K2Aqiek/Ab/+Ebrw2pPj0sdHO8ViAyyJWfhXXOP/+LQA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.28", + "@vue/shared": "3.5.28" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.28.tgz", + "integrity": "sha512-6TnKMiNkd6u6VeVDhZn/07KhEZuBSn43Wd2No5zaP5s3xm8IqFTHBj84HJah4UepSUJTro5SoqqlOY22FKY96g==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/parser": "^7.29.0", + "@vue/compiler-core": "3.5.28", + "@vue/compiler-dom": "3.5.28", + "@vue/compiler-ssr": "3.5.28", + "@vue/shared": "3.5.28", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.6", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.28.tgz", + "integrity": "sha512-JCq//9w1qmC6UGLWJX7RXzrGpKkroubey/ZFqTpvEIDJEKGgntuDMqkuWiZvzTzTA5h2qZvFBFHY7fAAa9475g==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.28", + "@vue/shared": "3.5.28" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, + "node_modules/@vue/language-core": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-3.2.4.tgz", + "integrity": "sha512-bqBGuSG4KZM45KKTXzGtoCl9cWju5jsaBKaJJe3h5hRAAWpZUuj5G+L+eI01sPIkm4H6setKRlw7E85wLdDNew==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.27", + "@vue/compiler-dom": "^3.5.0", + "@vue/shared": "^3.5.0", + "alien-signals": "^3.0.0", + "muggle-string": "^0.4.1", + "path-browserify": "^1.0.1", + "picomatch": "^4.0.2" + } + }, + "node_modules/@vue/reactivity": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.28.tgz", + "integrity": "sha512-gr5hEsxvn+RNyu9/9o1WtdYdwDjg5FgjUSBEkZWqgTKlo/fvwZ2+8W6AfKsc9YN2k/+iHYdS9vZYAhpi10kNaw==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/shared": "3.5.28" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.28.tgz", + "integrity": "sha512-POVHTdbgnrBBIpnbYU4y7pOMNlPn2QVxVzkvEA2pEgvzbelQq4ZOUxbp2oiyo+BOtiYlm8Q44wShHJoBvDPAjQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/reactivity": "3.5.28", + "@vue/shared": "3.5.28" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.28.tgz", + "integrity": "sha512-4SXxSF8SXYMuhAIkT+eBRqOkWEfPu6nhccrzrkioA6l0boiq7sp18HCOov9qWJA5HML61kW8p/cB4MmBiG9dSA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/reactivity": "3.5.28", + "@vue/runtime-core": "3.5.28", + "@vue/shared": "3.5.28", + "csstype": "^3.2.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.28.tgz", + "integrity": "sha512-pf+5ECKGj8fX95bNincbzJ6yp6nyzuLDhYZCeFxUNp8EBrQpPpQaLX3nNCp49+UbgbPun3CeVE+5CXVV1Xydfg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-ssr": "3.5.28", + "@vue/shared": "3.5.28" + }, + "peerDependencies": { + "vue": "3.5.28" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.28.tgz", + "integrity": "sha512-cfWa1fCGBxrvaHRhvV3Is0MgmrbSCxYTXCSCau2I0a1Xw1N1pHAvkWCiXPRAqjvToILvguNyEwjevUqAuBQWvQ==", + "license": "MIT" + }, + "node_modules/@vue/tsconfig": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@vue/tsconfig/-/tsconfig-0.7.0.tgz", + "integrity": "sha512-ku2uNz5MaZ9IerPPUyOHzyjhXoX2kVJaVf7hL315DC17vS6IiZRmmCPfggNbU16QTvM80+uYYy3eYJB59WCtvg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typescript": "5.x", + "vue": "^3.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/alien-signals": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-3.1.2.tgz", + "integrity": "sha512-d9dYqZTS90WLiU0I5c6DHj/HcKkF8ZyGN3G5x8wSbslulz70KOxaqCT0hQCo9KOyhVqzqGojvNdJXoTumZOtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "license": "MIT", + "peer": true + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/esbuild": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", + "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.3", + "@esbuild/android-arm": "0.27.3", + "@esbuild/android-arm64": "0.27.3", + "@esbuild/android-x64": "0.27.3", + "@esbuild/darwin-arm64": "0.27.3", + "@esbuild/darwin-x64": "0.27.3", + "@esbuild/freebsd-arm64": "0.27.3", + "@esbuild/freebsd-x64": "0.27.3", + "@esbuild/linux-arm": "0.27.3", + "@esbuild/linux-arm64": "0.27.3", + "@esbuild/linux-ia32": "0.27.3", + "@esbuild/linux-loong64": "0.27.3", + "@esbuild/linux-mips64el": "0.27.3", + "@esbuild/linux-ppc64": "0.27.3", + "@esbuild/linux-riscv64": "0.27.3", + "@esbuild/linux-s390x": "0.27.3", + "@esbuild/linux-x64": "0.27.3", + "@esbuild/netbsd-arm64": "0.27.3", + "@esbuild/netbsd-x64": "0.27.3", + "@esbuild/openbsd-arm64": "0.27.3", + "@esbuild/openbsd-x64": "0.27.3", + "@esbuild/openharmony-arm64": "0.27.3", + "@esbuild/sunos-x64": "0.27.3", + "@esbuild/win32-arm64": "0.27.3", + "@esbuild/win32-ia32": "0.27.3", + "@esbuild/win32-x64": "0.27.3" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/muggle-string": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.4.1.tgz", + "integrity": "sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pinia": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.3.1.tgz", + "integrity": "sha512-khUlZSwt9xXCaTbbxFYBKDc/bWAGWJjOgvxETwkTN7KRm66EeT1ZdZj6i2ceh9sP2Pzqsbc704r2yngBrxBVug==", + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^6.6.3", + "vue-demi": "^0.14.10" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "typescript": ">=4.4.4", + "vue": "^2.7.0 || ^3.5.11" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", + "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.57.1", + "@rollup/rollup-android-arm64": "4.57.1", + "@rollup/rollup-darwin-arm64": "4.57.1", + "@rollup/rollup-darwin-x64": "4.57.1", + "@rollup/rollup-freebsd-arm64": "4.57.1", + "@rollup/rollup-freebsd-x64": "4.57.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", + "@rollup/rollup-linux-arm-musleabihf": "4.57.1", + "@rollup/rollup-linux-arm64-gnu": "4.57.1", + "@rollup/rollup-linux-arm64-musl": "4.57.1", + "@rollup/rollup-linux-loong64-gnu": "4.57.1", + "@rollup/rollup-linux-loong64-musl": "4.57.1", + "@rollup/rollup-linux-ppc64-gnu": "4.57.1", + "@rollup/rollup-linux-ppc64-musl": "4.57.1", + "@rollup/rollup-linux-riscv64-gnu": "4.57.1", + "@rollup/rollup-linux-riscv64-musl": "4.57.1", + "@rollup/rollup-linux-s390x-gnu": "4.57.1", + "@rollup/rollup-linux-x64-gnu": "4.57.1", + "@rollup/rollup-linux-x64-musl": "4.57.1", + "@rollup/rollup-openbsd-x64": "4.57.1", + "@rollup/rollup-openharmony-arm64": "4.57.1", + "@rollup/rollup-win32-arm64-msvc": "4.57.1", + "@rollup/rollup-win32-ia32-msvc": "4.57.1", + "@rollup/rollup-win32-x64-gnu": "4.57.1", + "@rollup/rollup-win32-x64-msvc": "4.57.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "devOptional": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/vite": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", + "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vscode-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.1.0.tgz", + "integrity": "sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/vue": { + "version": "3.5.28", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.28.tgz", + "integrity": "sha512-BRdrNfeoccSoIZeIhyPBfvWSLFP4q8J3u8Ju8Ug5vu3LdD+yTM13Sg4sKtljxozbnuMu1NB1X5HBHRYUzFocKg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.28", + "@vue/compiler-sfc": "3.5.28", + "@vue/runtime-dom": "3.5.28", + "@vue/server-renderer": "3.5.28", + "@vue/shared": "3.5.28" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-demi": { + "version": "0.14.10", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz", + "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/vue-tsc": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-3.2.4.tgz", + "integrity": "sha512-xj3YCvSLNDKt1iF9OcImWHhmYcihVu9p4b9s4PGR/qp6yhW+tZJaypGxHScRyOrdnHvaOeF+YkZOdKwbgGvp5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/typescript": "2.4.27", + "@vue/language-core": "3.2.4" + }, + "bin": { + "vue-tsc": "bin/vue-tsc.js" + }, + "peerDependencies": { + "typescript": ">=5.0.0" + } + } + } +} diff --git a/src/composables/useMailSync.ts b/src/composables/useMailSync.ts index 1190aef..3e086d9 100644 --- a/src/composables/useMailSync.ts +++ b/src/composables/useMailSync.ts @@ -37,6 +37,7 @@ export function useMailSync(options: SyncOptions = {}) { const lastSync = ref(null); const error = ref(null); const sources = ref([]); + const signatures = ref>>>({}); let syncInterval: ReturnType | null = null; @@ -101,12 +102,12 @@ export function useMailSync(options: SyncOptions = {}) { // Add collections to check with their signatures source.collections.forEach(collection => { - // Look up signature from entities store first (updated by delta), fallback to collections store - let signature = entitiesStore.signatures[source.provider]?.[String(source.service)]?.[String(collection)]; + // Look up signature from local tracking (updated by delta) + let signature = signatures.value[source.provider]?.[String(source.service)]?.[String(collection)]; // Fallback to collection signature if not yet synced if (!signature) { - const collectionData = collectionsStore.collections[source.provider]?.[String(source.service)]?.[String(collection)]; + const collectionData = collectionsStore.collection(source.provider, source.service, collection); signature = collectionData?.signature || ''; } @@ -118,7 +119,7 @@ export function useMailSync(options: SyncOptions = {}) { }); // Get delta changes - const deltaResponse = await entitiesStore.getDelta(deltaSources); + const deltaResponse = await entitiesStore.delta(deltaSources); // If fetchDetails is enabled, fetch full entity data for additions and modifications if (fetchDetails) { const fetchPromises: Promise[] = []; @@ -131,6 +132,18 @@ export function useMailSync(options: SyncOptions = {}) { return; } + // Update signature tracking + if (collectionData.signature) { + if (!signatures.value[provider]) { + signatures.value[provider] = {}; + } + if (!signatures.value[provider][service]) { + signatures.value[provider][service] = {}; + } + signatures.value[provider][service][collection] = collectionData.signature; + console.log(`[Sync] Updated signature for ${provider}/${service}/${collection}: "${collectionData.signature}"`); + } + // Check if signature actually changed (if not, skip fetching) const oldSignature = deltaSources[provider]?.[service]?.[collection]; const newSignature = collectionData.signature; @@ -149,7 +162,7 @@ export function useMailSync(options: SyncOptions = {}) { if (identifiersToFetch.length > 0) { console.log(`[Sync] Fetching ${identifiersToFetch.length} entities for ${provider}/${service}/${collection}`); fetchPromises.push( - entitiesStore.getMessages( + entitiesStore.fetch( provider, service, collection, diff --git a/src/services/collectionService.ts b/src/services/collectionService.ts index f6e12df..08cc711 100644 --- a/src/services/collectionService.ts +++ b/src/services/collectionService.ts @@ -12,28 +12,74 @@ import type { CollectionFetchResponse, CollectionCreateRequest, CollectionCreateResponse, - CollectionModifyRequest, - CollectionModifyResponse, - CollectionDestroyRequest, - CollectionDestroyResponse + CollectionUpdateResponse, + CollectionUpdateRequest, + CollectionDeleteResponse, + CollectionDeleteRequest, + CollectionInterface, } from '../types/collection'; +import { useIntegrationStore } from '@KTXC/stores/integrationStore'; +import { CollectionObject } from '../models'; + +/** + * Helper to create the right collection model class based on provider identifier + * Uses provider-specific factory if available, otherwise returns base CollectionObject + */ +function createCollectionObject(data: CollectionInterface): CollectionObject { + const integrationStore = useIntegrationStore(); + const factoryItem = integrationStore.getItemById('mail_collection_factory', data.provider) as any; + const factory = factoryItem?.factory; + + // Use provider factory if available, otherwise base class + return factory ? factory(data) : new CollectionObject().fromJson(data); +} export const collectionService = { /** - * List all available collections + * Retrieve list of collections, optionally filtered by source selector * - * @param request - Collection list request parameters - * @returns Promise with collection list grouped by provider and service + * @param request - list request parameters + * + * @returns Promise with collection object list grouped by provider, service, and collection identifier */ - async list(request: CollectionListRequest = {}): Promise { - return await transceivePost('collection.list', request); + async list(request: CollectionListRequest = {}): Promise>>> { + const response = await transceivePost('collection.list', request); + + // Convert nested response to CollectionObject instances + const providerList: Record>> = {}; + Object.entries(response).forEach(([providerId, providerServices]) => { + const serviceList: Record> = {}; + Object.entries(providerServices).forEach(([serviceId, serviceCollections]) => { + const collectionList: Record = {}; + Object.entries(serviceCollections).forEach(([collectionId, collectionData]) => { + collectionList[collectionId] = createCollectionObject(collectionData); + }); + serviceList[serviceId] = collectionList; + }); + providerList[providerId] = serviceList; + }); + + return providerList; }, /** - * Check which collections exist/are available + * Retrieve a specific collection by provider and identifier + * + * @param request - fetch request parameters + * + * @returns Promise with collection object + */ + async fetch(request: CollectionFetchRequest): Promise { + const response = await transceivePost('collection.fetch', request); + return createCollectionObject(response); + }, + + /** + * Retrieve collection availability status for a given source selector + * + * @param request - extant request parameters * - * @param request - Collection extant request with source selector * @returns Promise with collection availability status */ async extant(request: CollectionExtantRequest): Promise { @@ -41,43 +87,38 @@ export const collectionService = { }, /** - * Fetch a specific collection + * Create a new collection * - * @param request - Collection fetch request - * @returns Promise with collection details + * @param request - create request parameters + * + * @returns Promise with created collection object */ - async fetch(request: CollectionFetchRequest): Promise { - return await transceivePost('collection.fetch', request); + async create(request: CollectionCreateRequest): Promise { + const response = await transceivePost('collection.create', request); + return createCollectionObject(response); }, /** - * Create a new collection/folder + * Update an existing collection * - * @param request - Collection creation parameters - * @returns Promise with created collection details + * @param request - update request parameters + * + * @returns Promise with updated collection object */ - async create(request: CollectionCreateRequest): Promise { - return await transceivePost('collection.create', request); + async update(request: CollectionUpdateRequest): Promise { + const response = await transceivePost('collection.update', request); + return createCollectionObject(response); }, /** - * Modify an existing collection/folder + * Delete a collection * - * @param request - Collection modification parameters - * @returns Promise with modified collection details - */ - async modify(request: CollectionModifyRequest): Promise { - return await transceivePost('collection.modify', request); - }, - - /** - * Destroy/delete a collection/folder + * @param request - delete request parameters * - * @param request - Collection destroy parameters - * @returns Promise with destroy operation result + * @returns Promise with deletion result */ - async destroy(request: CollectionDestroyRequest): Promise { - return await transceivePost('collection.destroy', request); + async delete(request: CollectionDeleteRequest): Promise { + return await transceivePost('collection.delete', request); }, }; diff --git a/src/services/entityService.ts b/src/services/entityService.ts index cafc6da..bbefddb 100644 --- a/src/services/entityService.ts +++ b/src/services/entityService.ts @@ -1,119 +1,161 @@ /** - * Message/Entity management service + * Entity management service */ import { transceivePost } from './transceive'; import type { - MessageListRequest, - MessageListResponse, - MessageDeltaRequest, - MessageDeltaResponse, - MessageExtantRequest, - MessageExtantResponse, - MessageFetchRequest, - MessageFetchResponse, - MessageSearchRequest, - MessageSearchResponse, - MessageSendRequest, - MessageSendResponse, - MessageCreateRequest, - MessageCreateResponse, - MessageUpdateRequest, - MessageUpdateResponse, - MessageDestroyRequest, - MessageDestroyResponse, + EntityListRequest, + EntityListResponse, + EntityFetchRequest, + EntityFetchResponse, + EntityExtantRequest, + EntityExtantResponse, + EntityCreateRequest, + EntityCreateResponse, + EntityUpdateRequest, + EntityUpdateResponse, + EntityDeleteRequest, + EntityDeleteResponse, + EntityDeltaRequest, + EntityDeltaResponse, + EntityTransmitRequest, + EntityTransmitResponse, + EntityInterface, } from '../types/entity'; +import { useIntegrationStore } from '@KTXC/stores/integrationStore'; +import { EntityObject } from '../models'; + +/** + * Helper to create the right entity model class based on provider identifier + * Uses provider-specific factory if available, otherwise returns base EntityObject + */ +function createEntityObject(data: EntityInterface): EntityObject { + const integrationStore = useIntegrationStore(); + const factoryItem = integrationStore.getItemById('mail_entity_factory', data.provider) as any; + const factory = factoryItem?.factory; + + // Use provider factory if available, otherwise base class + return factory ? factory(data) : new EntityObject().fromJson(data); +} export const entityService = { /** - * List all available messages + * Retrieve list of entities, optionally filtered by source selector * - * @param request - Message list request parameters - * @returns Promise with message list grouped by provider, service, and collection + * @param request - list request parameters + * + * @returns Promise with entity object list grouped by provider, service, collection, and entity identifier */ - async list(request: MessageListRequest = {}): Promise { - return await transceivePost('entity.list', request); + async list(request: EntityListRequest = {}): Promise>>>> { + const response = await transceivePost('entity.list', request); + + // Convert nested response to EntityObject instances + const providerList: Record>>> = {}; + Object.entries(response).forEach(([providerId, providerServices]) => { + const serviceList: Record>> = {}; + Object.entries(providerServices).forEach(([serviceId, serviceCollections]) => { + const collectionList: Record> = {}; + Object.entries(serviceCollections).forEach(([collectionId, collectionEntities]) => { + const entityList: Record = {}; + Object.entries(collectionEntities).forEach(([entityId, entityData]) => { + entityList[entityId] = createEntityObject(entityData); + }); + collectionList[collectionId] = entityList; + }); + serviceList[serviceId] = collectionList; + }); + providerList[providerId] = serviceList; + }); + + return providerList; }, /** - * Get delta changes for messages + * Retrieve a specific entity by provider and identifier + * + * @param request - fetch request parameters + * + * @returns Promise with entity objects keyed by identifier + */ + async fetch(request: EntityFetchRequest): Promise> { + const response = await transceivePost('entity.fetch', request); + + // Convert response to EntityObject instances + const list: Record = {}; + Object.entries(response).forEach(([identifier, entityData]) => { + list[identifier] = createEntityObject(entityData); + }); + + return list; + }, + + /** + * Retrieve entity availability status for a given source selector + * + * @param request - extant request parameters + * + * @returns Promise with entity availability status + */ + async extant(request: EntityExtantRequest): Promise { + return await transceivePost('entity.extant', request); + }, + + /** + * Create a new entity + * + * @param request - create request parameters + * + * @returns Promise with created entity object + */ + async create(request: EntityCreateRequest): Promise { + const response = await transceivePost('entity.create', request); + return createEntityObject(response); + }, + + /** + * Update an existing entity + * + * @param request - update request parameters + * + * @returns Promise with updated entity object + */ + async update(request: EntityUpdateRequest): Promise { + const response = await transceivePost('entity.update', request); + return createEntityObject(response); + }, + + /** + * Delete an entity + * + * @param request - delete request parameters + * + * @returns Promise with deletion result + */ + async delete(request: EntityDeleteRequest): Promise { + return await transceivePost('entity.delete', request); + }, + + /** + * Retrieve delta changes for entities + * + * @param request - delta request parameters * - * @param request - Message delta request with source selector * @returns Promise with delta changes (created, modified, deleted) */ - async delta(request: MessageDeltaRequest): Promise { - return await transceivePost('entity.delta', request); + async delta(request: EntityDeltaRequest): Promise { + return await transceivePost('entity.delta', request); }, /** - * Check which messages exist/are available + * Send an entity * - * @param request - Message extant request with source selector - * @returns Promise with message availability status - */ - async extant(request: MessageExtantRequest): Promise { - return await transceivePost('entity.extant', request); - }, - - /** - * Fetch specific messages + * @param request - transmit request parameters * - * @param request - Message fetch request - * @returns Promise with message details + * @returns Promise with transmission result */ - async fetch(request: MessageFetchRequest): Promise { - return await transceivePost('entity.fetch', request); - }, - - /** - * Search messages - * - * @param request - Message search request - * @returns Promise with search results - */ - async search(request: MessageSearchRequest): Promise { - return await transceivePost('entity.search', request); - }, - - /** - * Send a message - * - * @param request - Message send request - * @returns Promise with send result - */ - async send(request: MessageSendRequest): Promise { - return await transceivePost('entity.send', request); - }, - - /** - * Create a new message (draft) - * - * @param request - Message create request - * @returns Promise with created message details - */ - async create(request: MessageCreateRequest): Promise { - return await transceivePost('entity.create', request); - }, - - /** - * Update an existing message (flags, labels, etc.) - * - * @param request - Message update request - * @returns Promise with update result - */ - async update(request: MessageUpdateRequest): Promise { - return await transceivePost('entity.update', request); - }, - - /** - * Delete/destroy a message - * - * @param request - Message destroy request - * @returns Promise with destroy result - */ - async destroy(request: MessageDestroyRequest): Promise { - return await transceivePost('entity.destroy', request); + async transmit(request: EntityTransmitRequest): Promise { + return await transceivePost('entity.transmit', request); }, }; diff --git a/src/services/providerService.ts b/src/services/providerService.ts index 39cfb9e..800d79e 100644 --- a/src/services/providerService.ts +++ b/src/services/providerService.ts @@ -8,18 +8,32 @@ import type { ProviderExtantRequest, ProviderExtantResponse, ProviderFetchRequest, - ProviderFetchResponse, + ProviderFetchResponse, + ProviderInterface, } from '../types/provider'; +import { useIntegrationStore } from '@KTXC/stores/integrationStore'; import { transceivePost } from './transceive'; import { ProviderObject } from '../models/provider'; +/** + * Helper to create the right provider model class based on provider identifier + * Uses provider-specific factory if available, otherwise returns base ProviderObject + */ +function createProviderObject(data: ProviderInterface): ProviderObject { + const integrationStore = useIntegrationStore(); + const factoryItem = integrationStore.getItemById('mail_provider_factory', data.identifier) as any; + const factory = factoryItem?.factory; + + // Use provider factory if available, otherwise base class + return factory ? factory(data) : new ProviderObject().fromJson(data); +} export const providerService = { /** - * List available providers + * Retrieve list of providers, optionally filtered by source selector * - * @param request - List request parameters + * @param request - list request parameters * * @returns Promise with provider object list keyed by provider identifier */ @@ -29,28 +43,28 @@ export const providerService = { // Convert response to ProviderObject instances const list: Record = {}; Object.entries(response).forEach(([providerId, providerData]) => { - list[providerId] = new ProviderObject().fromJson(providerData); + list[providerId] = createProviderObject(providerData); }); return list; }, /** - * Fetch a specific provider + * Retrieve specific provider by identifier * - * @param request - Fetch request parameters + * @param request - fetch request parameters * * @returns Promise with provider object */ async fetch(request: ProviderFetchRequest): Promise { const response = await transceivePost('provider.fetch', request); - return new ProviderObject().fromJson(response); + return createProviderObject(response); }, /** - * Check which providers exist/are available + * Retrieve provider availability status for a given source selector * - * @param request - Extant request parameters + * @param request - extant request parameters * * @returns Promise with provider availability status */ diff --git a/src/services/serviceService.ts b/src/services/serviceService.ts index dca88f8..a5d0a24 100644 --- a/src/services/serviceService.ts +++ b/src/services/serviceService.ts @@ -18,13 +18,15 @@ import type { ServiceCreateRequest, ServiceUpdateResponse, ServiceUpdateRequest, + ServiceDeleteResponse, + ServiceDeleteRequest, } from '../types/service'; +import { useIntegrationStore } from '@KTXC/stores/integrationStore'; import { transceivePost } from './transceive'; import { ServiceObject } from '../models/service'; -import { useIntegrationStore } from '@KTXC/stores/integrationStore'; /** - * Helper to create the right service model class based on provider + * Helper to create the right service model class based on provider identifier * Uses provider-specific factory if available, otherwise returns base ServiceObject */ function createServiceObject(data: ServiceInterface): ServiceObject { @@ -39,9 +41,9 @@ function createServiceObject(data: ServiceInterface): ServiceObject { export const serviceService = { /** - * List available services + * Retrieve list of services, optionally filtered by source selector * - * @param request - Service list request parameters + * @param request - list request parameters * * @returns Promise with service object list grouped by provider and keyed by service identifier */ @@ -49,31 +51,23 @@ export const serviceService = { const response = await transceivePost('service.list', request); // Convert nested response to ServiceObject instances - const list: Record> = {}; + const providerList: Record> = {}; Object.entries(response).forEach(([providerId, providerServices]) => { - list[providerId] = {}; + const serviceList: Record = {}; Object.entries(providerServices).forEach(([serviceId, serviceData]) => { - list[providerId][serviceId] = createServiceObject(serviceData); + serviceList[serviceId] = createServiceObject(serviceData); }); + providerList[providerId] = serviceList; }); - return list; + return providerList; }, /** - * Check which services exist/are available + * Retrieve a specific service by provider and identifier * - * @param request - Service extant request with source selector - * @returns Promise with service availability status - */ - async extant(request: ServiceExtantRequest): Promise { - return await transceivePost('service.extant', request); - }, - - /** - * Fetch a specific service + * @param request - fetch request parameters * - * @param request - Service fetch request with provider and service IDs * @returns Promise with service object */ async fetch(request: ServiceFetchRequest): Promise { @@ -82,9 +76,21 @@ export const serviceService = { }, /** - * Discover mail service configuration from identity + * Retrieve service availability status for a given source selector + * + * @param request - extant request parameters + * + * @returns Promise with service availability status + */ + async extant(request: ServiceExtantRequest): Promise { + return await transceivePost('service.extant', request); + }, + + /** + * Retrieve discoverable services for a given source selector, sorted by provider + * + * @param request - discover request parameters * - * @param request - Discovery request with identity and optional hints * @returns Promise with array of discovered services sorted by provider */ async discover(request: ServiceDiscoverRequest): Promise { @@ -109,7 +115,7 @@ export const serviceService = { }, /** - * Test a mail service connection + * Test service connectivity and configuration * * @param request - Service test request * @returns Promise with test results @@ -121,7 +127,8 @@ export const serviceService = { /** * Create a new service * - * @param request - Service create request with provider ID and service data + * @param request - create request parameters + * * @returns Promise with created service object */ async create(request: ServiceCreateRequest): Promise { @@ -132,7 +139,8 @@ export const serviceService = { /** * Update a existing service * - * @param request - Service update request with provider ID, service ID, and updated data + * @param request - update request parameters + * * @returns Promise with updated service object */ async update(request: ServiceUpdateRequest): Promise { @@ -143,11 +151,12 @@ export const serviceService = { /** * Delete a service * - * @param request - Service delete request with provider ID and service ID + * @param request - delete request parameters + * * @returns Promise with deletion result */ async delete(request: { provider: string; identifier: string | number }): Promise { - return await transceivePost('service.delete', request); + return await transceivePost('service.delete', request); }, }; diff --git a/src/stores/collectionsStore.ts b/src/stores/collectionsStore.ts index 38ae48f..2cba247 100644 --- a/src/stores/collectionsStore.ts +++ b/src/stores/collectionsStore.ts @@ -1,169 +1,329 @@ +/** + * Collections Store + */ + +import { ref, computed, readonly } from 'vue' import { defineStore } from 'pinia' import { collectionService } from '../services' -import type { CollectionInterface, CollectionCreateRequest } from '../types' -import { CollectionObject, CollectionPropertiesObject } from '../models/collection' +import { CollectionObject } from '../models/collection' +import type { SourceSelector, ListFilter, ListSort, CollectionMutableProperties } from '../types' -export const useCollectionsStore = defineStore('mail-collections', { - state: () => ({ - collections: {} as Record>>, - loading: false, - error: null as string | null, - }), +export const useCollectionsStore = defineStore('mailCollectionsStore', () => { + // State + const _collections = ref>({}) + const transceiving = ref(false) - actions: { - async loadCollections(sources?: any) { - this.loading = true - this.error = null - try { - const response = await collectionService.list({ sources }) - - // Response is already in nested object format: provider -> service -> collection - // Transform to CollectionObject instances - const transformed: Record>> = {} - - for (const [providerId, providerData] of Object.entries(response)) { - transformed[providerId] = {} - - for (const [serviceId, collections] of Object.entries(providerData as any)) { - transformed[providerId][serviceId] = {} - - // Collections come as an object keyed by identifier - for (const [collectionId, collection] of Object.entries(collections as any)) { - // Create CollectionObject instance with provider and service set - const collectionData = { - ...collection, - provider: providerId, - service: serviceId, - } as CollectionInterface - - transformed[providerId][serviceId][collectionId] = new CollectionObject().fromJson(collectionData) - } + /** + * Get count of collections in store + */ + const count = computed(() => Object.keys(_collections.value).length) + + /** + * Check if any collections are present in store + */ + const has = computed(() => count.value > 0) + + /** + * Get all collections present in store + */ + const collections = computed(() => Object.values(_collections.value)) + + /** + * Get all collections present in store grouped by service + */ + const collectionsByService = computed(() => { + const groups: Record = {} + + Object.values(_collections.value).forEach((collection) => { + const serviceKey = `${collection.provider}:${collection.service}` + if (!groups[serviceKey]) { + groups[serviceKey] = [] + } + groups[serviceKey].push(collection) + }) + + return groups + }) + + /** + * Get a specific collection from store, with optional retrieval + * + * @param provider - provider identifier + * @param service - service identifier + * @param identifier - collection identifier + * @param retrieve - Retrieve behavior: true = fetch if missing or refresh, false = cache only + * + * @returns Collection object or null + */ + function collection(provider: string, service: string | number, identifier: string | number, retrieve: boolean = false): CollectionObject | null { + const key = identifierKey(provider, service, identifier) + if (retrieve === true && !_collections.value[key]) { + console.debug(`[Mail Manager][Store] - Force fetching collection "${key}"`) + fetch(provider, service, identifier) + } + + return _collections.value[key] || null + } + + /** + * Get all collections for a specific service + * + * @param provider - provider identifier + * @param service - service identifier + * @param retrieve - Retrieve behavior: true = fetch if missing or refresh, false = cache only + * + * @returns Array of collection objects + */ + function collectionsForService(provider: string, service: string | number, retrieve: boolean = false): CollectionObject[] { + const serviceKeyPrefix = `${provider}:${service}:` + const serviceCollections = Object.entries(_collections.value) + .filter(([key]) => key.startsWith(serviceKeyPrefix)) + .map(([_, collection]) => collection) + + if (retrieve === true && serviceCollections.length === 0) { + console.debug(`[Mail Manager][Store] - Force fetching collections for service "${provider}:${service}"`) + const sources: SourceSelector = { + [provider]: { + [String(service)]: true + } + } + list(sources) + } + + return serviceCollections + } + + function collectionsInCollection(provider: string, service: string | number, collectionId: string | number, retrieve: boolean = false): CollectionObject[] { + const collectionKeyPrefix = `${provider}:${service}:${collectionId}:` + const nestedCollections = Object.entries(_collections.value) + .filter(([key]) => key.startsWith(collectionKeyPrefix)) + .map(([_, collection]) => collection) + + if (retrieve === true && nestedCollections.length === 0) { + console.debug(`[Mail Manager][Store] - Force fetching collections in collection "${provider}:${service}:${collectionId}"`) + const sources: SourceSelector = { + [provider]: { + [String(service)]: { + [String(collectionId)]: true } } - - this.collections = transformed - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false } - }, + list(sources) + } + + return nestedCollections + } - async getCollection(provider: string, service: string | number, collectionId: string | number) { - this.loading = true - this.error = null - try { - const response = await collectionService.fetch({ - provider, - service, - collection: collectionId - }) - - // Create CollectionObject instance - const collectionObject = new CollectionObject().fromJson(response) - - // Update in store - if (!this.collections[provider]) { - this.collections[provider] = {} - } - if (!this.collections[provider][String(service)]) { - this.collections[provider][String(service)] = {} - } - this.collections[provider][String(service)][String(collectionId)] = collectionObject - - return collectionObject - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false - } - }, + /** + * Create unique key for a collection + */ + function identifierKey(provider: string, service: string | number | null, identifier: string | number | null): string { + return `${provider}:${service ?? ''}:${identifier ?? ''}` + } - async createCollection(params: { - provider: string - service: string | number - collection?: string | number | null - properties: CollectionPropertiesObject - }): Promise { - this.loading = true - this.error = null - - try { - // Prepare request data from CollectionPropertiesObject - const requestData: CollectionCreateRequest = { - provider: params.provider, - service: params.service, - collection: params.collection ?? null, - properties: { - '@type': 'mail.collection', - label: params.properties.label, - role: params.properties.role ?? null, - rank: params.properties.rank ?? 0, - subscribed: params.properties.subscribed ?? true, - }, - } - - // Call service to create collection - const response = await collectionService.create(requestData) - - // Create CollectionObject instance - const collectionObject = new CollectionObject().fromJson(response) - - // Update store with new collection - const provider = response.provider - const service = String(response.service) - const identifier = String(response.identifier) - - if (!this.collections[provider]) { - this.collections[provider] = {} - } - if (!this.collections[provider][service]) { - this.collections[provider][service] = {} - } - - this.collections[provider][service][identifier] = collectionObject - - return collectionObject - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false - } - }, - }, + // Actions + + /** + * Retrieve all or specific collections, optionally filtered by source selector + * + * @param sources - optional source selector + * @param filter - optional list filter + * @param sort - optional list sort + * + * @returns Promise with collection object list keyed by provider, service, and collection identifier + */ + async function list(sources?: SourceSelector, filter?: ListFilter, sort?: ListSort): Promise> { + transceiving.value = true + try { + const response = await collectionService.list({ sources, filter, sort }) - getters: { - collectionList: (state) => { - const list: CollectionObject[] = [] - Object.values(state.collections).forEach(providerCollections => { - Object.values(providerCollections).forEach(serviceCollections => { - Object.values(serviceCollections).forEach(collection => { - list.push(collection) + // Flatten nested structure: provider:service:collection -> "provider:service:collection": object + const collections: Record = {} + Object.entries(response).forEach(([_providerId, providerServices]) => { + Object.entries(providerServices).forEach(([_serviceId, serviceCollections]) => { + Object.entries(serviceCollections).forEach(([_collectionId, collectionObj]) => { + const key = identifierKey(collectionObj.provider, collectionObj.service, collectionObj.identifier) + collections[key] = collectionObj }) }) }) - return list - }, - collectionCount: (state) => { - let count = 0 - Object.values(state.collections).forEach(providerCollections => { - Object.values(providerCollections).forEach(serviceCollections => { - count += Object.keys(serviceCollections).length - }) + // Merge retrieved collections into state + _collections.value = { ..._collections.value, ...collections } + + console.debug('[Mail Manager][Store] - Successfully retrieved', Object.keys(collections).length, 'collections') + return collections + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to retrieve collections:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Retrieve a specific collection by provider, service, and identifier + * + * @param provider - provider identifier + * @param service - service identifier + * @param identifier - collection identifier + * + * @returns Promise with collection object + */ + async function fetch(provider: string, service: string | number, identifier: string | number): Promise { + transceiving.value = true + try { + const response = await collectionService.fetch({ provider, service, collection: identifier }) + + // Merge fetched collection into state + const key = identifierKey(response.provider, response.service, response.identifier) + _collections.value[key] = response + + console.debug('[Mail Manager][Store] - Successfully fetched collection:', key) + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to fetch collection:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Retrieve collection availability status for a given source selector + * + * @param sources - source selector to check availability for + * + * @returns Promise with collection availability status + */ + async function extant(sources: SourceSelector) { + transceiving.value = true + try { + const response = await collectionService.extant({ sources }) + + console.debug('[Mail Manager][Store] - Successfully checked', sources ? Object.keys(sources).length : 0, 'collections') + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to check collections:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Create a new collection with given provider, service, and data + * + * @param provider - provider identifier for the new collection + * @param service - service identifier for the new collection + * @param collection - optional parent collection identifier + * @param data - collection properties for creation + * + * @returns Promise with created collection object + */ + async function create(provider: string, service: string | number, collection: string | number | null, data: CollectionMutableProperties): Promise { + transceiving.value = true + try { + const response = await collectionService.create({ + provider, + service, + collection, + properties: data }) - return count - }, + + // Merge created collection into state + const key = identifierKey(response.provider, response.service, response.identifier) + _collections.value[key] = response + + console.debug('[Mail Manager][Store] - Successfully created collection:', key) + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to create collection:', error) + throw error + } finally { + transceiving.value = false + } + } - hasCollections: (state) => { - return Object.values(state.collections).some(providerCollections => - Object.values(providerCollections).some(serviceCollections => - Object.keys(serviceCollections).length > 0 - ) - ) - }, - }, + /** + * Update an existing collection with given provider, service, identifier, and data + * + * @param provider - provider identifier for the collection to update + * @param service - service identifier for the collection to update + * @param identifier - collection identifier for the collection to update + * @param data - collection properties for update + * + * @returns Promise with updated collection object + */ + async function update(provider: string, service: string | number, identifier: string | number, data: CollectionMutableProperties): Promise { + transceiving.value = true + try { + const response = await collectionService.update({ + provider, + service, + identifier, + properties: data + }) + + // Merge updated collection into state + const key = identifierKey(response.provider, response.service, response.identifier) + _collections.value[key] = response + + console.debug('[Mail Manager][Store] - Successfully updated collection:', key) + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to update collection:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Delete a collection by provider, service, and identifier + * + * @param provider - provider identifier for the collection to delete + * @param service - service identifier for the collection to delete + * @param identifier - collection identifier for the collection to delete + * + * @returns Promise with deletion result + */ + async function remove(provider: string, service: string | number, identifier: string | number): Promise { + transceiving.value = true + try { + await collectionService.delete({ provider, service, identifier }) + + // Remove deleted collection from state + const key = identifierKey(provider, service, identifier) + delete _collections.value[key] + + console.debug('[Mail Manager][Store] - Successfully deleted collection:', key) + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to delete collection:', error) + throw error + } finally { + transceiving.value = false + } + } + + // Return public API + return { + // State (readonly) + transceiving: readonly(transceiving), + // Getters + count, + has, + collections, + collectionsByService, + collectionsForService, + collectionsInCollection, + // Actions + collection, + list, + fetch, + extant, + create, + update, + delete: remove, + } }) diff --git a/src/stores/entitiesStore.ts b/src/stores/entitiesStore.ts index 6632cb4..4740392 100644 --- a/src/stores/entitiesStore.ts +++ b/src/stores/entitiesStore.ts @@ -1,261 +1,369 @@ +/** + * Entities Store + */ + +import { ref, computed, readonly } from 'vue' import { defineStore } from 'pinia' import { entityService } from '../services' -import type { MessageObject, EntityWrapper, MessageSendRequest } from '../types' +import { EntityObject } from '../models' +import type { EntityTransmitRequest, EntityTransmitResponse } from '../types/entity' +import type { SourceSelector, ListFilter, ListSort, ListRange } from '../types/common' -export const useEntitiesStore = defineStore('mail-entities', { - state: () => ({ - messages: {} as Record>>>>, - signatures: {} as Record>>, // Track delta signatures - loading: false, - error: null as string | null, - }), +export const useEntitiesStore = defineStore('mailEntitiesStore', () => { + // State + const _entities = ref>({}) + const transceiving = ref(false) - actions: { - async loadMessages(sources?: any, filter?: any, sort?: any, range?: any) { - this.loading = true - this.error = null - try { - const response = await entityService.list({ sources, filter, sort, range }) - - // Entities come as objects keyed by identifier - Object.entries(response).forEach(([provider, providerData]) => { - Object.entries(providerData).forEach(([service, serviceData]) => { - Object.entries(serviceData).forEach(([collection, entities]) => { - if (!this.messages[provider]) { - this.messages[provider] = {} - } - if (!this.messages[provider][service]) { - this.messages[provider][service] = {} - } - if (!this.messages[provider][service][collection]) { - this.messages[provider][service][collection] = {} - } - - // Entities are already keyed by identifier - this.messages[provider][service][collection] = entities as Record> - }) - }) - }) - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false - } - }, + /** + * Get count of entities in store + */ + const count = computed(() => Object.keys(_entities.value).length) - async getMessages( - provider: string, - service: string | number, - collection: string | number, - identifiers: (string | number)[], - properties?: string[] - ) { - this.loading = true - this.error = null - try { - const response = await entityService.fetch({ - provider, - service, - collection, - identifiers, - properties - }) - - // Update in store - if (!this.messages[provider]) { - this.messages[provider] = {} + /** + * Check if any entities are present in store + */ + const has = computed(() => count.value > 0) + + /** + * Get all entities present in store + */ + const entities = computed(() => Object.values(_entities.value)) + + /** + * Get a specific entity from store, with optional retrieval + * + * @param provider - provider identifier + * @param service - service identifier + * @param collection - collection identifier + * @param identifier - entity identifier + * @param retrieve - Retrieve behavior: true = fetch if missing or refresh, false = cache only + * + * @returns Entity object or null + */ + function entity(provider: string, service: string | number, collection: string | number, identifier: string | number, retrieve: boolean = false): EntityObject | null { + const key = identifierKey(provider, service, collection, identifier) + if (retrieve === true && !_entities.value[key]) { + console.debug(`[Mail Manager][Store] - Force fetching entity "${key}"`) + fetch(provider, service, collection, [identifier]) + } + + return _entities.value[key] || null + } + + /** + * Get all entities for a specific collection + * + * @param provider - provider identifier + * @param service - service identifier + * @param collection - collection identifier + * @param retrieve - Retrieve behavior: true = fetch if missing or refresh, false = cache only + * + * @returns Array of entity objects + */ + function entitiesForCollection(provider: string, service: string | number, collection: string | number, retrieve: boolean = false): EntityObject[] { + const collectionKeyPrefix = `${provider}:${service}:${collection}:` + const collectionEntities = Object.entries(_entities.value) + .filter(([key]) => key.startsWith(collectionKeyPrefix)) + .map(([_, entity]) => entity) + + if (retrieve === true && collectionEntities.length === 0) { + console.debug(`[Mail Manager][Store] - Force fetching entities for collection "${provider}:${service}:${collection}"`) + const sources: SourceSelector = { + [provider]: { + [String(service)]: { + [String(collection)]: true + } } - if (!this.messages[provider][String(service)]) { - this.messages[provider][String(service)] = {} - } - if (!this.messages[provider][String(service)][String(collection)]) { - this.messages[provider][String(service)][String(collection)] = {} - } - - // Index fetched entities by identifier - response.entities.forEach((entity: EntityWrapper) => { - this.messages[provider][String(service)][String(collection)][entity.identifier] = entity - }) - - return response - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false } - }, + list(sources) + } + + return collectionEntities + } - async searchMessages( - provider: string, - service: string | number, - query: string, - collections?: (string | number)[], - filter?: any, - sort?: any, - range?: any - ) { - this.loading = true - this.error = null - try { - const response = await entityService.search({ - provider, - service, - query, - collections, - filter, - sort, - range - }) - return response - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false - } - }, + /** + * Create unique key for an entity + */ + function identifierKey(provider: string, service: string | number, collection: string | number, identifier: string | number): string { + return `${provider}:${service}:${collection}:${identifier}` + } - async sendMessage(request: MessageSendRequest) { - this.loading = true - this.error = null - try { - const response = await entityService.send(request) - return response - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false - } - }, + // Actions + + /** + * Retrieve all or specific entities, optionally filtered by source selector + * + * @param sources - optional source selector + * @param filter - optional list filter + * @param sort - optional list sort + * @param range - optional list range + * + * @returns Promise with entity object list keyed by identifier + */ + async function list(sources?: SourceSelector, filter?: ListFilter, sort?: ListSort, range?: ListRange): Promise> { + transceiving.value = true + try { + const response = await entityService.list({ sources, filter, sort, range }) - async getDelta(sources: any) { - this.loading = true - this.error = null - try { - // Sources are already in correct format: { provider: { service: { collection: signature } } } - const response = await entityService.delta({ sources }) - - // Process delta and update store - Object.entries(response).forEach(([provider, providerData]) => { - Object.entries(providerData).forEach(([service, serviceData]) => { - Object.entries(serviceData).forEach(([collection, collectionData]) => { - // Skip if no changes (server returns false or string signature) - if (collectionData === false || typeof collectionData === 'string') { - return - } - - if (!this.messages[provider]) { - this.messages[provider] = {} - } - if (!this.messages[provider][service]) { - this.messages[provider][service] = {} - } - if (!this.messages[provider][service][collection]) { - this.messages[provider][service][collection] = {} - } - - const collectionMessages = this.messages[provider][service][collection] - - // Update signature if provided - if (typeof collectionData === 'object' && collectionData.signature) { - if (!this.signatures[provider]) { - this.signatures[provider] = {} - } - if (!this.signatures[provider][service]) { - this.signatures[provider][service] = {} - } - this.signatures[provider][service][collection] = collectionData.signature - console.log(`[Store] Updated signature for ${provider}/${service}/${collection}: "${collectionData.signature}"`) - } - - // Process additions (from delta response format) - if (collectionData.additions) { - // Note: additions are just identifiers, need to fetch full entities separately - // This is handled by the sync composable - } - - // Process modifications - if (collectionData.modifications) { - // Note: modifications are just identifiers, need to fetch full entities separately - } - - // Remove deleted messages - if (collectionData.deletions) { - collectionData.deletions.forEach((id: string | number) => { - delete collectionMessages[String(id)] - }) - } - - // Legacy support: Also handle created/modified/deleted format - if (collectionData.created) { - collectionData.created.forEach((entity: EntityWrapper) => { - collectionMessages[entity.identifier] = entity - }) - } - - if (collectionData.modified) { - collectionData.modified.forEach((entity: EntityWrapper) => { - collectionMessages[entity.identifier] = entity - }) - } - - if (collectionData.deleted) { - collectionData.deleted.forEach((id: string | number) => { - delete collectionMessages[String(id)] - }) - } - }) - }) - }) - - return response - } catch (error: any) { - this.error = error.message - throw error - } finally { - this.loading = false - } - }, - }, - - getters: { - messageList: (state) => { - const list: EntityWrapper[] = [] - Object.values(state.messages).forEach(providerMessages => { - Object.values(providerMessages).forEach(serviceMessages => { - Object.values(serviceMessages).forEach(collectionMessages => { - Object.values(collectionMessages).forEach(message => { - list.push(message) + // Flatten nested structure: provider:service:collection:entity -> "provider:service:collection:entity": object + const entities: Record = {} + Object.entries(response).forEach(([providerId, providerServices]) => { + Object.entries(providerServices).forEach(([serviceId, serviceCollections]) => { + Object.entries(serviceCollections).forEach(([collectionId, collectionEntities]) => { + Object.entries(collectionEntities).forEach(([entityId, entityData]) => { + const key = identifierKey(providerId, serviceId, collectionId, entityId) + entities[key] = entityData }) }) }) }) - return list - }, - messageCount: (state) => { - let count = 0 - Object.values(state.messages).forEach(providerMessages => { - Object.values(providerMessages).forEach(serviceMessages => { - Object.values(serviceMessages).forEach(collectionMessages => { - count += Object.keys(collectionMessages).length + // Merge retrieved entities into state + _entities.value = { ..._entities.value, ...entities } + + console.debug('[Mail Manager][Store] - Successfully retrieved', Object.keys(entities).length, 'entities') + return entities + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to retrieve entities:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Retrieve specific entities by provider, service, collection, and identifiers + * + * @param provider - provider identifier + * @param service - service identifier + * @param collection - collection identifier + * @param identifiers - array of entity identifiers to fetch + * + * @returns Promise with entity objects keyed by identifier + */ + async function fetch(provider: string, service: string | number, collection: string | number, identifiers: (string | number)[]): Promise> { + transceiving.value = true + try { + const response = await entityService.fetch({ provider, service, collection, identifiers }) + + // Merge fetched entities into state + const entities: Record = {} + Object.entries(response).forEach(([identifier, entityData]) => { + const key = identifierKey(provider, service, collection, identifier) + entities[key] = entityData + _entities.value[key] = entityData + }) + + console.debug('[Mail Manager][Store] - Successfully fetched', Object.keys(entities).length, 'entities') + return entities + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to fetch entities:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Retrieve entity availability status for a given source selector + * + * @param sources - source selector to check availability for + * + * @returns Promise with entity availability status + */ + async function extant(sources: SourceSelector) { + transceiving.value = true + try { + const response = await entityService.extant({ sources }) + console.debug('[Mail Manager][Store] - Successfully checked entity availability') + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to check entity availability:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Create a new entity with given provider, service, collection, and data + * + * @param provider - provider identifier for the new entity + * @param service - service identifier for the new entity + * @param collection - collection identifier for the new entity + * @param data - entity properties for creation + * + * @returns Promise with created entity object + */ + async function create(provider: string, service: string | number, collection: string | number, data: any): Promise { + transceiving.value = true + try { + const response = await entityService.create({ provider, service, collection, properties: data }) + + // Add created entity to state + const key = identifierKey(response.provider, response.service, response.collection, response.identifier) + _entities.value[key] = response + + console.debug('[Mail Manager][Store] - Successfully created entity:', key) + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to create entity:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Update an existing entity with given provider, service, collection, identifier, and data + * + * @param provider - provider identifier for the entity to update + * @param service - service identifier for the entity to update + * @param collection - collection identifier for the entity to update + * @param identifier - entity identifier for the entity to update + * @param data - entity properties for update + * + * @returns Promise with updated entity object + */ + async function update(provider: string, service: string | number, collection: string | number, identifier: string | number, data: any): Promise { + transceiving.value = true + try { + const response = await entityService.update({ provider, service, collection, identifier, properties: data }) + + // Update entity in state + const key = identifierKey(response.provider, response.service, response.collection, response.identifier) + _entities.value[key] = response + + console.debug('[Mail Manager][Store] - Successfully updated entity:', key) + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to update entity:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Delete an entity by provider, service, collection, and identifier + * + * @param provider - provider identifier for the entity to delete + * @param service - service identifier for the entity to delete + * @param collection - collection identifier for the entity to delete + * @param identifier - entity identifier for the entity to delete + * + * @returns Promise with deletion result + */ + async function remove(provider: string, service: string | number, collection: string | number, identifier: string | number): Promise { + transceiving.value = true + try { + const response = await entityService.delete({ provider, service, collection, identifier }) + + // Remove entity from state + const key = identifierKey(provider, service, collection, identifier) + delete _entities.value[key] + + console.debug('[Mail Manager][Store] - Successfully deleted entity:', key) + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to delete entity:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Retrieve delta changes for entities + * + * @param sources - source selector for delta check + * + * @returns Promise with delta changes (additions, modifications, deletions) + * + * Note: Delta returns only identifiers, not full entities. + * Caller should fetch full entities for additions/modifications separately. + */ + async function delta(sources: SourceSelector) { + transceiving.value = true + try { + const response = await entityService.delta({ sources }) + + // Process delta and update store + Object.entries(response).forEach(([provider, providerData]) => { + // Skip if no changes for provider + if (providerData === false) return + + Object.entries(providerData).forEach(([service, serviceData]) => { + // Skip if no changes for service + if (serviceData === false) return + + Object.entries(serviceData).forEach(([collection, collectionData]) => { + // Skip if no changes for collection + if (collectionData === false) return + + // Process deletions (remove from store) + if (collectionData.deletions && collectionData.deletions.length > 0) { + collectionData.deletions.forEach((identifier) => { + const key = identifierKey(provider, service, collection, identifier) + delete _entities.value[key] + }) + } + + // Note: additions and modifications contain only identifiers + // The caller should fetch full entities using the fetch() method }) }) }) - return count - }, - hasMessages: (state) => { - return Object.values(state.messages).some(providerMessages => - Object.values(providerMessages).some(serviceMessages => - Object.values(serviceMessages).some(collectionMessages => - Object.keys(collectionMessages).length > 0 - ) - ) - ) - }, - }, + console.debug('[Mail Manager][Store] - Successfully processed delta changes') + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to process delta:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Send/transmit an entity + * + * @param request - transmit request parameters + * + * @returns Promise with transmission result + */ + async function transmit(request: EntityTransmitRequest): Promise { + transceiving.value = true + try { + const response = await entityService.transmit(request) + console.debug('[Mail Manager][Store] - Successfully transmitted entity') + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to transmit entity:', error) + throw error + } finally { + transceiving.value = false + } + } + + // Return public API + return { + // State (readonly) + transceiving: readonly(transceiving), + // Getters + count, + has, + entities, + entitiesForCollection, + // Actions + entity, + list, + fetch, + extant, + create, + update, + delete: remove, + delta, + transmit, + } }) diff --git a/src/stores/providersStore.ts b/src/stores/providersStore.ts index 1194c6e..8bd6b81 100644 --- a/src/stores/providersStore.ts +++ b/src/stores/providersStore.ts @@ -12,59 +12,60 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => { // State const _providers = ref>({}) const transceiving = ref(false) - const error = ref(null) - // Getters + /** + * Get count of providers in store + */ const count = computed(() => Object.keys(_providers.value).length) + + /** + * Check if any providers are present in store + */ const has = computed(() => count.value > 0) /** - * Get providers as an array - * @returns Array of provider objects + * Get all providers present in store */ const providers = computed(() => Object.values(_providers.value)) /** - * Get a specific provider by identifier from cache + * Get a specific provider from store, with optional retrieval + * * @param identifier - Provider identifier + * @param retrieve - Retrieve behavior: true = fetch if missing or refresh, false = cache only + * * @returns Provider object or null */ - function provider(identifier: string): ProviderObject | null { + function provider(identifier: string, retrieve: boolean = false): ProviderObject | null { + if (retrieve === true && !_providers.value[identifier]) { + console.debug(`[Mail Manager][Store] - Force fetching provider "${identifier}"`) + fetch(identifier) + } + return _providers.value[identifier] || null } // Actions + /** - * Retrieve all or specific providers + * Retrieve all or specific providers, optionally filtered by source selector + * + * @param request - list request parameters + * + * @returns Promise with provider object list keyed by provider identifier */ async function list(sources?: SourceSelector): Promise> { transceiving.value = true - error.value = null try { - const response = await providerService.list({ sources }) + const providers = await providerService.list({ sources }) - console.debug('[Mail Manager](Store) - Successfully retrieved', Object.keys(response).length, 'providers') + // Merge retrieved providers into state + _providers.value = { ..._providers.value, ...providers } - _providers.value = response - return response - } catch (err: any) { - console.error('[Mail Manager](Store) - Failed to retrieve providers:', err) - error.value = err.message - throw err - } finally { - transceiving.value = false - } - } - - /** - * Fetch a specific provider - */ - async function fetch(identifier: string): Promise { - transceiving.value = true - try { - return await providerService.fetch({ identifier }) + console.debug('[Mail Manager][Store] - Successfully retrieved', Object.keys(providers).length, 'providers') + return providers } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to fetch provider:', error) + console.error('[Mail Manager][Store] - Failed to retrieve providers:', error) throw error } finally { transceiving.value = false @@ -72,19 +73,53 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => { } /** - * Check which providers exist/are available + * Retrieve a specific provider by identifier + * + * @param identifier - provider identifier + * + * @returns Promise with provider object + */ + async function fetch(identifier: string): Promise { + transceiving.value = true + try { + const provider = await providerService.fetch({ identifier }) + + // Merge fetched provider into state + _providers.value[provider.identifier] = provider + + console.debug('[Mail Manager][Store] - Successfully fetched provider:', provider.identifier) + return provider + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to fetch provider:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Retrieve provider availability status for a given source selector + * + * @param sources - source selector to check availability for + * + * @returns Promise with provider availability status */ async function extant(sources: SourceSelector) { transceiving.value = true - error.value = null try { const response = await providerService.extant({ sources }) - console.debug('[Mail Manager](Store) - Successfully checked', sources ? Object.keys(sources).length : 0, 'providers') + + Object.entries(response).forEach(([providerId, providerStatus]) => { + if (providerStatus === false) { + delete _providers.value[providerId] + } + }) + + console.debug('[Mail Manager][Store] - Successfully checked', sources ? Object.keys(sources).length : 0, 'providers') return response - } catch (err: any) { - console.error('[Mail Manager](Store) - Failed to check providers:', err) - error.value = err.message - throw err + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to check providers:', error) + throw error } finally { transceiving.value = false } @@ -94,7 +129,6 @@ export const useProvidersStore = defineStore('mailProvidersStore', () => { return { // State transceiving: readonly(transceiving), - error: readonly(error), // computed count, has, diff --git a/src/stores/servicesStore.ts b/src/stores/servicesStore.ts index 7aecb98..11d3859 100644 --- a/src/stores/servicesStore.ts +++ b/src/stores/servicesStore.ts @@ -10,27 +10,31 @@ import type { ServiceLocation, SourceSelector, ServiceIdentity, + ServiceInterface, } from '../types' export const useServicesStore = defineStore('mailServicesStore', () => { // State const _services = ref>({}) const transceiving = ref(false) - const lastTestResult = ref(null) - // Getters + /** + * Get count of services in store + */ const count = computed(() => Object.keys(_services.value).length) + + /** + * Check if any services are present in store + */ const has = computed(() => count.value > 0) /** - * Get services as an array - * @returns Array of service objects + * Get all services present in store */ const services = computed(() => Object.values(_services.value)) /** - * Get services grouped by provider - * @returns Services grouped by provider ID + * Get all services present in store grouped by provider */ const servicesByProvider = computed(() => { const groups: Record = {} @@ -45,9 +49,60 @@ export const useServicesStore = defineStore('mailServicesStore', () => { return groups }) - // Actions /** - * Retrieve for all or specific services + * Get a specific service from store, with optional retrieval + * + * @param provider - provider identifier + * @param identifier - service identifier + * @param retrieve - Retrieve behavior: true = fetch if missing or refresh, false = cache only + * + * @returns Service object or null + */ + function service(provider: string, identifier: string | number, retrieve: boolean = false): ServiceObject | null { + const key = identifierKey(provider, identifier) + if (retrieve === true && !_services.value[key]) { + console.debug(`[Mail Manager][Store] - Force fetching service "${key}"`) + fetch(provider, identifier) + } + + return _services.value[key] || null + } + + /** + * Get a service from store matching a given address, with optional retrieval + * + * @param address - email address to match against primary and secondary addresses + * @param retrieve - Retrieve behavior: true = fetch if missing, false = cache only + * + * @returns Service object or null + */ + function serviceForAddress(address: string, retrieve: boolean = false): ServiceObject | null { + const service = Object.values(_services.value).find(s => s.primaryAddress === address || s.secondaryAddresses?.includes(address)) + + if (retrieve === true && !service) { + console.debug(`[Mail Manager][Store] - No service found for address "${address}", discovery may be needed`) + + // TODO: Implement retrieving service by address + } + + return service || null + } + + /** + * Unique key for a service + */ + function identifierKey(provider: string, identifier: string | number | null): string { + return `${provider}:${identifier ?? ''}` + } + + // Actions + + /** + * Retrieve all or specific services, optionally filtered by source selector + * + * @param sources - optional source selector + * + * @returns Promise with service object list keyed by provider and service identifier */ async function list(sources?: SourceSelector): Promise> { transceiving.value = true @@ -55,20 +110,21 @@ export const useServicesStore = defineStore('mailServicesStore', () => { const response = await serviceService.list({ sources }) // Flatten nested structure: provider-id: { service-id: object } -> "provider-id:service-id": object - const flattened: Record = {} + const services: Record = {} Object.entries(response).forEach(([_providerId, providerServices]) => { Object.entries(providerServices).forEach(([_serviceId, serviceObj]) => { - const key = `${serviceObj.provider}:${serviceObj.identifier}` - flattened[key] = serviceObj + const key = identifierKey(serviceObj.provider, serviceObj.identifier) + services[key] = serviceObj }) }) - console.debug('[Mail Manager](Store) - Successfully retrieved', Object.keys(flattened).length, 'services') + // Merge retrieved services into state + _services.value = { ..._services.value, ...services } - _services.value = flattened - return flattened + console.debug('[Mail Manager][Store] - Successfully retrieved', Object.keys(services).length, 'services') + return services } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to retrieve services:', error) + console.error('[Mail Manager][Store] - Failed to retrieve services:', error) throw error } finally { transceiving.value = false @@ -76,14 +132,26 @@ export const useServicesStore = defineStore('mailServicesStore', () => { } /** - * Fetch a specific service + * Retrieve a specific service by provider and identifier + * + * @param provider - provider identifier + * @param identifier - service identifier + * + * @returns Promise with service object */ async function fetch(provider: string, identifier: string | number): Promise { transceiving.value = true try { - return await serviceService.fetch({ provider, identifier }) + const service = await serviceService.fetch({ provider, identifier }) + + // Merge fetched service into state + const key = identifierKey(service.provider, service.identifier) + _services.value[key] = service + + console.debug('[Mail Manager][Store] - Successfully fetched service:', key) + return service } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to fetch service:', error) + console.error('[Mail Manager][Store] - Failed to fetch service:', error) throw error } finally { transceiving.value = false @@ -91,9 +159,117 @@ export const useServicesStore = defineStore('mailServicesStore', () => { } /** - * Discover service configuration + * Retrieve service availability status for a given source selector * - * @returns Array of discovered services sorted by provider + * @param sources - source selector to check availability for + * + * @returns Promise with service availability status + */ + async function extant(sources: SourceSelector) { + transceiving.value = true + try { + const response = await serviceService.extant({ sources }) + + console.debug('[Mail Manager][Store] - Successfully checked', sources ? Object.keys(sources).length : 0, 'services') + return response + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to check services:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Create a new service with given provider and data + * + * @param provider - provider identifier for the new service + * @param data - partial service data for creation + * + * @returns Promise with created service object + */ + async function create(provider: string, data: Partial): Promise { + transceiving.value = true + try { + const service = await serviceService.create({ provider, data }) + + // Merge created service into state + const key = identifierKey(service.provider, service.identifier) + _services.value[key] = service + + console.debug('[Mail Manager][Store] - Successfully created service:', key) + return service + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to create service:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Update an existing service with given provider, identifier, and data + * + * @param provider - provider identifier for the service to update + * @param identifier - service identifier for the service to update + * @param data - partial service data for update + * + * @returns Promise with updated service object + */ + async function update(provider: string, identifier: string | number, data: Partial): Promise { + transceiving.value = true + try { + const service = await serviceService.update({ provider, identifier, data }) + + // Merge updated service into state + const key = identifierKey(service.provider, service.identifier) + _services.value[key] = service + + console.debug('[Mail Manager][Store] - Successfully updated service:', key) + return service + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to update service:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Delete a service by provider and identifier + * + * @param provider - provider identifier for the service to delete + * @param identifier - service identifier for the service to delete + * + * @returns Promise with deletion result + */ + async function remove(provider: string, identifier: string | number): Promise { + transceiving.value = true + try { + await serviceService.delete({ provider, identifier }) + + // Remove deleted service from state + const key = identifierKey(provider, identifier) + delete _services.value[key] + + console.debug('[Mail Manager][Store] - Successfully deleted service:', key) + } catch (error: any) { + console.error('[Mail Manager][Store] - Failed to delete service:', error) + throw error + } finally { + transceiving.value = false + } + } + + /** + * Discover services based on provided parameters + * + * @param identity - optional service identity for discovery + * @param secret - optional secret for discovery + * @param location - optional location for discovery + * @param provider - optional provider identifier for discovery + * + * @returns Promise with list of discovered service objects */ async function discover( identity: string, @@ -105,16 +281,27 @@ export const useServicesStore = defineStore('mailServicesStore', () => { try { const services = await serviceService.discover({identity, secret, location, provider}) - console.debug('[Mail Manager](Store) - Successfully discovered', services.length, 'services') + + console.debug('[Mail Manager][Store] - Successfully discovered', services.length, 'services') return services } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to discover service:', error) + console.error('[Mail Manager][Store] - Failed to discover service:', error) throw error } finally { transceiving.value = false } } + /** + * Test service connectivity and configuration + * + * @param provider - provider identifier for the service to test + * @param identifier - optional service identifier for testing existing service + * @param location - optional service location for testing new configuration + * @param identity - optional service identity for testing new configuration + * + * @return Promise with test results + */ async function test( provider: string, identifier?: string | number | null, @@ -124,62 +311,11 @@ export const useServicesStore = defineStore('mailServicesStore', () => { transceiving.value = true try { const response = await serviceService.test({ provider, identifier, location, identity }) - lastTestResult.value = response + + console.debug('[Mail Manager][Store] - Successfully tested service:', provider, identifier || location) return response } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to test service:', error) - throw error - } finally { - transceiving.value = false - } - } - - async function create(provider: string, data: any) { - transceiving.value = true - try { - const serviceObj = await serviceService.create({ provider, data }) - - // Add to store with composite key - const key = `${serviceObj.provider}:${serviceObj.identifier}` - _services.value[key] = serviceObj - - return serviceObj - } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to create service:', error) - throw error - } finally { - transceiving.value = false - } - } - - async function update(provider: string, identifier: string | number, data: any) { - transceiving.value = true - try { - const serviceObj = await serviceService.update({ provider, identifier, data }) - - // Update in store with composite key - const key = `${serviceObj.provider}:${serviceObj.identifier}` - _services.value[key] = serviceObj - - return serviceObj - } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to update service:', error) - throw error - } finally { - transceiving.value = false - } - } - - async function remove(provider: string, identifier: string | number) { - transceiving.value = true - try { - await serviceService.delete({ provider, identifier }) - - // Remove from store using composite key - const key = `${provider}:${identifier}` - delete _services.value[key] - } catch (error: any) { - console.error('[Mail Manager](Store) - Failed to delete service:', error) + console.error('[Mail Manager][Store] - Failed to test service:', error) throw error } finally { transceiving.value = false @@ -190,7 +326,6 @@ export const useServicesStore = defineStore('mailServicesStore', () => { return { // State (readonly) transceiving: readonly(transceiving), - lastTestResult: readonly(lastTestResult), // Getters count, has, @@ -198,12 +333,15 @@ export const useServicesStore = defineStore('mailServicesStore', () => { servicesByProvider, // Actions + service, + serviceForAddress, list, fetch, - discover, - test, + extant, create, update, delete: remove, + discover, + test, } }) diff --git a/src/types/collection.ts b/src/types/collection.ts index a651c32..df1d1e2 100644 --- a/src/types/collection.ts +++ b/src/types/collection.ts @@ -1,10 +1,10 @@ /** - * Collection-related type definitions for Mail Manager + * Collection type definitions */ -import type { SourceSelector } from './common'; +import type { ListFilter, ListSort, SourceSelector } from './common'; /** - * Collection interface (mailbox/folder) + * Collection information */ export interface CollectionInterface { provider: string; @@ -22,41 +22,29 @@ export interface CollectionBaseProperties { version: number; } -/** - * Immutable collection properties (computed by server) - */ export interface CollectionImmutableProperties extends CollectionBaseProperties { total?: number; unread?: number; role?: string | null; } -/** - * Mutable collection properties (can be modified by user) - */ export interface CollectionMutableProperties extends CollectionBaseProperties { label: string; rank?: number; subscribed?: boolean; } -/** - * Full collection properties (what server returns) - */ export interface CollectionPropertiesInterface extends CollectionMutableProperties, CollectionImmutableProperties {} /** - * Collection list request + * Collection list */ export interface CollectionListRequest { sources?: SourceSelector; - filter?: any; - sort?: any; + filter?: ListFilter; + sort?: ListSort; } -/** - * Collection list response - */ export interface CollectionListResponse { [providerId: string]: { [serviceId: string]: { @@ -66,15 +54,23 @@ export interface CollectionListResponse { } /** - * Collection extant request + * Collection fetch + */ +export interface CollectionFetchRequest { + provider: string; + service: string | number; + collection: string | number; +} + +export interface CollectionFetchResponse extends CollectionInterface {} + +/** + * Collection extant */ export interface CollectionExtantRequest { sources: SourceSelector; } -/** - * Collection extant response - */ export interface CollectionExtantResponse { [providerId: string]: { [serviceId: string]: { @@ -84,21 +80,7 @@ export interface CollectionExtantResponse { } /** - * Collection fetch request - */ -export interface CollectionFetchRequest { - provider: string; - service: string | number; - collection: string | number; -} - -/** - * Collection fetch response - */ -export interface CollectionFetchResponse extends CollectionInterface {} - -/** - * Collection create request + * Collection create */ export interface CollectionCreateRequest { provider: string; @@ -107,42 +89,33 @@ export interface CollectionCreateRequest { properties: CollectionMutableProperties; } -/** - * Collection create response - */ export interface CollectionCreateResponse extends CollectionInterface {} /** - * Collection modify request + * Collection modify */ -export interface CollectionModifyRequest { +export interface CollectionUpdateRequest { provider: string; service: string | number; identifier: string | number; properties: CollectionMutableProperties; } -/** - * Collection modify response - */ -export interface CollectionModifyResponse extends CollectionInterface {} +export interface CollectionUpdateResponse extends CollectionInterface {} /** - * Collection destroy request + * Collection delete */ -export interface CollectionDestroyRequest { +export interface CollectionDeleteRequest { provider: string; service: string | number; identifier: string | number; options?: { - force?: boolean; // Whether to force destroy even if collection is not empty - recursive?: boolean; // Whether to destroy child collections/items as well + force?: boolean; // Whether to force delete even if collection is not empty + recursive?: boolean; // Whether to delete child collections/items as well }; } -/** - * Collection destroy response - */ -export interface CollectionDestroyResponse { +export interface CollectionDeleteResponse { success: boolean; } diff --git a/src/types/common.ts b/src/types/common.ts index ba8bc15..ab912d4 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -1,5 +1,5 @@ /** - * Common types shared across Mail Manager services + * Common types shared across provider, service, collection, and entity request and responses. */ /** @@ -44,8 +44,19 @@ export interface ApiErrorResponse { export type ApiResponse = ApiSuccessResponse | ApiErrorResponse; /** - * Source selector structure for hierarchical resource selection - * Structure: Provider -> Service -> Collection -> Message + * Selector for targeting specific providers, services, collections, or entities in list or extant operations. + * + * Example usage: + * { + * "provider1": true, // Select all services/collections/entities under provider1 + * "provider2": { + * "serviceA": true, // Select all collections/entities under serviceA of provider2 + * "serviceB": { + * "collectionX": true, // Select all entities under collectionX of serviceB of provider2 + * "collectionY": [1, 2, 3] // Select entities with identifiers 1, 2, and 3 under collectionY of serviceB of provider2 + * } + * } + * } */ export type SourceSelector = { [provider: string]: boolean | ServiceSelector; @@ -56,38 +67,90 @@ export type ServiceSelector = { }; export type CollectionSelector = { - [collection: string | number]: boolean | MessageSelector; + [collection: string | number]: boolean | EntitySelector; }; -export type MessageSelector = (string | number)[]; +export type EntitySelector = (string | number)[]; + /** - * Filter condition for building complex queries + * Filter comparison for list operations */ -export interface FilterCondition { - field: string; - operator: string; - value: any; -} +export const ListFilterComparisonOperator = { + EQ: 1, // Equal + NEQ: 2, // Not Equal + GT: 4, // Greater Than + LT: 8, // Less Than + GTE: 16, // Greater Than or Equal + LTE: 32, // Less Than or Equal + IN: 64, // In Array + NIN: 128, // Not In Array + LIKE: 256, // Like + NLIKE: 512, // Not Like +} as const; + +export type ListFilterComparisonOperator = typeof ListFilterComparisonOperator[keyof typeof ListFilterComparisonOperator]; /** - * Filter criteria for list operations + * Filter conjunction for list operations + */ +export const ListFilterConjunctionOperator = { + NONE: '', + AND: 'AND', + OR: 'OR', +} as const; + +export type ListFilterConjunctionOperator = typeof ListFilterConjunctionOperator[keyof typeof ListFilterConjunctionOperator]; + +/** + * Filter condition for list operations + * + * Tuple format: [value, comparator?, conjunction?] + */ +export type ListFilterCondition = [ + string | number | boolean | string[] | number[], + ListFilterComparisonOperator?, + ListFilterConjunctionOperator? +]; + +/** + * Filter for list operations + * + * Values can be: + * - Simple primitives (string | number | boolean) for default equality comparison + * - ListFilterCondition tuple for explicit comparator/conjunction + * + * Examples: + * - Simple usage: { name: "John" } + * - With comparator: { age: [25, ListFilterComparisonOperator.GT] } + * - With conjunction: { age: [25, ListFilterComparisonOperator.GT, ListFilterConjunctionOperator.AND] } + * - With array value for IN operator: { status: [["active", "pending"], ListFilterComparisonOperator.IN] } */ export interface ListFilter { - [key: string]: any; + [attribute: string]: string | number | boolean | ListFilterCondition; } /** - * Sort options for list operations + * Sort for list operations + * + * Values can be: + * - true for ascending + * - false for descending */ export interface ListSort { - [key: string]: boolean; + [attribute: string]: boolean; } /** - * Range specification for pagination/limiting results + * Range for list operations + * + * Values can be: + * - relative based on item identifier + * - absolute based on item count */ export interface ListRange { - start: number; - limit: number; -} + type: 'tally'; + anchor: 'relative' | 'absolute'; + position: string | number; + tally: number; +} \ No newline at end of file diff --git a/src/types/entity.ts b/src/types/entity.ts index fe4c41c..87690c5 100644 --- a/src/types/entity.ts +++ b/src/types/entity.ts @@ -1,11 +1,11 @@ /** - * Entity type definitions for mail + * Entity type definitions */ -import type { SourceSelector } from './common'; +import type { SourceSelector, ListFilter, ListSort, ListRange } from './common'; import type { MessageInterface } from './message'; /** - * Entity wrapper with metadata + * Entity definition */ export interface EntityInterface { provider: string; @@ -19,18 +19,15 @@ export interface EntityInterface { } /** - * Entity list request + * Entity list */ export interface EntityListRequest { sources?: SourceSelector; - filter?: any; - sort?: any; - range?: { start: number; limit: number }; + filter?: ListFilter; + sort?: ListSort; + range?: ListRange; } -/** - * Entity list response - */ export interface EntityListResponse { [providerId: string]: { [serviceId: string]: { @@ -42,68 +39,38 @@ export interface EntityListResponse { } /** - * Entity delta request - */ -export interface EntityDeltaRequest { - sources: SourceSelector; -} - -/** - * Entity delta response - */ -export interface EntityDeltaResponse { - [providerId: string]: { - [serviceId: string]: { - [collectionId: string]: { - signature: string; - created?: EntityInterface[]; - modified?: EntityInterface[]; - deleted?: string[]; - }; - }; - }; -} - -/** - * Entity extant request - */ -export interface EntityExtantRequest { - sources: SourceSelector; -} - -/** - * Entity extant response - */ -export interface EntityExtantResponse { - [providerId: string]: { - [serviceId: string]: { - [collectionId: string]: { - [messageId: string]: boolean; - }; - }; - }; -} - -/** - * Entity fetch request + * Entity fetch */ export interface EntityFetchRequest { provider: string; service: string | number; collection: string | number; identifiers: (string | number)[]; - properties?: string[]; } -/** - * Entity fetch response - */ export interface EntityFetchResponse { - entities: EntityInterface[]; + [identifier: string]: EntityInterface; } /** - * Entity create request + * Entity extant + */ +export interface EntityExtantRequest { + sources: SourceSelector; +} + +export interface EntityExtantResponse { + [providerId: string]: { + [serviceId: string]: { + [collectionId: string]: { + [identifier: string]: boolean; + }; + }; + }; +} + +/** + * Entity create */ export interface EntityCreateRequest { provider: string; @@ -112,17 +79,12 @@ export interface EntityCreateRequest { properties: T; } -/** - * Entity create response - */ -export interface EntityCreateResponse { - entity: EntityInterface; -} +export interface EntityCreateResponse extends EntityInterface {} /** - * Entity modify request + * Entity update */ -export interface EntityModifyRequest { +export interface EntityUpdateRequest { provider: string; service: string | number; collection: string | number; @@ -130,35 +92,46 @@ export interface EntityModifyRequest { properties: T; } -/** - * Entity modify response - */ -export interface EntityModifyResponse { - success: boolean; - entity?: EntityInterface; -} +export interface EntityUpdateResponse extends EntityInterface {} /** - * Entity destroy request + * Entity delete */ -export interface EntityDestroyRequest { +export interface EntityDeleteRequest { provider: string; service: string | number; collection: string | number; identifier: string | number; } -/** - * Entity destroy response - */ -export interface EntityDestroyResponse { +export interface EntityDeleteResponse { success: boolean; } /** - * Entity send request + * Entity delta */ -export interface EntitySendRequest { +export interface EntityDeltaRequest { + sources: SourceSelector; +} + +export interface EntityDeltaResponse { + [providerId: string]: false | { + [serviceId: string]: false | { + [collectionId: string]: false | { + signature: string; + additions: (string | number)[]; + modifications: (string | number)[]; + deletions: (string | number)[]; + }; + }; + }; +} + +/** + * Entity transmit + */ +export interface EntityTransmitRequest { message: { from?: string; to: string[]; @@ -181,10 +154,7 @@ export interface EntitySendRequest { }; } -/** - * Entity send response - */ -export interface EntitySendResponse { +export interface EntityTransmitResponse { id: string; status: 'queued' | 'sent'; } \ No newline at end of file diff --git a/src/types/provider.ts b/src/types/provider.ts index d2c5247..6d9bae4 100644 --- a/src/types/provider.ts +++ b/src/types/provider.ts @@ -29,41 +29,32 @@ export interface ProviderInterface { } /** - * Provider list request + * Provider list */ export interface ProviderListRequest { sources?: SourceSelector; } -/** - * Provider list response - */ export interface ProviderListResponse { [identifier: string]: ProviderInterface; } /** - * Provider fetch request + * Provider fetch */ export interface ProviderFetchRequest { identifier: string; } -/** - * Provider fetch response - */ export interface ProviderFetchResponse extends ProviderInterface {} /** - * Provider extant request + * Provider extant */ export interface ProviderExtantRequest { sources: SourceSelector; } -/** - * Provider extant response - */ export interface ProviderExtantResponse { [identifier: string]: boolean; } diff --git a/src/types/service.ts b/src/types/service.ts index 19d192b..8b01924 100644 --- a/src/types/service.ts +++ b/src/types/service.ts @@ -1,7 +1,7 @@ /** - * Service-related type definitions + * Service type definitions */ -import type { SourceSelector } from './common'; +import type { SourceSelector, ListFilterComparisonOperator } from './common'; /** * Service capabilities @@ -9,29 +9,29 @@ import type { SourceSelector } from './common'; export interface ServiceCapabilitiesInterface { // Collection capabilities CollectionList?: boolean; - CollectionListFilter?: boolean | { [field: string]: string }; - CollectionListSort?: boolean | string[]; + CollectionListFilter?: ServiceListFilterCollection; + CollectionListSort?: ServiceListSortCollection; CollectionExtant?: boolean; CollectionFetch?: boolean; CollectionCreate?: boolean; - CollectionModify?: boolean; + CollectionUpdate?: boolean; CollectionDelete?: boolean; // Message capabilities EntityList?: boolean; - EntityListFilter?: boolean | { [field: string]: string }; - EntityListSort?: boolean | string[]; - EntityListRange?: boolean | { tally?: string[] }; + EntityListFilter?: ServiceListFilterEntity; + EntityListSort?: ServiceListSortEntity; + EntityListRange?: ServiceListRange; EntityDelta?: boolean; EntityExtant?: boolean; EntityFetch?: boolean; EntityCreate?: boolean; - EntityModify?: boolean; + EntityUpdate?: boolean; EntityDelete?: boolean; EntityMove?: boolean; EntityCopy?: boolean; // Send capability EntityTransmit?: boolean; - [key: string]: boolean | object | string[] | undefined; + [key: string]: boolean | object | string | string[] | undefined; } /** @@ -52,15 +52,12 @@ export interface ServiceInterface { } /** - * Service list request + * Service list */ export interface ServiceListRequest { sources?: SourceSelector; } -/** - * Service list response - */ export interface ServiceListResponse { [provider: string]: { [identifier: string]: ServiceInterface; @@ -68,15 +65,22 @@ export interface ServiceListResponse { } /** - * Service extant request + * Service fetch + */ +export interface ServiceFetchRequest { + provider: string; + identifier: string | number; +} + +export interface ServiceFetchResponse extends ServiceInterface {} + +/** + * Service extant */ export interface ServiceExtantRequest { sources: SourceSelector; } -/** - * Service extant response - */ export interface ServiceExtantResponse { [provider: string]: { [identifier: string]: boolean; @@ -84,45 +88,17 @@ export interface ServiceExtantResponse { } /** - * Service fetch request - */ -export interface ServiceFetchRequest { - provider: string; - identifier: string | number; -} - -/** - * Service fetch response - */ -export interface ServiceFetchResponse extends ServiceInterface {} - -/** - * Service find by address request - */ -export interface ServiceFindByAddressRequest { - address: string; -} - -/** - * Service find by address response - */ -export interface ServiceFindByAddressResponse extends ServiceInterface {} - -/** - * Service create request + * Service create */ export interface ServiceCreateRequest { provider: string; data: Partial; } -/** - * Service create response - */ export interface ServiceCreateResponse extends ServiceInterface {} /** - * Service update request + * Service update */ export interface ServiceUpdateRequest { provider: string; @@ -130,29 +106,20 @@ export interface ServiceUpdateRequest { data: Partial; } -/** - * Service update response - */ export interface ServiceUpdateResponse extends ServiceInterface {} /** - * Service delete request + * Service delete */ export interface ServiceDeleteRequest { provider: string; identifier: string | number; } -/** - * Service delete response - */ export interface ServiceDeleteResponse {} -// ==================== Discovery Types ==================== - /** - * Service discovery request - NEW VERSION - * Supports identity-based discovery with optional hints + * Service discovery */ export interface ServiceDiscoverRequest { identity: string; // Email address or domain @@ -161,42 +128,36 @@ export interface ServiceDiscoverRequest { secret?: string; // Optional: password/token for credential validation } -/** - * Service discovery response - NEW VERSION - * Provider-keyed map of discovered service locations - */ export interface ServiceDiscoverResponse { [provider: string]: ServiceLocation; // Uses existing ServiceLocation discriminated union } /** - * Discovery status tracking for real-time UI updates - * Used by store to track per-provider discovery progress + * Service connection test */ -export interface ProviderDiscoveryStatus { +export interface ServiceTestRequest { provider: string; - status: 'pending' | 'discovering' | 'success' | 'failed'; - location?: ServiceLocation; - error?: string; - metadata?: { - host?: string; - port?: number; - protocol?: string; - }; + // For existing service + identifier?: string | number | null; + // For fresh configuration + location?: ServiceLocation | null; + identity?: ServiceIdentity | null; } -// ==================== Service Testing Types ==================== +export interface ServiceTestResponse { + success: boolean; + message: string; +} /** - * Base service location interface + * Service location - Base */ export interface ServiceLocationBase { type: 'URI' | 'SOCKET_SOLE' | 'SOCKET_SPLIT' | 'FILE'; } /** - * URI-based service location for API and web services - * Used by: JMAP, Gmail API, etc. + * Service location - URI-based type */ export interface ServiceLocationUri extends ServiceLocationBase { type: 'URI'; @@ -209,8 +170,7 @@ export interface ServiceLocationUri extends ServiceLocationBase { } /** - * Single socket-based service location - * Used by: services using a single host/port combination + * Service location - Single socket-based type (combined inbound/outbound configuration) */ export interface ServiceLocationSocketSole extends ServiceLocationBase { type: 'SOCKET_SOLE'; @@ -222,8 +182,7 @@ export interface ServiceLocationSocketSole extends ServiceLocationBase { } /** - * Split socket-based service location - * Used by: traditional IMAP/SMTP configurations + * Service location - Split socket-based type (separate inbound/outbound configurations) */ export interface ServiceLocationSocketSplit extends ServiceLocationBase { type: 'SOCKET_SPLIT'; @@ -240,8 +199,7 @@ export interface ServiceLocationSocketSplit extends ServiceLocationBase { } /** - * File-based service location - * Used by: local file system providers + * Service location - File-based type (e.g., for local mail delivery or Unix socket) */ export interface ServiceLocationFile extends ServiceLocationBase { type: 'FILE'; @@ -249,7 +207,7 @@ export interface ServiceLocationFile extends ServiceLocationBase { } /** - * Discriminated union of all service location types + * Service location types */ export type ServiceLocation = | ServiceLocationUri @@ -257,24 +215,22 @@ export type ServiceLocation = | ServiceLocationSocketSplit | ServiceLocationFile; -// ==================== Service Identity Types ==================== - /** - * Base service identity interface + * Service identity - base */ export interface ServiceIdentityBase { type: 'NA' | 'BA' | 'TA' | 'OA' | 'CC'; } /** - * No authentication + * Service identity - No authentication */ export interface ServiceIdentityNone extends ServiceIdentityBase { type: 'NA'; } /** - * Basic authentication (username/password) + * Service identity - Basic authentication type */ export interface ServiceIdentityBasic extends ServiceIdentityBase { type: 'BA'; @@ -324,21 +280,58 @@ export type ServiceIdentity = | ServiceIdentityCertificate; /** - * Service connection test request + * List filter specification format + * + * Format: "type:length:defaultComparator:supportedComparators" + * + * Examples: + * - "s:200:256:771" = String field, max 200 chars, default LIKE, supports EQ|NEQ|LIKE|NLIKE + * - "a:10:64:192" = Array field, max 10 items, default IN, supports IN|NIN + * - "i:0:1:31" = Integer field, default EQ, supports EQ|NEQ|GT|LT|GTE|LTE + * + * Type codes: + * - s = string + * - i = integer + * - b = boolean + * - a = array + * + * Comparator values are bitmasks that can be combined */ -export interface ServiceTestRequest { - provider: string; - // For existing service - identifier?: string | number | null; - // For fresh configuration - location?: ServiceLocation | null; - identity?: ServiceIdentity | null; +export type ServiceListFilterCollection = { + 'label'?: string; + 'rank'?: string; + [attribute: string]: string | undefined; +}; + +export type ServiceListFilterEntity = { + '*'?: string; + 'from'?: string; + 'to'?: string; + 'cc'?: string; + 'bcc'?: string; + 'subject'?: string; + 'body'?: string; + 'before'?: string; + 'after'?: string; + 'min'?: string; + 'max'?: string; + [attribute: string]: string | undefined; } /** - * Service connection test response + * Service list sort specification */ -export interface ServiceTestResponse { - success: boolean; - message: string; +export type ServiceListSortCollection = ("label" | "rank" | string)[]; +export type ServiceListSortEntity = ("from" | "to" | "subject" | "received" | "sent" | "size" | string)[]; + +export type ServiceListRange = { + 'tally'?: string[]; +}; + + +export interface ServiceListFilterDefinition { + type: 'string' | 'integer' | 'date' | 'boolean' | 'array'; + length: number; + defaultComparator: ListFilterComparisonOperator; + supportedComparators: ListFilterComparisonOperator[]; } diff --git a/src/utils/serviceHelpers.ts b/src/utils/serviceHelpers.ts index 1f70f2a..86b122f 100644 --- a/src/utils/serviceHelpers.ts +++ b/src/utils/serviceHelpers.ts @@ -1,276 +1,61 @@ /** - * Helper functions for working with service identity and location types + * Helper functions for working with service types */ -import type { - ServiceIdentity, - ServiceIdentityNone, - ServiceIdentityBasic, - ServiceIdentityToken, - ServiceIdentityOAuth, - ServiceIdentityCertificate, - ServiceLocation, - ServiceLocationUri, - ServiceLocationSocketSole, - ServiceLocationSocketSplit, - ServiceLocationFile -} from '@/types/service'; - -// ==================== Identity Helpers ==================== +import type { ServiceListFilterDefinition } from '@/types/service'; +import { ListFilterComparisonOperator } from '@/types/common'; /** - * Create a "None" identity (no authentication) + * Parse a filter specification string into its components + * + * @param spec - Filter specification string (e.g., "s:200:256:771") + * @returns Parsed filter specification object + * + * @example + * parseFilterSpec("s:200:256:771") + * // Returns: { + * // type: 'string', + * // length: 200, + * // defaultComparator: 256 (LIKE), + * // supportedComparators: [1, 2, 256, 512] (EQ, NEQ, LIKE, NLIKE) + * // } */ -export function createIdentityNone(): ServiceIdentityNone { - return { type: 'NA' }; -} - -/** - * Create a Basic Auth identity - */ -export function createIdentityBasic(identity: string, secret: string): ServiceIdentityBasic { - return { - type: 'BA', - identity, - secret +export function parseFilterSpec(spec: string): ServiceListFilterDefinition { + const [typeCode, lengthStr, defaultComparatorStr, supportedComparatorsStr] = spec.split(':'); + + const typeMap: Record = { + 's': 'string', + 'i': 'integer', + 'd': 'date', + 'b': 'boolean', + 'a': 'array', }; -} - -/** - * Create a Token Auth identity - */ -export function createIdentityToken(token: string): ServiceIdentityToken { - return { - type: 'TA', - token - }; -} - -/** - * Create an OAuth identity - */ -export function createIdentityOAuth( - accessToken: string, - options?: { - accessScope?: string[]; - accessExpiry?: number; - refreshToken?: string; - refreshLocation?: string; + + const type = typeMap[typeCode]; + if (!type) { + throw new Error(`Invalid filter type code: ${typeCode}`); } -): ServiceIdentityOAuth { + + const length = parseInt(lengthStr, 10); + const defaultComparator = parseInt(defaultComparatorStr, 10) as ListFilterComparisonOperator; + + // Parse supported comparators from bitmask + const supportedComparators: ListFilterComparisonOperator[] = []; + const supportedBitmask = parseInt(supportedComparatorsStr, 10); + + if (supportedBitmask !== 0) { + const allComparators = Object.values(ListFilterComparisonOperator).filter(v => typeof v === 'number') as number[]; + for (const comparator of allComparators) { + if ((supportedBitmask & comparator) === comparator) { + supportedComparators.push(comparator as ListFilterComparisonOperator); + } + } + } + return { - type: 'OA', - accessToken, - ...options + type, + length, + defaultComparator, + supportedComparators, }; } - -/** - * Create a Certificate identity - */ -export function createIdentityCertificate( - certificate: string, - privateKey: string, - passphrase?: string -): ServiceIdentityCertificate { - return { - type: 'CC', - certificate, - privateKey, - ...(passphrase && { passphrase }) - }; -} - -// ==================== Location Helpers ==================== - -/** - * Create a URI-based location - */ -export function createLocationUri( - host: string, - options?: { - scheme?: 'http' | 'https'; - port?: number; - path?: string; - verifyPeer?: boolean; - verifyHost?: boolean; - } -): ServiceLocationUri { - return { - type: 'URI', - scheme: options?.scheme || 'https', - host, - port: options?.port || (options?.scheme === 'http' ? 80 : 443), - ...(options?.path && { path: options.path }), - verifyPeer: options?.verifyPeer ?? true, - verifyHost: options?.verifyHost ?? true - }; -} - -/** - * Create a URI location from a full URL string - */ -export function createLocationFromUrl(url: string): ServiceLocationUri { - try { - const parsed = new URL(url); - return { - type: 'URI', - scheme: parsed.protocol.replace(':', '') as 'http' | 'https', - host: parsed.hostname, - port: parsed.port ? parseInt(parsed.port) : (parsed.protocol === 'https:' ? 443 : 80), - path: parsed.pathname, - verifyPeer: true, - verifyHost: true - }; - } catch (error) { - throw new Error(`Invalid URL: ${url}`); - } -} - -/** - * Create a single socket location (IMAP, SMTP on same server) - */ -export function createLocationSocketSole( - host: string, - port: number, - encryption: 'none' | 'ssl' | 'tls' | 'starttls' = 'ssl', - options?: { - verifyPeer?: boolean; - verifyHost?: boolean; - } -): ServiceLocationSocketSole { - return { - type: 'SOCKET_SOLE', - host, - port, - encryption, - verifyPeer: options?.verifyPeer ?? true, - verifyHost: options?.verifyHost ?? true - }; -} - -/** - * Create a split socket location (separate IMAP/SMTP servers) - */ -export function createLocationSocketSplit( - config: { - inboundHost: string; - inboundPort: number; - inboundEncryption?: 'none' | 'ssl' | 'tls' | 'starttls'; - outboundHost: string; - outboundPort: number; - outboundEncryption?: 'none' | 'ssl' | 'tls' | 'starttls'; - inboundVerifyPeer?: boolean; - inboundVerifyHost?: boolean; - outboundVerifyPeer?: boolean; - outboundVerifyHost?: boolean; - } -): ServiceLocationSocketSplit { - return { - type: 'SOCKET_SPLIT', - inboundHost: config.inboundHost, - inboundPort: config.inboundPort, - inboundEncryption: config.inboundEncryption || 'ssl', - outboundHost: config.outboundHost, - outboundPort: config.outboundPort, - outboundEncryption: config.outboundEncryption || 'ssl', - inboundVerifyPeer: config.inboundVerifyPeer ?? true, - inboundVerifyHost: config.inboundVerifyHost ?? true, - outboundVerifyPeer: config.outboundVerifyPeer ?? true, - outboundVerifyHost: config.outboundVerifyHost ?? true - }; -} - -/** - * Create a file-based location - */ -export function createLocationFile(path: string): ServiceLocationFile { - return { - type: 'FILE', - path - }; -} - -// ==================== Validation Helpers ==================== - -/** - * Validate that an identity object is properly formed - */ -export function validateIdentity(identity: ServiceIdentity): boolean { - switch (identity.type) { - case 'NA': - return true; - case 'BA': - return !!(identity as ServiceIdentityBasic).identity && - !!(identity as ServiceIdentityBasic).secret; - case 'TA': - return !!(identity as ServiceIdentityToken).token; - case 'OA': - return !!(identity as ServiceIdentityOAuth).accessToken; - case 'CC': - return !!(identity as ServiceIdentityCertificate).certificate && - !!(identity as ServiceIdentityCertificate).privateKey; - default: - return false; - } -} - -/** - * Validate that a location object is properly formed - */ -export function validateLocation(location: ServiceLocation): boolean { - switch (location.type) { - case 'URI': - return !!(location as ServiceLocationUri).host && - !!(location as ServiceLocationUri).port; - case 'SOCKET_SOLE': - return !!(location as ServiceLocationSocketSole).host && - !!(location as ServiceLocationSocketSole).port; - case 'SOCKET_SPLIT': - const split = location as ServiceLocationSocketSplit; - return !!split.inboundHost && !!split.inboundPort && - !!split.outboundHost && !!split.outboundPort; - case 'FILE': - return !!(location as ServiceLocationFile).path; - default: - return false; - } -} - -// ==================== Type Guards ==================== - -export function isIdentityNone(identity: ServiceIdentity): identity is ServiceIdentityNone { - return identity.type === 'NA'; -} - -export function isIdentityBasic(identity: ServiceIdentity): identity is ServiceIdentityBasic { - return identity.type === 'BA'; -} - -export function isIdentityToken(identity: ServiceIdentity): identity is ServiceIdentityToken { - return identity.type === 'TA'; -} - -export function isIdentityOAuth(identity: ServiceIdentity): identity is ServiceIdentityOAuth { - return identity.type === 'OA'; -} - -export function isIdentityCertificate(identity: ServiceIdentity): identity is ServiceIdentityCertificate { - return identity.type === 'CC'; -} - -export function isLocationUri(location: ServiceLocation): location is ServiceLocationUri { - return location.type === 'URI'; -} - -export function isLocationSocketSole(location: ServiceLocation): location is ServiceLocationSocketSole { - return location.type === 'SOCKET_SOLE'; -} - -export function isLocationSocketSplit(location: ServiceLocation): location is ServiceLocationSocketSplit { - return location.type === 'SOCKET_SPLIT'; -} - -export function isLocationFile(location: ServiceLocation): location is ServiceLocationFile { - return location.type === 'FILE'; -} -- 2.39.5