Skip to content

feat: add maintenanceWindows resource for scheduling planned downtime#20

Merged
caballeto merged 2 commits into
mainfrom
feat/maintenance-windows-resource
May 6, 2026
Merged

feat: add maintenanceWindows resource for scheduling planned downtime#20
caballeto merged 2 commits into
mainfrom
feat/maintenance-windows-resource

Conversation

@caballeto
Copy link
Copy Markdown
Member

Summary

Adds a client.maintenanceWindows resource module so users can schedule
planned alert-suppression windows directly from the SDK — mirroring the
/api/v1/maintenance-windows surface that the API and dashboard already
expose. Closes the gap with cli / sdk-python, which previously had no
JS/TS counterpart for this workflow.

The resource is a thin, fully typed wrapper over the existing OpenAPI
contract — no new generated types, no spec changes, no runtime deps.

Use case

import {Devhelm} from '@devhelm/sdk'

const client = new Devhelm({token: process.env.DEVHELM_API_TOKEN!})

// Schedule a window for the upcoming DB migration
const window = await client.maintenanceWindows.create({
  monitorId: process.env.DB_MONITOR_ID,
  startsAt: '2026-06-01T03:00:00Z',
  endsAt:   '2026-06-01T04:00:00Z',
  reason:   'Quarterly db migration',
})

// What's currently in progress org-wide?
const active = await client.maintenanceWindows.list({filter: 'active'})

// Pull the plug if we finish early
await client.maintenanceWindows.cancel(window.id)

What's included

  • src/resources/maintenance-windows.tsMaintenanceWindows class with
    create, list (auto-paginating), listPage, get, update, cancel.
    Each method is async, JSDoc-documented with a @example, and returns the
    generated MaintenanceWindowDto (or Page<MaintenanceWindowDto>), never
    any.
  • Bridge updates in src/schemas.ts and src/types.ts for the
    MaintenanceWindowDto, CreateMaintenanceWindowRequest,
    UpdateMaintenanceWindowRequest, plus the SingleValueResponse /
    TableValueResult envelopes.
  • Wiring in src/client.ts and the MaintenanceWindows /
    MaintenanceWindowFilters re-exports in src/index.ts.
  • Five new entries in test/spec-paths.test.ts so spec drift around
    /api/v1/maintenance-windows is caught at test time.
  • test/maintenance-windows.test.ts — stubs globalThis.fetch (same shape
    as the existing surface-telemetry tests) and asserts the exact path,
    method, query string, and body for every method, plus auto-pagination
    and client-side validation behavior.

Test plan

  • npm run lint — clean
  • npm run typecheck — clean (strict mode, no any)
  • npm run build — succeeds
  • npm test — all 1321 tests pass (including 13 new
    maintenance-windows.test.ts cases)
  • CI green on the PR

Made with Cursor

caballeto and others added 2 commits May 6, 2026 12:23
Wires up `client.maintenanceWindows` so users can schedule alert-suppression
windows directly from the SDK. Mirrors the `/api/v1/maintenance-windows`
REST surface: list (auto-paginating + manual page control), listPage, get,
create, update, and cancel. List forwards optional `monitorId` and `filter`
('active' | 'upcoming') as query params.

Schemas/types are bridged through `src/schemas.ts` and `src/types.ts` so
the public type surface (`MaintenanceWindowDto`, `CreateMaintenanceWindowRequest`,
`UpdateMaintenanceWindowRequest`, `MaintenanceWindowFilters`) stays
strict-mode clean and re-exportable from `@devhelm/sdk`.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stubs `globalThis.fetch` (same approach as the surface-telemetry tests) to
capture each outbound request and assert on the exact path, HTTP method,
query string, and JSON body the SDK puts on the wire. Covers create,
list with filters, list auto-pagination, listPage, get, update, cancel,
plus a client-side validation guard that fails before any network I/O.

Co-authored-by: Cursor <cursoragent@cursor.com>
@caballeto caballeto merged commit 5020744 into main May 6, 2026
3 checks passed
@caballeto caballeto deleted the feat/maintenance-windows-resource branch May 6, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant