External DB Sync Plugin
Mirror Signals data into an external warehouse or ERP staging database using plugin exportable models, the export workflow action, and export.completed events.
External DB sync plugin
Plugins that mirror Signals data into an external database (warehouse, ERP staging table, BI lake) should compose three existing seams rather than shipping a bespoke exporter.
1. Exportable models
Register a handler implementing App\Contracts\Exports\ExportableModelContract (extends the P6-18 PluginExportHandler with key() + label()):
$registrar->exportableModel(new AcmeRentalMirrorExportable);
Export jobs with source_type=plugin and source_id=<your key> resolve through App\Services\Exports\PluginExportRegistry. Implement:
query(User $user, ?array $filters)— authorised under the creating usercolumns(User $user)— column keys/labels (and optional types)
Class-string registration via PluginExportRegistry::register($key, $handlerClass) remains supported for P6-18 callers.
2. Export workflow action
Invoke App\Actions\Exports\ExportWorkflowAction (registered on App\Services\Workflows\WorkflowActionHandlerRegistry under the key export) with an export definition. Delivery is pinned to in-app notification + download link only for now; the deliveryHint parameter is accepted for Phase 7 forward-compat but only in_app is implemented (no mailers or remote storage targets yet).
3. export.completed / export.failed
Subscribe via webhooks or the audit / AuditableEvent bus. Completed payloads include id, status, total_rows, format, and download_token so a plugin worker can fetch the artefact and load it into the external store.
Minimal register hook
public function register(PluginRegistrar $registrar): void
{
$registrar->exportableModel(new AcmeCatalogueItemMirrorExportable);
// Subscribe to export.completed via your plugin’s event/webhook wiring.
}
Related
- Plugin SDK — package overview (points here for the export-sync pattern)
- Workflows —
exportworkflow action registration