@clocknext/sdk 0.14.0 → 0.16.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 +274 -128
- package/dist/index.cjs +345 -281
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +689 -773
- package/dist/index.d.ts +689 -773
- package/dist/index.js +345 -281
- package/dist/index.js.map +1 -1
- package/examples/node-basic.ts +24 -32
- package/package.json +1 -1
- package/src/client.ts +15 -23
- package/src/customer-ref.ts +14 -0
- package/src/errors.ts +10 -2
- package/src/filters.ts +1 -1
- package/src/index.ts +32 -58
- package/src/resources/composites.ts +55 -20
- package/src/resources/credits.ts +40 -35
- package/src/resources/customers.ts +201 -82
- package/src/resources/invoices.ts +1 -1
- package/src/resources/outcomes.ts +40 -41
- package/src/resources/plans.ts +38 -32
- package/src/resources/signals.ts +8 -46
- package/src/resources/units.ts +37 -37
- package/src/types.ts +549 -619
- package/src/resources/webhooks.ts +0 -37
- package/src/resources/workspace.ts +0 -33
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Transport } from "../http.js";
|
|
2
|
-
import type { ThresholdKind, UpsertWebhookInput, Webhook } from "../types.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The `webhooks` resource — threshold alerts. At most one webhook per kind
|
|
6
|
-
* (CREDIT / OUTCOME / WALLET); posting a kind again upserts it. `/api/v1/webhooks`.
|
|
7
|
-
*/
|
|
8
|
-
export class Webhooks {
|
|
9
|
-
constructor(private readonly transport: Transport) {}
|
|
10
|
-
|
|
11
|
-
/** List configured webhooks. `GET /api/v1/webhooks`. */
|
|
12
|
-
async list(): Promise<Webhook[]> {
|
|
13
|
-
const res = await this.transport.request<{ webhooks: Webhook[] }>({
|
|
14
|
-
method: "GET",
|
|
15
|
-
path: "/api/v1/webhooks",
|
|
16
|
-
});
|
|
17
|
-
return res.webhooks;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Create or replace the webhook for a kind. `POST /api/v1/webhooks`. */
|
|
21
|
-
async upsert(input: UpsertWebhookInput): Promise<Webhook> {
|
|
22
|
-
const res = await this.transport.request<{ webhook: Webhook }>({
|
|
23
|
-
method: "POST",
|
|
24
|
-
path: "/api/v1/webhooks",
|
|
25
|
-
body: input,
|
|
26
|
-
});
|
|
27
|
-
return res.webhook;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Delete the webhook for a kind (idempotent). `DELETE /api/v1/webhooks/:kind`. */
|
|
31
|
-
async delete(kind: ThresholdKind): Promise<void> {
|
|
32
|
-
await this.transport.request({
|
|
33
|
-
method: "DELETE",
|
|
34
|
-
path: `/api/v1/webhooks/${encodeURIComponent(kind)}`,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { activeQuery, filterByActive } from "../filters.js";
|
|
2
|
-
import type { Transport } from "../http.js";
|
|
3
|
-
import type { Model, WorkspaceIdentity } from "../types.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The `workspace` resource — read-only introspection of the org behind the API
|
|
7
|
-
* key. Grounds an integration (which workspace, and is it `sandbox` or `live`?)
|
|
8
|
-
* and lists the models it may meter against. `/api/v1/me`, `/api/v1/models`.
|
|
9
|
-
*/
|
|
10
|
-
export class Workspace {
|
|
11
|
-
constructor(private readonly transport: Transport) {}
|
|
12
|
-
|
|
13
|
-
/** Identify the org + key behind the request, incl. `sandbox` | `live`. */
|
|
14
|
-
me(): Promise<WorkspaceIdentity> {
|
|
15
|
-
return this.transport.request<WorkspaceIdentity>({
|
|
16
|
-
method: "GET",
|
|
17
|
-
path: "/api/v1/me",
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** The org's enabled models with live prices. `{ active: true }` returns only
|
|
22
|
-
* the models that can be metered right now.
|
|
23
|
-
* `{ active: false }` returns only archived ones; omitting it returns
|
|
24
|
-
* both. See `activeQuery` — the API itself only supports `true`. */
|
|
25
|
-
async models(params: { active?: boolean } = {}): Promise<Model[]> {
|
|
26
|
-
const res = await this.transport.request<{ models: Model[] }>({
|
|
27
|
-
method: "GET",
|
|
28
|
-
path: "/api/v1/models",
|
|
29
|
-
query: { active: activeQuery(params.active) },
|
|
30
|
-
});
|
|
31
|
-
return filterByActive(res.models, params.active);
|
|
32
|
-
}
|
|
33
|
-
}
|