Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5326bda
Allowed HTTP Methods dynamically retrieved by OpenAPI JSON
JaySChad Sep 19, 2024
fe2ed23
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Sep 19, 2024
11465a7
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Sep 26, 2024
407b410
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Oct 22, 2024
4c3a856
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Oct 29, 2024
35f88f5
Merge branch 'axenox:1.x-dev' into 1.x-dev
JaySChad Nov 6, 2024
82721a6
Merge branch '1.x-dev' of https://github.com/JaySChad/ETL into 1.x-dev
JaySChad Nov 7, 2024
b70b390
NEW #889 Webservice Response is separate entity
JaySChad Nov 7, 2024
24dda39
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Dec 6, 2024
e637258
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Jan 9, 2025
93781e5
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Feb 12, 2025
f380741
Merge branch '1.x-dev' of https://github.com/axenox/ETL into 1.x-dev
JaySChad Feb 18, 2025
6f92c76
Merge pull request #126 from axenox/1.x-dev
kabachello Jun 10, 2025
ac7dfc2
Merge branch 'refactor/web-request-response-separated' into 1.x-dev
kabachello Jun 10, 2025
d9cf929
Merge pull request #81 from JaySChad/1.x-dev
kabachello Jun 10, 2025
0580af3
FIX Hotfix for broken model files
hail-cookies Jun 10, 2025
f9d5ab1
DEV Webservice Objects
hail-cookies Jun 10, 2025
6aaca33
FIX fixed broken metamodel updates
hail-cookies Jun 10, 2025
06e00a5
FIX Temp fixes
hail-cookies Jun 10, 2025
90ad664
DEV RequestLoggingMiddleware extracted respaonse creation
hail-cookies Jun 17, 2025
fb2faf0
REF AbstractETLPrototype extracted loadRequestData and loadResponseData
hail-cookies Jun 17, 2025
ca69f6b
REF DataSheetToApi
hail-cookies Jun 17, 2025
2fa15c7
Merge branch '1.x-dev' of https://github.com/axenox/ETL into refactor…
hail-cookies Jun 25, 2025
eb46eee
NEW WebserviceRequest file storage model
hail-cookies Jun 26, 2025
41dd17e
DEV WebserviceRequest metamodel updates
hail-cookies Jun 27, 2025
798356c
DEV WebserviceRequest mirgations
hail-cookies Jun 27, 2025
e1d3c1b
DEV WebServiceRequest updated request logs
hail-cookies Jun 27, 2025
b69153d
FIX OpenApiFacade manually reverted Commit 5326bda
hail-cookies Jun 27, 2025
31cd8b0
REF Separating request and response
hail-cookies Jun 27, 2025
4060d6a
REF RequestLoggingMiddleWare
hail-cookies Jun 27, 2025
b82b8cf
FIX DataFlowFacade formatting
hail-cookies Jun 27, 2025
49bf7cf
FIX WebserviceRequest migration typos
hail-cookies Jun 27, 2025
72a2f40
FIX RequestLoggingMiddleware fixed function call
hail-cookies Jul 1, 2025
fc7e84b
FIX Bad response headers
hail-cookies Jul 1, 2025
b9f3123
FIX response_header datatype
hail-cookies Jul 1, 2025
a4097b9
REF Load bodies via relation
hail-cookies Jul 2, 2025
3a81654
FIX RequestLoggingMiddleware removed redundant lines
hail-cookies Jul 2, 2025
dcb2526
FIX minor fixes
hail-cookies Jul 2, 2025
bdc14aa
FIX DataFlowFacade response_header datatype
hail-cookies Jul 2, 2025
68e774d
DEV Changed migrations destination folder
hail-cookies Jul 2, 2025
5906b4c
FIX Sql migrations
hail-cookies Jul 2, 2025
799a666
FIX migrations
hail-cookies Jul 2, 2025
1a0ab55
FIX migrations
hail-cookies Jul 2, 2025
4eb6fbd
FIX WebServiceRequest model changes
hail-cookies Jul 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Common/AbstractAPISchemaPrototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace axenox\ETL\Common;

use axenox\ETL\Common\AbstractETLPrototype;
use axenox\ETL\Common\OpenAPI\OpenAPI3;
use axenox\ETL\Interfaces\APISchema\APISchemaInterface;
use axenox\ETL\Interfaces\ETLStepDataInterface;
use exface\Core\CommonLogic\UxonObject;
Expand All @@ -12,7 +10,6 @@
use exface\Core\Exceptions\InvalidArgumentException;
use exface\Core\Factories\DataSheetFactory;
use exface\Core\Interfaces\DataSheets\DataSheetInterface;
use exface\Core\Widgets\DebugMessage;
use exface\Core\Interfaces\Tasks\TaskInterface;
use exface\Core\Interfaces\Tasks\HttpTaskInterface;
use axenox\ETL\Interfaces\OpenApiFacadeInterface;
Expand Down Expand Up @@ -63,27 +60,6 @@ protected function getAPISchema(ETLStepDataInterface $stepData) : APISchemaInter
return $model;
}


/**
* @param ETLStepDataInterface $stepData
* @param array $requestedColumns
* @return DataSheetInterface
*/
protected function loadRequestData(ETLStepDataInterface $stepData, array $requestedColumns): DataSheetInterface
{
$requestLogData = DataSheetFactory::createFromObjectIdOrAlias($this->getWorkbench(), 'axenox.ETL.webservice_request');
$requestLogData->getColumns()->addFromSystemAttributes();
$requestLogData->getColumns()->addMultiple($requestedColumns);
$requestLogData->getFilters()->addConditionFromString('flow_run', $stepData->getFlowRunUid());
$requestLogData->dataRead();

if ($requestLogData->countRows() > 1) {
throw new InvalidArgumentException('Ambiguous web requests!');
}

return $requestLogData;
}

/**
* Datasheets from OpenApi JSON data cannot have relations.
* There are only used for dynamic formulars like =Lookup()
Expand Down
60 changes: 60 additions & 0 deletions Common/AbstractETLPrototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use exface\Core\CommonLogic\DataSheets\CrudCounter;
use exface\Core\CommonLogic\Debugger\LogBooks\FlowStepLogBook;
use exface\Core\Exceptions\DataSheets\DataCheckFailedErrorMultiple;
use exface\Core\Exceptions\InvalidArgumentException;
use exface\Core\Factories\DataSheetFactory;
use exface\Core\Interfaces\DataSheets\DataSheetInterface;
use exface\Core\Interfaces\WorkbenchInterface;
use exface\Core\CommonLogic\UxonObject;
Expand Down Expand Up @@ -441,4 +443,62 @@ public function createDebugWidget(DebugMessage $debug_widget, ?ETLStepDataInterf
}
return $this->getLogBook($stepData)->createDebugWidget($debug_widget);
}

/**
* @param ETLStepDataInterface $stepData
* @param array $requestedColumns
* @return DataSheetInterface
*/
protected function loadRequestData(ETLStepDataInterface $stepData, array $requestedColumns = []): DataSheetInterface
{
$requestData = DataSheetFactory::createFromObjectIdOrAlias($this->getWorkbench(), 'axenox.ETL.webservice_request');
$requestData->getColumns()->addFromSystemAttributes();
$requestData->getColumns()->addMultiple($requestedColumns);
$requestData->getFilters()->addConditionFromString('flow_run', $stepData->getFlowRunUid());
$requestData->dataRead();

if ($requestData->countRows() > 1) {
throw new InvalidArgumentException('Ambiguous web requests!');
}

return $requestData;
}

/**
* @param string $requestUid
* @param array $requestedColumns
* @param bool $createIfNotFound
* @return DataSheetInterface
*/
protected function loadResponseData(
string $requestUid,
array $requestedColumns = [],
bool $createIfNotFound = true): DataSheetInterface
{
if(empty($requestUid)) {
throw new InvalidArgumentException('Cannot load response: Missing request UID!');
}

$responseData = DataSheetFactory::createFromObjectIdOrAlias($this->getWorkbench(), 'axenox.ETL.webservice_response');
$responseData->getColumns()->addFromSystemAttributes();
$responseData->getColumns()->addMultiple($requestedColumns);
$responseData->getColumns()->addFromExpression('webservice_request');
$responseData->getFilters()->addConditionFromString('webservice_request', $requestUid);
$responseData->dataRead();

if ($responseData->countRows() > 1) {
throw new InvalidArgumentException('Cannot load response: Ambiguous web requests!');
}

if($createIfNotFound && $responseData->countRows() === 0) {
$responseData->addRow([
'webservice_request' => $requestUid,
'http_response_code' => 200,
]);
$responseData->dataCreate();
$responseData->dataRead();
}

return $responseData;
}
}
31 changes: 2 additions & 29 deletions Common/AbstractOpenApiPrototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

namespace axenox\ETL\Common;

use axenox\ETL\Common\AbstractETLPrototype;
use axenox\ETL\Interfaces\ETLStepDataInterface;
use axenox\ETL\Interfaces\ETLStepResultInterface;
use exface\Core\CommonLogic\DataSheets\DataSheet;
use exface\Core\DataTypes\StringDataType;
use exface\Core\Exceptions\InvalidArgumentException;
use exface\Core\Facades\AbstractHttpFacade\Middleware\RouteConfigLoader;
use exface\Core\Factories\DataSheetFactory;
use exface\Core\Factories\FormulaFactory;
use exface\Core\Interfaces\DataSheets\DataSheetInterface;
use exface\Core\Widgets\DebugMessage;
use Flow\JSONPath\JSONPath;
use Flow\JSONPath\JSONPathException;
use Psr\Http\Message\ServerRequestInterface;
use exface\Core\Interfaces\Tasks\TaskInterface;
use exface\Core\Interfaces\Tasks\HttpTaskInterface;
use exface\Core\Exceptions\RuntimeException;
use axenox\ETL\Interfaces\OpenApiFacadeInterface;

abstract class AbstractOpenApiPrototype extends AbstractETLPrototype
Expand Down Expand Up @@ -129,29 +122,9 @@ function getSchema(ServerRequestInterface $request, string $openApiJson, string
return json_decode(json_encode($data), true);
}


/**
* @param ETLStepDataInterface $stepData
* @param array $requestedColumns
* @return DataSheet|DataSheetInterface
*/
protected function loadRequestData(ETLStepDataInterface $stepData, array $requestedColumns): DataSheet|DataSheetInterface
{
$requestLogData = DataSheetFactory::createFromObjectIdOrAlias($this->getWorkbench(), 'axenox.ETL.webservice_request');
$requestLogData->getColumns()->addFromSystemAttributes();
$requestLogData->getColumns()->addMultiple($requestedColumns);
$requestLogData->getFilters()->addConditionFromString('flow_run', $stepData->getFlowRunUid());
$requestLogData->dataRead();

if ($requestLogData->countRows() > 1) {
throw new InvalidArgumentException('Ambiguous web requests!');
}

return $requestLogData;
}

/**
* Adds additional data provided by the ´additional_rows´ config within the step to given row into the given datasheet.
* Adds additional data provided by the ´additional_rows´ config within the step to given row into the given
* datasheet.
*
* @param DataSheetInterface $dataSheet
* @param array $placeholder
Expand Down
36 changes: 20 additions & 16 deletions ETLPrototypes/DataSheetJsonToOpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ public function run(ETLStepDataInterface $stepData) : \Generator
$index = 0;
}

$requestLogData = $this->loadRequestData($stepData, ['response_body', 'response_header']);
$responseData = $this->loadResponseData(
$this->loadRequestData($stepData)->getRow()['UID'],
['body_file__CONTENTS', 'response_header']
);

$request = $stepTask->getHttpRequest();
$this->updateRequestData($requestLogData, $request, $openApiJson, $content, $fromObjectSchema[self::OPEN_API_ATTRIBUTE_TO_OBJECT_ALIAS], $placeholders);
$this->updateRequestData($responseData, $request, $openApiJson, $content, $fromObjectSchema[self::OPEN_API_ATTRIBUTE_TO_OBJECT_ALIAS], $placeholders);

return $result->setProcessedRowsCounter(count($content));
}
Expand Down Expand Up @@ -310,24 +314,24 @@ protected function createBodyFromSchema(array $responseSchema, array $newContent
}

/**
* @param DataSheetInterface $requestLogData
* @param DataSheetInterface $responseData
* @param ServerRequestInterface $request
* @param string|null $openApiJson
* @param array $rows
* @param string $objectAlias
* @param array $placeholders
* @param string|null $openApiJson
* @param array $rows
* @param string $objectAlias
* @param array $placeholders
* @return void
* @throws JSONPathException
*/
protected function updateRequestData(
DataSheetInterface $requestLogData,
DataSheetInterface $responseData,
ServerRequestInterface $request,
?string $openApiJson,
array $rows,
string $objectAlias,
array $placeholders): void
?string $openApiJson,
array $rows,
string $objectAlias,
array $placeholders): void
{
$currentBody = json_decode($requestLogData->getCellValue('response_body', 0), true);
$currentBody = json_decode($responseData->getCellValue('body_file__CONTENTS', 0), true);
$jsonPath = '$.paths.[#routePath#].[#methodType#].responses.200.content.[#ContentType#].schema';
$responseSchema = $this->getSchema($request, $openApiJson, $jsonPath);

Expand All @@ -339,9 +343,9 @@ protected function updateRequestData(

$newBody = $this->createBodyFromSchema($responseSchema, $rows, $objectAlias, $placeholders);
$newBody = $currentBody === null ? $newBody : $this->deepMerge($currentBody, $newBody);
$requestLogData->setCellValue('response_header', 0, 'application/json');
$requestLogData->setCellValue('response_body', 0, json_encode($newBody));
$requestLogData->dataUpdate();
$responseData->setCellValue('response_header', 0, json_encode(['Content-Type' => 'application/json']));
$responseData->setCellValue('body_file__CONTENTS', 0, json_encode($newBody));
$responseData->dataUpdate(true);
}

/**
Expand Down
35 changes: 18 additions & 17 deletions ETLPrototypes/DataSheetToJsonApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ public function run(ETLStepDataInterface $stepData) : \Generator
}
}

$requestLogData = $this->loadRequestData($stepData, ['response_body', 'response_header']);
$this->updateRequestData($requestLogData, $fromObjectSchema, $content, $placeholders);
$responseData = $this->loadResponseData(
$this->loadRequestData($stepData)->getRow()['UID'],
['body_file__CONTENTS', 'response_header']
);

$this->updateResponseData($responseData, $fromObjectSchema, $content, $placeholders);

return $result->setProcessedRowsCounter(count($content));
}
Expand Down Expand Up @@ -277,28 +281,25 @@ protected function createBodyFromSchema(array $jsonSchema, array $newContent, st
}

/**
* @param DataSheetInterface $requestLogData
* @param ServerRequestInterface $request
* @param string|null $openApiJson
* @param array $rows
* @param string $objectAlias
* @param array $placeholders
* @param DataSheetInterface $responseData
* @param APIObjectSchemaInterface $objectSchema
* @param array $rows
* @param array $placeholders
* @return void
* @throws JSONPathException
*/
protected function updateRequestData(
DataSheetInterface $requestLogData,
protected function updateResponseData(
DataSheetInterface $responseData,
APIObjectSchemaInterface $objectSchema,
array $rows,
array $placeholders): void
array $rows,
array $placeholders): void
{
$responseSchema = $objectSchema->getJsonSchema();
$currentBody = json_decode($requestLogData->getCellValue('response_body', 0), true);
$currentBody = json_decode($responseData->getCellValue('body_file__CONTENTS', 0), true);
$newBody = $this->createBodyFromSchema($responseSchema, $rows, $objectSchema->getMetaObject()->getAliasWithNamespace(), $placeholders);
$newBody = $currentBody === null ? $newBody : $this->deepMerge($currentBody, $newBody);
$requestLogData->setCellValue('response_header', 0, 'application/json');
$requestLogData->setCellValue('response_body', 0, json_encode($newBody));
$requestLogData->dataUpdate();
$responseData->setCellValue('response_header', 0, json_encode(['Content-Type' => 'application/json']));
$responseData->setCellValue('body_file__CONTENTS', 0, json_encode($newBody));
$responseData->dataUpdate();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ETLPrototypes/JsonApiToDataSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ public function run(ETLStepDataInterface $stepData) : \Generator

$this->getWorkbench()->eventManager()->dispatch(new OnBeforeETLStepRun($this, $logBook));

$requestLogData = $this->loadRequestData($stepData, ['http_body', 'http_content_type'])->getRow(0);
$requestBody = $requestLogData['http_body'];
$requestLogData = $this->loadRequestData($stepData, ['body_file__CONTENTS', 'http_content_type'])->getRow(0);
$requestBody = $requestLogData['body_file__CONTENTS'];

if ($requestLogData['http_content_type'] !== 'application/json' || $requestBody === null) {
$logBook->addLine($msg = 'No HTTP content found to process.');
Expand Down
4 changes: 2 additions & 2 deletions ETLPrototypes/OpenApiJsonToDataSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function run(ETLStepDataInterface $stepData) : \Generator
$this->baseSheet = $baseSheet;
$this->getWorkbench()->eventManager()->dispatch(new OnBeforeETLStepRun($this));

$requestLogData = $this->loadRequestData($stepData, ['http_body', 'http_content_type'])->getRow();
$requestBody = json_decode($requestLogData['http_body'], true);
$requestLogData = $this->loadRequestData($stepData, ['body_file__CONTENTS', 'http_content_type'])->getRow();
$requestBody = json_decode($requestLogData['body_file__CONTENTS'], true);

if ($requestLogData['http_content_type'] !== 'application/json' || $requestBody === null) {
yield 'No HTTP content found to process' . PHP_EOL;
Expand Down
Loading