@intelligence-cloud/sdk 0.2.0 → 0.3.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/CHANGELOG.md +47 -0
- package/README.md +290 -48
- package/dist/index.cjs +1610 -871
- package/dist/index.d.cts +682 -5128
- package/dist/index.d.ts +682 -5128
- package/dist/index.js +1608 -872
- package/dist/testing.cjs +1271 -0
- package/dist/testing.d.cts +209 -0
- package/dist/testing.d.ts +209 -0
- package/dist/testing.js +1263 -0
- package/package.json +19 -2
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { IntelligenceClientOptions, Client, Customer } from '@intelligence-cloud/sdk';
|
|
2
|
+
|
|
3
|
+
declare const RESELLER = "00000000-0000-4000-8000-0000000000aa";
|
|
4
|
+
declare const VERTICAL = "00000000-0000-4000-8000-0000000000bb";
|
|
5
|
+
declare const CONNECTOR_OUTCOMES: readonly ["active", "connected", "error", "stuck"];
|
|
6
|
+
type ConnectorOutcome = (typeof CONNECTOR_OUTCOMES)[number] | "connecting";
|
|
7
|
+
declare const NETWORK_FAILURES: readonly ["connect", "read_timeout", "write_timeout", "undecodable", "reset"];
|
|
8
|
+
type NetworkFailure = (typeof NETWORK_FAILURES)[number];
|
|
9
|
+
declare const SIGN_IN_OUTCOMES: readonly ["mfa_required", "password_expired", "invalid_credentials"];
|
|
10
|
+
type SignInOutcome = (typeof SIGN_IN_OUTCOMES)[number];
|
|
11
|
+
/** A fresh fictional id (UUID shaped). */
|
|
12
|
+
declare function newId(): string;
|
|
13
|
+
/** One request the fake received, whatever answered it (sign-in and token renewal are in `authLog` instead). */
|
|
14
|
+
interface FakeRequest {
|
|
15
|
+
method: string;
|
|
16
|
+
/** Without the /api/v1 prefix. */
|
|
17
|
+
path: string;
|
|
18
|
+
query: Record<string, string>;
|
|
19
|
+
body: any;
|
|
20
|
+
/** The operationId it matched in the published spec, or null. */
|
|
21
|
+
operation: string | null;
|
|
22
|
+
/** The HTTP status it got, or "network:connect" | "network:read_timeout" | ... */
|
|
23
|
+
answer: number | string | null;
|
|
24
|
+
}
|
|
25
|
+
/** One person `seedCustomer` created: sign in as them with `client({ role: "user", asUser })`. */
|
|
26
|
+
interface SeededPerson {
|
|
27
|
+
userId: string;
|
|
28
|
+
email: string;
|
|
29
|
+
license: "base_user" | "base_manager";
|
|
30
|
+
/** Location ids of their teams (Management not listed). */
|
|
31
|
+
teams: string[];
|
|
32
|
+
lines: string[];
|
|
33
|
+
}
|
|
34
|
+
/** What `FakeAPI.seedCustomer` built: the customer and the people's ids by email. */
|
|
35
|
+
interface SeededCustomer {
|
|
36
|
+
customer: Customer;
|
|
37
|
+
companyId: string;
|
|
38
|
+
baseUsers: Record<string, string>;
|
|
39
|
+
managers: Record<string, string>;
|
|
40
|
+
/** Everyone seeded, with license, teams and lines. */
|
|
41
|
+
people: SeededPerson[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An in-memory Intelligence Cloud API for tests and CI. Use `client()` to get a real `Client` wired to it.
|
|
45
|
+
*
|
|
46
|
+
* It behaves like the API where it matters to callers: products, groups and alert email preferences are
|
|
47
|
+
* per location; number mappings are company-wide with one extension per location (409 otherwise); new
|
|
48
|
+
* users start with alert email on; connectors settle in the background; a duplicate email is 409; access
|
|
49
|
+
* tokens expire and are renewed; and sending a refresh token a second time ends every session of that
|
|
50
|
+
* login, as on the platform (the old access token stops working; the next call signs in).
|
|
51
|
+
*
|
|
52
|
+
* Strict mode (`strict: true`, the default) refuses, with the API's error shape: a path or method the
|
|
53
|
+
* published spec does not define (404); a query parameter it does not define, or a query value of the
|
|
54
|
+
* wrong type, outside its enum or not in its format (400); a body missing a required top-level field, with
|
|
55
|
+
* a top-level field the spec does not define, or with a top-level field of the wrong JSON type, outside its
|
|
56
|
+
* enum or not in its format; for a list, each item's type, enum and format (422). It does not check nested
|
|
57
|
+
* objects, rules that join several fields, or how the platform searches and sorts; its data is simpler than
|
|
58
|
+
* the platform's. Run once against a test company before release.
|
|
59
|
+
*
|
|
60
|
+
* Supported surface (everything else is internal and may change): the constructor, `client`,
|
|
61
|
+
* `seedCustomer`, `seedCalls`, `connectorOutcome`, `settleConnector`, `failNext`, `failWrite`, `networkDown`, `rateLimit`,
|
|
62
|
+
* `expireAccessTokens`, the request log (`requests`, `writes`, `writesSince`, `count`, `resetLog`,
|
|
63
|
+
* `authLog`) and the readers `products`, `numbers`, `faNumbers`, `ihNumbers`, `groupMembers`.
|
|
64
|
+
*/
|
|
65
|
+
declare class FakeAPI {
|
|
66
|
+
/** Every request so far, oldest first, with what answered it (sign-in and token renewal are in `authLog`). */
|
|
67
|
+
readonly requests: FakeRequest[];
|
|
68
|
+
/** What a new connector turns into: `active`, `connected`, `error`, or `stuck` (never settles). */
|
|
69
|
+
connectorOutcome: ConnectorOutcome;
|
|
70
|
+
private readonly _strict;
|
|
71
|
+
private _clockN;
|
|
72
|
+
private _access;
|
|
73
|
+
private _refresh;
|
|
74
|
+
private _usedRefresh;
|
|
75
|
+
private _logins;
|
|
76
|
+
private _tokenN;
|
|
77
|
+
private _requestRole;
|
|
78
|
+
private _requestEmail;
|
|
79
|
+
private _failAt;
|
|
80
|
+
private _nextFailures;
|
|
81
|
+
private _down;
|
|
82
|
+
private _limited;
|
|
83
|
+
private readonly _ops;
|
|
84
|
+
private readonly _routes;
|
|
85
|
+
constructor(options?: {
|
|
86
|
+
connectorOutcome?: ConnectorOutcome;
|
|
87
|
+
role?: "admin" | "user";
|
|
88
|
+
strict?: boolean;
|
|
89
|
+
});
|
|
90
|
+
/** The fake holds connector keys and passwords in its state: it prints as a summary, never as that state. */
|
|
91
|
+
toJSON(): unknown;
|
|
92
|
+
/**
|
|
93
|
+
* A real Client wired to this fake. `role`: "admin" (an administrator login) or "user" (a person's own
|
|
94
|
+
* login); default the role given to FakeAPI. `asUser` (with role "user"): the user id or email of a person
|
|
95
|
+
* `seedCustomer` created; the client signs in as them, so the calls, alerts, tasks and Insights Hub it sees
|
|
96
|
+
* follow their license and teams. Clients for the same person share that login's sessions. Other options go to Client, for example `maskNumbers: false`.
|
|
97
|
+
* Waits (retries, connector checks) do not sleep unless you pass `sleep`.
|
|
98
|
+
*/
|
|
99
|
+
client(options?: {
|
|
100
|
+
role?: "admin" | "user";
|
|
101
|
+
asUser?: string;
|
|
102
|
+
} & Omit<IntelligenceClientOptions, "email" | "password" | "fetch">): Client;
|
|
103
|
+
/** Every write request so far as `[method, path]`, oldest first. */
|
|
104
|
+
get writes(): [string, string][];
|
|
105
|
+
/** The writes after `start` (an index into `requests`, e.g. `api.requests.length`). */
|
|
106
|
+
writesSince(start?: number): [string, string][];
|
|
107
|
+
/**
|
|
108
|
+
* Sign-in and token renewal, oldest first: `["login" | "refresh" | "refresh_reused", email]`.
|
|
109
|
+
* "refresh_reused" means a used refresh token was sent again and every session of that login ended.
|
|
110
|
+
*/
|
|
111
|
+
get authLog(): [string, string][];
|
|
112
|
+
/** How many requests matched `method` and the path pattern (a regex without /api/v1, anchored). */
|
|
113
|
+
count(method: string, pattern: string | RegExp): number;
|
|
114
|
+
/** Forget the request log and the auth log (state is kept). */
|
|
115
|
+
resetLog(): void;
|
|
116
|
+
/** Make the `nth` write from now (1 = the next one) fail once with `status`. */
|
|
117
|
+
failWrite(nth?: number, status?: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* Make the next request that matches `method` and the path pattern `path` (without /api/v1; sign-in is
|
|
120
|
+
* "/auth/login", renewal "/auth/refresh") fail once: with HTTP `status`, or with a `network` failure:
|
|
121
|
+
* "connect" (never left), "read_timeout", "write_timeout" or "reset" (left, no answer), or "undecodable" (an
|
|
122
|
+
* answer that cannot be read). A status answers before the platform acts (a renewal's token is
|
|
123
|
+
* not used); with `afterProcessing: true` it answers after the token was rotated, as a gateway error would. A
|
|
124
|
+
* renewal that fails with a network failure other than "connect" has used its refresh token.
|
|
125
|
+
* `signIn`: the next sign-in answers "mfa_required" (MfaRequiredError), "password_expired"
|
|
126
|
+
* (PasswordExpiredError) or "invalid_credentials" (AuthError, 401).
|
|
127
|
+
*/
|
|
128
|
+
failNext(options: {
|
|
129
|
+
status?: number;
|
|
130
|
+
network?: NetworkFailure;
|
|
131
|
+
signIn?: SignInOutcome;
|
|
132
|
+
method?: string;
|
|
133
|
+
path?: string;
|
|
134
|
+
retryAfter?: number;
|
|
135
|
+
afterProcessing?: boolean;
|
|
136
|
+
}): void;
|
|
137
|
+
/** Every request fails as if there were no network (the client throws NetworkError). */
|
|
138
|
+
networkDown(down?: boolean): void;
|
|
139
|
+
/** The next `count` requests (sign-in included) answer 429 with `Retry-After`. */
|
|
140
|
+
rateLimit(count?: number, retryAfter?: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Settle connectors that are waiting ("connecting"): the one with this id, or every waiting one at this
|
|
143
|
+
* location. `outcome`: "active", "connected" or "error". Returns how many were settled.
|
|
144
|
+
*/
|
|
145
|
+
settleConnector(connectorOrLocation: string, outcome?: "active" | "connected" | "error"): number;
|
|
146
|
+
/** Every access token stops working, as when they expire: the next call renews its token. */
|
|
147
|
+
expireAccessTokens(): void;
|
|
148
|
+
private _on;
|
|
149
|
+
private _operation;
|
|
150
|
+
private _checkStrict;
|
|
151
|
+
private _endSessions;
|
|
152
|
+
/** Use a refresh token once. A second use ends every session of its login. */
|
|
153
|
+
private _useRefresh;
|
|
154
|
+
private _takeFailure;
|
|
155
|
+
/** A network failure, with the shape Node's fetch (undici) gives: TypeError "fetch failed" whose cause is the underlying error. */
|
|
156
|
+
private _net;
|
|
157
|
+
private _failureResponse;
|
|
158
|
+
private _serve;
|
|
159
|
+
/**
|
|
160
|
+
* Build "Riverbend Auto Group" through the account layer: `teams` teams with connectors, the Management
|
|
161
|
+
* location, groups and the Low Sentiment alert (the phrase alerts stay pending: the fake holds no phrase
|
|
162
|
+
* lists). With `people`, two Base Users per team and one Base Manager on every team. The request log is
|
|
163
|
+
* cleared afterwards.
|
|
164
|
+
*/
|
|
165
|
+
seedCustomer(options?: {
|
|
166
|
+
teams?: number;
|
|
167
|
+
people?: boolean;
|
|
168
|
+
}): Promise<SeededCustomer>;
|
|
169
|
+
/**
|
|
170
|
+
* Add `n` fictional calls (today, or on `day`) for user logins to read, each with a detail record, an
|
|
171
|
+
* open task and, for every other call, an "Upset Customer" alert. Callers use 555-01xx numbers; each call
|
|
172
|
+
* reaches a seeded Base User's line at that location in turn (so a person signed in with `asUser` sees
|
|
173
|
+
* their own). `recording`: each call has a recording link (an example.com https address that expires in
|
|
174
|
+
* two hours). `topics`: topic volumes and rising topics for `topics()` and the Insights Hub dashboard.
|
|
175
|
+
* Returns the call ids, newest first.
|
|
176
|
+
*/
|
|
177
|
+
seedCalls(n?: number, options?: {
|
|
178
|
+
locationId?: string;
|
|
179
|
+
day?: Date | string;
|
|
180
|
+
alerts?: boolean;
|
|
181
|
+
tasks?: boolean;
|
|
182
|
+
recording?: boolean;
|
|
183
|
+
topics?: boolean;
|
|
184
|
+
}): string[];
|
|
185
|
+
private _locationUsers;
|
|
186
|
+
/** The products a user has at a location. */
|
|
187
|
+
products(uid: string, lid: string): Set<string>;
|
|
188
|
+
/** The numbers mapped to a user (on one connector, or on all). */
|
|
189
|
+
numbers(uid: string, connectorId?: string): string[];
|
|
190
|
+
/** The lines First Alert watches at a location. */
|
|
191
|
+
faNumbers(lid: string): string[];
|
|
192
|
+
/** The lines Insights Hub covers at a location. */
|
|
193
|
+
ihNumbers(lid: string): string[];
|
|
194
|
+
/** The user ids in the named group at a location. */
|
|
195
|
+
groupMembers(lid: string, name: string): string[];
|
|
196
|
+
/** The seeded person this request signed in as (`client({ asUser })`), or null for a generic login. */
|
|
197
|
+
private _viewer;
|
|
198
|
+
/** Locations where the person is in an alert group (a manager of that team). */
|
|
199
|
+
private _alertLocations;
|
|
200
|
+
/** What the platform shows a person: a manager their teams' calls, a Base User their own lines' calls. */
|
|
201
|
+
private _inScope;
|
|
202
|
+
private _alertInScope;
|
|
203
|
+
private _paged;
|
|
204
|
+
private _userAttrs;
|
|
205
|
+
private _locUser;
|
|
206
|
+
private _register;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { CONNECTOR_OUTCOMES, type ConnectorOutcome, FakeAPI, type FakeRequest, NETWORK_FAILURES, type NetworkFailure, RESELLER, SIGN_IN_OUTCOMES, type SeededCustomer, type SeededPerson, type SignInOutcome, VERTICAL, newId };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { IntelligenceClientOptions, Client, Customer } from '@intelligence-cloud/sdk';
|
|
2
|
+
|
|
3
|
+
declare const RESELLER = "00000000-0000-4000-8000-0000000000aa";
|
|
4
|
+
declare const VERTICAL = "00000000-0000-4000-8000-0000000000bb";
|
|
5
|
+
declare const CONNECTOR_OUTCOMES: readonly ["active", "connected", "error", "stuck"];
|
|
6
|
+
type ConnectorOutcome = (typeof CONNECTOR_OUTCOMES)[number] | "connecting";
|
|
7
|
+
declare const NETWORK_FAILURES: readonly ["connect", "read_timeout", "write_timeout", "undecodable", "reset"];
|
|
8
|
+
type NetworkFailure = (typeof NETWORK_FAILURES)[number];
|
|
9
|
+
declare const SIGN_IN_OUTCOMES: readonly ["mfa_required", "password_expired", "invalid_credentials"];
|
|
10
|
+
type SignInOutcome = (typeof SIGN_IN_OUTCOMES)[number];
|
|
11
|
+
/** A fresh fictional id (UUID shaped). */
|
|
12
|
+
declare function newId(): string;
|
|
13
|
+
/** One request the fake received, whatever answered it (sign-in and token renewal are in `authLog` instead). */
|
|
14
|
+
interface FakeRequest {
|
|
15
|
+
method: string;
|
|
16
|
+
/** Without the /api/v1 prefix. */
|
|
17
|
+
path: string;
|
|
18
|
+
query: Record<string, string>;
|
|
19
|
+
body: any;
|
|
20
|
+
/** The operationId it matched in the published spec, or null. */
|
|
21
|
+
operation: string | null;
|
|
22
|
+
/** The HTTP status it got, or "network:connect" | "network:read_timeout" | ... */
|
|
23
|
+
answer: number | string | null;
|
|
24
|
+
}
|
|
25
|
+
/** One person `seedCustomer` created: sign in as them with `client({ role: "user", asUser })`. */
|
|
26
|
+
interface SeededPerson {
|
|
27
|
+
userId: string;
|
|
28
|
+
email: string;
|
|
29
|
+
license: "base_user" | "base_manager";
|
|
30
|
+
/** Location ids of their teams (Management not listed). */
|
|
31
|
+
teams: string[];
|
|
32
|
+
lines: string[];
|
|
33
|
+
}
|
|
34
|
+
/** What `FakeAPI.seedCustomer` built: the customer and the people's ids by email. */
|
|
35
|
+
interface SeededCustomer {
|
|
36
|
+
customer: Customer;
|
|
37
|
+
companyId: string;
|
|
38
|
+
baseUsers: Record<string, string>;
|
|
39
|
+
managers: Record<string, string>;
|
|
40
|
+
/** Everyone seeded, with license, teams and lines. */
|
|
41
|
+
people: SeededPerson[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An in-memory Intelligence Cloud API for tests and CI. Use `client()` to get a real `Client` wired to it.
|
|
45
|
+
*
|
|
46
|
+
* It behaves like the API where it matters to callers: products, groups and alert email preferences are
|
|
47
|
+
* per location; number mappings are company-wide with one extension per location (409 otherwise); new
|
|
48
|
+
* users start with alert email on; connectors settle in the background; a duplicate email is 409; access
|
|
49
|
+
* tokens expire and are renewed; and sending a refresh token a second time ends every session of that
|
|
50
|
+
* login, as on the platform (the old access token stops working; the next call signs in).
|
|
51
|
+
*
|
|
52
|
+
* Strict mode (`strict: true`, the default) refuses, with the API's error shape: a path or method the
|
|
53
|
+
* published spec does not define (404); a query parameter it does not define, or a query value of the
|
|
54
|
+
* wrong type, outside its enum or not in its format (400); a body missing a required top-level field, with
|
|
55
|
+
* a top-level field the spec does not define, or with a top-level field of the wrong JSON type, outside its
|
|
56
|
+
* enum or not in its format; for a list, each item's type, enum and format (422). It does not check nested
|
|
57
|
+
* objects, rules that join several fields, or how the platform searches and sorts; its data is simpler than
|
|
58
|
+
* the platform's. Run once against a test company before release.
|
|
59
|
+
*
|
|
60
|
+
* Supported surface (everything else is internal and may change): the constructor, `client`,
|
|
61
|
+
* `seedCustomer`, `seedCalls`, `connectorOutcome`, `settleConnector`, `failNext`, `failWrite`, `networkDown`, `rateLimit`,
|
|
62
|
+
* `expireAccessTokens`, the request log (`requests`, `writes`, `writesSince`, `count`, `resetLog`,
|
|
63
|
+
* `authLog`) and the readers `products`, `numbers`, `faNumbers`, `ihNumbers`, `groupMembers`.
|
|
64
|
+
*/
|
|
65
|
+
declare class FakeAPI {
|
|
66
|
+
/** Every request so far, oldest first, with what answered it (sign-in and token renewal are in `authLog`). */
|
|
67
|
+
readonly requests: FakeRequest[];
|
|
68
|
+
/** What a new connector turns into: `active`, `connected`, `error`, or `stuck` (never settles). */
|
|
69
|
+
connectorOutcome: ConnectorOutcome;
|
|
70
|
+
private readonly _strict;
|
|
71
|
+
private _clockN;
|
|
72
|
+
private _access;
|
|
73
|
+
private _refresh;
|
|
74
|
+
private _usedRefresh;
|
|
75
|
+
private _logins;
|
|
76
|
+
private _tokenN;
|
|
77
|
+
private _requestRole;
|
|
78
|
+
private _requestEmail;
|
|
79
|
+
private _failAt;
|
|
80
|
+
private _nextFailures;
|
|
81
|
+
private _down;
|
|
82
|
+
private _limited;
|
|
83
|
+
private readonly _ops;
|
|
84
|
+
private readonly _routes;
|
|
85
|
+
constructor(options?: {
|
|
86
|
+
connectorOutcome?: ConnectorOutcome;
|
|
87
|
+
role?: "admin" | "user";
|
|
88
|
+
strict?: boolean;
|
|
89
|
+
});
|
|
90
|
+
/** The fake holds connector keys and passwords in its state: it prints as a summary, never as that state. */
|
|
91
|
+
toJSON(): unknown;
|
|
92
|
+
/**
|
|
93
|
+
* A real Client wired to this fake. `role`: "admin" (an administrator login) or "user" (a person's own
|
|
94
|
+
* login); default the role given to FakeAPI. `asUser` (with role "user"): the user id or email of a person
|
|
95
|
+
* `seedCustomer` created; the client signs in as them, so the calls, alerts, tasks and Insights Hub it sees
|
|
96
|
+
* follow their license and teams. Clients for the same person share that login's sessions. Other options go to Client, for example `maskNumbers: false`.
|
|
97
|
+
* Waits (retries, connector checks) do not sleep unless you pass `sleep`.
|
|
98
|
+
*/
|
|
99
|
+
client(options?: {
|
|
100
|
+
role?: "admin" | "user";
|
|
101
|
+
asUser?: string;
|
|
102
|
+
} & Omit<IntelligenceClientOptions, "email" | "password" | "fetch">): Client;
|
|
103
|
+
/** Every write request so far as `[method, path]`, oldest first. */
|
|
104
|
+
get writes(): [string, string][];
|
|
105
|
+
/** The writes after `start` (an index into `requests`, e.g. `api.requests.length`). */
|
|
106
|
+
writesSince(start?: number): [string, string][];
|
|
107
|
+
/**
|
|
108
|
+
* Sign-in and token renewal, oldest first: `["login" | "refresh" | "refresh_reused", email]`.
|
|
109
|
+
* "refresh_reused" means a used refresh token was sent again and every session of that login ended.
|
|
110
|
+
*/
|
|
111
|
+
get authLog(): [string, string][];
|
|
112
|
+
/** How many requests matched `method` and the path pattern (a regex without /api/v1, anchored). */
|
|
113
|
+
count(method: string, pattern: string | RegExp): number;
|
|
114
|
+
/** Forget the request log and the auth log (state is kept). */
|
|
115
|
+
resetLog(): void;
|
|
116
|
+
/** Make the `nth` write from now (1 = the next one) fail once with `status`. */
|
|
117
|
+
failWrite(nth?: number, status?: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* Make the next request that matches `method` and the path pattern `path` (without /api/v1; sign-in is
|
|
120
|
+
* "/auth/login", renewal "/auth/refresh") fail once: with HTTP `status`, or with a `network` failure:
|
|
121
|
+
* "connect" (never left), "read_timeout", "write_timeout" or "reset" (left, no answer), or "undecodable" (an
|
|
122
|
+
* answer that cannot be read). A status answers before the platform acts (a renewal's token is
|
|
123
|
+
* not used); with `afterProcessing: true` it answers after the token was rotated, as a gateway error would. A
|
|
124
|
+
* renewal that fails with a network failure other than "connect" has used its refresh token.
|
|
125
|
+
* `signIn`: the next sign-in answers "mfa_required" (MfaRequiredError), "password_expired"
|
|
126
|
+
* (PasswordExpiredError) or "invalid_credentials" (AuthError, 401).
|
|
127
|
+
*/
|
|
128
|
+
failNext(options: {
|
|
129
|
+
status?: number;
|
|
130
|
+
network?: NetworkFailure;
|
|
131
|
+
signIn?: SignInOutcome;
|
|
132
|
+
method?: string;
|
|
133
|
+
path?: string;
|
|
134
|
+
retryAfter?: number;
|
|
135
|
+
afterProcessing?: boolean;
|
|
136
|
+
}): void;
|
|
137
|
+
/** Every request fails as if there were no network (the client throws NetworkError). */
|
|
138
|
+
networkDown(down?: boolean): void;
|
|
139
|
+
/** The next `count` requests (sign-in included) answer 429 with `Retry-After`. */
|
|
140
|
+
rateLimit(count?: number, retryAfter?: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Settle connectors that are waiting ("connecting"): the one with this id, or every waiting one at this
|
|
143
|
+
* location. `outcome`: "active", "connected" or "error". Returns how many were settled.
|
|
144
|
+
*/
|
|
145
|
+
settleConnector(connectorOrLocation: string, outcome?: "active" | "connected" | "error"): number;
|
|
146
|
+
/** Every access token stops working, as when they expire: the next call renews its token. */
|
|
147
|
+
expireAccessTokens(): void;
|
|
148
|
+
private _on;
|
|
149
|
+
private _operation;
|
|
150
|
+
private _checkStrict;
|
|
151
|
+
private _endSessions;
|
|
152
|
+
/** Use a refresh token once. A second use ends every session of its login. */
|
|
153
|
+
private _useRefresh;
|
|
154
|
+
private _takeFailure;
|
|
155
|
+
/** A network failure, with the shape Node's fetch (undici) gives: TypeError "fetch failed" whose cause is the underlying error. */
|
|
156
|
+
private _net;
|
|
157
|
+
private _failureResponse;
|
|
158
|
+
private _serve;
|
|
159
|
+
/**
|
|
160
|
+
* Build "Riverbend Auto Group" through the account layer: `teams` teams with connectors, the Management
|
|
161
|
+
* location, groups and the Low Sentiment alert (the phrase alerts stay pending: the fake holds no phrase
|
|
162
|
+
* lists). With `people`, two Base Users per team and one Base Manager on every team. The request log is
|
|
163
|
+
* cleared afterwards.
|
|
164
|
+
*/
|
|
165
|
+
seedCustomer(options?: {
|
|
166
|
+
teams?: number;
|
|
167
|
+
people?: boolean;
|
|
168
|
+
}): Promise<SeededCustomer>;
|
|
169
|
+
/**
|
|
170
|
+
* Add `n` fictional calls (today, or on `day`) for user logins to read, each with a detail record, an
|
|
171
|
+
* open task and, for every other call, an "Upset Customer" alert. Callers use 555-01xx numbers; each call
|
|
172
|
+
* reaches a seeded Base User's line at that location in turn (so a person signed in with `asUser` sees
|
|
173
|
+
* their own). `recording`: each call has a recording link (an example.com https address that expires in
|
|
174
|
+
* two hours). `topics`: topic volumes and rising topics for `topics()` and the Insights Hub dashboard.
|
|
175
|
+
* Returns the call ids, newest first.
|
|
176
|
+
*/
|
|
177
|
+
seedCalls(n?: number, options?: {
|
|
178
|
+
locationId?: string;
|
|
179
|
+
day?: Date | string;
|
|
180
|
+
alerts?: boolean;
|
|
181
|
+
tasks?: boolean;
|
|
182
|
+
recording?: boolean;
|
|
183
|
+
topics?: boolean;
|
|
184
|
+
}): string[];
|
|
185
|
+
private _locationUsers;
|
|
186
|
+
/** The products a user has at a location. */
|
|
187
|
+
products(uid: string, lid: string): Set<string>;
|
|
188
|
+
/** The numbers mapped to a user (on one connector, or on all). */
|
|
189
|
+
numbers(uid: string, connectorId?: string): string[];
|
|
190
|
+
/** The lines First Alert watches at a location. */
|
|
191
|
+
faNumbers(lid: string): string[];
|
|
192
|
+
/** The lines Insights Hub covers at a location. */
|
|
193
|
+
ihNumbers(lid: string): string[];
|
|
194
|
+
/** The user ids in the named group at a location. */
|
|
195
|
+
groupMembers(lid: string, name: string): string[];
|
|
196
|
+
/** The seeded person this request signed in as (`client({ asUser })`), or null for a generic login. */
|
|
197
|
+
private _viewer;
|
|
198
|
+
/** Locations where the person is in an alert group (a manager of that team). */
|
|
199
|
+
private _alertLocations;
|
|
200
|
+
/** What the platform shows a person: a manager their teams' calls, a Base User their own lines' calls. */
|
|
201
|
+
private _inScope;
|
|
202
|
+
private _alertInScope;
|
|
203
|
+
private _paged;
|
|
204
|
+
private _userAttrs;
|
|
205
|
+
private _locUser;
|
|
206
|
+
private _register;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { CONNECTOR_OUTCOMES, type ConnectorOutcome, FakeAPI, type FakeRequest, NETWORK_FAILURES, type NetworkFailure, RESELLER, SIGN_IN_OUTCOMES, type SeededCustomer, type SeededPerson, type SignInOutcome, VERTICAL, newId };
|