Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 36aaa8b9c7 | |||
| 8af08d8936 | |||
| edc1aece13 | |||
| b81070338d | |||
| ab24fe2b54 | |||
| 3073cf9f75 | |||
| 8cf4993107 | |||
| 5bda58fbb9 | |||
| b6bc83e432 | |||
| 02f3662f40 | |||
| 2dd56e0662 | |||
| d449a71e80 | |||
| 1310de8a15 | |||
| c7eb46c7ac | |||
| c58d99988c | |||
| f5e7fa5f81 | |||
| 9a243e2c61 | |||
| 4a8cea943b | |||
| 8965c047d1 | |||
| 7fa75dafc9 | |||
| 8eb245f52f | |||
| 3c4b864339 | |||
| 64b933534b | |||
| d3f383e937 | |||
| 816c1cf931 | |||
| 072ea8c450 | |||
| 44c3b629a2 | |||
| aa0ac2da51 | |||
| 4ef881e5c1 | |||
| dc6d6081ee | |||
| 1a5339f069 | |||
| 9d95521247 | |||
| cfb99dfc01 | |||
| 609e7e577c | |||
| fa5e91f0a9 | |||
| 024c9656d4 | |||
| b950022081 | |||
| 2da8bebe61 | |||
| 439eaabce3 | |||
| 16df84cb28 | |||
| e7ba07bf03 | |||
| 69bbbb6c86 | |||
| fdfaf562a0 | |||
| 4cbde63865 | |||
| 808ed192af | |||
| 511a94a0fa | |||
| 52fdb17b09 | |||
| 9dc7a90f42 |
@@ -0,0 +1,59 @@
|
|||||||
|
name: PHP Integration Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Integration Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mongo:
|
||||||
|
image: mongo:8
|
||||||
|
options: >-
|
||||||
|
--health-cmd "mongosh --quiet --eval \"db.adminCommand('ping')\""
|
||||||
|
--health-interval 5s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 12
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Retrieve Server Install Action
|
||||||
|
uses: actions/checkout@v6.0.2
|
||||||
|
with:
|
||||||
|
repository: Nodarx/action-server-install
|
||||||
|
ref: main
|
||||||
|
path: action-server-install
|
||||||
|
github-server-url: https://git.ktrix.dev
|
||||||
|
|
||||||
|
- name: Install server
|
||||||
|
uses: ./action-server-install
|
||||||
|
with:
|
||||||
|
install-php: 'true'
|
||||||
|
php-version: '8.5'
|
||||||
|
server-path: './server'
|
||||||
|
database-uri: 'mongodb://mongo:27017/?tls=false'
|
||||||
|
database-name: 'ktrix_ci'
|
||||||
|
app-environment: 'test'
|
||||||
|
|
||||||
|
- name: Checkout module under test
|
||||||
|
uses: actions/checkout@v6.0.2
|
||||||
|
with:
|
||||||
|
repository: ${{ github.repository }}
|
||||||
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
path: server/modules/provider_jmapc
|
||||||
|
github-server-url: https://git.ktrix.dev
|
||||||
|
|
||||||
|
- name: Install module dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
working-directory: server/modules/provider_jmapc
|
||||||
|
|
||||||
|
- name: Install and enable module
|
||||||
|
working-directory: server
|
||||||
|
run: |
|
||||||
|
php bin/console module:install provider_jmapc
|
||||||
|
php bin/console module:enable provider_jmapc
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
working-directory: server/modules/provider_jmapc
|
||||||
|
run: composer test:integration
|
||||||
@@ -25,11 +25,17 @@ jobs:
|
|||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
|
|
||||||
- name: Install Renovate
|
- name: Install Renovate
|
||||||
run: npm install -g renovate
|
run: |
|
||||||
|
npm install --global --no-audit --fund=false \
|
||||||
|
--prefix "${{ runner.temp }}/renovate-npm" \
|
||||||
|
--cache "${{ runner.temp }}/renovate-npm-cache" \
|
||||||
|
renovate
|
||||||
|
"${{ runner.temp }}/renovate-npm/bin/renovate" --version
|
||||||
|
|
||||||
- name: Run Renovate
|
- name: Run Renovate
|
||||||
env:
|
env:
|
||||||
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
||||||
RENOVATE_PLATFORM: gitea
|
RENOVATE_PLATFORM: gitea
|
||||||
RENOVATE_ENDPOINT: https://git.ktrix.dev/api/v1
|
RENOVATE_ENDPOINT: https://git.ktrix.dev/api/v1
|
||||||
run: renovate ${{ gitea.repository }}
|
run: |
|
||||||
|
"${{ runner.temp }}/renovate-npm/bin/renovate" ${{ gitea.repository }}
|
||||||
|
|||||||
+1
-5
@@ -14,11 +14,7 @@ node_modules/
|
|||||||
# Backend development
|
# Backend development
|
||||||
/lib/vendor/
|
/lib/vendor/
|
||||||
coverage/
|
coverage/
|
||||||
phpunit.xml.cache
|
*.cache
|
||||||
.phpunit.cache
|
|
||||||
.phpunit.result.cache
|
|
||||||
.php-cs-fixer.cache
|
|
||||||
.phpstan.cache
|
|
||||||
.phpactor/
|
.phpactor/
|
||||||
|
|
||||||
# Editors
|
# Editors
|
||||||
|
|||||||
+6
-5
@@ -10,7 +10,7 @@
|
|||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "8.2"
|
"php": "8.3"
|
||||||
},
|
},
|
||||||
"autoloader-suffix": "ProviderJmapc",
|
"autoloader-suffix": "ProviderJmapc",
|
||||||
"vendor-dir": "lib/vendor",
|
"vendor-dir": "lib/vendor",
|
||||||
@@ -27,11 +27,11 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"guzzlehttp/guzzle": "^7.0",
|
"guzzlehttp/guzzle": "^7.0",
|
||||||
"guzzlehttp/psr7": "^2.0",
|
"guzzlehttp/psr7": "^2.0",
|
||||||
"php": ">=8.2 <=8.5",
|
"php": ">=8.3 <=8.5",
|
||||||
"sebastiankrupinski/jmap-client-php": "dev-main"
|
"sebastiankrupinski/jmap-client-php": "dev-main"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^13.0"
|
"phpunit/phpunit": "^12.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@@ -48,7 +48,8 @@
|
|||||||
],
|
],
|
||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
],
|
],
|
||||||
"test:unit": "phpunit --configuration tests/php/phpunit.unit.xml --colors=always --testdox",
|
"test:unit": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Unit Tests\" --colors=always --testdox",
|
||||||
"test:coverage": "XDEBUG_MODE=coverage phpunit --configuration tests/php/phpunit.unit.xml --coverage-html .phpunit.coverage --coverage-text"
|
"test:integration": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Integration Tests\" --colors=always --testdox",
|
||||||
|
"test:coverage": "XDEBUG_MODE=coverage phpunit --configuration tests/php/phpunit.xml --testsuite \"Unit Tests\" --coverage-html .phpunit.coverage --coverage-text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+273
-373
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderJmapc\Providers\Document;
|
namespace KTXM\ProviderJmapc\Providers\Document;
|
||||||
|
|
||||||
use KTXF\Resource\Documents\Collection\CollectionPropertiesMutableAbstract;
|
use KTXF\Documents\Collection\CollectionPropertiesMutableAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document Collection Properties Implementation
|
* Document Collection Properties Implementation
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderJmapc\Providers\Document;
|
namespace KTXM\ProviderJmapc\Providers\Document;
|
||||||
|
|
||||||
use KTXF\Resource\Documents\Collection\CollectionMutableAbstract;
|
use KTXF\Documents\Collection\CollectionMutableAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document Collection Resource Implementation
|
* Document Collection Resource Implementation
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderJmapc\Providers\Document;
|
namespace KTXM\ProviderJmapc\Providers\Document;
|
||||||
|
|
||||||
use KTXF\Resource\Documents\Entity\EntityPropertiesMutableAbstract;
|
use KTXF\Documents\Entity\EntityPropertiesMutableAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document Collection Properties Implementation
|
* Document Collection Properties Implementation
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderJmapc\Providers\Document;
|
namespace KTXM\ProviderJmapc\Providers\Document;
|
||||||
|
|
||||||
use KTXF\Resource\Documents\Entity\EntityMutableAbstract;
|
use KTXF\Documents\Entity\EntityMutableAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mail Entity Resource Implementation
|
* Mail Entity Resource Implementation
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderJmapc\Providers\Document;
|
namespace KTXM\ProviderJmapc\Providers\Document;
|
||||||
|
|
||||||
use KTXF\Resource\Documents\Provider\ProviderBaseInterface;
|
use KTXF\Documents\Provider\ProviderBaseInterface;
|
||||||
use KTXF\Resource\Documents\Provider\ProviderServiceMutateInterface;
|
use KTXF\Documents\Provider\ProviderServiceMutateInterface;
|
||||||
use KTXF\Resource\Documents\Provider\ProviderServiceTestInterface;
|
use KTXF\Documents\Provider\ProviderServiceTestInterface;
|
||||||
use KTXF\Resource\Documents\Service\ServiceBaseInterface;
|
use KTXF\Documents\Service\ServiceBaseInterface;
|
||||||
use KTXF\Resource\Documents\Service\ServiceMutableInterface;
|
use KTXF\Documents\Service\ServiceMutableInterface;
|
||||||
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
|
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
|
||||||
use KTXF\Resource\Provider\ResourceServiceMutateInterface;
|
use KTXF\Resource\Provider\ResourceServiceMutateInterface;
|
||||||
use KTXM\ProviderJmapc\Service\Discovery;
|
use KTXM\ProviderJmapc\Service\Discovery;
|
||||||
@@ -21,9 +21,9 @@ use KTXM\ProviderJmapc\Service\Remote\RemoteService;
|
|||||||
use KTXM\ProviderJmapc\Stores\ServiceStore;
|
use KTXM\ProviderJmapc\Stores\ServiceStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JMAP Mail Provider
|
* JMAP Documents Provider
|
||||||
*/
|
*/
|
||||||
class Provider implements ProviderServiceMutateInterface, ProviderServiceTestInterface
|
class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface, ProviderServiceTestInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public const JSON_TYPE = ProviderBaseInterface::JSON_TYPE;
|
public const JSON_TYPE = ProviderBaseInterface::JSON_TYPE;
|
||||||
@@ -63,7 +63,7 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceTestInt
|
|||||||
|
|
||||||
public function type(): string
|
public function type(): string
|
||||||
{
|
{
|
||||||
return self::TYPE_MAIL;
|
return self::TYPE_DOCUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function identifier(): string
|
public function identifier(): string
|
||||||
@@ -170,7 +170,7 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceTestInt
|
|||||||
return $discovery->discover($identity, $location, $secret, $verifySSL);
|
return $discovery->discover($identity, $location, $secret, $verifySSL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serviceTest(ServiceBaseInterface $service, array $options = []): array {
|
public function serviceTest(ServiceBaseInterface|ServiceMutableInterface $service, array $options = []): array {
|
||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -10,17 +10,20 @@ declare(strict_types=1);
|
|||||||
namespace KTXM\ProviderJmapc\Providers\Document;
|
namespace KTXM\ProviderJmapc\Providers\Document;
|
||||||
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use KTXF\Resource\Provider\ResourceServiceIdentityInterface;
|
use KTXF\Documents\Collection\CollectionBaseInterface;
|
||||||
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
|
use KTXF\Documents\Collection\CollectionMutableInterface;
|
||||||
|
use KTXF\Documents\Collection\CollectionPropertiesBaseInterface;
|
||||||
|
use KTXF\Documents\Service\ServiceBaseInterface;
|
||||||
|
use KTXF\Documents\Service\ServiceCollectionMutableInterface;
|
||||||
|
use KTXF\Documents\Service\ServiceConfigurableInterface;
|
||||||
|
use KTXF\Documents\Service\ServiceMutableInterface;
|
||||||
use KTXF\Resource\Delta\Delta;
|
use KTXF\Resource\Delta\Delta;
|
||||||
use KTXF\Resource\Documents\Collection\CollectionBaseInterface;
|
|
||||||
use KTXF\Resource\Documents\Collection\CollectionMutableInterface;
|
|
||||||
use KTXF\Resource\Documents\Service\ServiceBaseInterface;
|
|
||||||
use KTXF\Resource\Documents\Service\ServiceCollectionMutableInterface;
|
|
||||||
use KTXF\Resource\Documents\Service\ServiceConfigurableInterface;
|
|
||||||
use KTXF\Resource\Documents\Service\ServiceMutableInterface;
|
|
||||||
use KTXF\Resource\Filter\Filter;
|
use KTXF\Resource\Filter\Filter;
|
||||||
use KTXF\Resource\Filter\IFilter;
|
use KTXF\Resource\Filter\IFilter;
|
||||||
|
use KTXF\Resource\Identifier\CollectionIdentifierInterface;
|
||||||
|
use KTXF\Resource\Identifier\EntityIdentifierInterface;
|
||||||
|
use KTXF\Resource\Provider\ResourceServiceIdentityInterface;
|
||||||
|
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
|
||||||
use KTXF\Resource\Range\IRange;
|
use KTXF\Resource\Range\IRange;
|
||||||
use KTXF\Resource\Range\Range;
|
use KTXF\Resource\Range\Range;
|
||||||
use KTXF\Resource\Range\RangeType;
|
use KTXF\Resource\Range\RangeType;
|
||||||
@@ -316,18 +319,30 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
return new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectionCreate(string|int|null $location, CollectionMutableInterface $collection, array $options = []): CollectionBaseInterface
|
/**
|
||||||
|
* Convert incoming collection properties into a native CollectionResource
|
||||||
|
*/
|
||||||
|
private function collectionNative(CollectionPropertiesBaseInterface $properties, string|int|null $identifier = null): CollectionResource
|
||||||
|
{
|
||||||
|
if ($properties instanceof CollectionResource) {
|
||||||
|
return clone $properties;
|
||||||
|
}
|
||||||
|
$object = new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
||||||
|
$object->jsonDeserialize(array_filter([
|
||||||
|
CollectionResource::PROPERTY_IDENTIFIER => $identifier,
|
||||||
|
CollectionResource::PROPERTY_PROPERTIES => $properties->jsonSerialize(),
|
||||||
|
], fn($v) => $v !== null));
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collectionCreate(CollectionIdentifierInterface|null $target, CollectionPropertiesBaseInterface $properties, array $options = []): CollectionBaseInterface
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
if ($collection instanceof CollectionResource === false) {
|
$collection = $this->collectionNative($properties);
|
||||||
$object = new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
|
||||||
$object->jsonDeserialize($collection->jsonSerialize());
|
|
||||||
$collection = $object;
|
|
||||||
}
|
|
||||||
|
|
||||||
$collection = $collection->toJmap();
|
$collection = $collection->toJmap();
|
||||||
$collection = $this->remoteService->collectionCreate($location, $collection, $options);
|
$collection = $this->remoteService->collectionCreate($target?->collection(), $collection, $options);
|
||||||
|
|
||||||
$object = new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
$object = new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
||||||
$object->fromJmap($collection);
|
$object->fromJmap($collection);
|
||||||
@@ -335,15 +350,12 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectionUpdate(string|int $identifier, CollectionMutableInterface $collection): CollectionBaseInterface
|
public function collectionUpdate(CollectionIdentifierInterface $target, CollectionPropertiesBaseInterface $properties): CollectionBaseInterface
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
if ($collection instanceof CollectionResource === false) {
|
$identifier = $target->collection();
|
||||||
$object = new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
$collection = $this->collectionNative($properties, $identifier);
|
||||||
$object->jsonDeserialize($collection->jsonSerialize());
|
|
||||||
$collection = $object;
|
|
||||||
}
|
|
||||||
|
|
||||||
$collection = $collection->toJmap();
|
$collection = $collection->toJmap();
|
||||||
$collection = $this->remoteService->collectionModify($identifier, $collection);
|
$collection = $this->remoteService->collectionModify($identifier, $collection);
|
||||||
@@ -354,14 +366,17 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectionDelete(string|int $identifier, bool $force = false, bool $recursive = false): bool
|
public function collectionDelete(CollectionIdentifierInterface $target, bool $force = false): CollectionBaseInterface | true
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
return $this->remoteService->collectionDestroy($identifier, $force, $recursive) !== null;
|
if ($this->remoteService->collectionDestroy($target->collection(), $force, $force) === null) {
|
||||||
|
throw new \RuntimeException("Failed to delete collection: {$target->collection()}");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectionMove(string|int $identifier, string|int|null $targetLocation): CollectionBaseInterface
|
public function collectionMove(CollectionIdentifierInterface|null $target, CollectionIdentifierInterface $source): CollectionBaseInterface
|
||||||
{
|
{
|
||||||
// TODO: Implement collection move
|
// TODO: Implement collection move
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
@@ -369,12 +384,20 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function collectionCopy(CollectionIdentifierInterface|null $target, CollectionIdentifierInterface $source): CollectionBaseInterface
|
||||||
|
{
|
||||||
|
// TODO: Implement collection copy
|
||||||
|
$this->initialize();
|
||||||
|
$collection = new CollectionResource(provider: $this->provider(), service: $this->identifier());
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
// Entity operations
|
// Entity operations
|
||||||
|
|
||||||
public function entityList(string|int|null $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array
|
public function entityListBulk(string|int|null $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
$result = $this->remoteService->entityList($collection, $filter, $sort, $range, $properties);
|
$result = $this->remoteService->entityList($collection, $filter, $sort, $range, $properties);
|
||||||
|
|
||||||
$list = [];
|
$list = [];
|
||||||
@@ -390,7 +413,7 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityListStream(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): Generator
|
public function entityListStream(string|int|null $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): Generator
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
@@ -421,11 +444,11 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return new Range();
|
return new Range();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityDelta(string|int|null $collection, string $signature, string $detail = 'ids'): Delta
|
public function entityDelta(string|int|null $collection, string $signature): Delta
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
return $this->remoteService->entityDelta($collection, $signature, $detail);
|
return $this->remoteService->entityDelta($collection, $signature, 'ids');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityExtant(string|int|null $collection, string|int ...$identifiers): array
|
public function entityExtant(string|int|null $collection, string|int ...$identifiers): array
|
||||||
@@ -435,48 +458,45 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
|
|||||||
return $this->remoteService->entityExtant(...$identifiers);
|
return $this->remoteService->entityExtant(...$identifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityFetch(string|int|null $collection, string|int ...$identifiers): array
|
public function entityFetchBulk(EntityIdentifierInterface ...$identifiers): array
|
||||||
{
|
{
|
||||||
$this->initialize();
|
$this->initialize();
|
||||||
|
|
||||||
$entities = $this->remoteService->entityFetch(...$identifiers);
|
$entityIds = array_map(fn($identifier) => $identifier->entity(), $identifiers);
|
||||||
|
$entities = $this->remoteService->entityFetch(...$entityIds);
|
||||||
foreach ($entities as &$entity) {
|
|
||||||
|
$list = [];
|
||||||
|
foreach ($entities as $key => $entity) {
|
||||||
if (is_array($entity) && isset($entity['id'])) {
|
if (is_array($entity) && isset($entity['id'])) {
|
||||||
$object = new EntityResource(provider: $this->provider(), service: $this->identifier());
|
$object = new EntityResource(provider: $this->provider(), service: $this->identifier());
|
||||||
$object->fromJmap($entity);
|
$object->fromJmap($entity);
|
||||||
$entity = $object;
|
$list[$object->identifier()] = $object;
|
||||||
|
} else {
|
||||||
|
$list[$key] = $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entities;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityRead(string|int|null $collection, string|int $identifier): ?string
|
public function entityFetchStream(EntityIdentifierInterface ...$identifiers): Generator
|
||||||
|
{
|
||||||
|
yield from $this->entityFetchBulk(...$identifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function entityRead(EntityIdentifierInterface $target): ?string
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Node operations
|
public function entityReadStream(EntityIdentifierInterface $target)
|
||||||
|
|
||||||
public function nodeList(string|int|null $collection, bool $recursive = false, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array
|
|
||||||
{
|
{
|
||||||
return [];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function nodeListFilter(): IFilter
|
public function entityReadChunk(EntityIdentifierInterface $target, int $offset, int $length): ?string
|
||||||
{
|
{
|
||||||
return new Filter(['']);
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
public function nodeListSort(): ISort
|
|
||||||
{
|
|
||||||
return new Sort(['']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function nodeDelta(string|int|null $collection, string $signature, string $detail = 'ids'): Delta
|
|
||||||
{
|
|
||||||
return new Delta();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
$created = $this->serviceStore->create($tenantId, $userId, $service);
|
$created = $this->serviceStore->create($tenantId, $userId, $service);
|
||||||
return (string) $created['id'];
|
return (string) $created['sid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serviceModify(string $tenantId, string $userId, ResourceServiceMutateInterface $service): string
|
public function serviceModify(string $tenantId, string $userId, ResourceServiceMutateInterface $service): string
|
||||||
@@ -151,8 +151,8 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
|||||||
throw new \InvalidArgumentException('Service must be instance of JMAP Service');
|
throw new \InvalidArgumentException('Service must be instance of JMAP Service');
|
||||||
}
|
}
|
||||||
|
|
||||||
$updated = $this->serviceStore->modify($tenantId, $userId, $service);
|
$this->serviceStore->modify($tenantId, $userId, $service);
|
||||||
return (string) $updated['sid'];
|
return (string) $service->identifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serviceDestroy(string $tenantId, string $userId, ResourceServiceMutateInterface $service): bool
|
public function serviceDestroy(string $tenantId, string $userId, ResourceServiceMutateInterface $service): bool
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class Provider implements IProviderBase, IProviderServiceMutate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: This simplified interface doesn't pass tenantId
|
// Note: This simplified interface doesn't pass tenantId
|
||||||
// Will need to get it from SessionTenant in actual implementation
|
// Will need to get it from TenantContextInterface in actual implementation
|
||||||
throw new \RuntimeException('Use Mail Provider interface for service creation');
|
throw new \RuntimeException('Use Mail Provider interface for service creation');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use GuzzleHttp\Client as HttpClient;
|
|||||||
use GuzzleHttp\Psr7\HttpFactory;
|
use GuzzleHttp\Psr7\HttpFactory;
|
||||||
use JmapClient\Authentication\Basic;
|
use JmapClient\Authentication\Basic;
|
||||||
use JmapClient\Client as JmapClient;
|
use JmapClient\Client as JmapClient;
|
||||||
use KTXC\Server;
|
use KTXF\Security\Crypto;
|
||||||
use KTXF\Resource\Provider\ResourceServiceIdentityBasic;
|
use KTXF\Resource\Provider\ResourceServiceIdentityBasic;
|
||||||
use KTXF\Resource\Provider\ResourceServiceLocationUri;
|
use KTXF\Resource\Provider\ResourceServiceLocationUri;
|
||||||
use KTXM\ProviderJmapc\Providers\Mail\Service as MailService;
|
use KTXM\ProviderJmapc\Providers\Mail\Service as MailService;
|
||||||
@@ -73,8 +73,7 @@ class RemoteService {
|
|||||||
}
|
}
|
||||||
// debugging
|
// debugging
|
||||||
if ($service->getDebug()) {
|
if ($service->getDebug()) {
|
||||||
$logDir = Server::getInstance()?->logDir();
|
$logDir = dirname(__DIR__, 5) . '/var/log/jmap/' . $service->identifier() . '.json';
|
||||||
$logDir .= '/jmap/' . $service->identifier() . '.json';
|
|
||||||
$client->configureTransportLogState(true);
|
$client->configureTransportLogState(true);
|
||||||
$client->configureTransportLogLocation($logDir);
|
$client->configureTransportLogLocation($logDir);
|
||||||
}
|
}
|
||||||
@@ -200,7 +199,7 @@ class RemoteService {
|
|||||||
return $service;
|
return $service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function cookieStoreRetrieve(mixed $id): ?array {
|
public static function cookieStoreRetrieve(mixed $id, Crypto $crypto): ?array {
|
||||||
|
|
||||||
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . (string)$id . '.jmapc';
|
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . (string)$id . '.jmapc';
|
||||||
|
|
||||||
@@ -209,7 +208,6 @@ class RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = file_get_contents($file);
|
$data = file_get_contents($file);
|
||||||
$crypto = Server::getInstance()->container()->get(\KTXF\Security\Crypto::class);
|
|
||||||
$data = $crypto->decrypt($data);
|
$data = $crypto->decrypt($data);
|
||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
@@ -220,13 +218,12 @@ class RemoteService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function cookieStoreDeposit(mixed $id, array $value): void {
|
public static function cookieStoreDeposit(mixed $id, array $value, Crypto $crypto): void {
|
||||||
|
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$crypto = Server::getInstance()->container()->get(\KTXF\Security\Crypto::class);
|
|
||||||
$data = $crypto->encrypt(json_encode($value));
|
$data = $crypto->encrypt(json_encode($value));
|
||||||
|
|
||||||
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . (string)$id . '.jmapc';
|
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . (string)$id . '.jmapc';
|
||||||
|
|||||||
Generated
+1252
-538
File diff suppressed because it is too large
Load Diff
+4
-1
@@ -18,7 +18,7 @@
|
|||||||
"test:coverage": "vitest run --coverage --config tests/js/vitest.config.ts"
|
"test:coverage": "vitest run --coverage --config tests/js/vitest.config.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pinia": "^3.0.0",
|
"pinia": "^4.0.0",
|
||||||
"vue": "^3.5.18",
|
"vue": "^3.5.18",
|
||||||
"vue-router": "^5.0.0",
|
"vue-router": "^5.0.0",
|
||||||
"vuetify": "^4.0.0"
|
"vuetify": "^4.0.0"
|
||||||
@@ -27,9 +27,12 @@
|
|||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"@vitest/coverage-v8": "^4.0.18",
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
"@vitest/ui": "^4.0.18",
|
"@vitest/ui": "^4.0.18",
|
||||||
|
"@vue/test-utils": "^2.4.10",
|
||||||
"@vue/tsconfig": "^0.9.0",
|
"@vue/tsconfig": "^0.9.0",
|
||||||
|
"jsdom": "^30.0.0",
|
||||||
"typescript": "~6.0.0",
|
"typescript": "~6.0.0",
|
||||||
"vite": "^8.0.0",
|
"vite": "^8.0.0",
|
||||||
|
"vitest": "^4.0.18",
|
||||||
"vue-tsc": "^3.0.5"
|
"vue-tsc": "^3.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { defineConfig, configDefaults } from 'vitest/config'
|
import { defineConfig, configDefaults } from 'vitest/config'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import vuetify from 'vite-plugin-vuetify'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url)
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
const __dirname = path.dirname(__filename)
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue(), vuetify()],
|
plugins: [vue()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@KTXC': path.resolve(__dirname, '../../../core/src'),
|
'@': path.resolve(__dirname, '../../src'),
|
||||||
|
'@KTXC': path.resolve(__dirname, '../../../../core/src'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace KTXT\ProviderJmapc\Integration;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class BaseTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBasicAssertion(): void
|
||||||
|
{
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testArrayOperations(): void
|
||||||
|
{
|
||||||
|
$array = ['foo' => 'bar'];
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('foo', $array);
|
||||||
|
$this->assertEquals('bar', $array['foo']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStringOperations(): void
|
||||||
|
{
|
||||||
|
$string = 'Hello, World!';
|
||||||
|
|
||||||
|
$this->assertStringContainsString('World', $string);
|
||||||
|
$this->assertEquals(13, strlen($string));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
require dirname(__DIR__, 2).'/lib/vendor/autoload.php';
|
require dirname(__DIR__, 2).'/lib/vendor/autoload.php';
|
||||||
|
|
||||||
|
// When this module is checked out inside a full server (server/modules/<handle>,
|
||||||
|
// as it is in CI and in this monorepo checkout), also load the server's own
|
||||||
|
// core/shared autoloader so tests can reference framework (KTXC/KTXF) types.
|
||||||
|
// Standalone module checkouts without a server alongside them skip this.
|
||||||
|
define('SERVER_ROOT', dirname(__DIR__, 4));
|
||||||
|
$serverAutoload = SERVER_ROOT . '/vendor/autoload.php';
|
||||||
|
if (is_file($serverAutoload)) {
|
||||||
|
require $serverAutoload;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
|
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
|
||||||
umask(0000);
|
umask(0000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<testsuite name="Unit Tests">
|
<testsuite name="Unit Tests">
|
||||||
<directory>unit</directory>
|
<directory>unit</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<testsuite name="Integration Tests">
|
||||||
|
<directory>Integration</directory>
|
||||||
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<source ignoreSuppressionOfDeprecations="true"
|
<source ignoreSuppressionOfDeprecations="true"
|
||||||
@@ -29,8 +32,7 @@
|
|||||||
restrictWarnings="true"
|
restrictWarnings="true"
|
||||||
>
|
>
|
||||||
<include>
|
<include>
|
||||||
<directory>../../core/lib</directory>
|
<directory>../../lib</directory>
|
||||||
<directory>../../shared/lib</directory>
|
|
||||||
</include>
|
</include>
|
||||||
|
|
||||||
<deprecationTrigger>
|
<deprecationTrigger>
|
||||||
Reference in New Issue
Block a user