Export data via an extension hook

Hello,
we would like to publish the data to another system when saving the data in the backend. We have created a hook (action) that reads the data via the ItemsService from the collection with the query {fields: [‘..*’]} and posts it to an api. This also works so far.
We would like to validate the data on the other system. To do this, we have exported the typescript types via an extension (we have tried directus-sdk-typegen and directus-extension-generate-types).
However, with the data that we receive via the ItemsService, we have the problem that it does not match the schema/types that we generated with the extension. For example, the ItemsService delivers arrays as objects with the indexes as keys. The data that we receive via the itemservice is also different from the data that we receive via the Directus API. Is there a possibility that the itemservice at least delivers the same data or structure as the api? Or can someone tell me the best way to proceed in this regard?
Thanks Mark

The public APIs use the ItemsService internally to query and return the data, so the output there should match depending on your query. Keep in mind that a *.* query includes nested relational data, so you’ll have to account for that in your exported types.

The data that we receive via the itemservice is also different from the data that we receive via the Directus API. Is there a possibility that the itemservice at least delivers the same data or structure as the api?

Are you sure you’re querying the public API the same way as you’re querying the ItemsService? Outside of the data property wrapping the output in REST, the data itself is identical for identical queries.