@amazeelabs/silverback-gatsby 3.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/drupal/silverback_gatsby/.prettierignore +1 -0
- package/drupal/silverback_gatsby/CHANGELOG.md +1216 -0
- package/drupal/silverback_gatsby/README.md +297 -0
- package/drupal/silverback_gatsby/composer.json +15 -0
- package/drupal/silverback_gatsby/directives.gql +63 -0
- package/drupal/silverback_gatsby/directives.graphql +62 -0
- package/drupal/silverback_gatsby/drush.services.yml +9 -0
- package/drupal/silverback_gatsby/graphql/entity.directive.graphqls +2 -0
- package/drupal/silverback_gatsby/graphql/menu.directive.graphqls +17 -0
- package/drupal/silverback_gatsby/graphql/silverback_gatsby.base.graphqls +25 -0
- package/drupal/silverback_gatsby/graphql/silverback_gatsby.extension.graphqls +10 -0
- package/drupal/silverback_gatsby/graphql/stringTranslation.directive.graphqls +4 -0
- package/drupal/silverback_gatsby/graphql/translatableString.directive.graphqls +2 -0
- package/drupal/silverback_gatsby/modules/silverback_gatsby_example/directives.gql +6 -0
- package/drupal/silverback_gatsby/modules/silverback_gatsby_example/graphql/.graphqlrc.json +4 -0
- package/drupal/silverback_gatsby/modules/silverback_gatsby_example/graphql/silverback_gatsby_example.graphqls +39 -0
- package/drupal/silverback_gatsby/modules/silverback_gatsby_example/silverback_gatsby_example.info.yml +7 -0
- package/drupal/silverback_gatsby/modules/silverback_gatsby_example/silverback_gatsby_example.module +16 -0
- package/drupal/silverback_gatsby/modules/silverback_gatsby_example/src/Directives.php +24 -0
- package/drupal/silverback_gatsby/silverback_gatsby.info.yml +8 -0
- package/drupal/silverback_gatsby/silverback_gatsby.install +180 -0
- package/drupal/silverback_gatsby/silverback_gatsby.links.task.yml +6 -0
- package/drupal/silverback_gatsby/silverback_gatsby.module +119 -0
- package/drupal/silverback_gatsby/silverback_gatsby.permissions.yml +8 -0
- package/drupal/silverback_gatsby/silverback_gatsby.post_update.php +15 -0
- package/drupal/silverback_gatsby/silverback_gatsby.routing.yml +28 -0
- package/drupal/silverback_gatsby/silverback_gatsby.services.yml +50 -0
- package/drupal/silverback_gatsby/src/Annotation/GatsbyFeed.php +41 -0
- package/drupal/silverback_gatsby/src/Commands/SilverbackGatsbyCommands.php +102 -0
- package/drupal/silverback_gatsby/src/Controller/BuildController.php +45 -0
- package/drupal/silverback_gatsby/src/Controller/PublisherController.php +34 -0
- package/drupal/silverback_gatsby/src/Directives.php +51 -0
- package/drupal/silverback_gatsby/src/GatsbyBuildTrigger.php +230 -0
- package/drupal/silverback_gatsby/src/GatsbyBuildTriggerInterface.php +52 -0
- package/drupal/silverback_gatsby/src/GatsbyUpdate.php +38 -0
- package/drupal/silverback_gatsby/src/GatsbyUpdateHandler.php +181 -0
- package/drupal/silverback_gatsby/src/GatsbyUpdateTracker.php +98 -0
- package/drupal/silverback_gatsby/src/GatsbyUpdateTrackerInterface.php +59 -0
- package/drupal/silverback_gatsby/src/GatsbyUpdateTrigger.php +69 -0
- package/drupal/silverback_gatsby/src/GatsbyUpdateTriggerInterface.php +22 -0
- package/drupal/silverback_gatsby/src/GraphQL/Build.php +235 -0
- package/drupal/silverback_gatsby/src/GraphQL/ComposableSchema.php +73 -0
- package/drupal/silverback_gatsby/src/LocaleStorageDecorator.php +181 -0
- package/drupal/silverback_gatsby/src/MenuTreeStorageDecorator.php +139 -0
- package/drupal/silverback_gatsby/src/Plugin/FeedBase.php +121 -0
- package/drupal/silverback_gatsby/src/Plugin/FeedInterface.php +132 -0
- package/drupal/silverback_gatsby/src/Plugin/FeedPluginManager.php +39 -0
- package/drupal/silverback_gatsby/src/Plugin/Gatsby/Feed/EntityFeed.php +252 -0
- package/drupal/silverback_gatsby/src/Plugin/Gatsby/Feed/MenuFeed.php +292 -0
- package/drupal/silverback_gatsby/src/Plugin/Gatsby/Feed/StringTranslationFeed.php +171 -0
- package/drupal/silverback_gatsby/src/Plugin/Gatsby/Feed/TranslatableStringFeed.php +128 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/CurrentUserEntity.php +43 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/EntityQueryBase.php +40 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/FetchEntity.php +371 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/FetchString.php +64 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/FetchTranslatableString.php +74 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/FocalPoint.php +47 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/GatsbyBuildId.php +36 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/GatsbyExtractId.php +28 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/GatsbyExtractLangcode.php +28 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/ImageProps.php +149 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/ListEntities.php +88 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/ListStrings.php +87 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/StringId.php +37 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/DataProducer/StringTranslations.php +94 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/EntityFetch.php +51 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/EntityTranslationsWithDefault.php +30 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/FocalPoint.php +27 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/ImageProps.php +27 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/MenuLangcode.php +27 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/MenuTranslations.php +36 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/Directive/SilverbackGatsbyEntityId.php +39 -0
- package/drupal/silverback_gatsby/src/Plugin/GraphQL/SchemaExtension/SilverbackGatsbySchemaExtension.php +384 -0
- package/drupal/silverback_gatsby/src/SilverbackGatsbyServiceProvider.php +43 -0
- package/drupal/silverback_gatsby/src/SilverbackGatsbySessionConfiguration.php +30 -0
- package/drupal/silverback_gatsby/src/SilverbackReverseProxyMiddleware.php +49 -0
- package/drupal/silverback_gatsby/tests/queries/create-page-fields.gql +12 -0
- package/drupal/silverback_gatsby/tests/queries/current-user.gql +6 -0
- package/drupal/silverback_gatsby/tests/queries/feed_info.gql +12 -0
- package/drupal/silverback_gatsby/tests/queries/load-entity.gql +5 -0
- package/drupal/silverback_gatsby/tests/queries/menus.gql +31 -0
- package/drupal/silverback_gatsby/tests/queries/multilingual-menus.gql +11 -0
- package/drupal/silverback_gatsby/tests/queries/revisionable-translatable.gql +15 -0
- package/drupal/silverback_gatsby/tests/queries/revisionable.gql +8 -0
- package/drupal/silverback_gatsby/tests/queries/translatable.gql +14 -0
- package/drupal/silverback_gatsby/tests/queries/untranslatable.gql +10 -0
- package/drupal/silverback_gatsby/tests/schema/.graphqlrc.json +4 -0
- package/drupal/silverback_gatsby/tests/schema/translatable-strings.graphql +7 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/CurrentUserTest.php +37 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/EntityFeedTest.php +490 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/EntityFeedTestBase.php +178 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/GatsbyBuildTriggerTest.php +155 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/GatsbyFeedInfoTest.php +319 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/GatsbyUpdateHandlerTest.php +131 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/GatsbyUpdateTrackerTest.php +196 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/GatsbyUpdateTriggerTest.php +177 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/MenuFeedTest.php +192 -0
- package/drupal/silverback_gatsby/tests/src/Kernel/TranslatableStringFeedTest.php +210 -0
- package/drupal/silverback_gatsby/tests/src/Traits/NotificationCheckTrait.php +43 -0
- package/package.json +15 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Drupal\Tests\silverback_gatsby\Kernel;
|
|
4
|
+
|
|
5
|
+
use Drupal\locale\StringStorageInterface;
|
|
6
|
+
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Test case for translatable strings in GraphQL.
|
|
10
|
+
*/
|
|
11
|
+
class TranslatableStringFeedTest extends GraphQLTestBase {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* {@inheritdoc}
|
|
15
|
+
*/
|
|
16
|
+
protected $strictConfigSchema = FALSE;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* {@inheritdoc}
|
|
20
|
+
*/
|
|
21
|
+
protected static $modules = [
|
|
22
|
+
'locale',
|
|
23
|
+
'graphql_directives',
|
|
24
|
+
'silverback_gatsby',
|
|
25
|
+
'silverback_gatsby_example',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The string storage.
|
|
30
|
+
*/
|
|
31
|
+
protected StringStorageInterface $storage;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The GraphQL query for listing operations.
|
|
35
|
+
*/
|
|
36
|
+
protected string $query = <<<'GQL'
|
|
37
|
+
query {
|
|
38
|
+
_queryTranslatableStrings {
|
|
39
|
+
_id
|
|
40
|
+
source
|
|
41
|
+
_translations {
|
|
42
|
+
_id
|
|
43
|
+
language
|
|
44
|
+
translation
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
GQL;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The GraphQL query for loading a single operation.
|
|
52
|
+
*/
|
|
53
|
+
protected string $load = <<<'GQL'
|
|
54
|
+
query load($id: String!) {
|
|
55
|
+
_loadTranslatableString(id: $id) {
|
|
56
|
+
_id
|
|
57
|
+
source
|
|
58
|
+
_translations {
|
|
59
|
+
_id
|
|
60
|
+
language
|
|
61
|
+
translation
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
GQL;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* {@inheritdoc}
|
|
69
|
+
*/
|
|
70
|
+
protected function setUp(): void {
|
|
71
|
+
parent::setUp();
|
|
72
|
+
$this->storage = $this->container->get('locale.storage');
|
|
73
|
+
$this->installConfig('graphql_directives');
|
|
74
|
+
$this->installSchema('silverback_gatsby', ['gatsby_update_log']);
|
|
75
|
+
$this->installSchema('locale', [
|
|
76
|
+
'locales_source',
|
|
77
|
+
'locales_target',
|
|
78
|
+
'locales_location',
|
|
79
|
+
'locale_file',
|
|
80
|
+
]);
|
|
81
|
+
$schema = \Drupal::moduleHandler()->getModule('silverback_gatsby')->getPath()
|
|
82
|
+
. '/tests/schema/translatable-strings.graphql';
|
|
83
|
+
$this->createTestServer(
|
|
84
|
+
'directable',
|
|
85
|
+
'/gatsby',
|
|
86
|
+
[
|
|
87
|
+
'schema_configuration' => [
|
|
88
|
+
'directable' => [
|
|
89
|
+
'extensions' => [
|
|
90
|
+
'silverback_gatsby' => 'silverback_gatsby',
|
|
91
|
+
],
|
|
92
|
+
'schema_definition' => $schema,
|
|
93
|
+
'autoload_contexts' => 'drupal',
|
|
94
|
+
'build_webhook' => 'http://127.0.0.1:8888/__refresh',
|
|
95
|
+
],
|
|
96
|
+
],
|
|
97
|
+
]
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Verify that it just generates an empty result if there are no strings.
|
|
103
|
+
*/
|
|
104
|
+
public function testQueryWithoutStrings(): void {
|
|
105
|
+
$metadata = $this->defaultCacheMetaData();
|
|
106
|
+
$metadata->addCacheTags(['locale']);
|
|
107
|
+
$this->assertResults($this->query, [], [
|
|
108
|
+
'_queryTranslatableStrings' => [],
|
|
109
|
+
], $metadata);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Test querying an untranslated string.
|
|
114
|
+
*/
|
|
115
|
+
public function testQueryWithUntranslatedString(): void {
|
|
116
|
+
$metadata = $this->defaultCacheMetaData();
|
|
117
|
+
$metadata->addCacheTags(['locale']);
|
|
118
|
+
$this->storage->createString([
|
|
119
|
+
'source' => 'test source',
|
|
120
|
+
'context' => 'gatsby',
|
|
121
|
+
])->save();
|
|
122
|
+
$this->assertResults($this->query, [], [
|
|
123
|
+
'_queryTranslatableStrings' => [
|
|
124
|
+
[
|
|
125
|
+
'_id' => '1:en',
|
|
126
|
+
'source' => 'test source',
|
|
127
|
+
'_translations' => [],
|
|
128
|
+
],
|
|
129
|
+
],
|
|
130
|
+
], $metadata);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* List results with a translated string.
|
|
135
|
+
*/
|
|
136
|
+
public function testQueryWithTranslatedString(): void {
|
|
137
|
+
$metadata = $this->defaultCacheMetaData();
|
|
138
|
+
$metadata->addCacheTags(['locale']);
|
|
139
|
+
$string = $this->storage->createString([
|
|
140
|
+
'source' => 'test source',
|
|
141
|
+
'context' => 'gatsby',
|
|
142
|
+
]);
|
|
143
|
+
$string->save();
|
|
144
|
+
$this->storage->createTranslation([
|
|
145
|
+
'lid' => $string->lid,
|
|
146
|
+
'language' => 'de',
|
|
147
|
+
'translation' => 'test german',
|
|
148
|
+
])->save();
|
|
149
|
+
|
|
150
|
+
$this->assertResults($this->query, [], [
|
|
151
|
+
'_queryTranslatableStrings' => [
|
|
152
|
+
[
|
|
153
|
+
'_id' => '1:en',
|
|
154
|
+
'source' => 'test source',
|
|
155
|
+
'_translations' => [
|
|
156
|
+
[
|
|
157
|
+
'_id' => '1:de',
|
|
158
|
+
'language' => 'de',
|
|
159
|
+
'translation' => 'test german',
|
|
160
|
+
],
|
|
161
|
+
],
|
|
162
|
+
],
|
|
163
|
+
],
|
|
164
|
+
], $metadata);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Test loading a translated string that does not exist.
|
|
169
|
+
*/
|
|
170
|
+
public function testLoadNoneExistingString(): void {
|
|
171
|
+
$metadata = $this->defaultCacheMetaData();
|
|
172
|
+
$metadata->addCacheTags(['locale']);
|
|
173
|
+
$this->assertResults($this->load, ['id' => '1:en'], [
|
|
174
|
+
'_loadTranslatableString' => NULL,
|
|
175
|
+
], $metadata);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Test loading a translated string.
|
|
180
|
+
*/
|
|
181
|
+
public function testLoadTranslatedString(): void {
|
|
182
|
+
$metadata = $this->defaultCacheMetaData();
|
|
183
|
+
$metadata->addCacheTags(['locale']);
|
|
184
|
+
$string = $this->storage->createString([
|
|
185
|
+
'source' => 'test source',
|
|
186
|
+
'context' => 'gatsby',
|
|
187
|
+
]);
|
|
188
|
+
$string->save();
|
|
189
|
+
$this->storage->createTranslation([
|
|
190
|
+
'lid' => $string->lid,
|
|
191
|
+
'language' => 'de',
|
|
192
|
+
'translation' => 'test german',
|
|
193
|
+
])->save();
|
|
194
|
+
|
|
195
|
+
$this->assertResults($this->load, ['id' => '1:de'], [
|
|
196
|
+
'_loadTranslatableString' => [
|
|
197
|
+
'_id' => '1:de',
|
|
198
|
+
'source' => 'test source',
|
|
199
|
+
'_translations' => [
|
|
200
|
+
[
|
|
201
|
+
'_id' => '1:de',
|
|
202
|
+
'language' => 'de',
|
|
203
|
+
'translation' => 'test german',
|
|
204
|
+
],
|
|
205
|
+
],
|
|
206
|
+
],
|
|
207
|
+
], $metadata);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Drupal\Tests\silverback_gatsby\Traits;
|
|
4
|
+
|
|
5
|
+
use GuzzleHttp\Client;
|
|
6
|
+
use Prophecy\Argument;
|
|
7
|
+
use Psr\Http\Message\ResponseInterface;
|
|
8
|
+
|
|
9
|
+
trait NotificationCheckTrait {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @var \Prophecy\Prophecy\ObjectProphecy
|
|
13
|
+
*/
|
|
14
|
+
protected $clientProphecy;
|
|
15
|
+
|
|
16
|
+
protected function setupClientProphecy() {
|
|
17
|
+
$this->clientProphecy = $this->prophesize(Client::class);
|
|
18
|
+
$this->clientProphecy->post(Argument::any(), Argument::any())
|
|
19
|
+
->willReturn($this->prophesize(ResponseInterface::class)->reveal());
|
|
20
|
+
$this->container->set('http_client', $this->clientProphecy->reveal());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected function checkTotalNotifications(int $number) {
|
|
24
|
+
$this->clientProphecy->post(Argument::any(), Argument::any())->shouldHaveBeenCalledTimes($number);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected function checkBuildNotification(string $url, int $buildId) {
|
|
28
|
+
$this->clientProphecy->post(Argument::exact($url), Argument::exact([
|
|
29
|
+
'headers' => [
|
|
30
|
+
'User-Agent' => 'CMS',
|
|
31
|
+
],
|
|
32
|
+
'json' => ['buildId' => $buildId],
|
|
33
|
+
'timeout' => 2,
|
|
34
|
+
]))->shouldHaveBeenCalledTimes(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected function checkUpdateNotification(string $url, array $updates) {
|
|
38
|
+
$this->clientProphecy->post(Argument::exact($url), Argument::exact([
|
|
39
|
+
'json' => $updates,
|
|
40
|
+
'timeout' => 2,
|
|
41
|
+
]))->shouldHaveBeenCalledTimes(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amazeelabs/silverback-gatsby",
|
|
3
|
+
"version": "3.7.13",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"precommit": "pnpm precommit:fix && pnpm precommit:check && pnpm test:unit",
|
|
6
|
+
"precommit:fix": "pnpm --filter @custom/cms precommit:fix packages/@amazeelabs/silverback-gatsby/drupal",
|
|
7
|
+
"precommit:check": "pnpm --filter @custom/cms precommit:check packages/@amazeelabs/silverback-gatsby/drupal",
|
|
8
|
+
"test:unit": "pnpm --filter @custom/cms cms:test:unit --filter=silverback_gatsby",
|
|
9
|
+
"test:integration": "pnpm --filter @custom/cms cms:test:integration --filter=silverback_gatsby"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"gitHead": "8e0638f5452e77742f99aebe4a65606aac751103"
|
|
15
|
+
}
|