@allisall/sdk 0.2.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 (40) hide show
  1. package/README.md +5 -2
  2. package/dist/client.d.ts +6 -0
  3. package/dist/client.js +8 -0
  4. package/dist/generated/openapi.d.ts +1820 -47
  5. package/dist/generated/operations.d.ts +6 -1
  6. package/dist/generated/operations.js +191 -0
  7. package/dist/import-mapping.d.ts +10 -0
  8. package/dist/import-mapping.js +20 -0
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.js +1 -0
  11. package/dist/multipart.d.ts +3 -1
  12. package/dist/request.d.ts +9 -0
  13. package/dist/request.js +43 -3
  14. package/dist/resources/agents.d.ts +7 -0
  15. package/dist/resources/agents.js +7 -0
  16. package/dist/resources/calculations.d.ts +21 -1
  17. package/dist/resources/calculations.js +22 -0
  18. package/dist/resources/clients.d.ts +28 -0
  19. package/dist/resources/clients.js +28 -0
  20. package/dist/resources/cost.d.ts +7 -0
  21. package/dist/resources/cost.js +7 -0
  22. package/dist/resources/dashboard.d.ts +8 -0
  23. package/dist/resources/dashboard.js +8 -0
  24. package/dist/resources/events.d.ts +70 -1
  25. package/dist/resources/events.js +78 -2
  26. package/dist/resources/imports.d.ts +24 -1
  27. package/dist/resources/imports.js +27 -1
  28. package/dist/resources/onboarding.d.ts +29 -0
  29. package/dist/resources/onboarding.js +34 -0
  30. package/dist/resources/reports.d.ts +16 -1
  31. package/dist/resources/reports.js +17 -0
  32. package/dist/resources/value-models.d.ts +7 -0
  33. package/dist/resources/value-models.js +7 -0
  34. package/dist/resources/workspace.d.ts +15 -0
  35. package/dist/resources/workspace.js +18 -0
  36. package/dist/types.d.ts +28 -1
  37. package/dist/types.js +6 -0
  38. package/dist/version.d.ts +1 -1
  39. package/dist/version.js +1 -1
  40. package/package.json +1 -1
package/dist/request.d.ts CHANGED
@@ -78,6 +78,15 @@ export declare function requestPage<K extends OperationId>(config: TransportConf
78
78
  * options paging sets for that page. Every other member is carried forward.
79
79
  */
80
80
  export declare function pageArgs(args: CallArgs, query: object | undefined, options: RequestOptions): CallArgs;
81
+ /**
82
+ * The query member a walk pins to its first page's answer, by operation:
83
+ * when the caller's query leaves the member out, every later page sends the
84
+ * value the first page's body echoed. On the renewals list it is `today`,
85
+ * so a walk that crosses UTC midnight reads every page under one date.
86
+ */
87
+ export declare const PINNED_ECHO: {
88
+ readonly [K in OperationId]?: string;
89
+ };
81
90
  /** An operation's path parameters, from the generated types. */
82
91
  type PathOf<K extends OperationId> = NonNullable<operations[K]["parameters"]["path"]>;
83
92
  /**
package/dist/request.js CHANGED
@@ -69,6 +69,21 @@ function buildURL(config, operation, path, query) {
69
69
  // An absent member is left out; the SDK writes no parameter of its own.
70
70
  if (value === undefined)
71
71
  continue;
72
+ if (operation.repeatable.includes(name)) {
73
+ // One parameter per item, in order. Only an array is accepted, so a
74
+ // lone string is refused too; an empty array has no faithful form,
75
+ // because leaving the parameter out means every value.
76
+ if (!Array.isArray(value)) {
77
+ throw new TypeError(`allisall: the query parameter ${name} takes an array of values`);
78
+ }
79
+ if (value.length === 0) {
80
+ throw new TypeError(`allisall: the query parameter ${name} is an empty array; leave it out to match every value`);
81
+ }
82
+ for (const item of value) {
83
+ url.searchParams.append(name, queryText(name, item));
84
+ }
85
+ continue;
86
+ }
72
87
  url.searchParams.append(name, queryText(name, value));
73
88
  }
74
89
  }
@@ -303,8 +318,17 @@ export function requestPage(config, id, args = {}) {
303
318
  const body = await requestAccepting(config, id, pageArgs(args, query, options), breaksNoCycle(position + 1));
304
319
  // A list operation's reader checked the envelope.
305
320
  const list = body;
321
+ const pinnedName = PINNED_ECHO[id];
322
+ const pinnedValue = pinnedName === undefined ? undefined : Reflect.get(list, pinnedName);
306
323
  const next = list.has_more && typeof list.next_cursor === "string"
307
- ? nextQuery(query, list.next_cursor)
324
+ ? nextQuery(query, list.next_cursor,
325
+ // An empty or non-string echo is not pinned: the API refuses an
326
+ // empty parameter.
327
+ pinnedName !== undefined &&
328
+ typeof pinnedValue === "string" &&
329
+ pinnedValue !== ""
330
+ ? { name: pinnedName, value: pinnedValue }
331
+ : undefined)
308
332
  : undefined;
309
333
  return new Page(list, next === undefined
310
334
  ? undefined
@@ -343,13 +367,29 @@ function overlay(call, override) {
343
367
  }
344
368
  return merged;
345
369
  }
346
- /** The query of the next page: the same members, `page` dropped, `cursor` set. */
347
- function nextQuery(query, cursor) {
370
+ /**
371
+ * The query member a walk pins to its first page's answer, by operation:
372
+ * when the caller's query leaves the member out, every later page sends the
373
+ * value the first page's body echoed. On the renewals list it is `today`,
374
+ * so a walk that crosses UTC midnight reads every page under one date.
375
+ */
376
+ export const PINNED_ECHO = {
377
+ listRenewals: "today",
378
+ };
379
+ /**
380
+ * The query of the next page: the same members, `page` dropped, `cursor`
381
+ * set, and the pinned member, when the caller left it out, set to the value
382
+ * the first page echoed.
383
+ */
384
+ function nextQuery(query, cursor, pinned) {
348
385
  const next = {};
349
386
  for (const [name, value] of Object.entries(query ?? {})) {
350
387
  if (name !== "page")
351
388
  next[name] = value;
352
389
  }
390
+ if (pinned !== undefined && next[pinned.name] === undefined) {
391
+ next[pinned.name] = pinned.value;
392
+ }
353
393
  next.cursor = cursor;
354
394
  return next;
355
395
  }
@@ -10,6 +10,13 @@ export declare class Agents {
10
10
  * Lists agents. Await the result for one page; iterate it with
11
11
  * `for await` for every agent of every page.
12
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
+ *
13
20
  * Needs the `read` scope. Operation `listAgents`.
14
21
  */
15
22
  list(query?: ListAgentsQuery, options?: RequestOptions): PagePromise<AgentListItem, AgentList>;
@@ -10,6 +10,13 @@ export class Agents {
10
10
  * Lists agents. Await the result for one page; iterate it with
11
11
  * `for await` for every agent of every page.
12
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
+ *
13
20
  * Needs the `read` scope. Operation `listAgents`.
14
21
  */
15
22
  list(query, options) {
@@ -1,11 +1,31 @@
1
1
  import type { IdempotentRequestOptions, RequestOptions } from "../options.js";
2
2
  import type { PagePromise } from "../pagination.js";
3
3
  import type { TransportConfig } from "../transport.js";
4
- import type { Calculation, CalculationCreate, CalculationList, CalculationSummary, ChecklistInput, ListClientCalculationsQuery } from "../types.js";
4
+ import type { Calculation, CalculationCreate, CalculationList, CalculationSummary, ChecklistInput, ListCalculationsQuery, ListClientCalculationsQuery, WorkspaceCalculationList } from "../types.js";
5
5
  /** The `calculations` operations. */
6
6
  export declare class Calculations {
7
7
  #private;
8
8
  constructor(config: TransportConfig);
9
+ /**
10
+ * Lists the workspace's calculations across clients, without snapshots.
11
+ * Await the result for one page; iterate it with `for await` for every
12
+ * calculation of every page. `month` takes `YYYY-MM` and matches only a
13
+ * period that is exactly that calendar month in UTC.
14
+ *
15
+ * Calculations come latest period first, then newest first.
16
+ * `is_current` is decided among each client's own calculations for the
17
+ * period, before any filter or page applies.
18
+ *
19
+ * Pass `page` for a numbered page: its `body` then holds `page` and
20
+ * `total`. Only that first page is counted; every later page of a walk
21
+ * continues by cursor from it, and its `page` and `total` are `null`. To
22
+ * show another numbered page, call this method again with its `page`
23
+ * rather than `getNextPage()`. A `page` past the end has no items, and the
24
+ * walk ends there.
25
+ *
26
+ * Needs the `read` scope. Operation `listCalculations`.
27
+ */
28
+ list(query?: ListCalculationsQuery, options?: RequestOptions): PagePromise<CalculationSummary, WorkspaceCalculationList>;
9
29
  /**
10
30
  * Freezes a client's ROI for an ended period as a draft calculation. An
11
31
  * API key with the `write` scope may create a draft; validating and
@@ -7,6 +7,28 @@ export class Calculations {
7
7
  constructor(config) {
8
8
  this.#config = config;
9
9
  }
10
+ /**
11
+ * Lists the workspace's calculations across clients, without snapshots.
12
+ * Await the result for one page; iterate it with `for await` for every
13
+ * calculation of every page. `month` takes `YYYY-MM` and matches only a
14
+ * period that is exactly that calendar month in UTC.
15
+ *
16
+ * Calculations come latest period first, then newest first.
17
+ * `is_current` is decided among each client's own calculations for the
18
+ * period, before any filter or page applies.
19
+ *
20
+ * Pass `page` for a numbered page: its `body` then holds `page` and
21
+ * `total`. Only that first page is counted; every later page of a walk
22
+ * continues by cursor from it, and its `page` and `total` are `null`. To
23
+ * show another numbered page, call this method again with its `page`
24
+ * rather than `getNextPage()`. A `page` past the end has no items, and the
25
+ * walk ends there.
26
+ *
27
+ * Needs the `read` scope. Operation `listCalculations`.
28
+ */
29
+ list(query, options) {
30
+ return callPage(this.#config, "listCalculations", { query, options });
31
+ }
10
32
  /**
11
33
  * Freezes a client's ROI for an ended period as a draft calculation. An
12
34
  * API key with the `write` scope may create a draft; validating and
@@ -10,12 +10,28 @@ export declare class Clients {
10
10
  * Lists clients. Await the result for one page; iterate it with
11
11
  * `for await` for every client of every page.
12
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
+ *
13
20
  * Needs the `read` scope. Operation `listClients`.
14
21
  */
15
22
  list(query?: ListClientsQuery, options?: RequestOptions): PagePromise<Client, ClientList>;
16
23
  /**
17
24
  * Creates a client.
18
25
  *
26
+ * A `renewal_date` before the request's UTC date less one day is refused
27
+ * with `400` `out_of_range`, so no time zone's today is refused. With a
28
+ * `renewal_term`, an active client's renewal date rolls forward by whole
29
+ * terms once it passes.
30
+ *
31
+ * `client_key` is unique in the workspace, ignoring letter case and
32
+ * surrounding whitespace: a key another client already holds, in any
33
+ * case or padding, is refused with `409` `client_key_in_use`.
34
+ *
19
35
  * Every attempt of the call sends one `Idempotency-Key`, so a retry
20
36
  * cannot create a second client.
21
37
  *
@@ -32,6 +48,18 @@ export declare class Clients {
32
48
  * Updates a client with a merge patch: a member left out keeps its
33
49
  * value, `null` clears it, and any other value sets it.
34
50
  *
51
+ * Sending back the `renewal_date` a read returned keeps the client's
52
+ * renewal schedule: a date on the schedule, up to the one it shows on the
53
+ * next UTC day, changes nothing. Any other date is a new renewal date, and
54
+ * one before the request's UTC date less one day is refused with `400`
55
+ * `out_of_range`. A patch that changes `renewal_term` or `status` saves
56
+ * the date the client shows on the current UTC day as the new start of
57
+ * its schedule, without the patch sending a date.
58
+ *
59
+ * `client_key` is unique in the workspace, ignoring letter case and
60
+ * surrounding whitespace: a key another client already holds, in any
61
+ * case or padding, is refused with `409` `client_key_in_use`.
62
+ *
35
63
  * Never retried.
36
64
  *
37
65
  * Needs the `write` scope. Operation `updateClient`.
@@ -10,6 +10,13 @@ export class Clients {
10
10
  * Lists clients. Await the result for one page; iterate it with
11
11
  * `for await` for every client of every page.
12
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
+ *
13
20
  * Needs the `read` scope. Operation `listClients`.
14
21
  */
15
22
  list(query, options) {
@@ -18,6 +25,15 @@ export class Clients {
18
25
  /**
19
26
  * Creates a client.
20
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
+ *
21
37
  * Every attempt of the call sends one `Idempotency-Key`, so a retry
22
38
  * cannot create a second client.
23
39
  *
@@ -38,6 +54,18 @@ export class Clients {
38
54
  * Updates a client with a merge patch: a member left out keeps its
39
55
  * value, `null` clears it, and any other value sets it.
40
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
+ *
41
69
  * Never retried.
42
70
  *
43
71
  * Needs the `write` scope. Operation `updateClient`.
@@ -11,6 +11,13 @@ export declare class Cost {
11
11
  * Lists cost line items. Await the result for one page; iterate it with
12
12
  * `for await` for every line item of every page.
13
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
+ *
14
21
  * Needs the `read` scope. Operation `listCostLineItems`.
15
22
  */
16
23
  listLineItems(query?: ListCostLineItemsQuery, options?: RequestOptions): PagePromise<CostLineItem, CostLineItemList>;
@@ -10,6 +10,13 @@ export class Cost {
10
10
  * Lists cost line items. Await the result for one page; iterate it with
11
11
  * `for await` for every line item of every page.
12
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
+ *
13
20
  * Needs the `read` scope. Operation `listCostLineItems`.
14
21
  */
15
22
  listLineItems(query, options) {
@@ -18,6 +18,14 @@ export declare class DashboardOperations {
18
18
  * whatever month `get` reads. Await the result for one page; iterate it
19
19
  * with `for await` for every client of every page.
20
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
+ *
21
29
  * Needs the `read` scope. Operation `listRenewals`.
22
30
  */
23
31
  listRenewals(query?: ListRenewalsQuery, options?: RequestOptions): PagePromise<Renewal, RenewalList>;
@@ -20,6 +20,14 @@ export class DashboardOperations {
20
20
  * whatever month `get` reads. Await the result for one page; iterate it
21
21
  * with `for await` for every client of every page.
22
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
+ *
23
31
  * Needs the `read` scope. Operation `listRenewals`.
24
32
  */
25
33
  listRenewals(query, options) {
@@ -1,7 +1,7 @@
1
1
  import type { RequestOptions } from "../options.js";
2
2
  import type { PagePromise } from "../pagination.js";
3
3
  import { type TransportConfig } from "../transport.js";
4
- import type { AttributedEvent, ClientEventList, EventInput, IngestSummary, ListClientEventsQuery } from "../types.js";
4
+ import type { AttributedEvent, ClientEventList, EventArrivalList, EventInput, EventList, EventSummary, GetEventSummaryQuery, IngestSummary, ListClientEventsQuery, ListEventArrivalsQuery, ListEventsQuery } from "../types.js";
5
5
  /** The `events` operations. */
6
6
  export declare class Events {
7
7
  #private;
@@ -30,6 +30,75 @@ export declare class Events {
30
30
  * one the client would refuse, before anything is sent.
31
31
  */
32
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>;
33
102
  /**
34
103
  * Lists the events behind a client's totals: the event drill-down, over
35
104
  * the period `from` to `to`.
@@ -1,7 +1,8 @@
1
- // The `events` operations: ingest, and the event drill-down.
1
+ // The `events` operations: ingest, the workspace's events, their summary
2
+ // and arrivals, and the event drill-down.
2
3
  import { OPERATIONS } from "../generated/operations.js";
3
4
  import { ingest, readIngestResult } from "../ingest.js";
4
- import { callPage, policyOf } from "../request.js";
5
+ import { call, callPage, policyOf } from "../request.js";
5
6
  import { post } from "../transport.js";
6
7
  /** The `events` operations. */
7
8
  export class Events {
@@ -46,6 +47,81 @@ export class Events {
46
47
  const { timeout, maxRetries, headers } = policy;
47
48
  return ingest(events, (body, count, signal) => post(config, OPERATIONS.ingestEvents.path, body, (value) => readIngestResult(value, count), { timeout, maxRetries, headers, signal }), options.signal);
48
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
+ }
49
125
  /**
50
126
  * Lists the events behind a client's totals: the event drill-down, over
51
127
  * the period `from` to `to`.
@@ -1,11 +1,34 @@
1
1
  import type { ImportUpload } from "../multipart.js";
2
2
  import type { IdempotentRequestOptions, RequestOptions } from "../options.js";
3
+ import type { PagePromise } from "../pagination.js";
3
4
  import type { TransportConfig } from "../transport.js";
4
- import type { ImportPreview, ImportResult } from "../types.js";
5
+ import type { Import, ImportList, ImportPreview, ImportResult, ImportSummary, ListImportsQuery } from "../types.js";
5
6
  /** The `imports` operations. */
6
7
  export declare class Imports {
7
8
  #private;
8
9
  constructor(config: TransportConfig);
10
+ /**
11
+ * Lists the workspace's imports, newest first, each with its counts.
12
+ * Await the result for one page; iterate it with `for await` for every
13
+ * import of every page.
14
+ *
15
+ * Pass `page` for a numbered page: its `body` then holds `page` and
16
+ * `total`. Only that first page is counted; every later page of a walk
17
+ * continues by cursor from it, and its `page` and `total` are `null`. To
18
+ * show another numbered page, call this method again with its `page`
19
+ * rather than `getNextPage()`. A `page` past the end has no items, and the
20
+ * walk ends there.
21
+ *
22
+ * Needs the `read` scope. Operation `listImports`.
23
+ */
24
+ list(query?: ListImportsQuery, options?: RequestOptions): PagePromise<ImportSummary, ImportList>;
25
+ /**
26
+ * Reads an import, with the mapping it ran with. Pass that mapping to
27
+ * `toImportMapping` to send it as the next import's mapping.
28
+ *
29
+ * Needs the `read` scope. Operation `getImport`.
30
+ */
31
+ get(id: string, options?: RequestOptions): Promise<Import>;
9
32
  /**
10
33
  * Previews a CSV import: parses, maps and validates the file exactly as
11
34
  * `commit` would, and writes nothing.
@@ -1,11 +1,37 @@
1
1
  // The `imports` operations: a CSV file of events, previewed or committed.
2
- import { call } from "../request.js";
2
+ import { call, callPage } from "../request.js";
3
3
  /** The `imports` operations. */
4
4
  export class Imports {
5
5
  #config;
6
6
  constructor(config) {
7
7
  this.#config = config;
8
8
  }
9
+ /**
10
+ * Lists the workspace's imports, newest first, each with its counts.
11
+ * Await the result for one page; iterate it with `for await` for every
12
+ * import 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 `listImports`.
22
+ */
23
+ list(query, options) {
24
+ return callPage(this.#config, "listImports", { query, options });
25
+ }
26
+ /**
27
+ * Reads an import, with the mapping it ran with. Pass that mapping to
28
+ * `toImportMapping` to send it as the next import's mapping.
29
+ *
30
+ * Needs the `read` scope. Operation `getImport`.
31
+ */
32
+ get(id, options) {
33
+ return call(this.#config, "getImport", { path: { id }, options });
34
+ }
9
35
  /**
10
36
  * Previews a CSV import: parses, maps and validates the file exactly as
11
37
  * `commit` would, and writes nothing.
@@ -0,0 +1,29 @@
1
+ import type { RequestOptions } from "../options.js";
2
+ import type { TransportConfig } from "../transport.js";
3
+ import type { Onboarding, OnboardingSkippedStepsSet } from "../types.js";
4
+ /** The `onboarding` operations. */
5
+ export declare class OnboardingOperations {
6
+ #private;
7
+ constructor(config: TransportConfig);
8
+ /**
9
+ * Reads the guided setup's progress: the five steps in their fixed
10
+ * order, each with whether the workspace's data completes it and when it
11
+ * was skipped, and `current_step`, the first step neither completed nor
12
+ * skipped. This is the read for the guided setup's progress.
13
+ *
14
+ * Needs the `read` scope. Operation `getOnboarding`.
15
+ */
16
+ get(options?: RequestOptions): Promise<Onboarding>;
17
+ /**
18
+ * Replaces the set of skipped steps, and resolves with the whole
19
+ * progress. `steps` replaces the whole set: a step left out is no longer
20
+ * skipped, and `[]` clears every skip. A step already skipped keeps its
21
+ * `skipped_at`.
22
+ *
23
+ * Retried on a failure worth retrying, because a repeat leaves the same
24
+ * set.
25
+ *
26
+ * Needs the `write` scope. Operation `setOnboardingSkippedSteps`.
27
+ */
28
+ setSkippedSteps(body: OnboardingSkippedStepsSet, options?: RequestOptions): Promise<Onboarding>;
29
+ }