@iveri/contracts 0.118.0 → 0.121.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 +8 -1
- package/dist/api/chat/chat-app.type.d.ts +5 -2
- package/dist/api/chat/chat-embed.type.d.ts +19 -0
- package/dist/api/conduit/index.d.ts +3 -0
- package/dist/api/conduit/index.js +3 -0
- package/dist/api/conduit/route-criterion-miss.enum.d.ts +30 -0
- package/dist/api/conduit/route-criterion-miss.enum.js +31 -0
- package/dist/api/conduit/route-criterion.enum.d.ts +14 -0
- package/dist/api/conduit/route-criterion.enum.js +15 -0
- package/dist/api/conduit/route-test.type.d.ts +85 -0
- package/dist/api/conduit/route-test.type.js +1 -0
- package/dist/enum/user-permission.enum.d.ts +7 -0
- package/dist/enum/user-permission.enum.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,7 +154,9 @@ Inspect mode: `Endpoint`, `CaptureSummary`/`CaptureDetail`, `Provider` with its
|
|
|
154
154
|
`SignatureManifest`/`HandshakeManifest`, `Replay`, `SignatureDiagnostic`.
|
|
155
155
|
|
|
156
156
|
Gateway mode: `Destination`, `Route` with its `HeaderMatcher`/`BodyMatcher`, `Delivery` and
|
|
157
|
-
`DeliveryAttempt`.
|
|
157
|
+
`DeliveryAttempt`. A route test — would this route have matched this capture? — answers a
|
|
158
|
+
`RouteTestResult` of `RouteCriterionResult`s, with `RouteCriterion` and `RouteCriterionMiss`
|
|
159
|
+
saying which criterion and why it missed; `TestRouteBody` asks it of criteria not saved yet.
|
|
158
160
|
|
|
159
161
|
Plus the request bodies for each, and the seven enums they are built from — `SignatureVerdict`,
|
|
160
162
|
`SignatureAlgorithm`, `SignatureEncoding`, `SignatureHeaderScheme`, `HandshakeKind`,
|
|
@@ -284,6 +286,11 @@ Conduit's outbox.
|
|
|
284
286
|
`localization:render` permissions.
|
|
285
287
|
- Version `0.100.0` adds `notification:send-any`, the password-reset bodies and Conduit's usage metrics.
|
|
286
288
|
- Version `0.101.0` adds `UsageHistory`, a company's closed months of a product by metric.
|
|
289
|
+
- Version `0.121.0` adds Conduit's route test: `RouteTestResult`, `TestRouteBody`, `RouteCriterion` and
|
|
290
|
+
`RouteCriterionMiss`. (Tagged first as `v0.119.0`, which npm refused once 0.120.0 was out; 0.119.0 does not
|
|
291
|
+
exist on npm.)
|
|
292
|
+
- Version `0.120.0` adds `chat:embed:manage-any` and an optional `tenantId` on the embed requests, so HR opens every
|
|
293
|
+
company's conversations from its operator-workspace key.
|
|
287
294
|
- Widening a type is minor; narrowing it is major.
|
|
288
295
|
- Under `api/`, the contract follows the service: add the field to the service's DTO and to the
|
|
289
296
|
interface in the same release, and let `implements` prove they agree.
|
|
@@ -81,8 +81,11 @@ export type ServerChatParticipant = Omit<EmbeddedChatParticipant, 'userId'> & {
|
|
|
81
81
|
* `PUT /server/conversations`: the embed request, with each participant named by the app's own id for them rather
|
|
82
82
|
* than a Baasi id.
|
|
83
83
|
*/
|
|
84
|
-
/**
|
|
85
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Calls are not offered to other companies' apps yet, so an app's server cannot ask for them; and an app is one
|
|
86
|
+
* company, so its server names no other.
|
|
87
|
+
*/
|
|
88
|
+
export type OpenServerChatRequest = Omit<OpenEmbeddedChatRequest, 'participants' | 'callable' | 'tenantId'> & {
|
|
86
89
|
participants: ServerChatParticipant[];
|
|
87
90
|
};
|
|
88
91
|
/** `GET /server/users/:userId/export`: everything Baasi holds about one user of an app. */
|
|
@@ -26,6 +26,11 @@ export interface EmbeddedChatParticipant {
|
|
|
26
26
|
* two replicas and a reassignment land on one conversation, and participants are reconciled.
|
|
27
27
|
*/
|
|
28
28
|
export interface OpenEmbeddedChatRequest {
|
|
29
|
+
/**
|
|
30
|
+
* The company the conversation is for, when it is not the token's own. A 403 unless the token holds
|
|
31
|
+
* `chat:embed:manage-any` and comes from Iveri's operator workspace; naming your own company counts as naming one.
|
|
32
|
+
*/
|
|
33
|
+
tenantId?: UUID;
|
|
29
34
|
context: {
|
|
30
35
|
product: string;
|
|
31
36
|
type: string;
|
|
@@ -58,11 +63,25 @@ export interface OpenEmbeddedChatResponse {
|
|
|
58
63
|
}
|
|
59
64
|
/** A notice from the product: a translation key in the `chat-kit` namespace and its variables. */
|
|
60
65
|
export interface PostEmbeddedSystemMessageRequest {
|
|
66
|
+
/** As on `OpenEmbeddedChatRequest`: the company the conversation was opened for, behind `chat:embed:manage-any`. */
|
|
67
|
+
tenantId?: UUID;
|
|
61
68
|
key: string;
|
|
62
69
|
variables?: Record<string, string>;
|
|
63
70
|
/** So a retried notice is posted once. */
|
|
64
71
|
idempotencyKey: UUID;
|
|
65
72
|
}
|
|
73
|
+
/** `POST /embed/conversations/:id/close`. An empty body closes one in the token's own company. */
|
|
74
|
+
export interface CloseEmbeddedChatRequest {
|
|
75
|
+
/** As on `OpenEmbeddedChatRequest`: the company the conversation was opened for, behind `chat:embed:manage-any`. */
|
|
76
|
+
tenantId?: UUID;
|
|
77
|
+
}
|
|
78
|
+
/** `GET /embed/conversations`: the context to look up, and the company it is in as on `OpenEmbeddedChatRequest`. */
|
|
79
|
+
export interface EmbeddedChatReferenceQuery {
|
|
80
|
+
tenantId?: UUID;
|
|
81
|
+
product: string;
|
|
82
|
+
type: string;
|
|
83
|
+
id: string;
|
|
84
|
+
}
|
|
66
85
|
export interface EmbeddedChatReference {
|
|
67
86
|
conversationId: UUID;
|
|
68
87
|
context: {
|
|
@@ -17,6 +17,9 @@ export * from './handshake-kind.enum.js';
|
|
|
17
17
|
export * from './match-operator.enum.js';
|
|
18
18
|
export * from './provider.type.js';
|
|
19
19
|
export * from './replay.type.js';
|
|
20
|
+
export * from './route-criterion-miss.enum.js';
|
|
21
|
+
export * from './route-criterion.enum.js';
|
|
22
|
+
export * from './route-test.type.js';
|
|
20
23
|
export * from './route.type.js';
|
|
21
24
|
export * from './signature-algorithm.enum.js';
|
|
22
25
|
export * from './signature-encoding.enum.js';
|
|
@@ -17,6 +17,9 @@ export * from './handshake-kind.enum.js';
|
|
|
17
17
|
export * from './match-operator.enum.js';
|
|
18
18
|
export * from './provider.type.js';
|
|
19
19
|
export * from './replay.type.js';
|
|
20
|
+
export * from './route-criterion-miss.enum.js';
|
|
21
|
+
export * from './route-criterion.enum.js';
|
|
22
|
+
export * from './route-test.type.js';
|
|
20
23
|
export * from './route.type.js';
|
|
21
24
|
export * from './signature-algorithm.enum.js';
|
|
22
25
|
export * from './signature-encoding.enum.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why one criterion of a route did not match a request.
|
|
3
|
+
*
|
|
4
|
+
* A closed set, so a client can say it in the reader's language and an operator can tell the five
|
|
5
|
+
* remedies apart. Three of them say the body could not be read at all, and they are separate
|
|
6
|
+
* because the fixes are: an empty body needs a different route, an oversized one is a limit, and
|
|
7
|
+
* a form-encoded one needs a path or header criterion instead, since a body matcher cannot read
|
|
8
|
+
* inside a form.
|
|
9
|
+
*
|
|
10
|
+
* Every one of them means **not matched**. A criterion that cannot be evaluated does not match:
|
|
11
|
+
* a gateway that forwards on "I could not tell" sends a customer's data somewhere they did not ask
|
|
12
|
+
* for.
|
|
13
|
+
*/
|
|
14
|
+
export declare enum RouteCriterionMiss {
|
|
15
|
+
/** The request carried a value, and it is not the one the rule asks for. */
|
|
16
|
+
DIFFERENT_VALUE = "different-value",
|
|
17
|
+
/**
|
|
18
|
+
* The header, or the body field, is not on the request. A body path that resolves to an
|
|
19
|
+
* object, an array or `null` counts as absent too: a matcher compares strings.
|
|
20
|
+
*/
|
|
21
|
+
FIELD_ABSENT = "field-absent",
|
|
22
|
+
/** The operator compares against a value and the rule gives none. */
|
|
23
|
+
NO_OPERAND = "no-operand",
|
|
24
|
+
/** A body matcher, and the request had no body. */
|
|
25
|
+
BODY_EMPTY = "body-empty",
|
|
26
|
+
/** A body matcher, and the body is over the 1 MB the gateway parses for routing. */
|
|
27
|
+
BODY_TOO_LARGE = "body-too-large",
|
|
28
|
+
/** A body matcher, and the body is not JSON — form-encoded, XML, or malformed. */
|
|
29
|
+
BODY_NOT_JSON = "body-not-json"
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why one criterion of a route did not match a request.
|
|
3
|
+
*
|
|
4
|
+
* A closed set, so a client can say it in the reader's language and an operator can tell the five
|
|
5
|
+
* remedies apart. Three of them say the body could not be read at all, and they are separate
|
|
6
|
+
* because the fixes are: an empty body needs a different route, an oversized one is a limit, and
|
|
7
|
+
* a form-encoded one needs a path or header criterion instead, since a body matcher cannot read
|
|
8
|
+
* inside a form.
|
|
9
|
+
*
|
|
10
|
+
* Every one of them means **not matched**. A criterion that cannot be evaluated does not match:
|
|
11
|
+
* a gateway that forwards on "I could not tell" sends a customer's data somewhere they did not ask
|
|
12
|
+
* for.
|
|
13
|
+
*/
|
|
14
|
+
export var RouteCriterionMiss;
|
|
15
|
+
(function (RouteCriterionMiss) {
|
|
16
|
+
/** The request carried a value, and it is not the one the rule asks for. */
|
|
17
|
+
RouteCriterionMiss["DIFFERENT_VALUE"] = "different-value";
|
|
18
|
+
/**
|
|
19
|
+
* The header, or the body field, is not on the request. A body path that resolves to an
|
|
20
|
+
* object, an array or `null` counts as absent too: a matcher compares strings.
|
|
21
|
+
*/
|
|
22
|
+
RouteCriterionMiss["FIELD_ABSENT"] = "field-absent";
|
|
23
|
+
/** The operator compares against a value and the rule gives none. */
|
|
24
|
+
RouteCriterionMiss["NO_OPERAND"] = "no-operand";
|
|
25
|
+
/** A body matcher, and the request had no body. */
|
|
26
|
+
RouteCriterionMiss["BODY_EMPTY"] = "body-empty";
|
|
27
|
+
/** A body matcher, and the body is over the 1 MB the gateway parses for routing. */
|
|
28
|
+
RouteCriterionMiss["BODY_TOO_LARGE"] = "body-too-large";
|
|
29
|
+
/** A body matcher, and the body is not JSON — form-encoded, XML, or malformed. */
|
|
30
|
+
RouteCriterionMiss["BODY_NOT_JSON"] = "body-not-json";
|
|
31
|
+
})(RouteCriterionMiss || (RouteCriterionMiss = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One kind of condition a route can set, in the order the gateway evaluates them.
|
|
3
|
+
*
|
|
4
|
+
* The order is the evaluator's, not an arbitrary listing: a route test reports criteria in it, so
|
|
5
|
+
* the first criterion that missed is the one the gateway stopped at.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum RouteCriterion {
|
|
8
|
+
ENDPOINT = "endpoint",
|
|
9
|
+
PROVIDER = "provider",
|
|
10
|
+
METHOD = "method",
|
|
11
|
+
PATH = "path",
|
|
12
|
+
HEADER = "header",
|
|
13
|
+
BODY = "body"
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One kind of condition a route can set, in the order the gateway evaluates them.
|
|
3
|
+
*
|
|
4
|
+
* The order is the evaluator's, not an arbitrary listing: a route test reports criteria in it, so
|
|
5
|
+
* the first criterion that missed is the one the gateway stopped at.
|
|
6
|
+
*/
|
|
7
|
+
export var RouteCriterion;
|
|
8
|
+
(function (RouteCriterion) {
|
|
9
|
+
RouteCriterion["ENDPOINT"] = "endpoint";
|
|
10
|
+
RouteCriterion["PROVIDER"] = "provider";
|
|
11
|
+
RouteCriterion["METHOD"] = "method";
|
|
12
|
+
RouteCriterion["PATH"] = "path";
|
|
13
|
+
RouteCriterion["HEADER"] = "header";
|
|
14
|
+
RouteCriterion["BODY"] = "body";
|
|
15
|
+
})(RouteCriterion || (RouteCriterion = {}));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
2
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
3
|
+
import type { MatchOperator } from './match-operator.enum.js';
|
|
4
|
+
import type { RouteCriterionMiss } from './route-criterion-miss.enum.js';
|
|
5
|
+
import type { RouteCriterion } from './route-criterion.enum.js';
|
|
6
|
+
import type { BodyMatcherInput, HeaderMatcherInput } from './route.type.js';
|
|
7
|
+
/** How one criterion of a route fared against one capture. */
|
|
8
|
+
export interface RouteCriterionResult {
|
|
9
|
+
criterion: RouteCriterion;
|
|
10
|
+
/** The header name or the body path. Null for the other four criteria. */
|
|
11
|
+
field: Nullable<string>;
|
|
12
|
+
/** The header or body matcher's operator. Null for the other four, which compare for equality or by glob. */
|
|
13
|
+
operator: Nullable<MatchOperator>;
|
|
14
|
+
/**
|
|
15
|
+
* What the rule asks for: the endpoint id, provider key, method, path glob, or the matcher's
|
|
16
|
+
* operand. Null for `exists`, which takes none.
|
|
17
|
+
*/
|
|
18
|
+
expected: Nullable<string>;
|
|
19
|
+
/**
|
|
20
|
+
* What the capture carried, exactly as the matcher compared it — a repeated header joined
|
|
21
|
+
* with `, `, a body leaf as its JSON spelling. Null when it carried nothing there. Cut to
|
|
22
|
+
* 1000 characters and ended with `…` when longer; the comparison used the whole value.
|
|
23
|
+
*/
|
|
24
|
+
actual: Nullable<string>;
|
|
25
|
+
matched: boolean;
|
|
26
|
+
/** Null when the criterion matched. */
|
|
27
|
+
miss: Nullable<RouteCriterionMiss>;
|
|
28
|
+
}
|
|
29
|
+
/** A route that stops evaluation before another one is reached. */
|
|
30
|
+
export interface RouteTestStopper {
|
|
31
|
+
id: UUID;
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `GET /api/v1/routes/:routeId/test?captureId=` and `POST /api/v1/routes/test`.
|
|
36
|
+
*
|
|
37
|
+
* Evaluated by the same matcher the gateway runs on every inbound request, against the stored
|
|
38
|
+
* capture as it arrived. Nothing is sent and nothing is written.
|
|
39
|
+
*/
|
|
40
|
+
export interface RouteTestResult {
|
|
41
|
+
captureId: UUID;
|
|
42
|
+
/** Every criterion matched. A route that sets no criterion matches every request. */
|
|
43
|
+
matched: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Only the criteria the route sets, in the order the gateway evaluates them. Unlike the
|
|
46
|
+
* gateway, which stops at the first miss, every criterion is evaluated, so an operator sees
|
|
47
|
+
* all of what is wrong at once.
|
|
48
|
+
*/
|
|
49
|
+
criteria: RouteCriterionResult[];
|
|
50
|
+
/**
|
|
51
|
+
* An earlier active route with `stopOnMatch` that also matches this capture, so the gateway
|
|
52
|
+
* stops before it reaches this one: the route matches and would still not fire. Null when
|
|
53
|
+
* nothing stands in the way. Reported whether or not this route matched.
|
|
54
|
+
*/
|
|
55
|
+
stoppedBy: Nullable<RouteTestStopper>;
|
|
56
|
+
/**
|
|
57
|
+
* The endpoint's provider key the provider criterion was compared with. A capture does not
|
|
58
|
+
* record it, so this is the endpoint's **current** key; null when the endpoint has none or is
|
|
59
|
+
* gone.
|
|
60
|
+
*/
|
|
61
|
+
providerKey: Nullable<string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `POST /api/v1/routes/test`: criteria not saved yet, as a route form holds them.
|
|
65
|
+
*
|
|
66
|
+
* The criteria take the same values and the same "absent means any" meaning as
|
|
67
|
+
* `CreateRouteBody`, and are normalised the same way before they are evaluated.
|
|
68
|
+
*/
|
|
69
|
+
export interface TestRouteBody {
|
|
70
|
+
captureId: UUID;
|
|
71
|
+
/**
|
|
72
|
+
* The route being edited, if any: it is not reported as stopping itself, and its age decides
|
|
73
|
+
* its place among routes of the same priority. Omitted for a route not created yet, which
|
|
74
|
+
* would be evaluated after every existing route of its priority.
|
|
75
|
+
*/
|
|
76
|
+
routeId?: Nullable<UUID>;
|
|
77
|
+
endpointId?: Nullable<UUID>;
|
|
78
|
+
providerKey?: Nullable<string>;
|
|
79
|
+
method?: Nullable<string>;
|
|
80
|
+
pathPattern?: Nullable<string>;
|
|
81
|
+
headerMatchers?: Nullable<HeaderMatcherInput[]>;
|
|
82
|
+
bodyMatchers?: Nullable<BodyMatcherInput[]>;
|
|
83
|
+
/** Decides which routes are evaluated before it. Default 100, as on create. */
|
|
84
|
+
priority?: Nullable<number>;
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -621,6 +621,13 @@ export declare enum UserPermission {
|
|
|
621
621
|
GYM_REPORT_READ = "gym:report:read",
|
|
622
622
|
/** Open, reconcile and close conversations about something in a product. Held by that product's service key. */
|
|
623
623
|
CHAT_EMBED_MANAGE = "chat:embed:manage",
|
|
624
|
+
/**
|
|
625
|
+
* Open, reconcile and close embedded conversations for a company the request names in `tenantId`, rather than the
|
|
626
|
+
* token's own. A platform permission: held only by a service credential in Iveri's operator workspace, so a product
|
|
627
|
+
* sold to many companies (HR) keeps every company's conversations from one key. The conversation is filed in, and
|
|
628
|
+
* its participants are people of, the company it names.
|
|
629
|
+
*/
|
|
630
|
+
CHAT_EMBED_MANAGE_ANY = "chat:embed:manage-any",
|
|
624
631
|
/** See the moderation queue and what a report copied. Every read of a conversation is logged. */
|
|
625
632
|
CHAT_MODERATION_READ = "chat:moderation:read",
|
|
626
633
|
/** Decide a case: dismiss it, remove the message, warn, suspend or ban. */
|
|
@@ -691,6 +691,13 @@ export var UserPermission;
|
|
|
691
691
|
// Chat
|
|
692
692
|
/** Open, reconcile and close conversations about something in a product. Held by that product's service key. */
|
|
693
693
|
UserPermission["CHAT_EMBED_MANAGE"] = "chat:embed:manage";
|
|
694
|
+
/**
|
|
695
|
+
* Open, reconcile and close embedded conversations for a company the request names in `tenantId`, rather than the
|
|
696
|
+
* token's own. A platform permission: held only by a service credential in Iveri's operator workspace, so a product
|
|
697
|
+
* sold to many companies (HR) keeps every company's conversations from one key. The conversation is filed in, and
|
|
698
|
+
* its participants are people of, the company it names.
|
|
699
|
+
*/
|
|
700
|
+
UserPermission["CHAT_EMBED_MANAGE_ANY"] = "chat:embed:manage-any";
|
|
694
701
|
/** See the moderation queue and what a report copied. Every read of a conversation is logged. */
|
|
695
702
|
UserPermission["CHAT_MODERATION_READ"] = "chat:moderation:read";
|
|
696
703
|
/** Decide a case: dismiss it, remove the message, warn, suspend or ban. */
|
|
@@ -745,6 +752,7 @@ export const PLATFORM_PERMISSIONS = Object.freeze([
|
|
|
745
752
|
UserPermission.BILLING_USAGE_RECORD_ANY,
|
|
746
753
|
UserPermission.BILLING_USAGE_READ_ANY,
|
|
747
754
|
UserPermission.NOTIFICATION_SEND_ANY,
|
|
755
|
+
UserPermission.CHAT_EMBED_MANAGE_ANY,
|
|
748
756
|
]);
|
|
749
757
|
/** Whether a permission acts across companies, and so may only be held in Iveri's operator workspace. */
|
|
750
758
|
export function isPlatformPermission(permission) {
|