@agentpost-tools/resourceshark-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/{client-C-4s_6Qp.d.ts → client-DEn-MdAz.d.ts} +133 -22
- package/dist/{client-D2ya4ahY.js → client-bcl2_fz8.js} +2 -1
- package/dist/{commit-BxtiTSez.d.ts → commit-93Qao_5l.d.ts} +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{refusals-D39vDFy2.js → refusals-C8SBj-15.js} +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/workflows/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,19 @@ export async function freeSlots(key: string, resourceId: string) {
|
|
|
24
24
|
|
|
25
25
|
[ResourceShark SDK docs](https://agentpost.tools/docs/resourceshark/sdk) cover the client, workflows, and server helpers.
|
|
26
26
|
|
|
27
|
+
## Changes
|
|
28
|
+
|
|
27
29
|
On 0.x, changes that break existing calls, exports, types, or workflow behavior bump the minor version; other changes bump the patch.
|
|
28
30
|
|
|
31
|
+
### 0.2.0
|
|
32
|
+
|
|
33
|
+
- A schedule's first save sends no `If-Match`. `If-Match: 0`, or a malformed one, is `invalid_request` on every route; on `PUT /config` and the patches it was `stale_version`.
|
|
34
|
+
- `client.events.read` takes `types` as a list or a string separated by commas, and `after: 'latest'` to start from now. `EventsQuery` is now the client's own type for that input, so existing calls keep compiling. A cursor behind the oldest change kept is refused with `cursor_expired` (410), whose `details` give `oldest` and `latest`, where the feed used to skip ahead silently. A page shorter than `limit` gives a `next` past the changes a `types` filter skipped. A numeric `after` takes digits only. `limit` is coerced to a whole number from 1 to 500, and a repeated query parameter takes its first value.
|
|
35
|
+
- An `Idempotency-Key` answer 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 and `If-Match` are part of what a key names. A blank key is `invalid_request`. A retry under a key first sent before this release runs again once.
|
|
36
|
+
- 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 is `idempotency_mismatch`.
|
|
37
|
+
- `POST /availability` takes no `Idempotency-Key`: it changes nothing, so it runs on every request.
|
|
38
|
+
- A JSON `null` request body is `invalid_request`.
|
|
39
|
+
- A `forbidden` or `unauthenticated` refusal's `details` name the `operation` only, no longer the resource it reached.
|
|
40
|
+
- `ResourcesharkApiError` narrows `details` by `code`: after `error.code === 'insufficient_supply'`, `error.details` is `{ lines }`, and `cursor_expired`, `stale_version`, `key_in_use`, `settings_locked`, `exhausted_until_supply`, `assignment_infeasible`, `hold_expired`, and `hold_resolved` are typed too. `code` is ResourceShark's codes, the Platform's, and `unknown`, rather than any string, and `ErrorDetails`, `ErrorDetailsOf`, and `ResourcesharkApiErrorCode` name the types. Code that compared `code` with a string outside those, or typed a narrowed `details` itself, may need to change.
|
|
41
|
+
|
|
29
42
|
Proprietary: use with Agentpost's hosted services under [LICENSE.md](./LICENSE.md).
|
|
@@ -112,7 +112,7 @@ interface BatchesPage<T = string> {
|
|
|
112
112
|
}
|
|
113
113
|
/** The kind a principal may declare. A principal that declared none has no `kind`. */
|
|
114
114
|
type PrincipalKind = 'human' | 'agent' | 'service';
|
|
115
|
-
/** A principal that acted
|
|
115
|
+
/** A principal that acted, with the kind it declared for itself. */
|
|
116
116
|
interface PrincipalRef {
|
|
117
117
|
kind?: PrincipalKind;
|
|
118
118
|
id: string;
|
|
@@ -154,7 +154,12 @@ interface Claim<T = string> {
|
|
|
154
154
|
holdId?: HoldId;
|
|
155
155
|
/** What its hold's commit took for good; the rest of `quantity` was released. */
|
|
156
156
|
committed?: Quantity;
|
|
157
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* The entries it drew from, when the resource keeps its supply apart. On
|
|
159
|
+
* a resource that lets its balance go below zero, they can cover less
|
|
160
|
+
* than the claim: the rest was owed, or a hold's line holds it with no
|
|
161
|
+
* entry until its commit takes it.
|
|
162
|
+
*/
|
|
158
163
|
pegs?: Peg[];
|
|
159
164
|
/** The conversion that took this claim's quantity. */
|
|
160
165
|
transformationId?: TransformationId;
|
|
@@ -162,6 +167,7 @@ interface Claim<T = string> {
|
|
|
162
167
|
estimate?: Quantity;
|
|
163
168
|
/** The real quantity an estimate was settled at. Set once, by the settle. */
|
|
164
169
|
settled?: Quantity;
|
|
170
|
+
/** Your app's name for the holder, such as `principal:external:u_maya`. */
|
|
165
171
|
holderRef?: Ref;
|
|
166
172
|
/** What it was taken for. A claim taken by a hold commit carries the commit's evidence. */
|
|
167
173
|
evidence?: Evidence;
|
|
@@ -314,7 +320,42 @@ interface ConfigResponse<T = string> {
|
|
|
314
320
|
}
|
|
315
321
|
type Duration = string;
|
|
316
322
|
type ErrorClass = 'retry_later' | 'exhausted' | 'change_the_request';
|
|
317
|
-
|
|
323
|
+
/** What `stale_version` carries in `details`: the version the record is at, and on a count, the balance's on hand at that version. */
|
|
324
|
+
interface StaleVersionDetails {
|
|
325
|
+
version: number;
|
|
326
|
+
onHand?: Quantity;
|
|
327
|
+
}
|
|
328
|
+
/** What `key_in_use` carries in `details`: the field whose value is taken, and the value. */
|
|
329
|
+
interface KeyInUseDetails {
|
|
330
|
+
field: string;
|
|
331
|
+
value: string;
|
|
332
|
+
}
|
|
333
|
+
/** What `settings_locked` carries in `details`: the resource's version, and the settings that can no longer change. */
|
|
334
|
+
interface SettingsLockedDetails {
|
|
335
|
+
version: number;
|
|
336
|
+
fields: string[];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* What `details` holds for each code whose details have one shape. A code
|
|
340
|
+
* left out has no details, or details that differ by where it came from:
|
|
341
|
+
* the Platform answers `invalid_request`, `forbidden`, and `conflict` with
|
|
342
|
+
* its own before a request reaches resourceshark, `invalid_quantity` names
|
|
343
|
+
* what each operation checked, and `duplicate_source` names the stored
|
|
344
|
+
* record only when the caller may read it.
|
|
345
|
+
*/
|
|
346
|
+
interface ErrorDetails extends FeedErrorDetails {
|
|
347
|
+
stale_version: StaleVersionDetails;
|
|
348
|
+
key_in_use: KeyInUseDetails;
|
|
349
|
+
settings_locked: SettingsLockedDetails;
|
|
350
|
+
insufficient_supply: InsufficientSupplyDetails;
|
|
351
|
+
exhausted_until_supply: ExhaustedUntilSupplyDetails;
|
|
352
|
+
assignment_infeasible: AssignmentInfeasibleDetails;
|
|
353
|
+
hold_expired: HoldExpiredDetails;
|
|
354
|
+
hold_resolved: HoldResolvedDetails;
|
|
355
|
+
}
|
|
356
|
+
/** The type of `details` for one code: its entry in {@link ErrorDetails}, or `unknown` for a code with none there. */
|
|
357
|
+
type ErrorDetailsOf<C extends string> = C extends keyof ErrorDetails ? ErrorDetails[C] : unknown;
|
|
358
|
+
type ErrorCode = 'invalid_request' | 'unauthenticated' | 'forbidden' | 'not_found' | 'conflict' | 'idempotency_mismatch' | 'stale_version' | 'payload_too_large' | 'internal_error' | 'key_in_use' | 'settings_locked' | 'insufficient_supply' | 'exhausted_until_supply' | 'assignment_infeasible' | 'hold_expired' | 'hold_resolved' | 'cursor_expired' | 'duplicate_source' | 'invalid_quantity';
|
|
318
359
|
interface ErrorBody {
|
|
319
360
|
error: {
|
|
320
361
|
code: ErrorCode;
|
|
@@ -324,9 +365,11 @@ interface ErrorBody {
|
|
|
324
365
|
docs: string;
|
|
325
366
|
};
|
|
326
367
|
}
|
|
327
|
-
/** One change-feed record: CloudEvents 1.0, structured JSON. */
|
|
368
|
+
/** One change-feed record: CloudEvents 1.0, structured JSON. Written out in full, the kit's `ChangeEventBase` with this service's source, so the SDK's generated types need nothing from the kit. */
|
|
328
369
|
interface ChangeEvent<T = string> {
|
|
370
|
+
/** A plain ULID, unique to the event. */
|
|
329
371
|
id: string;
|
|
372
|
+
/** The event's place in the project's feed, from 1. Pass it as `after` to read the events after it. */
|
|
330
373
|
seq: number;
|
|
331
374
|
specversion: '1.0';
|
|
332
375
|
type: string;
|
|
@@ -342,19 +385,16 @@ interface ChangeEvent<T = string> {
|
|
|
342
385
|
[k: string]: unknown;
|
|
343
386
|
};
|
|
344
387
|
}
|
|
345
|
-
|
|
346
|
-
after: number;
|
|
347
|
-
limit: number;
|
|
348
|
-
types?: string | undefined;
|
|
349
|
-
};
|
|
388
|
+
/** One page of the feed. `after=latest` answers no events and the newest `seq` as `next`; a cursor behind the oldest event kept is `cursor_expired`. */
|
|
350
389
|
interface EventsPage<T = string> {
|
|
351
390
|
events: ChangeEvent<T>[];
|
|
352
|
-
/** Pass as `after` to continue.
|
|
391
|
+
/** Pass as `after` to continue. Always present. A full page gives its last event's `seq`. A shorter page has caught up, so it gives the newest `seq` read, past any events a `types` filter skipped. */
|
|
353
392
|
next: number;
|
|
354
393
|
}
|
|
355
394
|
/** What one holder has on one resource. */
|
|
356
395
|
interface HolderBalance<T = string> {
|
|
357
396
|
resourceId: ResourceId;
|
|
397
|
+
/** Your app's name for the holder, such as `principal:external:u_maya`. */
|
|
358
398
|
holderRef: Ref;
|
|
359
399
|
onHand: Quantity;
|
|
360
400
|
held: Quantity;
|
|
@@ -628,6 +668,17 @@ interface QuantityChange {
|
|
|
628
668
|
before: Quantity;
|
|
629
669
|
after: Quantity;
|
|
630
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* How what a balance owes moved. Only a resource that keeps its supply
|
|
673
|
+
* apart and lets its balance go below zero owes: a take beyond what its
|
|
674
|
+
* live entries have takes what they have and owes the rest, which sits on
|
|
675
|
+
* no entry and never expires. Supply that becomes on hand while something
|
|
676
|
+
* is owed pays it first.
|
|
677
|
+
*/
|
|
678
|
+
interface OwedChange extends QuantityChange {
|
|
679
|
+
/** The supply entries whose units paid it down, and how much each paid. What came down without them was a claim's own debt given back. */
|
|
680
|
+
pegs?: Peg[];
|
|
681
|
+
}
|
|
631
682
|
/** The history of one change to a balance. */
|
|
632
683
|
interface Movement<T = string> extends QuantityChange {
|
|
633
684
|
id: MovementId;
|
|
@@ -640,6 +691,12 @@ interface Movement<T = string> extends QuantityChange {
|
|
|
640
691
|
/** How held moved, when it did. */
|
|
641
692
|
held?: QuantityChange;
|
|
642
693
|
expected?: QuantityChange;
|
|
694
|
+
/**
|
|
695
|
+
* How what the balance owes moved, when it did. On a take, what its
|
|
696
|
+
* `pegs` don't cover was owed. On an `add`, what paid it down left the
|
|
697
|
+
* entry at once, so the entry keeps the rest.
|
|
698
|
+
*/
|
|
699
|
+
owed?: OwedChange;
|
|
643
700
|
reason: MovementReason;
|
|
644
701
|
supplyId?: SupplyId;
|
|
645
702
|
/** The supply entries it drew from or returned to. */
|
|
@@ -669,6 +726,7 @@ type MovementsQuery = {
|
|
|
669
726
|
holderRef?: string | undefined;
|
|
670
727
|
batchId?: string | undefined;
|
|
671
728
|
instanceId?: string | undefined;
|
|
729
|
+
order?: 'asc' | 'desc' | undefined;
|
|
672
730
|
};
|
|
673
731
|
interface MovementResponse<T = string> {
|
|
674
732
|
movement: Movement<T>;
|
|
@@ -730,7 +788,10 @@ interface ResourceTotals {
|
|
|
730
788
|
* attribute on the resource's supply entries, by value and the entries
|
|
731
789
|
* without it last. A unit counts in the group of the entry it sits on,
|
|
732
790
|
* and a movement in the groups of the entries it drew from or added to,
|
|
733
|
-
* so the groups add up to the resource's totals.
|
|
791
|
+
* so the groups add up to the resource's totals. What a balance owes,
|
|
792
|
+
* and what holds hold beyond its entries, sit on no entry and count in
|
|
793
|
+
* the null group, and so does what is available on a balance that has
|
|
794
|
+
* either. Null on a resource that
|
|
734
795
|
* keeps one running balance or counts in buckets: it keeps no supply
|
|
735
796
|
* entries apart, so there is nothing to group by.
|
|
736
797
|
*/
|
|
@@ -744,6 +805,7 @@ interface TotalsReport<T = string> {
|
|
|
744
805
|
from?: T;
|
|
745
806
|
to?: T;
|
|
746
807
|
groupBy?: string;
|
|
808
|
+
/** Your app's name for the holder, such as `principal:external:u_maya`. */
|
|
747
809
|
holderRef?: Ref;
|
|
748
810
|
/** The resources the selection matched, in the order they were created. */
|
|
749
811
|
resources: ResourceTotals[];
|
|
@@ -1010,6 +1072,7 @@ interface OverCapacityClaim {
|
|
|
1010
1072
|
/** What it holds, or what it took. */
|
|
1011
1073
|
quantity: Quantity;
|
|
1012
1074
|
holdId?: HoldId;
|
|
1075
|
+
/** Your app's name for the holder, such as `principal:external:u_maya`. */
|
|
1013
1076
|
holderRef?: Ref;
|
|
1014
1077
|
}
|
|
1015
1078
|
/** A bucket where what is held and taken is more than its capacity. */
|
|
@@ -1021,7 +1084,7 @@ interface OverCapacityBucket<T = string> {
|
|
|
1021
1084
|
taken: Quantity;
|
|
1022
1085
|
/** What holds not past their expiry hold. */
|
|
1023
1086
|
held: Quantity;
|
|
1024
|
-
/** Every claim in it
|
|
1087
|
+
/** Every claim in it, so your app can choose which to move, release, or cancel. */
|
|
1025
1088
|
claims: OverCapacityClaim[];
|
|
1026
1089
|
}
|
|
1027
1090
|
/**
|
|
@@ -1136,7 +1199,7 @@ interface Peg {
|
|
|
1136
1199
|
supplyId: SupplyId;
|
|
1137
1200
|
quantity: Quantity;
|
|
1138
1201
|
}
|
|
1139
|
-
/** An opaque reference to another system's record, such as `ord_01J…`. ResourceShark
|
|
1202
|
+
/** An opaque reference to another system's record, such as `ord_01J…`. ResourceShark stores it and answers with it. */
|
|
1140
1203
|
type Ref = string;
|
|
1141
1204
|
/** What a change was made for, such as `{ kind: "order", ref: "ord_…" }`. */
|
|
1142
1205
|
interface Evidence {
|
|
@@ -1160,6 +1223,7 @@ interface Span<T = string> {
|
|
|
1160
1223
|
interface Scope {
|
|
1161
1224
|
placeId?: PlaceId;
|
|
1162
1225
|
condition?: string;
|
|
1226
|
+
/** Your app's name for the holder, such as `principal:external:u_maya`. */
|
|
1163
1227
|
holderRef?: Ref;
|
|
1164
1228
|
instanceId?: InstanceId;
|
|
1165
1229
|
}
|
|
@@ -1171,8 +1235,7 @@ interface Unit {
|
|
|
1171
1235
|
precision: number;
|
|
1172
1236
|
}
|
|
1173
1237
|
/**
|
|
1174
|
-
* The business's own labels. ResourceShark stores them
|
|
1175
|
-
* never reads meaning into them.
|
|
1238
|
+
* The business's own labels. ResourceShark stores them and answers with them.
|
|
1176
1239
|
*/
|
|
1177
1240
|
type Attributes = Record<string, string>;
|
|
1178
1241
|
/** Half-open, `[start, end)`, in UTC, with an end. */
|
|
@@ -1354,7 +1417,9 @@ interface SupplyEntry<T = string> {
|
|
|
1354
1417
|
* what the entry still has. For expected supply it is what is still
|
|
1355
1418
|
* due; for added supply that has not started, what will be on hand
|
|
1356
1419
|
* when it does; and otherwise it is the quantity the entry was made
|
|
1357
|
-
* with.
|
|
1420
|
+
* with. Where the balance owed something when the entry became on hand,
|
|
1421
|
+
* what paid it is not remaining: one whose start has come reads so
|
|
1422
|
+
* whether or not anything has landed it.
|
|
1358
1423
|
*/
|
|
1359
1424
|
remaining: Quantity;
|
|
1360
1425
|
/** What open holds have pegged here, or zero when pegging does not apply. */
|
|
@@ -1366,7 +1431,7 @@ interface SupplyEntry<T = string> {
|
|
|
1366
1431
|
/** When what it has left stops being on hand. */
|
|
1367
1432
|
expiresAt?: T;
|
|
1368
1433
|
batchId?: BatchId;
|
|
1369
|
-
/** The business's own labels for this entry
|
|
1434
|
+
/** The business's own labels for this entry. ResourceShark stores them and answers with them. */
|
|
1370
1435
|
attributes?: Attributes;
|
|
1371
1436
|
/** Lower numbers are drawn first; a missing value counts as 0. */
|
|
1372
1437
|
drawOrder?: number;
|
|
@@ -1450,6 +1515,20 @@ interface SupplyReverseResponse<T = string> {
|
|
|
1450
1515
|
/** Set when the `sourceKey` already named this request: nothing was taken again. */
|
|
1451
1516
|
duplicate?: true;
|
|
1452
1517
|
}
|
|
1518
|
+
/** A code the Platform answers with beside the shared ones. */
|
|
1519
|
+
type PlatformErrorCode = 'unavailable' | 'secret_key_invalid' | 'origin_not_allowed' | 'confirmation_required' | 'throttled' | 'quota_exceeded' | 'balance_exhausted' | 'not_ready';
|
|
1520
|
+
/** The details of `cursor_expired`: the feed's two ends, so a reader knows where to start again. */
|
|
1521
|
+
interface CursorExpiredDetails {
|
|
1522
|
+
/** The first `seq` still kept. */
|
|
1523
|
+
oldest: number;
|
|
1524
|
+
/** The newest `seq` written. */
|
|
1525
|
+
latest: number;
|
|
1526
|
+
}
|
|
1527
|
+
/** The details of the feed's codes. A service with a change feed extends its `ErrorDetails` from it. */
|
|
1528
|
+
interface FeedErrorDetails {
|
|
1529
|
+
/** The feed's two ends, so a reader knows where to start again. */
|
|
1530
|
+
cursor_expired: CursorExpiredDetails;
|
|
1531
|
+
}
|
|
1453
1532
|
declare const HOSTED_BASE_URL = "https://api.agentpost.tools/v1/resources";
|
|
1454
1533
|
interface ClientOptions {
|
|
1455
1534
|
/** The API root. Defaults to {@link HOSTED_BASE_URL}. Set it to send requests through your own proxy, or to a stand-in during a test. */
|
|
@@ -1472,18 +1551,50 @@ interface VersionedOptions extends CallOptions {
|
|
|
1472
1551
|
ifMatch: number;
|
|
1473
1552
|
idempotencyKey?: string;
|
|
1474
1553
|
}
|
|
1475
|
-
|
|
1554
|
+
/**
|
|
1555
|
+
* A stable code to act on: one of ResourceShark's error codes, one of the
|
|
1556
|
+
* Platform's (such as `throttled`), or `unknown` when the response wasn't
|
|
1557
|
+
* the standard error shape. A code newer than this SDK still comes as the
|
|
1558
|
+
* API sent it.
|
|
1559
|
+
*/
|
|
1560
|
+
type ResourcesharkApiErrorCode = ErrorCode | PlatformErrorCode | 'unknown';
|
|
1561
|
+
/**
|
|
1562
|
+
* Each code with its `details`, so checking `code` gives `details` its
|
|
1563
|
+
* type, such as `{ lines }` for `insufficient_supply`. A code whose details
|
|
1564
|
+
* ResourceShark doesn't type, and every Platform code, has `details` as
|
|
1565
|
+
* sent.
|
|
1566
|
+
*/
|
|
1567
|
+
type DetailsByCode = { [C in ResourcesharkApiErrorCode]: {
|
|
1568
|
+
readonly code: C;
|
|
1569
|
+
readonly details?: ErrorDetailsOf<C>;
|
|
1570
|
+
}; }[ResourcesharkApiErrorCode];
|
|
1571
|
+
/** ResourceShark's refusal: the HTTP status, a stable code, its class and details, and the page that explains it. */
|
|
1572
|
+
type ResourcesharkApiError = Error & {
|
|
1476
1573
|
readonly status: number;
|
|
1477
|
-
|
|
1574
|
+
/** What to do next without knowing the code. Absent on a Platform code. */
|
|
1478
1575
|
readonly errorClass?: ErrorClass;
|
|
1479
|
-
|
|
1576
|
+
/** The page that explains the code. */
|
|
1480
1577
|
readonly docs?: string;
|
|
1481
|
-
|
|
1578
|
+
} & DetailsByCode;
|
|
1579
|
+
interface ResourcesharkApiErrorConstructor {
|
|
1580
|
+
/** Takes the code and details as the API sent them. */
|
|
1581
|
+
new (status: number, code: ResourcesharkApiErrorCode | (string & {}), message: string, details?: unknown, docs?: string, errorClass?: ErrorClass): ResourcesharkApiError;
|
|
1582
|
+
readonly prototype: ResourcesharkApiError;
|
|
1482
1583
|
}
|
|
1584
|
+
declare const ResourcesharkApiError: ResourcesharkApiErrorConstructor;
|
|
1483
1585
|
/** True when a response has the service's standard error body. */
|
|
1484
1586
|
declare function isErrorBody(value: unknown): value is ErrorBody;
|
|
1485
1587
|
/** Filters and pagination for a resource list, before server defaults apply. */
|
|
1486
1588
|
type ResourcesQueryInput = Partial<ResourcesQuery>;
|
|
1589
|
+
/** A read of the change feed, before server defaults apply. */
|
|
1590
|
+
interface EventsQuery {
|
|
1591
|
+
/** The `seq` to read after, default 0 for the oldest change kept, or `'latest'` to start from now: no events, and `next` set to the newest `seq`. */
|
|
1592
|
+
after?: number | 'latest';
|
|
1593
|
+
/** The most events to answer with, from 1 to 500. Default 100. */
|
|
1594
|
+
limit?: number;
|
|
1595
|
+
/** Full event types to keep, as a list or separated by commas. Without it, every type. */
|
|
1596
|
+
types?: string | readonly string[];
|
|
1597
|
+
}
|
|
1487
1598
|
interface ResourcesharkClient {
|
|
1488
1599
|
config: {
|
|
1489
1600
|
get(opts?: CallOptions): Promise<ConfigResponse>;
|
|
@@ -1589,4 +1700,4 @@ interface ResourcesharkClient {
|
|
|
1589
1700
|
};
|
|
1590
1701
|
}
|
|
1591
1702
|
declare function createClient(options?: ClientOptions): ResourcesharkClient;
|
|
1592
|
-
export {
|
|
1703
|
+
export { ExceptionId as $, ResourcePatch as $t, Claim as A, TransferResponse as An, InstancesPage as At, CountResponse as B, MovementsQuery as Bt, BatchCreate as C, SupplyResponse as Cn, HoldsPage as Ct, BatchesPage as D, TotalsQuery as Dn, InstanceId as Dt, BatchResponse as E, TotalsBalance as En, InstanceCreate as Et, ClaimsQuery as F, MovementId as Ft, ErrorCode as G, PlaceResponse as Gt, Duration as H, PlaceCreate as Ht, ConfigResponse as I, MovementReason as It, EventsPage as J, Quantity as Jt, ErrorDetails as K, PlacesPage as Kt, ConsumeRequest as L, MovementResponse as Lt, ClaimLine as M, TransformationId as Mn, InsufficientSupplyDetails as Mt, ClaimResponse as N, TransformationResponse as Nn, KeyInUseDetails as Nt, BatchesQuery as O, TotalsReport as On, InstancePatch as Ot, ClaimsPage as P, Unit as Pn, Movement as Pt, ExceptionDeleteResponse as Q, ResourceId as Qt, ConsumeResponse as R, MovementSums as Rt, Batch as S, SupplyQuery as Sn, HolderBalancesQuery as St, BatchPatch as T, SupplyReverseResponse as Tn, Instance as Tt, ErrorBody as U, PlaceId as Ut, CursorExpiredDetails as V, Place as Vt, ErrorClass as W, PlacePatch as Wt, ExceptionCreate as X, Resource as Xt, Evidence as Y, Ref as Yt, ExceptionCreateResponse as Z, ResourceCreate as Zt, Attributes as _, SupplyCreateInput as _n, HoldRescheduleResponse as _t, ResourcesQueryInput as a, SchedulePut as an, FiniteSpan as at, BalanceQuery as b, SupplyId as bn, HolderBalanceResponse as bt, ResourcesharkApiErrorConstructor as c, Scope as cn, HoldCancel as ct, WriteOptions as d, SettleResponse as dn, HoldCommitResponse as dt, ResourceResponse as en, ExceptionPatch as et, createClient as f, ShortLine as fn, HoldCreate as ft, AssignmentInfeasibleDetails as g, StaleVersionDetails as gn, HoldReschedule as gt, AdjustmentResponse as h, SlotsResponse as hn, HoldId as ht, HOSTED_BASE_URL as i, RetainedHold as in, ExhaustedUntilSupplyDetails as it, ClaimId as j, TransformationCreate as jn, InstancesQuery as jt, ChangeEvent as k, TransferCreate as kn, InstanceResponse as kt, ResourcesharkClient as l, SettingsLockedDetails as ln, HoldCancelResponse as lt, AdjustmentCreate as m, SlotsQuery as mn, HoldExtend as mt, ClientOptions as n, ResourcesQuery as nn, ExceptionsList as nt, ResourcesharkApiError as o, ScheduleResponse as on, FreeInstancesQuery as ot, isErrorBody as p, Slot as pn, HoldExpiredDetails as pt, ErrorDetailsOf as q, PlacesQuery as qt, EventsQuery as r, ResourcesharkConfig as rn, ExceptionsQuery as rt, ResourcesharkApiErrorCode as s, ScheduleSaveResponse as sn, Hold as st, CallOptions as t, ResourcesPage as tn, ExceptionResponse as tt, VersionedOptions as u, SettleRequest as un, HoldCommit as ut, AvailabilityRequest as v, SupplyEntry as vn, HoldResolvedDetails as vt, BatchId as w, SupplyReverse as wn, HoldsQueryInput as wt, BalanceResponse as x, SupplyPage as xn, HolderBalancesPage as xt, AvailabilityResponse as y, SupplyGetResponse as yn, HoldResponse as yt, CountCreate as z, MovementsPage as zt };
|
|
@@ -57,7 +57,7 @@ const ROUTES = {
|
|
|
57
57
|
};
|
|
58
58
|
// src/client.ts
|
|
59
59
|
const HOSTED_BASE_URL = "https://api.agentpost.tools/v1/resources";
|
|
60
|
-
|
|
60
|
+
const ResourcesharkApiError = class ResourcesharkApiError extends Error {
|
|
61
61
|
status;
|
|
62
62
|
code;
|
|
63
63
|
errorClass;
|
|
@@ -107,6 +107,7 @@ function createClient(options = {}) {
|
|
|
107
107
|
for (const [key, value] of Object.entries(parts.query ?? {})) {
|
|
108
108
|
if (value === void 0 || value === null) continue;
|
|
109
109
|
if (key === "attributes") for (const [name, attribute] of Object.entries(value)) search.set(`attribute.${name}`, String(attribute));
|
|
110
|
+
else if (Array.isArray(value)) search.set(key, value.join(","));
|
|
110
111
|
else search.set(key, String(value));
|
|
111
112
|
}
|
|
112
113
|
const query = search.toString();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as Duration, Jt as Quantity, M as ClaimLine, Pt as Movement, Qt as ResourceId, R as ConsumeResponse, W as ErrorClass, Y as Evidence, Yt as Ref, at as FiniteSpan, cn as Scope, fn as ShortLine, ht as HoldId, in as RetainedHold, j as ClaimId, l as ResourcesharkClient, mn as SlotsQuery, pn as Slot, st as Hold, vt as HoldResolvedDetails } from "./client-DEn-MdAz.js";
|
|
2
2
|
/** How the workflow reaches the service: directly with a secret key, or through the customer's endpoint. */
|
|
3
3
|
interface HoldTransport<Place, Extend, Commit> {
|
|
4
4
|
slots(q: SlotsQuery): Promise<{
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cn as SupplyResponse, En as TotalsBalance, H as Duration, It as MovementReason, Jt as Quantity, On as TotalsReport, Pn as Unit, Qt as ResourceId, Rt as MovementSums, Tn as SupplyReverseResponse, Y as Evidence, _ as Attributes, _n as SupplyCreateInput, bn as SupplyId, cn as Scope, l as ResourcesharkClient, o as ResourcesharkApiError, pn as Slot } from "../client-DEn-MdAz.js";
|
|
2
2
|
type Cadence = {
|
|
3
3
|
every: 'month';
|
|
4
4
|
count: number;
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ResourcesharkApiError } from "../client-
|
|
2
|
-
import { i as shortLines } from "../refusals-
|
|
1
|
+
import { n as ResourcesharkApiError } from "../client-bcl2_fz8.js";
|
|
2
|
+
import { i as shortLines } from "../refusals-C8SBj-15.js";
|
|
3
3
|
// src/helpers/zone.ts
|
|
4
4
|
function requireTimeZone(timeZone) {
|
|
5
5
|
if (typeof timeZone !== "string") throw new TypeError("timeZone is required");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ExceptionId, $t as ResourcePatch, A as Claim, An as TransferResponse, At as InstancesPage, B as CountResponse, Bt as MovementsQuery, C as BatchCreate, Cn as SupplyResponse, Ct as HoldsPage, D as BatchesPage, Dn as TotalsQuery, Dt as InstanceId, E as BatchResponse, En as TotalsBalance, Et as InstanceCreate, F as ClaimsQuery, Ft as MovementId, G as ErrorCode, Gt as PlaceResponse, H as Duration, Ht as PlaceCreate, I as ConfigResponse, It as MovementReason, J as EventsPage, Jt as Quantity, K as ErrorDetails, Kt as PlacesPage, L as ConsumeRequest, Lt as MovementResponse, M as ClaimLine, Mn as TransformationId, Mt as InsufficientSupplyDetails, N as ClaimResponse, Nn as TransformationResponse, Nt as KeyInUseDetails, O as BatchesQuery, On as TotalsReport, Ot as InstancePatch, P as ClaimsPage, Pn as Unit, Pt as Movement, Q as ExceptionDeleteResponse, Qt as ResourceId, R as ConsumeResponse, Rt as MovementSums, S as Batch, Sn as SupplyQuery, St as HolderBalancesQuery, T as BatchPatch, Tn as SupplyReverseResponse, Tt as Instance, U as ErrorBody, Ut as PlaceId, V as CursorExpiredDetails, Vt as Place, W as ErrorClass, Wt as PlacePatch, X as ExceptionCreate, Xt as Resource, Y as Evidence, Yt as Ref, Z as ExceptionCreateResponse, Zt as ResourceCreate, _ as Attributes, _n as SupplyCreateInput, _t as HoldRescheduleResponse, a as ResourcesQueryInput, an as SchedulePut, at as FiniteSpan, b as BalanceQuery, bn as SupplyId, bt as HolderBalanceResponse, c as ResourcesharkApiErrorConstructor, cn as Scope, ct as HoldCancel, d as WriteOptions, dn as SettleResponse, dt as HoldCommitResponse, en as ResourceResponse, et as ExceptionPatch, f as createClient, fn as ShortLine, ft as HoldCreate, g as AssignmentInfeasibleDetails, gn as StaleVersionDetails, gt as HoldReschedule, h as AdjustmentResponse, hn as SlotsResponse, ht as HoldId, i as HOSTED_BASE_URL, in as RetainedHold, it as ExhaustedUntilSupplyDetails, j as ClaimId, jn as TransformationCreate, jt as InstancesQuery, k as ChangeEvent, kn as TransferCreate, kt as InstanceResponse, l as ResourcesharkClient, ln as SettingsLockedDetails, lt as HoldCancelResponse, m as AdjustmentCreate, mn as SlotsQuery, mt as HoldExtend, n as ClientOptions, nn as ResourcesQuery, nt as ExceptionsList, o as ResourcesharkApiError, on as ScheduleResponse, ot as FreeInstancesQuery, p as isErrorBody, pn as Slot, pt as HoldExpiredDetails, q as ErrorDetailsOf, qt as PlacesQuery, r as EventsQuery, rn as ResourcesharkConfig, rt as ExceptionsQuery, s as ResourcesharkApiErrorCode, sn as ScheduleSaveResponse, st as Hold, t as CallOptions, tn as ResourcesPage, tt as ExceptionResponse, u as VersionedOptions, un as SettleRequest, ut as HoldCommit, v as AvailabilityRequest, vn as SupplyEntry, vt as HoldResolvedDetails, w as BatchId, wn as SupplyReverse, wt as HoldsQueryInput, x as BalanceResponse, xn as SupplyPage, xt as HolderBalancesPage, y as AvailabilityResponse, yn as SupplyGetResponse, yt as HoldResponse, z as CountCreate, zt as MovementsPage } from "./client-DEn-MdAz.js";
|
|
2
2
|
/** The lines a refusal couldn't cover, short of supply or naming a unit that isn't free, as the service reported them. */
|
|
3
3
|
export declare function shortLines(e: unknown): ShortLine[] | undefined;
|
|
4
4
|
/** The earliest next supply time reported by an exhausted scope. */
|
|
@@ -7,4 +7,4 @@ export declare function nextSupplyAt(e: unknown): string | undefined;
|
|
|
7
7
|
export declare function expiredHold(e: unknown): HoldExpiredDetails | undefined;
|
|
8
8
|
/** The first outcome of a hold the service had already resolved. */
|
|
9
9
|
export declare function resolvedHold(e: unknown): HoldResolvedDetails | undefined;
|
|
10
|
-
export { type AdjustmentCreate, type AdjustmentResponse, type AssignmentInfeasibleDetails, type Attributes, type AvailabilityRequest, type AvailabilityResponse, type BalanceQuery, type BalanceResponse, type Batch, type BatchCreate, type BatchId, type BatchPatch, type BatchResponse, type BatchesPage, type BatchesQuery, type CallOptions, type ChangeEvent, type Claim, type ClaimId, type ClaimLine, type ClaimResponse, type ClaimsPage, type ClaimsQuery, type ClientOptions, type ConfigResponse, type ConsumeRequest, type ConsumeResponse, type CountCreate, type CountResponse, type Duration, type ErrorBody, type ErrorClass, type ErrorCode, type EventsPage, type EventsQuery, type Evidence, type ExceptionCreate, type ExceptionCreateResponse, type ExceptionDeleteResponse, type ExceptionId, type ExceptionPatch, type ExceptionResponse, type ExceptionsList, type ExceptionsQuery, type ExhaustedUntilSupplyDetails, type FiniteSpan, type FreeInstancesQuery, HOSTED_BASE_URL, type Hold, type HoldCancel, type HoldCancelResponse, type HoldCommit, type HoldCommitResponse, type HoldCreate, type HoldExpiredDetails, type HoldExtend, type HoldId, type HoldReschedule, type HoldRescheduleResponse, type HoldResolvedDetails, type HoldResponse, type HolderBalanceResponse, type HolderBalancesPage, type HolderBalancesQuery, type HoldsPage, type HoldsQueryInput, type Instance, type InstanceCreate, type InstanceId, type InstancePatch, type InstanceResponse, type InstancesPage, type InstancesQuery, type InsufficientSupplyDetails, type Movement, type MovementId, type MovementReason, type MovementResponse, type MovementSums, type MovementsPage, type MovementsQuery, type Place, type PlaceCreate, type PlaceId, type PlacePatch, type PlaceResponse, type PlacesPage, type PlacesQuery, type Quantity, type Ref, type Resource, type ResourceCreate, type ResourceId, type ResourcePatch, type ResourceResponse, type ResourcesPage, type ResourcesQuery, type ResourcesQueryInput, ResourcesharkApiError, type ResourcesharkClient, type ResourcesharkConfig, type RetainedHold, type SchedulePut, type ScheduleResponse, type ScheduleSaveResponse, type Scope, type SettleRequest, type SettleResponse, type ShortLine, type Slot, type SlotsQuery, type SlotsResponse, type SupplyCreateInput, type SupplyEntry, type SupplyGetResponse, type SupplyId, type SupplyPage, type SupplyQuery, type SupplyResponse, type SupplyReverse, type SupplyReverseResponse, type TotalsBalance, type TotalsQuery, type TotalsReport, type TransferCreate, type TransferResponse, type TransformationCreate, type TransformationId, type TransformationResponse, type Unit, type VersionedOptions, type WriteOptions, createClient, isErrorBody };
|
|
10
|
+
export { type AdjustmentCreate, type AdjustmentResponse, type AssignmentInfeasibleDetails, type Attributes, type AvailabilityRequest, type AvailabilityResponse, type BalanceQuery, type BalanceResponse, type Batch, type BatchCreate, type BatchId, type BatchPatch, type BatchResponse, type BatchesPage, type BatchesQuery, type CallOptions, type ChangeEvent, type Claim, type ClaimId, type ClaimLine, type ClaimResponse, type ClaimsPage, type ClaimsQuery, type ClientOptions, type ConfigResponse, type ConsumeRequest, type ConsumeResponse, type CountCreate, type CountResponse, type CursorExpiredDetails, type Duration, type ErrorBody, type ErrorClass, type ErrorCode, type ErrorDetails, type ErrorDetailsOf, type EventsPage, type EventsQuery, type Evidence, type ExceptionCreate, type ExceptionCreateResponse, type ExceptionDeleteResponse, type ExceptionId, type ExceptionPatch, type ExceptionResponse, type ExceptionsList, type ExceptionsQuery, type ExhaustedUntilSupplyDetails, type FiniteSpan, type FreeInstancesQuery, HOSTED_BASE_URL, type Hold, type HoldCancel, type HoldCancelResponse, type HoldCommit, type HoldCommitResponse, type HoldCreate, type HoldExpiredDetails, type HoldExtend, type HoldId, type HoldReschedule, type HoldRescheduleResponse, type HoldResolvedDetails, type HoldResponse, type HolderBalanceResponse, type HolderBalancesPage, type HolderBalancesQuery, type HoldsPage, type HoldsQueryInput, type Instance, type InstanceCreate, type InstanceId, type InstancePatch, type InstanceResponse, type InstancesPage, type InstancesQuery, type InsufficientSupplyDetails, type KeyInUseDetails, type Movement, type MovementId, type MovementReason, type MovementResponse, type MovementSums, type MovementsPage, type MovementsQuery, type Place, type PlaceCreate, type PlaceId, type PlacePatch, type PlaceResponse, type PlacesPage, type PlacesQuery, type Quantity, type Ref, type Resource, type ResourceCreate, type ResourceId, type ResourcePatch, type ResourceResponse, type ResourcesPage, type ResourcesQuery, type ResourcesQueryInput, ResourcesharkApiError, type ResourcesharkApiErrorCode, type ResourcesharkApiErrorConstructor, type ResourcesharkClient, type ResourcesharkConfig, type RetainedHold, type SchedulePut, type ScheduleResponse, type ScheduleSaveResponse, type Scope, type SettingsLockedDetails, type SettleRequest, type SettleResponse, type ShortLine, type Slot, type SlotsQuery, type SlotsResponse, type StaleVersionDetails, type SupplyCreateInput, type SupplyEntry, type SupplyGetResponse, type SupplyId, type SupplyPage, type SupplyQuery, type SupplyResponse, type SupplyReverse, type SupplyReverseResponse, type TotalsBalance, type TotalsQuery, type TotalsReport, type TransferCreate, type TransferResponse, type TransformationCreate, type TransformationId, type TransformationResponse, type Unit, type VersionedOptions, type WriteOptions, createClient, isErrorBody };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as isErrorBody, n as ResourcesharkApiError, r as createClient, t as HOSTED_BASE_URL } from "./client-
|
|
2
|
-
import { i as shortLines, n as nextSupplyAt, r as resolvedHold, t as expiredHold } from "./refusals-
|
|
1
|
+
import { i as isErrorBody, n as ResourcesharkApiError, r as createClient, t as HOSTED_BASE_URL } from "./client-bcl2_fz8.js";
|
|
2
|
+
import { i as shortLines, n as nextSupplyAt, r as resolvedHold, t as expiredHold } from "./refusals-C8SBj-15.js";
|
|
3
3
|
export { HOSTED_BASE_URL, ResourcesharkApiError, createClient, expiredHold, isErrorBody, nextSupplyAt, resolvedHold, shortLines };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as readError, n as ResourcesharkApiError } from "./client-
|
|
1
|
+
import { a as readError, n as ResourcesharkApiError } from "./client-bcl2_fz8.js";
|
|
2
2
|
// src/refusals.ts
|
|
3
3
|
function refusalDetails(value, ...codes) {
|
|
4
4
|
const error = value instanceof ResourcesharkApiError ? value : readError(value);
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as CommitInput, f as PlaceInput, i as commitHold, n as CommitOutcome, r as ExpiredLine, s as BuyInput, t as BuyOutcome, u as ExtendInput } from "./commit-
|
|
1
|
+
import { W as ErrorClass, in as RetainedHold, mn as SlotsQuery, st as Hold } from "./client-DEn-MdAz.js";
|
|
2
|
+
import { c as CommitInput, f as PlaceInput, i as commitHold, n as CommitOutcome, r as ExpiredLine, s as BuyInput, t as BuyOutcome, u as ExtendInput } from "./commit-93Qao_5l.js";
|
|
3
3
|
/**
|
|
4
4
|
* A refusal from one of the app's hooks, such as a hold longer than the
|
|
5
5
|
* app allows or a user at their cap of open holds. It reaches the page as
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResourcesharkApiError, r as createClient } from "./client-
|
|
1
|
+
import { n as ResourcesharkApiError, r as createClient } from "./client-bcl2_fz8.js";
|
|
2
2
|
import { i as apiTransport, o as WorkflowFailure, t as commitHold } from "./commit-B_gOf0Ji.js";
|
|
3
3
|
// src/server.ts
|
|
4
4
|
const ERRORS_PAGE = "https://agentpost.tools/docs/resourceshark/errors#";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as WorkflowError, c as CommitInput, d as HoldTransport, f as PlaceInput, i as commitHold, l as EndpointTransportOptions, m as endpointTransport, n as CommitOutcome, o as ApiTransportOptions, p as apiTransport, r as ExpiredLine, s as BuyInput, t as BuyOutcome, u as ExtendInput } from "../commit-
|
|
1
|
+
import { fn as ShortLine, in as RetainedHold, mn as SlotsQuery, pn as Slot, st as Hold, vt as HoldResolvedDetails } from "../client-DEn-MdAz.js";
|
|
2
|
+
import { a as WorkflowError, c as CommitInput, d as HoldTransport, f as PlaceInput, i as commitHold, l as EndpointTransportOptions, m as endpointTransport, n as CommitOutcome, o as ApiTransportOptions, p as apiTransport, r as ExpiredLine, s as BuyInput, t as BuyOutcome, u as ExtendInput } from "../commit-93Qao_5l.js";
|
|
3
3
|
interface Store<T> {
|
|
4
4
|
getSnapshot(): T;
|
|
5
5
|
subscribe(listener: () => void): () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentpost-tools/resourceshark-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A typed client for resourceshark, for servers and browsers, with the framework-independent hold and booking workflows.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://agentpost.tools/docs/resourceshark/sdk",
|