@allisall/sdk 0.0.0-stage → 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.
Files changed (70) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +2 -0
  3. package/README.md +227 -2
  4. package/dist/client.d.ts +121 -0
  5. package/dist/client.js +193 -0
  6. package/dist/decimal.d.ts +20 -0
  7. package/dist/decimal.js +23 -0
  8. package/dist/errors.d.ts +79 -0
  9. package/dist/errors.js +98 -0
  10. package/dist/generated/openapi.d.ts +7724 -0
  11. package/dist/generated/openapi.js +4 -0
  12. package/dist/generated/operations.d.ts +37 -0
  13. package/dist/generated/operations.js +976 -0
  14. package/dist/index.d.ts +10 -0
  15. package/dist/index.js +5 -0
  16. package/dist/ingest.d.ts +28 -0
  17. package/dist/ingest.js +247 -0
  18. package/dist/money.d.ts +57 -0
  19. package/dist/money.js +284 -0
  20. package/dist/multipart.d.ts +27 -0
  21. package/dist/multipart.js +48 -0
  22. package/dist/options.d.ts +50 -0
  23. package/dist/options.js +73 -0
  24. package/dist/pagination.d.ts +55 -0
  25. package/dist/pagination.js +85 -0
  26. package/dist/request.d.ts +117 -0
  27. package/dist/request.js +363 -0
  28. package/dist/resources/agents.d.ts +51 -0
  29. package/dist/resources/agents.js +65 -0
  30. package/dist/resources/analytics.d.ts +42 -0
  31. package/dist/resources/analytics.js +68 -0
  32. package/dist/resources/api-keys.d.ts +54 -0
  33. package/dist/resources/api-keys.js +63 -0
  34. package/dist/resources/calculations.d.ts +78 -0
  35. package/dist/resources/calculations.js +111 -0
  36. package/dist/resources/clients.d.ts +65 -0
  37. package/dist/resources/clients.js +85 -0
  38. package/dist/resources/cost.d.ts +69 -0
  39. package/dist/resources/cost.js +89 -0
  40. package/dist/resources/dashboard.d.ts +24 -0
  41. package/dist/resources/dashboard.js +28 -0
  42. package/dist/resources/events.d.ts +47 -0
  43. package/dist/resources/events.js +69 -0
  44. package/dist/resources/health.d.ts +14 -0
  45. package/dist/resources/health.js +17 -0
  46. package/dist/resources/imports.d.ts +33 -0
  47. package/dist/resources/imports.js +37 -0
  48. package/dist/resources/outcome-types.d.ts +25 -0
  49. package/dist/resources/outcome-types.js +33 -0
  50. package/dist/resources/reports.d.ts +77 -0
  51. package/dist/resources/reports.js +103 -0
  52. package/dist/resources/value-models.d.ts +92 -0
  53. package/dist/resources/value-models.js +126 -0
  54. package/dist/retry.d.ts +18 -0
  55. package/dist/retry.js +105 -0
  56. package/dist/runtime.d.ts +19 -0
  57. package/dist/runtime.js +61 -0
  58. package/dist/share.d.ts +52 -0
  59. package/dist/share.js +60 -0
  60. package/dist/transport.d.ts +102 -0
  61. package/dist/transport.js +269 -0
  62. package/dist/types.d.ts +268 -0
  63. package/dist/types.js +89 -0
  64. package/dist/unicode.d.ts +2 -0
  65. package/dist/unicode.js +11 -0
  66. package/dist/uuid.d.ts +6 -0
  67. package/dist/uuid.js +20 -0
  68. package/dist/version.d.ts +2 -0
  69. package/dist/version.js +2 -0
  70. package/package.json +40 -4
@@ -0,0 +1,69 @@
1
+ // The `events` operations: ingest, and the event drill-down.
2
+ import { OPERATIONS } from "../generated/operations.js";
3
+ import { ingest, readIngestResult } from "../ingest.js";
4
+ import { callPage, policyOf } from "../request.js";
5
+ import { post } from "../transport.js";
6
+ /** The `events` operations. */
7
+ export class Events {
8
+ #config;
9
+ constructor(config) {
10
+ this.#config = config;
11
+ }
12
+ /**
13
+ * Ingests any number of events. They are sent in batches of at most 500
14
+ * events and 4,000,000 bytes, one batch after another, each retried as
15
+ * the client allows. Every event without an `event_id` gets a generated
16
+ * one, so a retry never stores an event twice. Your objects are not
17
+ * modified.
18
+ *
19
+ * An event too large to send even alone is not sent, and is reported as a
20
+ * rejected row with the code `too_large`.
21
+ *
22
+ * @returns the combined outcome over the whole list.
23
+ * @throws {IngestError} when a batch fails; the call stops there, and the
24
+ * error carries the summary so far and every event from the failed batch
25
+ * onward, to send again. A batch fails on an error response, on no
26
+ * response, on the caller's cancellation, or when its token cannot be
27
+ * had: an error from `tokenProvider`, or, in a browser without
28
+ * `dangerouslyAllowBrowser`, a provider's token that is an API key. The
29
+ * error is the `IngestError`'s `cause`.
30
+ * @throws {TypeError} when an event cannot be encoded, or `options.headers`
31
+ * names a header the SDK sets, before anything is sent.
32
+ * @throws {AllisallError} when `options.timeout` or `options.maxRetries` is
33
+ * one the client would refuse, before anything is sent.
34
+ */
35
+ ingest(events, options = {}) {
36
+ const config = this.#config;
37
+ let policy;
38
+ try {
39
+ policy = policyOf(config, "ingestEvents", OPERATIONS.ingestEvents, options);
40
+ }
41
+ catch (err) {
42
+ return Promise.reject(err);
43
+ }
44
+ // Each batch has its own signal; ingest is always eligible for a retry,
45
+ // because event_id deduplicates, which post() sets.
46
+ const { timeout, maxRetries, headers } = policy;
47
+ 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
+ * Lists the events behind a client's totals: the event drill-down, over
51
+ * the period `from` to `to`.
52
+ *
53
+ * Pass `page` or `cursor`, not both; neither means page 1. A `page`
54
+ * beyond the end returns no rows and the true `total`. Await the result
55
+ * for one page, whose `body` holds `total` and `period`; iterate it with
56
+ * `for await` for every event of every page from there.
57
+ *
58
+ * Needs the `read` scope. Operation `listClientEvents`.
59
+ *
60
+ * @param clientId - the client's id.
61
+ */
62
+ listForClient(clientId, query, options) {
63
+ return callPage(this.#config, "listClientEvents", {
64
+ path: { id: clientId },
65
+ query,
66
+ options,
67
+ });
68
+ }
69
+ }
@@ -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
+ }
@@ -0,0 +1,33 @@
1
+ import type { ImportUpload } from "../multipart.js";
2
+ import type { IdempotentRequestOptions, RequestOptions } from "../options.js";
3
+ import type { TransportConfig } from "../transport.js";
4
+ import type { ImportPreview, ImportResult } from "../types.js";
5
+ /** The `imports` operations. */
6
+ export declare class Imports {
7
+ #private;
8
+ constructor(config: TransportConfig);
9
+ /**
10
+ * Previews a CSV import: parses, maps and validates the file exactly as
11
+ * `commit` would, and writes nothing.
12
+ *
13
+ * Never retried, although it writes nothing; repeat the call to try
14
+ * again.
15
+ *
16
+ * Needs the `ingest` scope. Operation `previewImport`.
17
+ */
18
+ preview(upload: ImportUpload, options?: RequestOptions): Promise<ImportPreview>;
19
+ /**
20
+ * Imports a CSV file: stores its valid rows and records an import batch.
21
+ * A problem with one row rejects that row only. The result lists the
22
+ * problems of the rejected rows, one `errors` entry per problem, up to the
23
+ * first 1,000; `errors_truncated` says when more were omitted, and the
24
+ * counts always cover the whole file. Events deduplicate as they do on
25
+ * ingest.
26
+ *
27
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
28
+ * cannot record a second import batch.
29
+ *
30
+ * Needs the `ingest` scope. Operation `commitImport`.
31
+ */
32
+ commit(upload: ImportUpload, options?: IdempotentRequestOptions): Promise<ImportResult>;
33
+ }
@@ -0,0 +1,37 @@
1
+ // The `imports` operations: a CSV file of events, previewed or committed.
2
+ import { call } from "../request.js";
3
+ /** The `imports` operations. */
4
+ export class Imports {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ /**
10
+ * Previews a CSV import: parses, maps and validates the file exactly as
11
+ * `commit` would, and writes nothing.
12
+ *
13
+ * Never retried, although it writes nothing; repeat the call to try
14
+ * again.
15
+ *
16
+ * Needs the `ingest` scope. Operation `previewImport`.
17
+ */
18
+ preview(upload, options) {
19
+ return call(this.#config, "previewImport", { body: upload, options });
20
+ }
21
+ /**
22
+ * Imports a CSV file: stores its valid rows and records an import batch.
23
+ * A problem with one row rejects that row only. The result lists the
24
+ * problems of the rejected rows, one `errors` entry per problem, up to the
25
+ * first 1,000; `errors_truncated` says when more were omitted, and the
26
+ * counts always cover the whole file. Events deduplicate as they do on
27
+ * ingest.
28
+ *
29
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
30
+ * cannot record a second import batch.
31
+ *
32
+ * Needs the `ingest` scope. Operation `commitImport`.
33
+ */
34
+ commit(upload, options) {
35
+ return call(this.#config, "commitImport", { body: upload, options });
36
+ }
37
+ }
@@ -0,0 +1,25 @@
1
+ import type { RequestOptions } from "../options.js";
2
+ import type { PagePromise } from "../pagination.js";
3
+ import type { TransportConfig } from "../transport.js";
4
+ import type { ListClientOutcomeTypesQuery, ListOutcomeTypesQuery, OutcomeTypeList, OutcomeTypeUsage } from "../types.js";
5
+ /** The `outcomeTypes` operations. */
6
+ export declare class OutcomeTypes {
7
+ #private;
8
+ constructor(config: TransportConfig);
9
+ /**
10
+ * Lists the workspace's outcome types. Await the result for one page;
11
+ * iterate it with `for await` for every outcome type of every page.
12
+ *
13
+ * Needs the `read` scope. Operation `listOutcomeTypes`.
14
+ */
15
+ list(query?: ListOutcomeTypesQuery, options?: RequestOptions): PagePromise<OutcomeTypeUsage, OutcomeTypeList>;
16
+ /**
17
+ * Lists a client's outcome types. Await the result for one page; iterate
18
+ * it with `for await` for every outcome type of every page.
19
+ *
20
+ * Needs the `read` scope. Operation `listClientOutcomeTypes`.
21
+ *
22
+ * @param clientId - the client's id.
23
+ */
24
+ listForClient(clientId: string, query?: ListClientOutcomeTypesQuery, options?: RequestOptions): PagePromise<OutcomeTypeUsage, OutcomeTypeList>;
25
+ }
@@ -0,0 +1,33 @@
1
+ // The `outcomeTypes` operations.
2
+ import { callPage } from "../request.js";
3
+ /** The `outcomeTypes` operations. */
4
+ export class OutcomeTypes {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ /**
10
+ * Lists the workspace's outcome types. Await the result for one page;
11
+ * iterate it with `for await` for every outcome type of every page.
12
+ *
13
+ * Needs the `read` scope. Operation `listOutcomeTypes`.
14
+ */
15
+ list(query, options) {
16
+ return callPage(this.#config, "listOutcomeTypes", { query, options });
17
+ }
18
+ /**
19
+ * Lists a client's outcome types. Await the result for one page; iterate
20
+ * it with `for await` for every outcome type of every page.
21
+ *
22
+ * Needs the `read` scope. Operation `listClientOutcomeTypes`.
23
+ *
24
+ * @param clientId - the client's id.
25
+ */
26
+ listForClient(clientId, query, options) {
27
+ return callPage(this.#config, "listClientOutcomeTypes", {
28
+ path: { id: clientId },
29
+ query,
30
+ options,
31
+ });
32
+ }
33
+ }
@@ -0,0 +1,77 @@
1
+ import type { IdempotentRequestOptions, RequestOptions } from "../options.js";
2
+ import type { PagePromise } from "../pagination.js";
3
+ import type { TransportConfig } from "../transport.js";
4
+ import type { ListCalculationReportsQuery, Report, ReportList, ReportPatch, ReportSummary, ReportWithPreview } from "../types.js";
5
+ /** The `reports` operations. */
6
+ export declare class Reports {
7
+ #private;
8
+ constructor(config: TransportConfig);
9
+ /**
10
+ * Composes a report on a published calculation, with its disclosures
11
+ * taken from the calculation's coverage.
12
+ *
13
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
14
+ * cannot create a second report.
15
+ *
16
+ * Needs the `write` scope. Operation `createReport`.
17
+ *
18
+ * @param calculationId - the calculation's id.
19
+ */
20
+ createForCalculation(calculationId: string, options?: IdempotentRequestOptions): Promise<Report>;
21
+ /**
22
+ * Lists a calculation's reports. Await the result for one page; iterate
23
+ * it with `for await` for every report of every page. Each item is a
24
+ * summary without `disclosures`; `get` reads a report with them.
25
+ *
26
+ * Needs the `read` scope. Operation `listCalculationReports`.
27
+ *
28
+ * @param calculationId - the calculation's id.
29
+ */
30
+ listForCalculation(calculationId: string, query?: ListCalculationReportsQuery, options?: RequestOptions): PagePromise<ReportSummary, ReportList>;
31
+ /**
32
+ * Reads a report.
33
+ *
34
+ * Needs the `read` scope. Operation `getReport`.
35
+ */
36
+ get(id: string, options?: RequestOptions): Promise<ReportWithPreview>;
37
+ /**
38
+ * Edits a report with a merge patch: a member left out keeps its value,
39
+ * `null` clears it, and any other value sets it. An array, such as
40
+ * `disclosures`, replaces the stored one whole.
41
+ *
42
+ * Never retried.
43
+ *
44
+ * Needs the `write` scope. Operation `updateReport`.
45
+ */
46
+ update(id: string, patch: ReportPatch, options?: RequestOptions): Promise<Report>;
47
+ /**
48
+ * Deletes an unshared report. A shared report cannot be deleted; revoke
49
+ * its link instead.
50
+ *
51
+ * A retry after a lost response can answer `404` for a delete that
52
+ * succeeded.
53
+ *
54
+ * Needs the `write` scope. Operation `deleteReport`.
55
+ */
56
+ delete(id: string, options?: RequestOptions): Promise<void>;
57
+ /**
58
+ * Shares a report: mints its share token and seals the report against
59
+ * edits. Anyone holding the token can read the report, so handle it like
60
+ * a secret.
61
+ *
62
+ * Needs a session token: sharing is a human trust step. An API key is
63
+ * refused with `403` `session_required`, as an `ApiError`. Never retried.
64
+ *
65
+ * Operation `shareReport`.
66
+ */
67
+ share(id: string, options?: RequestOptions): Promise<Report>;
68
+ /**
69
+ * Revokes a report's link: its share token stops working.
70
+ *
71
+ * Needs a session token: it undoes a human trust step. An API key is
72
+ * refused with `403` `session_required`, as an `ApiError`. Never retried.
73
+ *
74
+ * Operation `revokeReport`.
75
+ */
76
+ revoke(id: string, options?: RequestOptions): Promise<Report>;
77
+ }
@@ -0,0 +1,103 @@
1
+ // The `reports` operations: a report on a published calculation, and the
2
+ // human steps that share it and revoke its link.
3
+ import { call, callPage } from "../request.js";
4
+ /** The `reports` operations. */
5
+ export class Reports {
6
+ #config;
7
+ constructor(config) {
8
+ this.#config = config;
9
+ }
10
+ /**
11
+ * Composes a report on a published calculation, with its disclosures
12
+ * taken from the calculation's coverage.
13
+ *
14
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
15
+ * cannot create a second report.
16
+ *
17
+ * Needs the `write` scope. Operation `createReport`.
18
+ *
19
+ * @param calculationId - the calculation's id.
20
+ */
21
+ createForCalculation(calculationId, options) {
22
+ return call(this.#config, "createReport", {
23
+ path: { id: calculationId },
24
+ options,
25
+ });
26
+ }
27
+ /**
28
+ * Lists a calculation's reports. Await the result for one page; iterate
29
+ * it with `for await` for every report of every page. Each item is a
30
+ * summary without `disclosures`; `get` reads a report with them.
31
+ *
32
+ * Needs the `read` scope. Operation `listCalculationReports`.
33
+ *
34
+ * @param calculationId - the calculation's id.
35
+ */
36
+ listForCalculation(calculationId, query, options) {
37
+ return callPage(this.#config, "listCalculationReports", {
38
+ path: { id: calculationId },
39
+ query,
40
+ options,
41
+ });
42
+ }
43
+ /**
44
+ * Reads a report.
45
+ *
46
+ * Needs the `read` scope. Operation `getReport`.
47
+ */
48
+ get(id, options) {
49
+ return call(this.#config, "getReport", { path: { id }, options });
50
+ }
51
+ /**
52
+ * Edits a report with a merge patch: a member left out keeps its value,
53
+ * `null` clears it, and any other value sets it. An array, such as
54
+ * `disclosures`, replaces the stored one whole.
55
+ *
56
+ * Never retried.
57
+ *
58
+ * Needs the `write` scope. Operation `updateReport`.
59
+ */
60
+ update(id, patch, options) {
61
+ return call(this.#config, "updateReport", {
62
+ path: { id },
63
+ body: patch,
64
+ options,
65
+ });
66
+ }
67
+ /**
68
+ * Deletes an unshared report. A shared report cannot be deleted; revoke
69
+ * its link instead.
70
+ *
71
+ * A retry after a lost response can answer `404` for a delete that
72
+ * succeeded.
73
+ *
74
+ * Needs the `write` scope. Operation `deleteReport`.
75
+ */
76
+ delete(id, options) {
77
+ return call(this.#config, "deleteReport", { path: { id }, options });
78
+ }
79
+ /**
80
+ * Shares a report: mints its share token and seals the report against
81
+ * edits. Anyone holding the token can read the report, so handle it like
82
+ * a secret.
83
+ *
84
+ * Needs a session token: sharing is a human trust step. An API key is
85
+ * refused with `403` `session_required`, as an `ApiError`. Never retried.
86
+ *
87
+ * Operation `shareReport`.
88
+ */
89
+ share(id, options) {
90
+ return call(this.#config, "shareReport", { path: { id }, options });
91
+ }
92
+ /**
93
+ * Revokes a report's link: its share token stops working.
94
+ *
95
+ * Needs a session token: it undoes a human trust step. An API key is
96
+ * refused with `403` `session_required`, as an `ApiError`. Never retried.
97
+ *
98
+ * Operation `revokeReport`.
99
+ */
100
+ revoke(id, options) {
101
+ return call(this.#config, "revokeReport", { path: { id }, options });
102
+ }
103
+ }
@@ -0,0 +1,92 @@
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 { ListValueModelsQuery, ListValueTemplatesQuery, ValueLineItemsSet, ValueModel, ValueModelCreate, ValueModelList, ValueModelPatch, ValueModelSummary, ValueTemplate, ValueTemplateList } from "../types.js";
6
+ /** The `valueModels` operations. */
7
+ export declare class ValueModels {
8
+ #private;
9
+ constructor(config: TransportConfig);
10
+ /**
11
+ * Lists value models. Await the result for one page; iterate it with
12
+ * `for await` for every value model of every page.
13
+ *
14
+ * Needs the `read` scope. Operation `listValueModels`.
15
+ */
16
+ list(query?: ListValueModelsQuery, options?: RequestOptions): PagePromise<ValueModelSummary, ValueModelList>;
17
+ /**
18
+ * Reads a value model by its own id: any model in the workspace,
19
+ * archived ones included.
20
+ *
21
+ * Needs the `read` scope. Operation `getValueModel`.
22
+ *
23
+ * @param id - the value model's id, not its client's.
24
+ */
25
+ get(id: string, options?: RequestOptions): Promise<ValueModel>;
26
+ /**
27
+ * Reads a client's active value model.
28
+ *
29
+ * Needs the `read` scope. Operation `getClientValueModel`.
30
+ *
31
+ * @param clientId - the client's id.
32
+ */
33
+ getForClient(clientId: string, options?: RequestOptions): Promise<ValueModel>;
34
+ /**
35
+ * Creates a client's value model.
36
+ *
37
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
38
+ * cannot create a second value model.
39
+ *
40
+ * Needs the `write` scope. Operation `createValueModel`.
41
+ *
42
+ * @param clientId - the client's id.
43
+ */
44
+ createForClient(clientId: string, body: ValueModelCreate, options?: IdempotentRequestOptions): Promise<ValueModel>;
45
+ /**
46
+ * Updates a client's active value model with a merge patch: a member
47
+ * left out keeps its value, `null` clears it, and any other value sets
48
+ * it.
49
+ *
50
+ * Never retried.
51
+ *
52
+ * Needs the `write` scope. Operation `updateValueModel`.
53
+ *
54
+ * @param clientId - the client's id.
55
+ */
56
+ updateForClient(clientId: string, patch: ValueModelPatch, options?: RequestOptions): Promise<ValueModel>;
57
+ /**
58
+ * Deletes a client's active value model.
59
+ *
60
+ * A retry after a lost response can answer `404` for a delete that
61
+ * succeeded.
62
+ *
63
+ * Needs the `write` scope. Operation `deleteValueModel`.
64
+ *
65
+ * @param clientId - the client's id.
66
+ */
67
+ deleteForClient(clientId: string, options?: RequestOptions): Promise<void>;
68
+ /**
69
+ * Replaces the line items of a client's active value model, as a whole
70
+ * set. It is guarded by `version`: a stale version is refused rather
71
+ * than overwriting a co-editor's change.
72
+ *
73
+ * Each `unit_value` takes a `Decimal` or a `number`.
74
+ *
75
+ * Never retried, because the `version` guard refuses a repeat of a write
76
+ * that already landed as a stale version. On a `ConnectionError` the
77
+ * write may have landed: read the value model again for its current
78
+ * `version` before trying again.
79
+ *
80
+ * Needs the `write` scope. Operation `setValueModelLineItems`.
81
+ *
82
+ * @param clientId - the client's id.
83
+ */
84
+ setLineItemsForClient(clientId: string, body: MoneyInput<ValueLineItemsSet>, options?: RequestOptions): Promise<ValueModel>;
85
+ /**
86
+ * Lists value templates. Await the result for one page; iterate it with
87
+ * `for await` for every template of every page.
88
+ *
89
+ * Needs the `read` scope. Operation `listValueTemplates`.
90
+ */
91
+ listTemplates(query?: ListValueTemplatesQuery, options?: RequestOptions): PagePromise<ValueTemplate, ValueTemplateList>;
92
+ }
@@ -0,0 +1,126 @@
1
+ // The `valueModels` operations: value models, read by their own id or
2
+ // through the client they belong to, and value templates.
3
+ import { call, callPage } from "../request.js";
4
+ /** The `valueModels` operations. */
5
+ export class ValueModels {
6
+ #config;
7
+ constructor(config) {
8
+ this.#config = config;
9
+ }
10
+ /**
11
+ * Lists value models. Await the result for one page; iterate it with
12
+ * `for await` for every value model of every page.
13
+ *
14
+ * Needs the `read` scope. Operation `listValueModels`.
15
+ */
16
+ list(query, options) {
17
+ return callPage(this.#config, "listValueModels", { query, options });
18
+ }
19
+ /**
20
+ * Reads a value model by its own id: any model in the workspace,
21
+ * archived ones included.
22
+ *
23
+ * Needs the `read` scope. Operation `getValueModel`.
24
+ *
25
+ * @param id - the value model's id, not its client's.
26
+ */
27
+ get(id, options) {
28
+ return call(this.#config, "getValueModel", { path: { id }, options });
29
+ }
30
+ /**
31
+ * Reads a client's active value model.
32
+ *
33
+ * Needs the `read` scope. Operation `getClientValueModel`.
34
+ *
35
+ * @param clientId - the client's id.
36
+ */
37
+ getForClient(clientId, options) {
38
+ return call(this.#config, "getClientValueModel", {
39
+ path: { id: clientId },
40
+ options,
41
+ });
42
+ }
43
+ /**
44
+ * Creates a client's value model.
45
+ *
46
+ * Every attempt of the call sends one `Idempotency-Key`, so a retry
47
+ * cannot create a second value model.
48
+ *
49
+ * Needs the `write` scope. Operation `createValueModel`.
50
+ *
51
+ * @param clientId - the client's id.
52
+ */
53
+ createForClient(clientId, body, options) {
54
+ return call(this.#config, "createValueModel", {
55
+ path: { id: clientId },
56
+ body,
57
+ options,
58
+ });
59
+ }
60
+ /**
61
+ * Updates a client's active value model with a merge patch: a member
62
+ * left out keeps its value, `null` clears it, and any other value sets
63
+ * it.
64
+ *
65
+ * Never retried.
66
+ *
67
+ * Needs the `write` scope. Operation `updateValueModel`.
68
+ *
69
+ * @param clientId - the client's id.
70
+ */
71
+ updateForClient(clientId, patch, options) {
72
+ return call(this.#config, "updateValueModel", {
73
+ path: { id: clientId },
74
+ body: patch,
75
+ options,
76
+ });
77
+ }
78
+ /**
79
+ * Deletes a client's active value model.
80
+ *
81
+ * A retry after a lost response can answer `404` for a delete that
82
+ * succeeded.
83
+ *
84
+ * Needs the `write` scope. Operation `deleteValueModel`.
85
+ *
86
+ * @param clientId - the client's id.
87
+ */
88
+ deleteForClient(clientId, options) {
89
+ return call(this.#config, "deleteValueModel", {
90
+ path: { id: clientId },
91
+ options,
92
+ });
93
+ }
94
+ /**
95
+ * Replaces the line items of a client's active value model, as a whole
96
+ * set. It is guarded by `version`: a stale version is refused rather
97
+ * than overwriting a co-editor's change.
98
+ *
99
+ * Each `unit_value` takes a `Decimal` or a `number`.
100
+ *
101
+ * Never retried, because the `version` guard refuses a repeat of a write
102
+ * that already landed as a stale version. On a `ConnectionError` the
103
+ * write may have landed: read the value model again for its current
104
+ * `version` before trying again.
105
+ *
106
+ * Needs the `write` scope. Operation `setValueModelLineItems`.
107
+ *
108
+ * @param clientId - the client's id.
109
+ */
110
+ setLineItemsForClient(clientId, body, options) {
111
+ return call(this.#config, "setValueModelLineItems", {
112
+ path: { id: clientId },
113
+ body,
114
+ options,
115
+ });
116
+ }
117
+ /**
118
+ * Lists value templates. Await the result for one page; iterate it with
119
+ * `for await` for every template of every page.
120
+ *
121
+ * Needs the `read` scope. Operation `listValueTemplates`.
122
+ */
123
+ listTemplates(query, options) {
124
+ return callPage(this.#config, "listValueTemplates", { query, options });
125
+ }
126
+ }
@@ -0,0 +1,18 @@
1
+ /** The longest `Retry-After` the SDK honours. A longer one ends the call. */
2
+ export declare const MAX_RETRY_AFTER_MS = 60000;
3
+ /** The statuses worth repeating: a proxy's `408`, `429`, `500`, and a gateway's `502`, `503`, `504`. */
4
+ export declare function isRetryableStatus(status: number): boolean;
5
+ /**
6
+ * The wait before retry `n` (1 for the first retry) when the response
7
+ * carried no usable `Retry-After`: `min(0.5 s × 2^(n−1), 8 s)`, multiplied
8
+ * by a random factor between 0.75 and 1.
9
+ */
10
+ export declare function backoffMs(retry: number): number;
11
+ /**
12
+ * Parses a `Retry-After` value, delay-seconds or an HTTP-date (RFC 9110
13
+ * §10.2.3), into milliseconds from `now`. Returns `undefined` for a value
14
+ * that does not parse or names a time in the past.
15
+ */
16
+ export declare function parseRetryAfter(value: string | null, now: number): number | undefined;
17
+ /** Waits `ms` milliseconds, or rejects with the signal's reason when it aborts first. */
18
+ export declare function sleep(ms: number, signal: AbortSignal | undefined): Promise<void>;