generated from Nodarx/template
Compare commits
1 Commits
renovate/p
...
a3787334fd
| Author | SHA1 | Date | |
|---|---|---|---|
| a3787334fd |
@@ -23,7 +23,7 @@
|
|||||||
"doctrine/lexer": "^3.0"
|
"doctrine/lexer": "^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^13.0"
|
"phpunit/phpunit": "^11.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ final class StoreCommand implements CommandInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
FetchTarget|string|SequenceSet|null $target = null,
|
FetchTarget|string|SequenceSet|null $target = null,
|
||||||
private array $flags = [],
|
private readonly array $flags = [],
|
||||||
private string $action = '',
|
private readonly string $action = '',
|
||||||
private bool $silent = true,
|
private readonly bool $silent = true,
|
||||||
) {
|
) {
|
||||||
$resolvedTarget = match (true) {
|
$resolvedTarget = match (true) {
|
||||||
$target instanceof FetchTarget => $target,
|
$target instanceof FetchTarget => $target,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ use KTXM\ProviderImap\Stores\ServiceStore;
|
|||||||
class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface, ProviderServiceDiscoverInterface, ProviderServiceTestInterface
|
class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface, ProviderServiceDiscoverInterface, ProviderServiceTestInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public const JSON_TYPE = ProviderBaseInterface::JSON_TYPE;
|
||||||
protected const PROVIDER_IDENTIFIER = 'imap';
|
protected const PROVIDER_IDENTIFIER = 'imap';
|
||||||
protected const PROVIDER_LABEL = 'IMAP Mail Provider';
|
protected const PROVIDER_LABEL = 'IMAP Mail Provider';
|
||||||
protected const PROVIDER_DESCRIPTION = 'Provides mail services via the IMAP protocol';
|
protected const PROVIDER_DESCRIPTION = 'Provides mail services via the IMAP protocol';
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace KTXM\ProviderImap\Providers;
|
|||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use KTXF\Mail\Collection\CollectionBaseInterface;
|
use KTXF\Mail\Collection\CollectionBaseInterface;
|
||||||
|
use KTXF\Mail\Collection\CollectionMutableInterface;
|
||||||
use KTXF\Mail\Collection\CollectionPropertiesBaseInterface;
|
use KTXF\Mail\Collection\CollectionPropertiesBaseInterface;
|
||||||
use KTXF\Mail\Object\Address;
|
use KTXF\Mail\Object\Address;
|
||||||
use KTXF\Mail\Object\AddressInterface;
|
use KTXF\Mail\Object\AddressInterface;
|
||||||
@@ -39,7 +40,7 @@ use KTXM\ProviderImap\Service\Remote\RemoteService;
|
|||||||
use KTXM\ProviderImap\Providers\CollectionResource;
|
use KTXM\ProviderImap\Providers\CollectionResource;
|
||||||
use KTXF\Mail\Collection\CollectionRoles;
|
use KTXF\Mail\Collection\CollectionRoles;
|
||||||
use KTXF\Mail\Object\MessagePropertiesMutableInterface;
|
use KTXF\Mail\Object\MessagePropertiesMutableInterface;
|
||||||
use KTXF\Resource\Identifier\EntityIdentifierInterface;
|
use KTXF\Mail\Service\ServiceEntityMutableInterface;
|
||||||
use KTXM\ProviderImap\Providers\EntityResource;
|
use KTXM\ProviderImap\Providers\EntityResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -498,7 +499,7 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = match ($deleteMode) {
|
$result = match ($deleteMode) {
|
||||||
'soft' => $this->collectionMove(new CollectionIdentifier($target->provider(), $target->service(), $deleteTarget), $target),
|
'soft' => $this->collectionMove($target, new CollectionIdentifier($target->provider(), $target->service(), $deleteTarget)),
|
||||||
'hard' => $this->mailService->collectionDestroy((string) $target->collection()),
|
'hard' => $this->mailService->collectionDestroy((string) $target->collection()),
|
||||||
};
|
};
|
||||||
return $result;
|
return $result;
|
||||||
@@ -520,9 +521,8 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
$sourceDelimiter = $sourceMailbox->delimiter() ?? '/';
|
$sourceDelimiter = $sourceMailbox->delimiter() ?? '/';
|
||||||
$targetDelimiter = $targetMailbox->delimiter() ?? '/';
|
$targetDelimiter = $targetMailbox->delimiter() ?? '/';
|
||||||
|
|
||||||
$extantPath = $sourceMailbox->name();
|
$targetPath = rtrim($targetMailbox->name(), $targetDelimiter) . $targetDelimiter . end(explode($sourceDelimiter, $sourceMailbox->name()));
|
||||||
$freshPath = rtrim($targetMailbox->name(), $targetDelimiter) . $targetDelimiter . end(explode($sourceDelimiter, $extantPath));
|
$mutatedMailbox = $this->mailService->collectionRename($sourceMailbox->name(), $targetPath);
|
||||||
$mutatedMailbox = $this->mailService->collectionRename($extantPath, $freshPath);
|
|
||||||
|
|
||||||
$collection = $this->collectionFresh();
|
$collection = $this->collectionFresh();
|
||||||
$collection->fromImap($mutatedMailbox, ['delimiter' => $targetDelimiter]);
|
$collection->fromImap($mutatedMailbox, ['delimiter' => $targetDelimiter]);
|
||||||
@@ -531,9 +531,9 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
|
|
||||||
// ── Entity operations ─────────────────────────────────────────────────────
|
// ── Entity operations ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
public function entityListBulk(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array
|
public function entityList(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array
|
||||||
{
|
{
|
||||||
return iterator_to_array($this->entityListStream((string) $collection, $filter, $sort, $range), true);
|
return iterator_to_array($this->entityList((string) $collection, $filter, $sort, $range), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityListStream(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): Generator
|
public function entityListStream(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): Generator
|
||||||
@@ -543,7 +543,7 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
foreach ($this->mailService->entityList((string) $collection, $filter, $sort, $range) as $identifier => $message) {
|
foreach ($this->mailService->entityList((string) $collection, $filter, $sort, $range) as $identifier => $message) {
|
||||||
$resource = $this->entityFresh();
|
$resource = $this->entityFresh();
|
||||||
$resource->fromImap($message, $collection);
|
$resource->fromImap($message, $collection);
|
||||||
yield $resource->urn() => $resource;
|
yield $identifier => $resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,25 +565,12 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityFetchBulk(EntityIdentifierInterface ...$identifiers): array
|
public function entityFetch(string|int $collection, string|int ...$identifiers): array
|
||||||
{
|
|
||||||
return iterator_to_array($this->entityFetchStream(...$identifiers), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function entityFetchStream(EntityIdentifierInterface ...$identifiers): Generator
|
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
$identifiers = $this->groupEntitiesByCollection(...$identifiers);
|
$uids = array_map('intval', $identifiers);
|
||||||
|
return $this->mailService->entityFetch((string) $collection, ...$uids);
|
||||||
foreach ($identifiers as $collection => $entities) {
|
|
||||||
$uids = array_keys($entities);
|
|
||||||
foreach ($this->mailService->entityFetch((string) $collection, ...$uids) as $uid => $message) {
|
|
||||||
$resource = $this->entityFresh();
|
|
||||||
$resource->fromImap($message, $collection);
|
|
||||||
yield $resource->urn() => $resource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityDelta(string|int $collection, string $signature, string $detail = 'ids'): Delta
|
public function entityDelta(string|int $collection, string $signature, string $detail = 'ids'): Delta
|
||||||
@@ -619,29 +606,6 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
throw new \RuntimeException('Entity modification is not supported in this service');
|
throw new \RuntimeException('Entity modification is not supported in this service');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityPatch(MessagePropertiesMutableInterface $properties, EntityIdentifier ...$targets): array
|
|
||||||
{
|
|
||||||
// validate identifiers and group by collection
|
|
||||||
$targets = $this->groupEntitiesByCollection(...$targets);
|
|
||||||
|
|
||||||
// move entities on remote store and construct result map
|
|
||||||
$this->initialize();
|
|
||||||
|
|
||||||
$list = [];
|
|
||||||
|
|
||||||
foreach ($targets as $targetCollection => $targetIdentifiers) {
|
|
||||||
$uids = array_keys($targetIdentifiers);
|
|
||||||
|
|
||||||
$mutations = $this->mailService->entityPatch($targetCollection, $properties, ...$uids);
|
|
||||||
|
|
||||||
foreach ($uids as $uid) {
|
|
||||||
$list[(string)$targetIdentifiers[$uid]] = ['disposition' => 'patched'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function entityDelete(EntityIdentifier ...$targets): array
|
public function entityDelete(EntityIdentifier ...$targets): array
|
||||||
{
|
{
|
||||||
// validate identifiers and group by collection
|
// validate identifiers and group by collection
|
||||||
@@ -680,11 +644,6 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
$deleteTargetIdentifier = new CollectionIdentifier($this->provider(), (string) $this->identifier(), $deleteTargetNative);
|
$deleteTargetIdentifier = new CollectionIdentifier($this->provider(), (string) $this->identifier(), $deleteTargetNative);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if all targets are already in the delete target collection, we should hard delete instead of moving to avoid duplicates in the trash
|
|
||||||
if (array_keys($targets) === [$deleteTargetNative]) {
|
|
||||||
$deleteMode = 'hard';
|
|
||||||
}
|
|
||||||
|
|
||||||
// entities need to be moved or deleted by collection
|
// entities need to be moved or deleted by collection
|
||||||
$list = [];
|
$list = [];
|
||||||
foreach ($targets as $sourceCollection => $sourceEntities) {
|
foreach ($targets as $sourceCollection => $sourceEntities) {
|
||||||
@@ -700,11 +659,11 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
};
|
};
|
||||||
|
|
||||||
foreach ($uids as $uid) {
|
foreach ($uids as $uid) {
|
||||||
$mutatedUid = !isset($mutations[$uid]) || $mutations[$uid] === true ? null : $mutations[$uid];
|
$mutatedUid = $mutations[$uid] ?? null;
|
||||||
$list[(string)$sourceEntities[$uid]] = [
|
$list[(string)$sourceEntities[$uid]] = [
|
||||||
'disposition' => $deleteMode === 'soft' ? 'moved' : 'deleted',
|
'disposition' => $deleteMode === 'soft' ? 'moved' : 'deleted',
|
||||||
'destination' => $deleteMode === 'soft' ? $deleteTargetIdentifier : null,
|
'destination' => $deleteMode === 'soft' ? $deleteTargetIdentifier : null,
|
||||||
'mutation' => $deleteMode === 'soft' && $mutatedUid !== null ? new EntityIdentifier($this->provider(), $this->identifier(), $deleteTargetIdentifier->collection(), $mutatedUid) : null,
|
'mutation' => $mutatedUid !== null ? new EntityIdentifier($this->provider(), $this->identifier(), $deleteTargetIdentifier->collection(), $mutatedUid) : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -712,6 +671,34 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function entityPatch(MessagePropertiesMutableInterface $properties, EntityIdentifier ...$targets): array
|
||||||
|
{
|
||||||
|
throw new \RuntimeException('Entity patching is not supported in this service');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entityPatch(MessagePropertiesMutableInterface $properties, EntityIdentifier ...$targets): array
|
||||||
|
{
|
||||||
|
// validate identifiers and group by collection
|
||||||
|
$targets = $this->groupEntitiesByCollection(...$targets);
|
||||||
|
|
||||||
|
// move entities on remote store and construct result map
|
||||||
|
$this->initialize();
|
||||||
|
|
||||||
|
$list = [];
|
||||||
|
|
||||||
|
foreach ($targets as $targetCollection => $targetIdentifiers) {
|
||||||
|
$uids = array_keys($targetIdentifiers);
|
||||||
|
|
||||||
|
$mutations = $this->mailService->entityPatch($targetCollection, $properties, ...$uids);
|
||||||
|
|
||||||
|
foreach ($uids as $uid) {
|
||||||
|
$list[(string)$targetIdentifiers[$uid]] = ['disposition' => 'patched'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
public function entityCopy(CollectionIdentifier $target, EntityIdentifier ...$sources): array
|
public function entityCopy(CollectionIdentifier $target, EntityIdentifier ...$sources): array
|
||||||
{
|
{
|
||||||
// validate target belongs to this service
|
// validate target belongs to this service
|
||||||
@@ -778,6 +765,11 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function entityCopy(CollectionIdentifier $target, EntityIdentifier ...$sources): array
|
||||||
|
{
|
||||||
|
throw new \RuntimeException('Entity copying is not supported in this service');
|
||||||
|
}
|
||||||
|
|
||||||
private function groupEntitiesByCollection(EntityIdentifier ...$identifiers): array
|
private function groupEntitiesByCollection(EntityIdentifier ...$identifiers): array
|
||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|||||||
2046
package-lock.json
generated
2046
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -14,16 +14,16 @@
|
|||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pinia": "^3.0.0",
|
"pinia": "^2.3.1",
|
||||||
"vue": "^3.5.18",
|
"vue": "^3.5.18",
|
||||||
"vue-router": "^5.0.0",
|
"vue-router": "^4.5.1",
|
||||||
"vuetify": "^4.0.0"
|
"vuetify": "^3.10.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"@vue/tsconfig": "^0.9.0",
|
"@vue/tsconfig": "^0.7.0",
|
||||||
"typescript": "~6.0.0",
|
"typescript": "~6.0.0",
|
||||||
"vite": "^8.0.0",
|
"vite": "^7.1.2",
|
||||||
"vue-tsc": "^3.0.5"
|
"vue-tsc": "^3.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user