From 346582d5c28d075d253dbc57ae4299ead7ea240d Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Fri, 17 Jul 2020 21:02:33 -0700 Subject: [PATCH] v2.1.0 - use gdbots/ncr ^v2.1 --- CHANGELOG-2.x.md | 5 +++++ README.md | 18 +++++++++--------- composer.json | 4 ++-- config/services.xml | 8 ++++++++ ...mand.php => CreateSearchStorageCommand.php} | 7 +++---- ...ateCommand.php => CreateStorageCommand.php} | 7 +++---- ...nd.php => DescribeSearchStorageCommand.php} | 7 +++---- ...eCommand.php => DescribeStorageCommand.php} | 7 +++---- src/Command/ExportNodesCommand.php | 3 +-- src/Command/ReindexNodesCommand.php | 9 ++++----- src/Command/SyncNodeCommand.php | 3 +-- src/Command/SyncNodesCommand.php | 11 +++++------ src/DependencyInjection/Configuration.php | 1 - src/Twig/NcrExtension.php | 3 +-- 14 files changed, 48 insertions(+), 45 deletions(-) rename src/Command/{CreateSearchCommand.php => CreateSearchStorageCommand.php} (93%) rename src/Command/{CreateCommand.php => CreateStorageCommand.php} (94%) rename src/Command/{DescribeSearchCommand.php => DescribeSearchStorageCommand.php} (93%) rename src/Command/{DescribeCommand.php => DescribeStorageCommand.php} (93%) diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index 4313357..ec5efa8 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -2,6 +2,11 @@ This changelog references the relevant changes done in 2.x versions. +## v2.1.0 +* Uses `"gdbots/ncr": "^2.1"` +* Uses `"gdbots/pbjx-bundle": "^2.1"` + + ## v2.0.0 __BREAKING CHANGES__ diff --git a/README.md b/README.md index 233cdc7..ac6ff24 100644 --- a/README.md +++ b/README.md @@ -171,15 +171,15 @@ __Other twig functions (documentation wip):__ This library provides the basics for creating and extracting data from the Ncr services. Run the Symfony console and look for __ncr__ commands. ```txt -ncr:create-search Creates the NcrSearch storage. -ncr:create Creates the Ncr storage. -ncr:describe-search Describes the NcrSearch storage. -ncr:describe Describes the Ncr storage. -ncr:export-nodes Pipes nodes from the Ncr to STDOUT. -ncr:get-node Fetches a single node by its NodeRef and writes to STDOUT. -ncr:reindex-nodes Pipes nodes from the Ncr and reindexes them. -ncr:sync-node Syncs a single node from the Ncr with the EventStore. -ncr:sync-nodes Syncs nodes from the Ncr with the EventStore. +ncr:create-search-storage Creates the NcrSearch storage. +ncr:create-storage Creates the Ncr storage. +ncr:describe-search-storage Describes the NcrSearch storage. +ncr:describe-storage Describes the Ncr storage. +ncr:export-nodes Pipes nodes from the Ncr to STDOUT. +ncr:get-node Fetches a single node by its NodeRef and writes to STDOUT. +ncr:reindex-nodes Pipes nodes from the Ncr and reindexes them. +ncr:sync-node Syncs a single node from the Ncr with the EventStore. +ncr:sync-nodes Syncs nodes from the Ncr with the EventStore. ``` Review the `--help` on the ncr commands for more details. diff --git a/composer.json b/composer.json index 1bf5272..0a52f2e 100755 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ "license": "Apache-2.0", "require": { "php": ">=7.4", - "gdbots/ncr": "^2.0", - "gdbots/pbjx-bundle": "^2.0" + "gdbots/ncr": "^2.1", + "gdbots/pbjx-bundle": "^2.1" }, "require-dev": { "phpunit/phpunit": "^9.2", diff --git a/config/services.xml b/config/services.xml index 5cd8aad..070bf6f 100644 --- a/config/services.xml +++ b/config/services.xml @@ -89,6 +89,14 @@ + + + + + + + + diff --git a/src/Command/CreateSearchCommand.php b/src/Command/CreateSearchStorageCommand.php similarity index 93% rename from src/Command/CreateSearchCommand.php rename to src/Command/CreateSearchStorageCommand.php index c7a6f92..257d270 100644 --- a/src/Command/CreateSearchCommand.php +++ b/src/Command/CreateSearchStorageCommand.php @@ -7,7 +7,6 @@ use Gdbots\Pbj\MessageResolver; use Gdbots\Pbj\SchemaCurie; use Gdbots\Pbj\SchemaQName; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,9 +15,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\ContainerInterface; -final class CreateSearchCommand extends Command +final class CreateSearchStorageCommand extends Command { - protected static $defaultName = 'ncr:create-search'; + protected static $defaultName = 'ncr:create-search-storage'; protected ContainerInterface $container; protected NcrSearch $ncrSearch; @@ -87,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [SchemaQName::fromString($input->getArgument('qname'))] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); foreach ($qnames as $qname) { diff --git a/src/Command/CreateCommand.php b/src/Command/CreateStorageCommand.php similarity index 94% rename from src/Command/CreateCommand.php rename to src/Command/CreateStorageCommand.php index 21ae529..83a23a6 100644 --- a/src/Command/CreateCommand.php +++ b/src/Command/CreateStorageCommand.php @@ -7,7 +7,6 @@ use Gdbots\Pbj\MessageResolver; use Gdbots\Pbj\SchemaCurie; use Gdbots\Pbj\SchemaQName; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,9 +15,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\ContainerInterface; -final class CreateCommand extends Command +final class CreateStorageCommand extends Command { - protected static $defaultName = 'ncr:create'; + protected static $defaultName = 'ncr:create-storage'; protected ContainerInterface $container; protected Ncr $ncr; @@ -87,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [SchemaQName::fromString($input->getArgument('qname'))] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); foreach ($qnames as $qname) { diff --git a/src/Command/DescribeSearchCommand.php b/src/Command/DescribeSearchStorageCommand.php similarity index 93% rename from src/Command/DescribeSearchCommand.php rename to src/Command/DescribeSearchStorageCommand.php index 7a8115f..b9970d9 100644 --- a/src/Command/DescribeSearchCommand.php +++ b/src/Command/DescribeSearchStorageCommand.php @@ -7,7 +7,6 @@ use Gdbots\Pbj\MessageResolver; use Gdbots\Pbj\SchemaCurie; use Gdbots\Pbj\SchemaQName; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,9 +15,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\ContainerInterface; -final class DescribeSearchCommand extends Command +final class DescribeSearchStorageCommand extends Command { - protected static $defaultName = 'ncr:describe-search'; + protected static $defaultName = 'ncr:describe-search-storage'; protected ContainerInterface $container; protected NcrSearch $ncrSearch; @@ -79,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [SchemaQName::fromString($input->getArgument('qname'))] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); foreach ($qnames as $qname) { diff --git a/src/Command/DescribeCommand.php b/src/Command/DescribeStorageCommand.php similarity index 93% rename from src/Command/DescribeCommand.php rename to src/Command/DescribeStorageCommand.php index 7d886a4..2ab49f1 100644 --- a/src/Command/DescribeCommand.php +++ b/src/Command/DescribeStorageCommand.php @@ -7,7 +7,6 @@ use Gdbots\Pbj\MessageResolver; use Gdbots\Pbj\SchemaCurie; use Gdbots\Pbj\SchemaQName; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,9 +15,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\ContainerInterface; -final class DescribeCommand extends Command +final class DescribeStorageCommand extends Command { - protected static $defaultName = 'ncr:describe'; + protected static $defaultName = 'ncr:describe-storage'; protected ContainerInterface $container; protected Ncr $ncr; @@ -79,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [SchemaQName::fromString($input->getArgument('qname'))] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); foreach ($qnames as $qname) { diff --git a/src/Command/ExportNodesCommand.php b/src/Command/ExportNodesCommand.php index dcab4d9..fcf1640 100644 --- a/src/Command/ExportNodesCommand.php +++ b/src/Command/ExportNodesCommand.php @@ -8,7 +8,6 @@ use Gdbots\Pbj\SchemaCurie; use Gdbots\Pbj\SchemaQName; use Gdbots\Pbj\Util\NumberUtil; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -100,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [$qname] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); $i = 0; diff --git a/src/Command/ReindexNodesCommand.php b/src/Command/ReindexNodesCommand.php index 443fcb1..9c58ea7 100644 --- a/src/Command/ReindexNodesCommand.php +++ b/src/Command/ReindexNodesCommand.php @@ -10,7 +10,6 @@ use Gdbots\Pbj\SchemaCurie; use Gdbots\Pbj\SchemaQName; use Gdbots\Pbj\Util\NumberUtil; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -126,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [$qname] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); foreach ($qnames as $q) { @@ -140,9 +139,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'etag:%s, title:%s', $i, $node->generateNodeRef(), - $node->get(NodeV1Mixin::STATUS_FIELD), - $node->get(NodeV1Mixin::ETAG_FIELD), - $node->get(NodeV1Mixin::TITLE_FIELD) + $node->get('status'), + $node->get('etag'), + $node->get('title') )); if (count($queue) >= $batchSize) { diff --git a/src/Command/SyncNodeCommand.php b/src/Command/SyncNodeCommand.php index 7d3eeb6..b14aa9d 100644 --- a/src/Command/SyncNodeCommand.php +++ b/src/Command/SyncNodeCommand.php @@ -9,7 +9,6 @@ use Gdbots\Ncr\NcrSearch; use Gdbots\Pbj\WellKnown\NodeRef; use Gdbots\Pbjx\Pbjx; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -100,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $expectedEtag = null; } else { $node = $this->ncr->getNode($nodeRef, true, $context); - $expectedEtag = $node->get(NodeV1Mixin::ETAG_FIELD); + $expectedEtag = $node->get('etag'); $aggregate = AggregateResolver::resolve($nodeRef->getQName())::fromNode($node, $this->pbjx); } } catch (NodeNotFound $nf) { diff --git a/src/Command/SyncNodesCommand.php b/src/Command/SyncNodesCommand.php index 156087f..b230811 100644 --- a/src/Command/SyncNodesCommand.php +++ b/src/Command/SyncNodesCommand.php @@ -12,7 +12,6 @@ use Gdbots\Pbj\SchemaQName; use Gdbots\Pbj\Util\NumberUtil; use Gdbots\Pbjx\Pbjx; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -117,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ? [$qname] : array_map( fn(string $curie) => SchemaCurie::fromString($curie)->getQName(), - MessageResolver::findAllUsingMixin(NodeV1Mixin::SCHEMA_CURIE_MAJOR, false) + MessageResolver::findAllUsingMixin('gdbots:ncr:mixin:node:v1', false) ); foreach ($qnames as $qname) { @@ -127,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $nodeRef = $node->generateNodeRef(); try { - $expectedEtag = $node->get(NodeV1Mixin::ETAG_FIELD); + $expectedEtag = $node->get('etag'); $aggregate = AggregateResolver::resolve($nodeRef->getQName())::fromNode($node, $this->pbjx); $aggregate->sync($context); @@ -143,9 +142,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $i, $aggregate->getEtag() !== $expectedEtag ? 'SYNCED' : 'MATCHED', $nodeRef, - $node->get(NodeV1Mixin::STATUS_FIELD), - $node->get(NodeV1Mixin::ETAG_FIELD), - $node->get(NodeV1Mixin::TITLE_FIELD) + $node->get('status'), + $node->get('etag'), + $node->get('title') )); ++$synced; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 474f4eb..c55cb97 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -4,7 +4,6 @@ namespace Gdbots\Bundle\NcrBundle\DependencyInjection; use Gdbots\Ncr\Repository\DynamoDb\DynamoDbNcr; -use Gdbots\Ncr\Repository\DynamoDb\NodeTable; use Gdbots\Ncr\Repository\DynamoDb\TableManager; use Gdbots\Ncr\Repository\Psr6Ncr; use Gdbots\Ncr\Search\Elastica\ElasticaNcrSearch; diff --git a/src/Twig/NcrExtension.php b/src/Twig/NcrExtension.php index 0031dd2..b175f1e 100644 --- a/src/Twig/NcrExtension.php +++ b/src/Twig/NcrExtension.php @@ -11,7 +11,6 @@ use Gdbots\Pbj\WellKnown\MessageRef; use Gdbots\Pbj\WellKnown\NodeRef; use Gdbots\Schemas\Ncr\Enum\NodeStatus; -use Gdbots\Schemas\Ncr\Mixin\Node\NodeV1Mixin; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Twig\Extension\AbstractExtension; @@ -114,7 +113,7 @@ public function isNodePublished($node): bool return false; } - return NodeStatus::PUBLISHED === $node->fget(NodeV1Mixin::STATUS_FIELD); + return NodeStatus::PUBLISHED === $node->fget('status'); } /**