Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
// R-P5 (P5) — reference integration adapter (the only adapter shipped in v1).
|
||||
//
|
||||
// Demonstrates the IntegrationAdapter contract end-to-end (validate / health /
|
||||
// sync) without any external provider. Concrete adapters (Gmail/AirCall/Mollie)
|
||||
// follow this shape in their module phases. Registers itself on import (the
|
||||
// registry barrel imports this for its side effect).
|
||||
|
||||
import { registerIntegrationAdapter, type AdapterResult, type AdapterSyncOutcome, type IntegrationAdapter } from "@hivegrid/foundation";
|
||||
|
||||
type SampleCreds = { baseUrl: string; apiKey: string };
|
||||
|
||||
const ACTIVE: AdapterResult = { ok: true, health: "active", messageKey: "integrations.health.active" };
|
||||
|
||||
function validate(creds: SampleCreds): Promise<AdapterResult> {
|
||||
if (!creds.baseUrl || !creds.apiKey) {
|
||||
return Promise.resolve({ ok: false, health: "broken", messageKey: "integrations.health.missingCredentials" });
|
||||
}
|
||||
return Promise.resolve(ACTIVE);
|
||||
}
|
||||
|
||||
export const sampleDataSyncAdapter: IntegrationAdapter<SampleCreds> = registerIntegrationAdapter<SampleCreds>({
|
||||
key: "sample-data-sync",
|
||||
connectionType: "rest_api",
|
||||
validateConnection: validate,
|
||||
healthCheck: validate,
|
||||
sync: (): Promise<AdapterSyncOutcome> =>
|
||||
Promise.resolve({
|
||||
items: [
|
||||
{ entityType: "contact", externalId: "ext-1", operation: "created", status: "synced" },
|
||||
{ entityType: "contact", externalId: "ext-2", operation: "updated", status: "synced" },
|
||||
],
|
||||
summaryKey: "integrations.sync.summary.ok",
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user