Skip to content

Commit cbb4305

Browse files
committed
[Http] Add Http adapter functions
Avro & Excel added to DSL documentation
1 parent 49734e3 commit cbb4305

10 files changed

Lines changed: 58 additions & 5 deletions

File tree

bin/docs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ public function execute(InputInterface $input, OutputInterface $output) : int
3737

3838
$paths = [
3939
__DIR__ . '/../src/core/etl/src/Flow/ETL/DSL/functions.php',
40+
__DIR__ . '/../src/adapter/etl-adapter-avro/src/Flow/ETL/Adapter/Avro/functions.php',
4041
__DIR__ . '/../src/adapter/etl-adapter-chartjs/src/Flow/ETL/Adapter/ChartJS/functions.php',
4142
__DIR__ . '/../src/adapter/etl-adapter-csv/src/Flow/ETL/Adapter/CSV/functions.php',
4243
__DIR__ . '/../src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/functions.php',
44+
__DIR__ . '/../src/adapter/etl-adapter-excel/src/Flow/ETL/Adapter/Excel/DSL/functions.php',
4345
__DIR__ . '/../src/adapter/etl-adapter-elasticsearch/src/Flow/ETL/Adapter/Elasticsearch/functions.php',
4446
__DIR__ . '/../src/adapter/etl-adapter-google-sheet/src/Flow/ETL/Adapter/GoogleSheet/functions.php',
47+
__DIR__ . '/../src/adapter/etl-adapter-http/src/Flow/ETL/Adapter/Http/DSL/functions.php',
4548
__DIR__ . '/../src/adapter/etl-adapter-json/src/Flow/ETL/Adapter/JSON/functions.php',
4649
__DIR__ . '/../src/adapter/etl-adapter-meilisearch/src/Flow/ETL/Adapter/Meilisearch/functions.php',
4750
__DIR__ . '/../src/adapter/etl-adapter-parquet/src/Flow/ETL/Adapter/Parquet/functions.php',

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
"src/adapter/etl-adapter-elasticsearch/src/Flow/ETL/Adapter/Elasticsearch/functions.php",
147147
"src/adapter/etl-adapter-excel/src/Flow/ETL/Adapter/Excel/DSL/functions.php",
148148
"src/adapter/etl-adapter-google-sheet/src/Flow/ETL/Adapter/GoogleSheet/functions.php",
149+
"src/adapter/etl-adapter-http/src/Flow/ETL/Adapter/Http/DSL/functions.php",
149150
"src/adapter/etl-adapter-json/src/Flow/ETL/Adapter/JSON/functions.php",
150151
"src/adapter/etl-adapter-meilisearch/src/Flow/ETL/Adapter/Meilisearch/functions.php",
151152
"src/adapter/etl-adapter-parquet/src/Flow/ETL/Adapter/Parquet/functions.php",

src/adapter/etl-adapter-avro/src/Flow/ETL/Adapter/Avro/functions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
use function Flow\ETL\DSL\from_all;
88
use Flow\ETL\Adapter\Avro\FlixTech\{AvroExtractor, AvroLoader};
9-
use Flow\ETL\{Extractor, Schema};
9+
use Flow\ETL\{Attribute\DocumentationDSL, Attribute\Module, Attribute\Type, Extractor, Schema};
1010
use Flow\Filesystem\Path;
1111

12+
#[DocumentationDSL(module: Module::AVRO, type: Type::EXTRACTOR)]
1213
function from_avro(Path|string|array $path) : Extractor
1314
{
1415
if (\is_array($path)) {
@@ -29,6 +30,7 @@ function from_avro(Path|string|array $path) : Extractor
2930
);
3031
}
3132

33+
#[DocumentationDSL(module: Module::AVRO, type: Type::LOADER)]
3234
function to_avro(Path|string $path, ?Schema $schema = null) : AvroLoader
3335
{
3436
return new AvroLoader(

src/adapter/etl-adapter-excel/src/Flow/ETL/Adapter/Excel/DSL/functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function from_excel(
2121
return new ExcelExtractor(\is_string($path) ? Path::realpath($path) : $path);
2222
}
2323

24+
#[DocumentationDSL(module: Module::EXCEL, type: DSLType::HELPER)]
2425
function is_valid_excel_sheet_name(string|ScalarFunction $sheet_name) : IsValidExcelSheetName
2526
{
2627
return new IsValidExcelSheetName($sheet_name);

src/adapter/etl-adapter-http/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"Flow\\": [
3030
"src/Flow"
3131
]
32-
}
32+
},
33+
"files": [
34+
"src/Flow/ETL/Adapter/Http/DSL/functions.php"
35+
]
3336
},
3437
"autoload-dev": {
3538
"psr-4": {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Flow\ETL\Adapter\Http;
6+
7+
use Flow\ETL\{Adapter\Http\DynamicExtractor\NextRequestFactory,
8+
Attribute\DocumentationDSL,
9+
Attribute\Module,
10+
Attribute\Type};
11+
use Psr\Http\Client\ClientInterface;
12+
use Psr\Http\Message\RequestInterface;
13+
14+
#[DocumentationDSL(module: Module::HTTP, type: Type::EXTRACTOR)]
15+
function from_dynamic_http_requests(
16+
ClientInterface $client,
17+
NextRequestFactory $requestFactory,
18+
) : PsrHttpClientDynamicExtractor {
19+
return new PsrHttpClientDynamicExtractor(
20+
$client,
21+
$requestFactory,
22+
);
23+
}
24+
25+
/**
26+
* @param iterable<RequestInterface> $requests
27+
*/
28+
#[DocumentationDSL(module: Module::HTTP, type: Type::EXTRACTOR)]
29+
function from_static_http_requests(
30+
ClientInterface $client,
31+
iterable $requests,
32+
) : PsrHttpClientStaticExtractor {
33+
return new PsrHttpClientStaticExtractor(
34+
$client,
35+
$requests,
36+
);
37+
}

src/core/etl/src/Flow/ETL/Attribute/Module.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66

77
enum Module : string
88
{
9+
case AVRO = 'AVRO';
910
case AZURE_FILESYSTEM = 'AZURE_FILESYSTEM';
1011
case AZURE_SDK = 'AZURE_SDK';
1112
case CHART_JS = 'CHART_JS';
1213
case CORE = 'CORE';
1314
case CSV = 'CSV';
14-
1515
case DEPRECATED = 'DEPRECATED';
1616
case DOCTRINE = 'DOCTRINE';
1717
case ELASTIC_SEARCH = 'ELASTIC_SEARCH';
1818
case EXCEL = 'EXCEL';
1919
case FILESYSTEM = 'FILESYSTEM';
2020
case GOOGLE_SHEET = 'GOOGLE_SHEET';
21+
case HTTP = 'HTTP';
2122
case JSON = 'JSON';
2223
case MEILI_SEARCH = 'MEILI_SEARCH';
2324
case PARQUET = 'PARQUET';

web/landing/resources/dsl.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

web/landing/src/Flow/Website/Model/Documentation/Module.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66

77
enum Module : string
88
{
9+
case AVRO = 'Avro';
910
case AZURE_FILESYSTEM = 'Azure Filesystem';
1011
case AZURE_SDK = 'Azure SDK';
1112
case CHART_JS = 'Chart.js';
1213
case CORE = 'Core';
1314
case CSV = 'CSV';
1415
case DOCTRINE = 'Doctrine';
1516
case ELASTIC_SEARCH = 'Elastic Search';
17+
case EXCEL = 'Excel';
1618
case FILESYSTEM = 'Filesystem';
1719
case GOOGLE_SHEET = 'Google Sheet';
20+
case HTTP = 'HTTP';
1821
case JSON = 'JSON';
1922
case MEILI_SEARCH = 'Meili Search';
2023
case PARQUET = 'Parquet';
@@ -48,6 +51,8 @@ public function priority() : int
4851
self::TYPES => 13,
4952
self::AZURE_FILESYSTEM => 14,
5053
self::AZURE_SDK => 15,
54+
self::HTTP => 16,
55+
self::EXCEL => 17,
5156
default => 99,
5257
};
5358
}

web/landing/tests/Flow/Website/Tests/Functional/DocumentationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function test_documentation_dsl_page() : void
3232
self::assertResponseIsSuccessful();
3333
self::assertGreaterThan(0, $client->getCrawler()->filter('[data-dsl-function]')->count());
3434
self::assertGreaterThan(0, $client->getCrawler()->filter('[data-dsl-source-link]')->count());
35-
self::assertEquals(17, $client->getCrawler()->filter('[data-dsl-module]')->count());
35+
self::assertEquals(20, $client->getCrawler()->filter('[data-dsl-module]')->count());
3636
self::assertEquals(12, $client->getCrawler()->filter('[data-dsl-type]')->count());
3737
}
3838

0 commit comments

Comments
 (0)