From 2f10cbcec2e2ffaee4298581dfb65ee05640ddff Mon Sep 17 00:00:00 2001 From: jbiskur Date: Wed, 18 Mar 2026 16:19:10 +0000 Subject: [PATCH 1/2] feat: add data-pathways delete and health check commands Add two missing SDK commands for data-pathways control plane: - DataPathwayDeleteCommand (DELETE /api/v1/pathways/:id) - DataPathwayHealthCheckCommand (GET /api/v1/health) Co-Authored-By: Claude Opus 4.6 (1M context) --- deno.json | 2 +- src/commands/data-pathways/health.check.ts | 30 ++++++++++++++ src/commands/data-pathways/index.ts | 4 ++ src/commands/data-pathways/pathway.delete.ts | 43 ++++++++++++++++++++ src/contracts/data-pathways.ts | 13 ++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/commands/data-pathways/health.check.ts create mode 100644 src/commands/data-pathways/pathway.delete.ts diff --git a/deno.json b/deno.json index 18f0819..ebd6ac0 100644 --- a/deno.json +++ b/deno.json @@ -2,7 +2,7 @@ "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", "name": "@flowcore/sdk", "description": "Flowcore SDK", - "version": "1.70.0", + "version": "1.71.0", "license": "MIT", "exports": "./src/mod.ts", "publish": { diff --git a/src/commands/data-pathways/health.check.ts b/src/commands/data-pathways/health.check.ts new file mode 100644 index 0000000..167311b --- /dev/null +++ b/src/commands/data-pathways/health.check.ts @@ -0,0 +1,30 @@ +import { Command } from "../../common/command.ts" +import { type DataPathwayHealth, DataPathwayHealthSchema } from "../../contracts/data-pathways.ts" +import { parseResponseHelper } from "../../utils/parse-response-helper.ts" + +export type DataPathwayHealthCheckInput = Record + +export class DataPathwayHealthCheckCommand extends Command { + protected override retryOnFailure: boolean = false + protected override allowedModes: ("apiKey" | "bearer")[] = ["bearer"] + + protected override getMethod(): string { + return "GET" + } + + protected override getBaseUrl(): string { + return "https://data-pathways.api.flowcore.io" + } + + protected override getPath(): string { + return "/api/v1/health" + } + + protected override getBody(): Record { + return {} + } + + protected override parseResponse(rawResponse: unknown): DataPathwayHealth { + return parseResponseHelper(DataPathwayHealthSchema, rawResponse) + } +} diff --git a/src/commands/data-pathways/index.ts b/src/commands/data-pathways/index.ts index 1e59d91..3471ec6 100644 --- a/src/commands/data-pathways/index.ts +++ b/src/commands/data-pathways/index.ts @@ -3,6 +3,7 @@ export * from "./pathway.create.ts" export * from "./pathway.fetch.ts" export * from "./pathway.list.ts" export * from "./pathway.disable.ts" +export * from "./pathway.delete.ts" // Slots export * from "./slot.register.ts" @@ -40,3 +41,6 @@ export * from "./quota.list.ts" // Pump State export * from "./pump-state.fetch.ts" export * from "./pump-state.save.ts" + +// Health +export * from "./health.check.ts" diff --git a/src/commands/data-pathways/pathway.delete.ts b/src/commands/data-pathways/pathway.delete.ts new file mode 100644 index 0000000..a6a0a7b --- /dev/null +++ b/src/commands/data-pathways/pathway.delete.ts @@ -0,0 +1,43 @@ +import { Command } from "../../common/command.ts" +import { type DataPathwayMutationResponse, DataPathwayMutationResponseSchema } from "../../contracts/data-pathways.ts" +import type { ClientError } from "../../exceptions/client-error.ts" +import { NotFoundException } from "../../exceptions/not-found.ts" +import { parseResponseHelper } from "../../utils/parse-response-helper.ts" + +export interface DataPathwayDeleteInput { + id: string + reason?: string +} + +export class DataPathwayDeleteCommand extends Command { + protected override retryOnFailure: boolean = false + protected override allowedModes: ("apiKey" | "bearer")[] = ["bearer"] + + protected override getMethod(): string { + return "DELETE" + } + + protected override getBaseUrl(): string { + return "https://data-pathways.api.flowcore.io" + } + + protected override getPath(): string { + return `/api/v1/pathways/${this.input.id}` + } + + protected override getBody(): Record { + const { id: _id, ...payload } = this.input + return payload + } + + protected override parseResponse(rawResponse: unknown): DataPathwayMutationResponse { + return parseResponseHelper(DataPathwayMutationResponseSchema, rawResponse) + } + + protected override handleClientError(error: ClientError): void { + if (error.status === 404) { + throw new NotFoundException("DataPathway", { id: this.input.id }) + } + throw error + } +} diff --git a/src/contracts/data-pathways.ts b/src/contracts/data-pathways.ts index b864777..45db7e6 100644 --- a/src/contracts/data-pathways.ts +++ b/src/contracts/data-pathways.ts @@ -455,3 +455,16 @@ export const DataPathwayPumpStateSaveResponseSchema: TObject<{ status: Type.String(), }) export type DataPathwayPumpStateSaveResponse = Static + +// ── Health ── + +export const DataPathwayHealthSchema: TObject<{ + status: TUnion<[TLiteral<"healthy">, TLiteral<"unhealthy">]> + checks: TObject<{ db: TUnion<[TLiteral<"ok">, TLiteral<"error">]> }> + uptime: TNumber +}> = Type.Object({ + status: Type.Union([Type.Literal("healthy"), Type.Literal("unhealthy")]), + checks: Type.Object({ db: Type.Union([Type.Literal("ok"), Type.Literal("error")]) }), + uptime: Type.Number(), +}) +export type DataPathwayHealth = Static From a7858eb7a57818a9f0ab67a1b5673938e387749c Mon Sep 17 00:00:00 2001 From: jbiskur Date: Wed, 18 Mar 2026 16:26:37 +0000 Subject: [PATCH 2/2] fix: remove unnecessary getBody override from health check command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GET requests should not send a body — use base class default (undefined). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/data-pathways/health.check.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/commands/data-pathways/health.check.ts b/src/commands/data-pathways/health.check.ts index 167311b..65256d4 100644 --- a/src/commands/data-pathways/health.check.ts +++ b/src/commands/data-pathways/health.check.ts @@ -20,10 +20,6 @@ export class DataPathwayHealthCheckCommand extends Command { - return {} - } - protected override parseResponse(rawResponse: unknown): DataPathwayHealth { return parseResponseHelper(DataPathwayHealthSchema, rawResponse) }