import { WorkspaceScopedResource, extractData } from './base.js';
/**
 * Manage data sources — connections to external databases, warehouses,
 * or data feeds that the platform can query and sync from.
 */
export class DataSourcesResource extends WorkspaceScopedResource {
    async create(body) {
        return extractData(await this.client.POST('/v1/{workspace_id}/data-sources', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    async list(params) {
        return extractData(await this.client.GET('/v1/{workspace_id}/data-sources', {
            params: { path: { workspace_id: this.workspaceId }, query: params },
        }));
    }
    listAutoPaging(params) {
        return this.iteratePaginatedList((pageParams) => this.list(pageParams), params);
    }
    async get(dataSourceId) {
        return extractData(await this.client.GET('/v1/{workspace_id}/data-sources/{data_source_id}', {
            params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId } },
        }));
    }
    async update(dataSourceId, body) {
        return extractData(await this.client.PATCH('/v1/{workspace_id}/data-sources/{data_source_id}', {
            params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId } },
            body,
        }));
    }
    async delete(dataSourceId) {
        await this.client.DELETE('/v1/{workspace_id}/data-sources/{data_source_id}', {
            params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId } },
        });
    }
    /** Get event counts, sync status, and health for a data source */
    async getStatus(dataSourceId) {
        return extractData(await this.client.GET('/v1/{workspace_id}/data-sources/{data_source_id}/status', {
            params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId } },
        }));
    }
    /** Get daily event timeline + recent sync failures for a data source */
    async getSyncHistory(dataSourceId) {
        return extractData(await this.client.GET('/v1/{workspace_id}/data-sources/{data_source_id}/sync-history', {
            params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId } },
        }));
    }
    /**
     * Trigger a one-off manual sync of a data source.
     *
     * Bypasses the business-hours gate and per-resource cadence counter on
     * connector-runner. Resolves with `{ status: "started", ... }` once the
     * request is queued — the poll itself runs asynchronously. Platform-api
     * returns 409 if the source is already mid-sync (see
     * `TriggerSyncConflictResponse` for the body shape), 503 if
     * connector-runner is unreachable.
     */
    async triggerSync(dataSourceId) {
        return extractData(await this.client.POST('/v1/{workspace_id}/data-sources/{data_source_id}/sync', {
            params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId } },
        }));
    }
}
//# sourceMappingURL=data-sources.js.map