@agentpost-tools/resourceshark-sdk
v0.2.0
Published
A typed client for resourceshark, for servers and browsers, with the framework-independent hold and booking workflows.
Readme
ResourceShark SDK
A typed client for ResourceShark's HTTP API, with hold and booking workflows. It runs in Node 24, browsers, and React Native wherever fetch is available.
npm i @agentpost-tools/resourceshark-sdkYou need an Agentpost workspace and a project key for a project that uses ResourceShark. Read a resource's free slots on your server with its secret key:
import { createClient } from '@agentpost-tools/resourceshark-sdk';
export async function freeSlots(key: string, resourceId: string) {
const resources = createClient({ token: key });
const { slots } = await resources.slots.list({
resourceId,
from: '2028-01-07T00:00:00+07:00',
to: '2028-01-08T00:00:00+07:00',
});
return slots.filter((slot) => slot.available > 0);
}ResourceShark SDK docs cover the client, workflows, and server helpers.
Changes
On 0.x, changes that break existing calls, exports, types, or workflow behavior bump the minor version; other changes bump the patch.
0.2.0
- A schedule's first save sends no
If-Match.If-Match: 0, or a malformed one, isinvalid_requeston every route; onPUT /configand the patches it wasstale_version. client.events.readtakestypesas a list or a string separated by commas, andafter: 'latest'to start from now.EventsQueryis now the client's own type for that input, so existing calls keep compiling. A cursor behind the oldest change kept is refused withcursor_expired(410), whosedetailsgiveoldestandlatest, where the feed used to skip ahead silently. A page shorter thanlimitgives anextpast the changes atypesfilter skipped. A numericaftertakes digits only.limitis coerced to a whole number from 1 to 500, and a repeated query parameter takes its first value.- An
Idempotency-Keyanswer is kept sealed with your project's cipher. A request in progress holds its key for up to 5 minutes, not 60 seconds. The query andIf-Matchare part of what a key names. A blank key isinvalid_request. A retry under a key first sent before this release runs again once. - A repeat whose caller your host now refuses, or now confines to one holder on an operation for trusted callers only, gets
forbidden; any other change in what your host allows that caller isidempotency_mismatch. POST /availabilitytakes noIdempotency-Key: it changes nothing, so it runs on every request.- A JSON
nullrequest body isinvalid_request. - A
forbiddenorunauthenticatedrefusal'sdetailsname theoperationonly, no longer the resource it reached. ResourcesharkApiErrornarrowsdetailsbycode: aftererror.code === 'insufficient_supply',error.detailsis{ lines }, andcursor_expired,stale_version,key_in_use,settings_locked,exhausted_until_supply,assignment_infeasible,hold_expired, andhold_resolvedare typed too.codeis ResourceShark's codes, the Platform's, andunknown, rather than any string, andErrorDetails,ErrorDetailsOf, andResourcesharkApiErrorCodename the types. Code that comparedcodewith a string outside those, or typed a narroweddetailsitself, may need to change.
Proprietary: use with Agentpost's hosted services under LICENSE.md.
