@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.
- package/README.md +145 -4
- package/dist/client.d.ts +87 -37
- package/dist/client.js +144 -73
- package/dist/generated/openapi.d.ts +9497 -0
- package/dist/generated/openapi.js +4 -0
- package/dist/generated/operations.d.ts +42 -0
- package/dist/generated/operations.js +1167 -0
- package/dist/import-mapping.d.ts +10 -0
- package/dist/import-mapping.js +20 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +2 -0
- package/dist/ingest.d.ts +1 -1
- package/dist/ingest.js +2 -2
- package/dist/money.d.ts +57 -0
- package/dist/money.js +284 -0
- package/dist/multipart.d.ts +29 -0
- package/dist/multipart.js +48 -0
- package/dist/options.d.ts +50 -0
- package/dist/options.js +73 -0
- package/dist/pagination.d.ts +55 -0
- package/dist/pagination.js +85 -0
- package/dist/request.d.ts +126 -0
- package/dist/request.js +403 -0
- package/dist/resources/agents.d.ts +58 -0
- package/dist/resources/agents.js +72 -0
- package/dist/resources/analytics.d.ts +42 -0
- package/dist/resources/analytics.js +68 -0
- package/dist/resources/api-keys.d.ts +54 -0
- package/dist/resources/api-keys.js +63 -0
- package/dist/resources/calculations.d.ts +98 -0
- package/dist/resources/calculations.js +133 -0
- package/dist/resources/clients.d.ts +93 -0
- package/dist/resources/clients.js +113 -0
- package/dist/resources/cost.d.ts +76 -0
- package/dist/resources/cost.js +96 -0
- package/dist/resources/dashboard.d.ts +32 -0
- package/dist/resources/dashboard.js +36 -0
- package/dist/resources/events.d.ts +116 -0
- package/dist/resources/events.js +145 -0
- package/dist/resources/health.d.ts +14 -0
- package/dist/resources/health.js +17 -0
- package/dist/resources/imports.d.ts +56 -0
- package/dist/resources/imports.js +63 -0
- package/dist/resources/onboarding.d.ts +29 -0
- package/dist/resources/onboarding.js +34 -0
- package/dist/resources/outcome-types.d.ts +25 -0
- package/dist/resources/outcome-types.js +33 -0
- package/dist/resources/reports.d.ts +92 -0
- package/dist/resources/reports.js +120 -0
- package/dist/resources/value-models.d.ts +99 -0
- package/dist/resources/value-models.js +133 -0
- package/dist/resources/workspace.d.ts +15 -0
- package/dist/resources/workspace.js +18 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -1
- package/dist/share.d.ts +52 -0
- package/dist/share.js +60 -0
- package/dist/transport.d.ts +54 -5
- package/dist/transport.js +81 -32
- package/dist/types.d.ts +163 -3
- package/dist/types.js +18 -3
- package/dist/unicode.d.ts +2 -0
- package/dist/unicode.js +11 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,58 @@
|
|
|
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 { Agent, AgentCreate, AgentDetail, AgentList, AgentListItem, AgentPatch, GetAgentQuery, ListAgentsQuery } from "../types.js";
|
|
5
|
+
/** The `agents` operations. */
|
|
6
|
+
export declare class Agents {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: TransportConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Lists agents. Await the result for one page; iterate it with
|
|
11
|
+
* `for await` for every agent 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 `listAgents`.
|
|
21
|
+
*/
|
|
22
|
+
list(query?: ListAgentsQuery, options?: RequestOptions): PagePromise<AgentListItem, AgentList>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an agent.
|
|
25
|
+
*
|
|
26
|
+
* Every attempt of the call sends one `Idempotency-Key`, so a retry
|
|
27
|
+
* cannot create a second agent.
|
|
28
|
+
*
|
|
29
|
+
* Needs the `write` scope. Operation `createAgent`.
|
|
30
|
+
*/
|
|
31
|
+
create(body: AgentCreate, options?: IdempotentRequestOptions): Promise<Agent>;
|
|
32
|
+
/**
|
|
33
|
+
* Reads an agent, with its statistics. `from` and `to` bound the
|
|
34
|
+
* statistics only; absent bounds mean all time.
|
|
35
|
+
*
|
|
36
|
+
* Needs the `read` scope. Operation `getAgent`.
|
|
37
|
+
*/
|
|
38
|
+
get(id: string, query?: GetAgentQuery, options?: RequestOptions): Promise<AgentDetail>;
|
|
39
|
+
/**
|
|
40
|
+
* Updates an agent with a merge patch: a member left out keeps its value,
|
|
41
|
+
* `null` clears it, and any other value sets it.
|
|
42
|
+
*
|
|
43
|
+
* Never retried.
|
|
44
|
+
*
|
|
45
|
+
* Needs the `write` scope. Operation `updateAgent`.
|
|
46
|
+
*/
|
|
47
|
+
update(id: string, patch: AgentPatch, options?: RequestOptions): Promise<Agent>;
|
|
48
|
+
/**
|
|
49
|
+
* Deletes an agent. Refused while events reference the agent; set its
|
|
50
|
+
* status to `retired` instead.
|
|
51
|
+
*
|
|
52
|
+
* A retry after a lost response can answer `404` for a delete that
|
|
53
|
+
* succeeded.
|
|
54
|
+
*
|
|
55
|
+
* Needs the `write` scope. Operation `deleteAgent`.
|
|
56
|
+
*/
|
|
57
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The `agents` operations.
|
|
2
|
+
import { call, callPage } from "../request.js";
|
|
3
|
+
/** The `agents` operations. */
|
|
4
|
+
export class Agents {
|
|
5
|
+
#config;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.#config = config;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Lists agents. Await the result for one page; iterate it with
|
|
11
|
+
* `for await` for every agent 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 `listAgents`.
|
|
21
|
+
*/
|
|
22
|
+
list(query, options) {
|
|
23
|
+
return callPage(this.#config, "listAgents", { query, options });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an agent.
|
|
27
|
+
*
|
|
28
|
+
* Every attempt of the call sends one `Idempotency-Key`, so a retry
|
|
29
|
+
* cannot create a second agent.
|
|
30
|
+
*
|
|
31
|
+
* Needs the `write` scope. Operation `createAgent`.
|
|
32
|
+
*/
|
|
33
|
+
create(body, options) {
|
|
34
|
+
return call(this.#config, "createAgent", { body, options });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reads an agent, with its statistics. `from` and `to` bound the
|
|
38
|
+
* statistics only; absent bounds mean all time.
|
|
39
|
+
*
|
|
40
|
+
* Needs the `read` scope. Operation `getAgent`.
|
|
41
|
+
*/
|
|
42
|
+
get(id, query, options) {
|
|
43
|
+
return call(this.#config, "getAgent", { path: { id }, query, options });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Updates an agent with a merge patch: a member left out keeps its value,
|
|
47
|
+
* `null` clears it, and any other value sets it.
|
|
48
|
+
*
|
|
49
|
+
* Never retried.
|
|
50
|
+
*
|
|
51
|
+
* Needs the `write` scope. Operation `updateAgent`.
|
|
52
|
+
*/
|
|
53
|
+
update(id, patch, options) {
|
|
54
|
+
return call(this.#config, "updateAgent", {
|
|
55
|
+
path: { id },
|
|
56
|
+
body: patch,
|
|
57
|
+
options,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Deletes an agent. Refused while events reference the agent; set its
|
|
62
|
+
* status to `retired` instead.
|
|
63
|
+
*
|
|
64
|
+
* A retry after a lost response can answer `404` for a delete that
|
|
65
|
+
* succeeded.
|
|
66
|
+
*
|
|
67
|
+
* Needs the `write` scope. Operation `deleteAgent`.
|
|
68
|
+
*/
|
|
69
|
+
delete(id, options) {
|
|
70
|
+
return call(this.#config, "deleteAgent", { path: { id }, options });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { RequestOptions } from "../options.js";
|
|
2
|
+
import type { TransportConfig } from "../transport.js";
|
|
3
|
+
import type { Anomalies, ClientCost, ClientValue, GetClientAnomaliesQuery, GetClientCostQuery, GetClientRoiQuery, GetClientValueQuery, RoiResult } from "../types.js";
|
|
4
|
+
/** The `analytics` operations. */
|
|
5
|
+
export declare class Analytics {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: TransportConfig);
|
|
8
|
+
/**
|
|
9
|
+
* Computes a client's value.
|
|
10
|
+
*
|
|
11
|
+
* Needs the `read` scope. Operation `getClientValue`.
|
|
12
|
+
*
|
|
13
|
+
* @param clientId - the client's id.
|
|
14
|
+
*/
|
|
15
|
+
getValueForClient(clientId: string, query?: GetClientValueQuery, options?: RequestOptions): Promise<ClientValue>;
|
|
16
|
+
/**
|
|
17
|
+
* Computes a client's cost over a period. Both bounds are required:
|
|
18
|
+
* standing charges are prorated day by day, so an open `from` would
|
|
19
|
+
* prorate each charge from its own start date, however long ago.
|
|
20
|
+
*
|
|
21
|
+
* Needs the `read` scope. Operation `getClientCost`.
|
|
22
|
+
*
|
|
23
|
+
* @param clientId - the client's id.
|
|
24
|
+
*/
|
|
25
|
+
getCostForClient(clientId: string, query: GetClientCostQuery, options?: RequestOptions): Promise<ClientCost>;
|
|
26
|
+
/**
|
|
27
|
+
* Computes a client's ROI over a period.
|
|
28
|
+
*
|
|
29
|
+
* Needs the `read` scope. Operation `getClientRoi`.
|
|
30
|
+
*
|
|
31
|
+
* @param clientId - the client's id.
|
|
32
|
+
*/
|
|
33
|
+
getRoiForClient(clientId: string, query: GetClientRoiQuery, options?: RequestOptions): Promise<RoiResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Flags anomalies in a client's period.
|
|
36
|
+
*
|
|
37
|
+
* Needs the `read` scope. Operation `getClientAnomalies`.
|
|
38
|
+
*
|
|
39
|
+
* @param clientId - the client's id.
|
|
40
|
+
*/
|
|
41
|
+
getAnomaliesForClient(clientId: string, query: GetClientAnomaliesQuery, options?: RequestOptions): Promise<Anomalies>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The `analytics` operations: a client's value, cost, ROI and anomalies
|
|
2
|
+
// over a period.
|
|
3
|
+
import { call } from "../request.js";
|
|
4
|
+
/** The `analytics` operations. */
|
|
5
|
+
export class Analytics {
|
|
6
|
+
#config;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.#config = config;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Computes a client's value.
|
|
12
|
+
*
|
|
13
|
+
* Needs the `read` scope. Operation `getClientValue`.
|
|
14
|
+
*
|
|
15
|
+
* @param clientId - the client's id.
|
|
16
|
+
*/
|
|
17
|
+
getValueForClient(clientId, query, options) {
|
|
18
|
+
return call(this.#config, "getClientValue", {
|
|
19
|
+
path: { id: clientId },
|
|
20
|
+
query,
|
|
21
|
+
options,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Computes a client's cost over a period. Both bounds are required:
|
|
26
|
+
* standing charges are prorated day by day, so an open `from` would
|
|
27
|
+
* prorate each charge from its own start date, however long ago.
|
|
28
|
+
*
|
|
29
|
+
* Needs the `read` scope. Operation `getClientCost`.
|
|
30
|
+
*
|
|
31
|
+
* @param clientId - the client's id.
|
|
32
|
+
*/
|
|
33
|
+
getCostForClient(clientId, query, options) {
|
|
34
|
+
return call(this.#config, "getClientCost", {
|
|
35
|
+
path: { id: clientId },
|
|
36
|
+
query,
|
|
37
|
+
options,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Computes a client's ROI over a period.
|
|
42
|
+
*
|
|
43
|
+
* Needs the `read` scope. Operation `getClientRoi`.
|
|
44
|
+
*
|
|
45
|
+
* @param clientId - the client's id.
|
|
46
|
+
*/
|
|
47
|
+
getRoiForClient(clientId, query, options) {
|
|
48
|
+
return call(this.#config, "getClientRoi", {
|
|
49
|
+
path: { id: clientId },
|
|
50
|
+
query,
|
|
51
|
+
options,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Flags anomalies in a client's period.
|
|
56
|
+
*
|
|
57
|
+
* Needs the `read` scope. Operation `getClientAnomalies`.
|
|
58
|
+
*
|
|
59
|
+
* @param clientId - the client's id.
|
|
60
|
+
*/
|
|
61
|
+
getAnomaliesForClient(clientId, query, options) {
|
|
62
|
+
return call(this.#config, "getClientAnomalies", {
|
|
63
|
+
path: { id: clientId },
|
|
64
|
+
query,
|
|
65
|
+
options,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RequestOptions } from "../options.js";
|
|
2
|
+
import type { PagePromise } from "../pagination.js";
|
|
3
|
+
import type { TransportConfig } from "../transport.js";
|
|
4
|
+
import type { ApiKey, ApiKeyCreate, ApiKeyList, ApiKeyWithToken, ListApiKeysQuery } from "../types.js";
|
|
5
|
+
/** The `apiKeys` operations. */
|
|
6
|
+
export declare class ApiKeys {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: TransportConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Creates an API key, and returns its complete token once. Store the
|
|
11
|
+
* token at once: no later call returns it, because the API keeps only a
|
|
12
|
+
* hash.
|
|
13
|
+
*
|
|
14
|
+
* Never retried, because a retried create would make a second key. On a
|
|
15
|
+
* `ConnectionError`, list the keys to learn whether it was created.
|
|
16
|
+
*
|
|
17
|
+
* Needs a session token: an API key cannot create a key. An API key is
|
|
18
|
+
* refused with `403` `session_required`, as an `ApiError`.
|
|
19
|
+
*
|
|
20
|
+
* Operation `createApiKey`.
|
|
21
|
+
*/
|
|
22
|
+
create(body: ApiKeyCreate, options?: RequestOptions): Promise<ApiKeyWithToken>;
|
|
23
|
+
/**
|
|
24
|
+
* Lists API keys. Await the result for one page; iterate it with
|
|
25
|
+
* `for await` for every key of every page.
|
|
26
|
+
*
|
|
27
|
+
* Needs a session token. An API key is refused with `403`
|
|
28
|
+
* `session_required`, as an `ApiError`.
|
|
29
|
+
*
|
|
30
|
+
* Operation `listApiKeys`.
|
|
31
|
+
*/
|
|
32
|
+
list(query?: ListApiKeysQuery, options?: RequestOptions): PagePromise<ApiKey, ApiKeyList>;
|
|
33
|
+
/**
|
|
34
|
+
* Reads an API key. Its token is never returned.
|
|
35
|
+
*
|
|
36
|
+
* Needs a session token. An API key is refused with `403`
|
|
37
|
+
* `session_required`, as an `ApiError`.
|
|
38
|
+
*
|
|
39
|
+
* Operation `getApiKey`.
|
|
40
|
+
*/
|
|
41
|
+
get(id: string, options?: RequestOptions): Promise<ApiKey>;
|
|
42
|
+
/**
|
|
43
|
+
* Revokes an API key. The next request bearing the key is refused with
|
|
44
|
+
* `401`.
|
|
45
|
+
*
|
|
46
|
+
* Needs a session token. An API key is refused with `403`
|
|
47
|
+
* `session_required`, as an `ApiError`. Never retried.
|
|
48
|
+
*
|
|
49
|
+
* Operation `revokeApiKey`.
|
|
50
|
+
*
|
|
51
|
+
* @param id - the key's `id`, not its token.
|
|
52
|
+
*/
|
|
53
|
+
revoke(id: string, options?: RequestOptions): Promise<ApiKey>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The `apiKeys` operations: a workspace's API keys, managed with a
|
|
2
|
+
// session token.
|
|
3
|
+
import { call, callPage } from "../request.js";
|
|
4
|
+
/** The `apiKeys` operations. */
|
|
5
|
+
export class ApiKeys {
|
|
6
|
+
#config;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.#config = config;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates an API key, and returns its complete token once. Store the
|
|
12
|
+
* token at once: no later call returns it, because the API keeps only a
|
|
13
|
+
* hash.
|
|
14
|
+
*
|
|
15
|
+
* Never retried, because a retried create would make a second key. On a
|
|
16
|
+
* `ConnectionError`, list the keys to learn whether it was created.
|
|
17
|
+
*
|
|
18
|
+
* Needs a session token: an API key cannot create a key. An API key is
|
|
19
|
+
* refused with `403` `session_required`, as an `ApiError`.
|
|
20
|
+
*
|
|
21
|
+
* Operation `createApiKey`.
|
|
22
|
+
*/
|
|
23
|
+
create(body, options) {
|
|
24
|
+
return call(this.#config, "createApiKey", { body, options });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Lists API keys. Await the result for one page; iterate it with
|
|
28
|
+
* `for await` for every key of every page.
|
|
29
|
+
*
|
|
30
|
+
* Needs a session token. An API key is refused with `403`
|
|
31
|
+
* `session_required`, as an `ApiError`.
|
|
32
|
+
*
|
|
33
|
+
* Operation `listApiKeys`.
|
|
34
|
+
*/
|
|
35
|
+
list(query, options) {
|
|
36
|
+
return callPage(this.#config, "listApiKeys", { query, options });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reads an API key. Its token is never returned.
|
|
40
|
+
*
|
|
41
|
+
* Needs a session token. An API key is refused with `403`
|
|
42
|
+
* `session_required`, as an `ApiError`.
|
|
43
|
+
*
|
|
44
|
+
* Operation `getApiKey`.
|
|
45
|
+
*/
|
|
46
|
+
get(id, options) {
|
|
47
|
+
return call(this.#config, "getApiKey", { path: { id }, options });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Revokes an API key. The next request bearing the key is refused with
|
|
51
|
+
* `401`.
|
|
52
|
+
*
|
|
53
|
+
* Needs a session token. An API key is refused with `403`
|
|
54
|
+
* `session_required`, as an `ApiError`. Never retried.
|
|
55
|
+
*
|
|
56
|
+
* Operation `revokeApiKey`.
|
|
57
|
+
*
|
|
58
|
+
* @param id - the key's `id`, not its token.
|
|
59
|
+
*/
|
|
60
|
+
revoke(id, options) {
|
|
61
|
+
return call(this.#config, "revokeApiKey", { path: { id }, options });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { Calculation, CalculationCreate, CalculationList, CalculationSummary, ChecklistInput, ListCalculationsQuery, ListClientCalculationsQuery, WorkspaceCalculationList } from "../types.js";
|
|
5
|
+
/** The `calculations` operations. */
|
|
6
|
+
export declare class Calculations {
|
|
7
|
+
#private;
|
|
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>;
|
|
29
|
+
/**
|
|
30
|
+
* Freezes a client's ROI for an ended period as a draft calculation. An
|
|
31
|
+
* API key with the `write` scope may create a draft; validating and
|
|
32
|
+
* publishing it need a session token.
|
|
33
|
+
*
|
|
34
|
+
* Every attempt of the call sends one `Idempotency-Key`, so a retry
|
|
35
|
+
* cannot create a second calculation.
|
|
36
|
+
*
|
|
37
|
+
* Needs the `write` scope. Operation `createCalculation`.
|
|
38
|
+
*
|
|
39
|
+
* @param clientId - the client's id.
|
|
40
|
+
*/
|
|
41
|
+
createForClient(clientId: string, body: CalculationCreate, options?: IdempotentRequestOptions): Promise<Calculation>;
|
|
42
|
+
/**
|
|
43
|
+
* Lists a client's calculations. Await the result for one page; iterate
|
|
44
|
+
* it with `for await` for every calculation of every page.
|
|
45
|
+
*
|
|
46
|
+
* Needs the `read` scope. Operation `listClientCalculations`.
|
|
47
|
+
*
|
|
48
|
+
* @param clientId - the client's id.
|
|
49
|
+
*/
|
|
50
|
+
listForClient(clientId: string, query?: ListClientCalculationsQuery, options?: RequestOptions): PagePromise<CalculationSummary, CalculationList>;
|
|
51
|
+
/**
|
|
52
|
+
* Reads a calculation.
|
|
53
|
+
*
|
|
54
|
+
* Needs the `read` scope. Operation `getCalculation`.
|
|
55
|
+
*/
|
|
56
|
+
get(id: string, options?: RequestOptions): Promise<Calculation>;
|
|
57
|
+
/**
|
|
58
|
+
* Deletes a draft calculation.
|
|
59
|
+
*
|
|
60
|
+
* A retry after a lost response can answer `404` for a delete that
|
|
61
|
+
* succeeded.
|
|
62
|
+
*
|
|
63
|
+
* Needs the `write` scope. Operation `deleteCalculation`.
|
|
64
|
+
*/
|
|
65
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Validates a calculation: records the validation checklist, an
|
|
68
|
+
* attestation that the figures were reviewed, and moves a draft to
|
|
69
|
+
* `validated`.
|
|
70
|
+
*
|
|
71
|
+
* Needs a session token: validation is a human attestation. An API key
|
|
72
|
+
* is refused with `403` `session_required`, as an `ApiError`. Never
|
|
73
|
+
* retried.
|
|
74
|
+
*
|
|
75
|
+
* Operation `validateCalculation`.
|
|
76
|
+
*/
|
|
77
|
+
validate(id: string, body: ChecklistInput, options?: RequestOptions): Promise<Calculation>;
|
|
78
|
+
/**
|
|
79
|
+
* Publishes a calculation: moves a validated calculation to `published`.
|
|
80
|
+
* Publication is terminal.
|
|
81
|
+
*
|
|
82
|
+
* Needs a session token: publishing is a human trust step. An API key is
|
|
83
|
+
* refused with `403` `session_required`, as an `ApiError`. Never retried.
|
|
84
|
+
*
|
|
85
|
+
* Operation `publishCalculation`.
|
|
86
|
+
*/
|
|
87
|
+
publish(id: string, options?: RequestOptions): Promise<Calculation>;
|
|
88
|
+
/**
|
|
89
|
+
* Reopens a calculation: moves a validated calculation back to `draft`,
|
|
90
|
+
* clearing its attestation.
|
|
91
|
+
*
|
|
92
|
+
* Needs a session token: it undoes a human trust step. An API key is
|
|
93
|
+
* refused with `403` `session_required`, as an `ApiError`. Never retried.
|
|
94
|
+
*
|
|
95
|
+
* Operation `reopenCalculation`.
|
|
96
|
+
*/
|
|
97
|
+
reopen(id: string, options?: RequestOptions): Promise<Calculation>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// The `calculations` operations: a client's frozen ROI for a period, and
|
|
2
|
+
// the human steps that validate, publish and reopen it.
|
|
3
|
+
import { call, callPage } from "../request.js";
|
|
4
|
+
/** The `calculations` operations. */
|
|
5
|
+
export class Calculations {
|
|
6
|
+
#config;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.#config = config;
|
|
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
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Freezes a client's ROI for an ended period as a draft calculation. An
|
|
34
|
+
* API key with the `write` scope may create a draft; validating and
|
|
35
|
+
* publishing it need a session token.
|
|
36
|
+
*
|
|
37
|
+
* Every attempt of the call sends one `Idempotency-Key`, so a retry
|
|
38
|
+
* cannot create a second calculation.
|
|
39
|
+
*
|
|
40
|
+
* Needs the `write` scope. Operation `createCalculation`.
|
|
41
|
+
*
|
|
42
|
+
* @param clientId - the client's id.
|
|
43
|
+
*/
|
|
44
|
+
createForClient(clientId, body, options) {
|
|
45
|
+
return call(this.#config, "createCalculation", {
|
|
46
|
+
path: { id: clientId },
|
|
47
|
+
body,
|
|
48
|
+
options,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Lists a client's calculations. Await the result for one page; iterate
|
|
53
|
+
* it with `for await` for every calculation of every page.
|
|
54
|
+
*
|
|
55
|
+
* Needs the `read` scope. Operation `listClientCalculations`.
|
|
56
|
+
*
|
|
57
|
+
* @param clientId - the client's id.
|
|
58
|
+
*/
|
|
59
|
+
listForClient(clientId, query, options) {
|
|
60
|
+
return callPage(this.#config, "listClientCalculations", {
|
|
61
|
+
path: { id: clientId },
|
|
62
|
+
query,
|
|
63
|
+
options,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Reads a calculation.
|
|
68
|
+
*
|
|
69
|
+
* Needs the `read` scope. Operation `getCalculation`.
|
|
70
|
+
*/
|
|
71
|
+
get(id, options) {
|
|
72
|
+
return call(this.#config, "getCalculation", { path: { id }, options });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Deletes a draft calculation.
|
|
76
|
+
*
|
|
77
|
+
* A retry after a lost response can answer `404` for a delete that
|
|
78
|
+
* succeeded.
|
|
79
|
+
*
|
|
80
|
+
* Needs the `write` scope. Operation `deleteCalculation`.
|
|
81
|
+
*/
|
|
82
|
+
delete(id, options) {
|
|
83
|
+
return call(this.#config, "deleteCalculation", { path: { id }, options });
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validates a calculation: records the validation checklist, an
|
|
87
|
+
* attestation that the figures were reviewed, and moves a draft to
|
|
88
|
+
* `validated`.
|
|
89
|
+
*
|
|
90
|
+
* Needs a session token: validation is a human attestation. An API key
|
|
91
|
+
* is refused with `403` `session_required`, as an `ApiError`. Never
|
|
92
|
+
* retried.
|
|
93
|
+
*
|
|
94
|
+
* Operation `validateCalculation`.
|
|
95
|
+
*/
|
|
96
|
+
validate(id, body, options) {
|
|
97
|
+
return call(this.#config, "validateCalculation", {
|
|
98
|
+
path: { id },
|
|
99
|
+
body,
|
|
100
|
+
options,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Publishes a calculation: moves a validated calculation to `published`.
|
|
105
|
+
* Publication is terminal.
|
|
106
|
+
*
|
|
107
|
+
* Needs a session token: publishing is a human trust step. An API key is
|
|
108
|
+
* refused with `403` `session_required`, as an `ApiError`. Never retried.
|
|
109
|
+
*
|
|
110
|
+
* Operation `publishCalculation`.
|
|
111
|
+
*/
|
|
112
|
+
publish(id, options) {
|
|
113
|
+
return call(this.#config, "publishCalculation", {
|
|
114
|
+
path: { id },
|
|
115
|
+
options,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Reopens a calculation: moves a validated calculation back to `draft`,
|
|
120
|
+
* clearing its attestation.
|
|
121
|
+
*
|
|
122
|
+
* Needs a session token: it undoes a human trust step. An API key is
|
|
123
|
+
* refused with `403` `session_required`, as an `ApiError`. Never retried.
|
|
124
|
+
*
|
|
125
|
+
* Operation `reopenCalculation`.
|
|
126
|
+
*/
|
|
127
|
+
reopen(id, options) {
|
|
128
|
+
return call(this.#config, "reopenCalculation", {
|
|
129
|
+
path: { id },
|
|
130
|
+
options,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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 { Client, ClientAgents, ClientAgentsSet, ClientCreate, ClientDetail, ClientList, ClientPatch, ListClientsQuery } from "../types.js";
|
|
5
|
+
/** The `clients` operations. */
|
|
6
|
+
export declare class Clients {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: TransportConfig);
|
|
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?: ListClientsQuery, options?: RequestOptions): PagePromise<Client, ClientList>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a client.
|
|
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
|
+
*
|
|
35
|
+
* Every attempt of the call sends one `Idempotency-Key`, so a retry
|
|
36
|
+
* cannot create a second client.
|
|
37
|
+
*
|
|
38
|
+
* Needs the `write` scope. Operation `createClient`.
|
|
39
|
+
*/
|
|
40
|
+
create(body: ClientCreate, options?: IdempotentRequestOptions): Promise<Client>;
|
|
41
|
+
/**
|
|
42
|
+
* Reads a client.
|
|
43
|
+
*
|
|
44
|
+
* Needs the `read` scope. Operation `getClient`.
|
|
45
|
+
*/
|
|
46
|
+
get(id: string, options?: RequestOptions): Promise<ClientDetail>;
|
|
47
|
+
/**
|
|
48
|
+
* Updates a client with a merge patch: a member left out keeps its
|
|
49
|
+
* value, `null` clears it, and any other value sets it.
|
|
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
|
+
*
|
|
63
|
+
* Never retried.
|
|
64
|
+
*
|
|
65
|
+
* Needs the `write` scope. Operation `updateClient`.
|
|
66
|
+
*/
|
|
67
|
+
update(id: string, patch: ClientPatch, options?: RequestOptions): Promise<Client>;
|
|
68
|
+
/**
|
|
69
|
+
* Deletes a client. Refused while events carry the client's key, or
|
|
70
|
+
* while the client has a validated or published calculation; set its
|
|
71
|
+
* status to `churned` instead.
|
|
72
|
+
*
|
|
73
|
+
* A retry after a lost response can answer `404` for a delete that
|
|
74
|
+
* succeeded.
|
|
75
|
+
*
|
|
76
|
+
* Needs the `write` scope. Operation `deleteClient`.
|
|
77
|
+
*/
|
|
78
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Replaces a client's assigned agents. Assignment decides how later
|
|
81
|
+
* events are attributed: an event without `client_key` from an agent
|
|
82
|
+
* assigned to exactly one client is attributed to that client. A
|
|
83
|
+
* `model` or `outcome` event from an agent assigned to two or more
|
|
84
|
+
* clients must carry `client_key`, or it is refused with
|
|
85
|
+
* `client_key_required`.
|
|
86
|
+
*
|
|
87
|
+
* Retried on a failure worth retrying, because a repeat leaves the same
|
|
88
|
+
* agents assigned.
|
|
89
|
+
*
|
|
90
|
+
* Needs the `write` scope. Operation `setClientAgents`.
|
|
91
|
+
*/
|
|
92
|
+
setAgents(id: string, body: ClientAgentsSet, options?: RequestOptions): Promise<ClientAgents>;
|
|
93
|
+
}
|