@allisall/sdk 0.1.0 → 0.4.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.
Files changed (66) hide show
  1. package/README.md +145 -4
  2. package/dist/client.d.ts +87 -37
  3. package/dist/client.js +144 -73
  4. package/dist/generated/openapi.d.ts +9497 -0
  5. package/dist/generated/openapi.js +4 -0
  6. package/dist/generated/operations.d.ts +42 -0
  7. package/dist/generated/operations.js +1167 -0
  8. package/dist/import-mapping.d.ts +10 -0
  9. package/dist/import-mapping.js +20 -0
  10. package/dist/index.d.ts +8 -2
  11. package/dist/index.js +2 -0
  12. package/dist/ingest.d.ts +1 -1
  13. package/dist/ingest.js +2 -2
  14. package/dist/money.d.ts +57 -0
  15. package/dist/money.js +284 -0
  16. package/dist/multipart.d.ts +29 -0
  17. package/dist/multipart.js +48 -0
  18. package/dist/options.d.ts +50 -0
  19. package/dist/options.js +73 -0
  20. package/dist/pagination.d.ts +55 -0
  21. package/dist/pagination.js +85 -0
  22. package/dist/request.d.ts +126 -0
  23. package/dist/request.js +403 -0
  24. package/dist/resources/agents.d.ts +58 -0
  25. package/dist/resources/agents.js +72 -0
  26. package/dist/resources/analytics.d.ts +42 -0
  27. package/dist/resources/analytics.js +68 -0
  28. package/dist/resources/api-keys.d.ts +54 -0
  29. package/dist/resources/api-keys.js +63 -0
  30. package/dist/resources/calculations.d.ts +98 -0
  31. package/dist/resources/calculations.js +133 -0
  32. package/dist/resources/clients.d.ts +93 -0
  33. package/dist/resources/clients.js +113 -0
  34. package/dist/resources/cost.d.ts +76 -0
  35. package/dist/resources/cost.js +96 -0
  36. package/dist/resources/dashboard.d.ts +32 -0
  37. package/dist/resources/dashboard.js +36 -0
  38. package/dist/resources/events.d.ts +116 -0
  39. package/dist/resources/events.js +145 -0
  40. package/dist/resources/health.d.ts +14 -0
  41. package/dist/resources/health.js +17 -0
  42. package/dist/resources/imports.d.ts +56 -0
  43. package/dist/resources/imports.js +63 -0
  44. package/dist/resources/onboarding.d.ts +29 -0
  45. package/dist/resources/onboarding.js +34 -0
  46. package/dist/resources/outcome-types.d.ts +25 -0
  47. package/dist/resources/outcome-types.js +33 -0
  48. package/dist/resources/reports.d.ts +92 -0
  49. package/dist/resources/reports.js +120 -0
  50. package/dist/resources/value-models.d.ts +99 -0
  51. package/dist/resources/value-models.js +133 -0
  52. package/dist/resources/workspace.d.ts +15 -0
  53. package/dist/resources/workspace.js +18 -0
  54. package/dist/runtime.d.ts +2 -0
  55. package/dist/runtime.js +2 -1
  56. package/dist/share.d.ts +52 -0
  57. package/dist/share.js +60 -0
  58. package/dist/transport.d.ts +54 -5
  59. package/dist/transport.js +81 -32
  60. package/dist/types.d.ts +163 -3
  61. package/dist/types.js +18 -3
  62. package/dist/unicode.d.ts +2 -0
  63. package/dist/unicode.js +11 -0
  64. package/dist/version.d.ts +1 -1
  65. package/dist/version.js +1 -1
  66. package/package.json +4 -3
@@ -0,0 +1,113 @@
1
+ // The `clients` operations.
2
+ import { call, callPage } from "../request.js";
3
+ /** The `clients` operations. */
4
+ export class Clients {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ /**
10
+ * Lists clients. Await the result for one page; iterate it with
11
+ * `for await` for every client of every page.
12
+ *
13
+ * Pass `page` for a numbered page: its `body` then holds `page` and
14
+ * `total`. Only that first page is counted; every later page of a walk
15
+ * continues by cursor from it, and its `page` and `total` are `null`. To
16
+ * show another numbered page, call this method again with its `page`
17
+ * rather than `getNextPage()`. A `page` past the end has no items, and the
18
+ * walk ends there.
19
+ *
20
+ * Needs the `read` scope. Operation `listClients`.
21
+ */
22
+ list(query, options) {
23
+ return callPage(this.#config, "listClients", { query, options });
24
+ }
25
+ /**
26
+ * Creates a client.
27
+ *
28
+ * A `renewal_date` before the request's UTC date less one day is refused
29
+ * with `400` `out_of_range`, so no time zone's today is refused. With a
30
+ * `renewal_term`, an active client's renewal date rolls forward by whole
31
+ * terms once it passes.
32
+ *
33
+ * `client_key` is unique in the workspace, ignoring letter case and
34
+ * surrounding whitespace: a key another client already holds, in any
35
+ * case or padding, is refused with `409` `client_key_in_use`.
36
+ *
37
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
38
+ * cannot create a second client.
39
+ *
40
+ * Needs the `write` scope. Operation `createClient`.
41
+ */
42
+ create(body, options) {
43
+ return call(this.#config, "createClient", { body, options });
44
+ }
45
+ /**
46
+ * Reads a client.
47
+ *
48
+ * Needs the `read` scope. Operation `getClient`.
49
+ */
50
+ get(id, options) {
51
+ return call(this.#config, "getClient", { path: { id }, options });
52
+ }
53
+ /**
54
+ * Updates a client with a merge patch: a member left out keeps its
55
+ * value, `null` clears it, and any other value sets it.
56
+ *
57
+ * Sending back the `renewal_date` a read returned keeps the client's
58
+ * renewal schedule: a date on the schedule, up to the one it shows on the
59
+ * next UTC day, changes nothing. Any other date is a new renewal date, and
60
+ * one before the request's UTC date less one day is refused with `400`
61
+ * `out_of_range`. A patch that changes `renewal_term` or `status` saves
62
+ * the date the client shows on the current UTC day as the new start of
63
+ * its schedule, without the patch sending a date.
64
+ *
65
+ * `client_key` is unique in the workspace, ignoring letter case and
66
+ * surrounding whitespace: a key another client already holds, in any
67
+ * case or padding, is refused with `409` `client_key_in_use`.
68
+ *
69
+ * Never retried.
70
+ *
71
+ * Needs the `write` scope. Operation `updateClient`.
72
+ */
73
+ update(id, patch, options) {
74
+ return call(this.#config, "updateClient", {
75
+ path: { id },
76
+ body: patch,
77
+ options,
78
+ });
79
+ }
80
+ /**
81
+ * Deletes a client. Refused while events carry the client's key, or
82
+ * while the client has a validated or published calculation; set its
83
+ * status to `churned` instead.
84
+ *
85
+ * A retry after a lost response can answer `404` for a delete that
86
+ * succeeded.
87
+ *
88
+ * Needs the `write` scope. Operation `deleteClient`.
89
+ */
90
+ delete(id, options) {
91
+ return call(this.#config, "deleteClient", { path: { id }, options });
92
+ }
93
+ /**
94
+ * Replaces a client's assigned agents. Assignment decides how later
95
+ * events are attributed: an event without `client_key` from an agent
96
+ * assigned to exactly one client is attributed to that client. A
97
+ * `model` or `outcome` event from an agent assigned to two or more
98
+ * clients must carry `client_key`, or it is refused with
99
+ * `client_key_required`.
100
+ *
101
+ * Retried on a failure worth retrying, because a repeat leaves the same
102
+ * agents assigned.
103
+ *
104
+ * Needs the `write` scope. Operation `setClientAgents`.
105
+ */
106
+ setAgents(id, body, options) {
107
+ return call(this.#config, "setClientAgents", {
108
+ path: { id },
109
+ body,
110
+ options,
111
+ });
112
+ }
113
+ }
@@ -0,0 +1,76 @@
1
+ import type { MoneyInput } from "../money.js";
2
+ import type { IdempotentRequestOptions, RequestOptions } from "../options.js";
3
+ import type { PagePromise } from "../pagination.js";
4
+ import type { TransportConfig } from "../transport.js";
5
+ import type { CostLineItem, CostLineItemCreate, CostLineItemList, CostLineItemPatch, ListCostLineItemsQuery, PriceTable, PriceTableSet } from "../types.js";
6
+ /** The `cost` operations. */
7
+ export declare class Cost {
8
+ #private;
9
+ constructor(config: TransportConfig);
10
+ /**
11
+ * Lists cost line items. Await the result for one page; iterate it with
12
+ * `for await` for every line item of every page.
13
+ *
14
+ * Pass `page` for a numbered page: its `body` then holds `page` and
15
+ * `total`. Only that first page is counted; every later page of a walk
16
+ * continues by cursor from it, and its `page` and `total` are `null`. To
17
+ * show another numbered page, call this method again with its `page`
18
+ * rather than `getNextPage()`. A `page` past the end has no items, and the
19
+ * walk ends there.
20
+ *
21
+ * Needs the `read` scope. Operation `listCostLineItems`.
22
+ */
23
+ listLineItems(query?: ListCostLineItemsQuery, options?: RequestOptions): PagePromise<CostLineItem, CostLineItemList>;
24
+ /**
25
+ * Creates a cost line item. `monthly_amount` takes a `Decimal` or a
26
+ * `number`.
27
+ *
28
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
29
+ * cannot create a second line item.
30
+ *
31
+ * Needs the `write` scope. Operation `createCostLineItem`.
32
+ */
33
+ createLineItem(body: MoneyInput<CostLineItemCreate>, options?: IdempotentRequestOptions): Promise<CostLineItem>;
34
+ /**
35
+ * Reads a cost line item.
36
+ *
37
+ * Needs the `read` scope. Operation `getCostLineItem`.
38
+ */
39
+ getLineItem(id: string, options?: RequestOptions): Promise<CostLineItem>;
40
+ /**
41
+ * Updates a cost line item with a merge patch: a member left out keeps
42
+ * its value, `null` clears it, and any other value sets it.
43
+ * `monthly_amount` takes a `Decimal` or a `number`.
44
+ *
45
+ * Never retried.
46
+ *
47
+ * Needs the `write` scope. Operation `updateCostLineItem`.
48
+ */
49
+ updateLineItem(id: string, patch: MoneyInput<CostLineItemPatch>, options?: RequestOptions): Promise<CostLineItem>;
50
+ /**
51
+ * Deletes a cost line item.
52
+ *
53
+ * A retry after a lost response can answer `404` for a delete that
54
+ * succeeded.
55
+ *
56
+ * Needs the `write` scope. Operation `deleteCostLineItem`.
57
+ */
58
+ deleteLineItem(id: string, options?: RequestOptions): Promise<void>;
59
+ /**
60
+ * Reads the price table.
61
+ *
62
+ * Needs the `read` scope. Operation `getPriceTable`.
63
+ */
64
+ getPriceTable(options?: RequestOptions): Promise<PriceTable>;
65
+ /**
66
+ * Replaces the price table, as a whole. Each rate takes a `Decimal` or a
67
+ * `number`, so a table read with `getPriceTable` can be sent back as it
68
+ * is.
69
+ *
70
+ * Retried on a failure worth retrying, because a repeat leaves the same
71
+ * price table.
72
+ *
73
+ * Needs the `write` scope. Operation `setPriceTable`.
74
+ */
75
+ setPriceTable(body: MoneyInput<PriceTableSet>, options?: RequestOptions): Promise<PriceTable>;
76
+ }
@@ -0,0 +1,96 @@
1
+ // The `cost` operations: cost line items and the price table.
2
+ import { call, callPage } from "../request.js";
3
+ /** The `cost` operations. */
4
+ export class Cost {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ /**
10
+ * Lists cost line items. Await the result for one page; iterate it with
11
+ * `for await` for every line item of every page.
12
+ *
13
+ * Pass `page` for a numbered page: its `body` then holds `page` and
14
+ * `total`. Only that first page is counted; every later page of a walk
15
+ * continues by cursor from it, and its `page` and `total` are `null`. To
16
+ * show another numbered page, call this method again with its `page`
17
+ * rather than `getNextPage()`. A `page` past the end has no items, and the
18
+ * walk ends there.
19
+ *
20
+ * Needs the `read` scope. Operation `listCostLineItems`.
21
+ */
22
+ listLineItems(query, options) {
23
+ return callPage(this.#config, "listCostLineItems", { query, options });
24
+ }
25
+ /**
26
+ * Creates a cost line item. `monthly_amount` takes a `Decimal` or a
27
+ * `number`.
28
+ *
29
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
30
+ * cannot create a second line item.
31
+ *
32
+ * Needs the `write` scope. Operation `createCostLineItem`.
33
+ */
34
+ createLineItem(body, options) {
35
+ return call(this.#config, "createCostLineItem", { body, options });
36
+ }
37
+ /**
38
+ * Reads a cost line item.
39
+ *
40
+ * Needs the `read` scope. Operation `getCostLineItem`.
41
+ */
42
+ getLineItem(id, options) {
43
+ return call(this.#config, "getCostLineItem", { path: { id }, options });
44
+ }
45
+ /**
46
+ * Updates a cost line item with a merge patch: a member left out keeps
47
+ * its value, `null` clears it, and any other value sets it.
48
+ * `monthly_amount` takes a `Decimal` or a `number`.
49
+ *
50
+ * Never retried.
51
+ *
52
+ * Needs the `write` scope. Operation `updateCostLineItem`.
53
+ */
54
+ updateLineItem(id, patch, options) {
55
+ return call(this.#config, "updateCostLineItem", {
56
+ path: { id },
57
+ body: patch,
58
+ options,
59
+ });
60
+ }
61
+ /**
62
+ * Deletes a cost line item.
63
+ *
64
+ * A retry after a lost response can answer `404` for a delete that
65
+ * succeeded.
66
+ *
67
+ * Needs the `write` scope. Operation `deleteCostLineItem`.
68
+ */
69
+ deleteLineItem(id, options) {
70
+ return call(this.#config, "deleteCostLineItem", {
71
+ path: { id },
72
+ options,
73
+ });
74
+ }
75
+ /**
76
+ * Reads the price table.
77
+ *
78
+ * Needs the `read` scope. Operation `getPriceTable`.
79
+ */
80
+ getPriceTable(options) {
81
+ return call(this.#config, "getPriceTable", { options });
82
+ }
83
+ /**
84
+ * Replaces the price table, as a whole. Each rate takes a `Decimal` or a
85
+ * `number`, so a table read with `getPriceTable` can be sent back as it
86
+ * is.
87
+ *
88
+ * Retried on a failure worth retrying, because a repeat leaves the same
89
+ * price table.
90
+ *
91
+ * Needs the `write` scope. Operation `setPriceTable`.
92
+ */
93
+ setPriceTable(body, options) {
94
+ return call(this.#config, "setPriceTable", { body, options });
95
+ }
96
+ }
@@ -0,0 +1,32 @@
1
+ import type { RequestOptions } from "../options.js";
2
+ import type { PagePromise } from "../pagination.js";
3
+ import type { TransportConfig } from "../transport.js";
4
+ import type { Dashboard, GetDashboardQuery, ListRenewalsQuery, Renewal, RenewalList } from "../types.js";
5
+ /** The `dashboard` operations. */
6
+ export declare class DashboardOperations {
7
+ #private;
8
+ constructor(config: TransportConfig);
9
+ /**
10
+ * Reads the workspace's month: its published figures for the calendar
11
+ * month `month`, such as `2026-08`, which is required.
12
+ *
13
+ * Needs the `read` scope. Operation `getDashboard`.
14
+ */
15
+ get(query: GetDashboardQuery, options?: RequestOptions): Promise<Dashboard>;
16
+ /**
17
+ * Lists renewal readiness: each client's latest published figures,
18
+ * whatever month `get` reads. Await the result for one page; iterate it
19
+ * with `for await` for every client of every page.
20
+ *
21
+ * `today` is the date renewal dates are rolled against and `window` is
22
+ * measured from; left out, it is the current UTC date, which the response
23
+ * echoes. A walk sends the first page's `today` on every later page, so it
24
+ * reads one date even across midnight UTC; to page by number instead,
25
+ * send that `today` yourself with each `page`. `renewal_term` takes an
26
+ * array, sent as one parameter per item; an empty array is refused
27
+ * before sending, because leaving it out means every term.
28
+ *
29
+ * Needs the `read` scope. Operation `listRenewals`.
30
+ */
31
+ listRenewals(query?: ListRenewalsQuery, options?: RequestOptions): PagePromise<Renewal, RenewalList>;
32
+ }
@@ -0,0 +1,36 @@
1
+ // The `dashboard` operations.
2
+ import { call, callPage } from "../request.js";
3
+ /** The `dashboard` operations. */
4
+ export class DashboardOperations {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ /**
10
+ * Reads the workspace's month: its published figures for the calendar
11
+ * month `month`, such as `2026-08`, which is required.
12
+ *
13
+ * Needs the `read` scope. Operation `getDashboard`.
14
+ */
15
+ get(query, options) {
16
+ return call(this.#config, "getDashboard", { query, options });
17
+ }
18
+ /**
19
+ * Lists renewal readiness: each client's latest published figures,
20
+ * whatever month `get` reads. Await the result for one page; iterate it
21
+ * with `for await` for every client of every page.
22
+ *
23
+ * `today` is the date renewal dates are rolled against and `window` is
24
+ * measured from; left out, it is the current UTC date, which the response
25
+ * echoes. A walk sends the first page's `today` on every later page, so it
26
+ * reads one date even across midnight UTC; to page by number instead,
27
+ * send that `today` yourself with each `page`. `renewal_term` takes an
28
+ * array, sent as one parameter per item; an empty array is refused
29
+ * before sending, because leaving it out means every term.
30
+ *
31
+ * Needs the `read` scope. Operation `listRenewals`.
32
+ */
33
+ listRenewals(query, options) {
34
+ return callPage(this.#config, "listRenewals", { query, options });
35
+ }
36
+ }
@@ -0,0 +1,116 @@
1
+ import type { RequestOptions } from "../options.js";
2
+ import type { PagePromise } from "../pagination.js";
3
+ import { type TransportConfig } from "../transport.js";
4
+ import type { AttributedEvent, ClientEventList, EventArrivalList, EventInput, EventList, EventSummary, GetEventSummaryQuery, IngestSummary, ListClientEventsQuery, ListEventArrivalsQuery, ListEventsQuery } from "../types.js";
5
+ /** The `events` operations. */
6
+ export declare class Events {
7
+ #private;
8
+ constructor(config: TransportConfig);
9
+ /**
10
+ * Ingests any number of events. They are sent in batches of at most 500
11
+ * events and 4,000,000 bytes, one batch after another, each retried as
12
+ * the client allows. Every event without an `event_id` gets a generated
13
+ * one, so a retry never stores an event twice. Your objects are not
14
+ * modified.
15
+ *
16
+ * An event too large to send even alone is not sent, and is reported as a
17
+ * rejected row with the code `too_large`.
18
+ *
19
+ * @returns the combined outcome over the whole list.
20
+ * @throws {IngestError} when a batch fails; the call stops there, and the
21
+ * error carries the summary so far and every event from the failed batch
22
+ * onward, to send again. A batch fails on an error response, on no
23
+ * response, on the caller's cancellation, or when its token cannot be
24
+ * had: an error from `tokenProvider`, or, in a browser without
25
+ * `dangerouslyAllowBrowser`, a provider's token that is an API key. The
26
+ * error is the `IngestError`'s `cause`.
27
+ * @throws {TypeError} when an event cannot be encoded, or `options.headers`
28
+ * names a header the SDK sets, before anything is sent.
29
+ * @throws {AllisallError} when `options.timeout` or `options.maxRetries` is
30
+ * one the client would refuse, before anything is sent.
31
+ */
32
+ ingest(events: readonly EventInput[], options?: RequestOptions): Promise<IngestSummary>;
33
+ /**
34
+ * Lists the workspace's events whose `timestamp` falls in the period,
35
+ * newest first. Await the result for one page; iterate it with
36
+ * `for await` for every event of every page.
37
+ *
38
+ * `from` and `to` are required unless `import_batch_id` is sent, and
39
+ * then are both sent or neither; the API refuses a missing bound with
40
+ * `required`. The type cannot say so, so both are optional in it.
41
+ *
42
+ * The list is held still under an arrival limit, `as_of`, which the first
43
+ * response issues. A walk follows `next_cursor`, which carries it, so
44
+ * every page of one walk reads the same events while new ones arrive. To
45
+ * show numbered pages instead, send the first response's `as_of` with each
46
+ * later `page`. Filtered by `import_batch_id`, `as_of` is issued but not
47
+ * applied, because an import's events appear together when it commits.
48
+ * Otherwise an event appears a second or two after the API stores it, and
49
+ * later while a long request, such as a large import, is still in
50
+ * progress, so a read straight after an ingest may not include it yet.
51
+ *
52
+ * Pass `page` for a numbered page: its `body` then holds `page`, `total`
53
+ * and `total_capped`. `total` counts at most 10,000 events, and
54
+ * `total_capped` is `true` when more matched; filtered by
55
+ * `import_batch_id`, `total` is exact. Only that first page is counted;
56
+ * every later page of a walk continues by cursor from it, and its `page`,
57
+ * `total` and `total_capped` are `null`. To show another numbered page,
58
+ * call this method again with its `page` rather than `getNextPage()`.
59
+ *
60
+ * `sort` and `dir` other than `timestamp` descending need `page`, or the
61
+ * API refuses the call with `required` on `page`. A walk from a sorted
62
+ * page continues by offset and reads every earlier row for each page, so
63
+ * walk in the default order.
64
+ *
65
+ * Needs the `read` scope. Operation `listEvents`.
66
+ */
67
+ list(query?: ListEventsQuery, options?: RequestOptions): PagePromise<AttributedEvent, EventList>;
68
+ /**
69
+ * Counts the events `list` holds under the same period, filters and
70
+ * `as_of`: in all, per day and per category. A day is 24 hours counted
71
+ * from `from`, so local midnight with its offset as `from` gives local
72
+ * days. The period is required, also with `import_batch_id`. Without
73
+ * `import_batch_id`, an event is counted a second or two after the API
74
+ * stores it, and later while a long request, such as a large import, is
75
+ * still in progress, so a read straight after an ingest may not count it
76
+ * yet.
77
+ *
78
+ * Needs the `read` scope. Operation `getEventSummary`.
79
+ */
80
+ getSummary(query: GetEventSummaryQuery, options?: RequestOptions): Promise<EventSummary>;
81
+ /**
82
+ * Lists the workspace's events in the order the API stored them, newest
83
+ * first, below an arrival limit, `as_of`, which the response issues.
84
+ * Await the result for one page; iterate it with `for await` for every
85
+ * event of every page. `from` and `to` filter by `timestamp`, and each is
86
+ * optional on its own.
87
+ *
88
+ * With `since`, the list holds the events that arrived at or after it, and
89
+ * `body.count` counts them. To poll, send each response's `as_of` as the
90
+ * next call's `since` and walk the result: consecutive windows meet
91
+ * without a gap or an overlap. To learn only how many arrived, pass a
92
+ * `limit` of 1 and read `body.count`. The SDK does not poll on its own.
93
+ * `since` may be at most 24 hours back; a feed further behind reloads
94
+ * without it. An event falls below `as_of` a second or two after the API
95
+ * stores it, and later while a long request, such as a large import, is
96
+ * still in progress. A read straight after an ingest may not include it
97
+ * yet; poll with `since` until it does.
98
+ *
99
+ * Needs the `read` scope. Operation `listEventArrivals`.
100
+ */
101
+ listArrivals(query?: ListEventArrivalsQuery, options?: RequestOptions): PagePromise<AttributedEvent, EventArrivalList>;
102
+ /**
103
+ * Lists the events behind a client's totals: the event drill-down, over
104
+ * the period `from` to `to`.
105
+ *
106
+ * Pass `page` or `cursor`, not both; neither means page 1. A `page`
107
+ * beyond the end returns no rows and the true `total`. Await the result
108
+ * for one page, whose `body` holds `total` and `period`; iterate it with
109
+ * `for await` for every event of every page from there.
110
+ *
111
+ * Needs the `read` scope. Operation `listClientEvents`.
112
+ *
113
+ * @param clientId - the client's id.
114
+ */
115
+ listForClient(clientId: string, query: ListClientEventsQuery, options?: RequestOptions): PagePromise<AttributedEvent, ClientEventList>;
116
+ }
@@ -0,0 +1,145 @@
1
+ // The `events` operations: ingest, the workspace's events, their summary
2
+ // and arrivals, and the event drill-down.
3
+ import { OPERATIONS } from "../generated/operations.js";
4
+ import { ingest, readIngestResult } from "../ingest.js";
5
+ import { call, callPage, policyOf } from "../request.js";
6
+ import { post } from "../transport.js";
7
+ /** The `events` operations. */
8
+ export class Events {
9
+ #config;
10
+ constructor(config) {
11
+ this.#config = config;
12
+ }
13
+ /**
14
+ * Ingests any number of events. They are sent in batches of at most 500
15
+ * events and 4,000,000 bytes, one batch after another, each retried as
16
+ * the client allows. Every event without an `event_id` gets a generated
17
+ * one, so a retry never stores an event twice. Your objects are not
18
+ * modified.
19
+ *
20
+ * An event too large to send even alone is not sent, and is reported as a
21
+ * rejected row with the code `too_large`.
22
+ *
23
+ * @returns the combined outcome over the whole list.
24
+ * @throws {IngestError} when a batch fails; the call stops there, and the
25
+ * error carries the summary so far and every event from the failed batch
26
+ * onward, to send again. A batch fails on an error response, on no
27
+ * response, on the caller's cancellation, or when its token cannot be
28
+ * had: an error from `tokenProvider`, or, in a browser without
29
+ * `dangerouslyAllowBrowser`, a provider's token that is an API key. The
30
+ * error is the `IngestError`'s `cause`.
31
+ * @throws {TypeError} when an event cannot be encoded, or `options.headers`
32
+ * names a header the SDK sets, before anything is sent.
33
+ * @throws {AllisallError} when `options.timeout` or `options.maxRetries` is
34
+ * one the client would refuse, before anything is sent.
35
+ */
36
+ ingest(events, options = {}) {
37
+ const config = this.#config;
38
+ let policy;
39
+ try {
40
+ policy = policyOf(config, "ingestEvents", OPERATIONS.ingestEvents, options);
41
+ }
42
+ catch (err) {
43
+ return Promise.reject(err);
44
+ }
45
+ // Each batch has its own signal; ingest is always eligible for a retry,
46
+ // because event_id deduplicates, which post() sets.
47
+ const { timeout, maxRetries, headers } = policy;
48
+ return ingest(events, (body, count, signal) => post(config, OPERATIONS.ingestEvents.path, body, (value) => readIngestResult(value, count), { timeout, maxRetries, headers, signal }), options.signal);
49
+ }
50
+ /**
51
+ * Lists the workspace's events whose `timestamp` falls in the period,
52
+ * newest first. Await the result for one page; iterate it with
53
+ * `for await` for every event of every page.
54
+ *
55
+ * `from` and `to` are required unless `import_batch_id` is sent, and
56
+ * then are both sent or neither; the API refuses a missing bound with
57
+ * `required`. The type cannot say so, so both are optional in it.
58
+ *
59
+ * The list is held still under an arrival limit, `as_of`, which the first
60
+ * response issues. A walk follows `next_cursor`, which carries it, so
61
+ * every page of one walk reads the same events while new ones arrive. To
62
+ * show numbered pages instead, send the first response's `as_of` with each
63
+ * later `page`. Filtered by `import_batch_id`, `as_of` is issued but not
64
+ * applied, because an import's events appear together when it commits.
65
+ * Otherwise an event appears a second or two after the API stores it, and
66
+ * later while a long request, such as a large import, is still in
67
+ * progress, so a read straight after an ingest may not include it yet.
68
+ *
69
+ * Pass `page` for a numbered page: its `body` then holds `page`, `total`
70
+ * and `total_capped`. `total` counts at most 10,000 events, and
71
+ * `total_capped` is `true` when more matched; filtered by
72
+ * `import_batch_id`, `total` is exact. Only that first page is counted;
73
+ * every later page of a walk continues by cursor from it, and its `page`,
74
+ * `total` and `total_capped` are `null`. To show another numbered page,
75
+ * call this method again with its `page` rather than `getNextPage()`.
76
+ *
77
+ * `sort` and `dir` other than `timestamp` descending need `page`, or the
78
+ * API refuses the call with `required` on `page`. A walk from a sorted
79
+ * page continues by offset and reads every earlier row for each page, so
80
+ * walk in the default order.
81
+ *
82
+ * Needs the `read` scope. Operation `listEvents`.
83
+ */
84
+ list(query, options) {
85
+ return callPage(this.#config, "listEvents", { query, options });
86
+ }
87
+ /**
88
+ * Counts the events `list` holds under the same period, filters and
89
+ * `as_of`: in all, per day and per category. A day is 24 hours counted
90
+ * from `from`, so local midnight with its offset as `from` gives local
91
+ * days. The period is required, also with `import_batch_id`. Without
92
+ * `import_batch_id`, an event is counted a second or two after the API
93
+ * stores it, and later while a long request, such as a large import, is
94
+ * still in progress, so a read straight after an ingest may not count it
95
+ * yet.
96
+ *
97
+ * Needs the `read` scope. Operation `getEventSummary`.
98
+ */
99
+ getSummary(query, options) {
100
+ return call(this.#config, "getEventSummary", { query, options });
101
+ }
102
+ /**
103
+ * Lists the workspace's events in the order the API stored them, newest
104
+ * first, below an arrival limit, `as_of`, which the response issues.
105
+ * Await the result for one page; iterate it with `for await` for every
106
+ * event of every page. `from` and `to` filter by `timestamp`, and each is
107
+ * optional on its own.
108
+ *
109
+ * With `since`, the list holds the events that arrived at or after it, and
110
+ * `body.count` counts them. To poll, send each response's `as_of` as the
111
+ * next call's `since` and walk the result: consecutive windows meet
112
+ * without a gap or an overlap. To learn only how many arrived, pass a
113
+ * `limit` of 1 and read `body.count`. The SDK does not poll on its own.
114
+ * `since` may be at most 24 hours back; a feed further behind reloads
115
+ * without it. An event falls below `as_of` a second or two after the API
116
+ * stores it, and later while a long request, such as a large import, is
117
+ * still in progress. A read straight after an ingest may not include it
118
+ * yet; poll with `since` until it does.
119
+ *
120
+ * Needs the `read` scope. Operation `listEventArrivals`.
121
+ */
122
+ listArrivals(query, options) {
123
+ return callPage(this.#config, "listEventArrivals", { query, options });
124
+ }
125
+ /**
126
+ * Lists the events behind a client's totals: the event drill-down, over
127
+ * the period `from` to `to`.
128
+ *
129
+ * Pass `page` or `cursor`, not both; neither means page 1. A `page`
130
+ * beyond the end returns no rows and the true `total`. Await the result
131
+ * for one page, whose `body` holds `total` and `period`; iterate it with
132
+ * `for await` for every event of every page from there.
133
+ *
134
+ * Needs the `read` scope. Operation `listClientEvents`.
135
+ *
136
+ * @param clientId - the client's id.
137
+ */
138
+ listForClient(clientId, query, options) {
139
+ return callPage(this.#config, "listClientEvents", {
140
+ path: { id: clientId },
141
+ query,
142
+ options,
143
+ });
144
+ }
145
+ }
@@ -0,0 +1,14 @@
1
+ import type { RequestOptions } from "../options.js";
2
+ import type { TransportConfig } from "../transport.js";
3
+ import type { Health } from "../types.js";
4
+ /** The `health` operations. */
5
+ export declare class HealthOperations {
6
+ #private;
7
+ constructor(config: TransportConfig);
8
+ /**
9
+ * Checks liveness. Sends no credential.
10
+ *
11
+ * Operation `getHealth`.
12
+ */
13
+ get(options?: RequestOptions): Promise<Health>;
14
+ }
@@ -0,0 +1,17 @@
1
+ // The `health` operations.
2
+ import { call } from "../request.js";
3
+ /** The `health` operations. */
4
+ export class HealthOperations {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ /**
10
+ * Checks liveness. Sends no credential.
11
+ *
12
+ * Operation `getHealth`.
13
+ */
14
+ get(options) {
15
+ return call(this.#config, "getHealth", { options });
16
+ }
17
+ }