@iveri/contracts 0.152.0 → 0.154.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 CHANGED
@@ -324,6 +324,10 @@ Conduit's outbox.
324
324
  `UniboxAgents` under `@iveri/contracts/unibox`, so the inbox picks agents by name.
325
325
  - Version `0.139.0` adds a trainer's notes on a member: `GymTrainerNote`, `GymTrainerNotes`, `SaveGymTrainerNoteRequest`,
326
326
  `GymMyTrainerNote` and the `GymRefusal` member `not-their-trainer` under `@iveri/contracts/gym`.
327
+ - Version `0.154.0` lets an agent send a failed Unibox reply again: `Message.resendOfMessageId`,
328
+ `ResendMessageResponse`, and the `UniboxRefusal` members `reply-not-failed` and `handed-over`.
329
+ - Version `0.153.0` adds `UserPermission.CONDUIT_DISPATCH_READ_ANY` (`conduit:dispatch:read-any`, a platform
330
+ permission) and `MarkConversationReadBody` under `@iveri/contracts/unibox`.
327
331
  - Version `0.152.0` adds the glossary shapes under `@iveri/contracts/localization` (`GlossaryTerm`,
328
332
  `GlossaryTermTranslation`, `GlossaryTermList`, `CreateGlossaryTermBody`, `UpdateGlossaryTermBody`,
329
333
  `TranslationConsistencyGlossary`; `TranslationConsistencyGroup.glossary` and
@@ -1,3 +1,5 @@
1
1
  export * from './taxi-admin.type.js';
2
+ export * from './taxi-cancellation-reason.enum.js';
3
+ export * from './taxi-expiry-kind.enum.js';
2
4
  export * from './taxi-refusal.enum.js';
3
5
  export * from './taxi-ride-status.enum.js';
@@ -1,3 +1,5 @@
1
1
  export * from './taxi-admin.type.js';
2
+ export * from './taxi-cancellation-reason.enum.js';
3
+ export * from './taxi-expiry-kind.enum.js';
2
4
  export * from './taxi-refusal.enum.js';
3
5
  export * from './taxi-ride-status.enum.js';
@@ -2,6 +2,8 @@ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
2
  import type { Nullable } from '../../type/nil.type.js';
3
3
  import type { Paginated } from '../../type/paginated.type.js';
4
4
  import type { UUID } from '../../type/uuid.type.js';
5
+ import type { TaxiCancellationReason } from './taxi-cancellation-reason.enum.js';
6
+ import type { TaxiExpiryKind } from './taxi-expiry-kind.enum.js';
5
7
  import type { TaxiRideStatus } from './taxi-ride-status.enum.js';
6
8
  /** A place as the passenger gave it. There is no address search, so it is coordinates only. */
7
9
  export interface TaxiPoint {
@@ -36,7 +38,19 @@ export interface TaxiBoardRide {
36
38
  startedAt: Nullable<IsoDateTime>;
37
39
  completedAt: Nullable<IsoDateTime>;
38
40
  cancelledAt: Nullable<IsoDateTime>;
41
+ /** Where exactly the passenger said they would wait; null when they said nothing or past the retention window. */
42
+ pickupNote: Nullable<string>;
43
+ /** Why the passenger cancelled, when they said; null on any other ride. */
44
+ cancellationReason: Nullable<TaxiCancellationReason>;
45
+ /** Why an expired ride ended without a trip; null on any other ride. */
46
+ expiryKind: Nullable<TaxiExpiryKind>;
39
47
  }
48
+ /**
49
+ * `GET /company/rides?status=&passengerUserId=&driverUserId=&from=&to=&limit=&offset=`: every ride the company was
50
+ * asked for, newest first, for finding the one a passenger or driver is calling about. `from` and `to` are instants
51
+ * bounding when the ride was asked for. Waiting quotes are listed too, since a passenger may call about one.
52
+ */
53
+ export type TaxiCompanyRidesPage = Paginated<TaxiBoardRide>;
40
54
  /**
41
55
  * `GET /company/board?since=`: what is happening now, and what finished since `since` (the start of the company's
42
56
  * day, which only the panel knows). Each list is capped and newest first.
@@ -109,10 +123,32 @@ export interface TaxiDailyTotals {
109
123
  /** Sum of the quoted fares of that day's completed rides, per currency. */
110
124
  completedQuotedFares: TaxiQuotedFareTotal[];
111
125
  }
112
- /** `GET /company/reports/daily?days=&timeZone=`: oldest day first, every day present, zeroes included. */
126
+ /** How many of the period's cancelled rides gave one reason; `reason` null counts those that gave none. */
127
+ export interface TaxiCancellationCount {
128
+ reason: Nullable<TaxiCancellationReason>;
129
+ rides: number;
130
+ }
131
+ /** How many of the period's expired rides ended one way. */
132
+ export interface TaxiExpiryCount {
133
+ kind: TaxiExpiryKind;
134
+ rides: number;
135
+ }
136
+ /**
137
+ * Why the period's rides ended without a trip. Every reason and kind is present, zeroes included, so the counts add up
138
+ * to the days' `cancelled` and `expired`.
139
+ */
140
+ export interface TaxiLostRides {
141
+ cancellations: TaxiCancellationCount[];
142
+ expiries: TaxiExpiryCount[];
143
+ }
144
+ /**
145
+ * `GET /company/reports/daily?days=&timeZone=`: oldest day first, every day present, zeroes included. A ride no driver
146
+ * was ever sent to keeps counting after its row is deleted (24 hours after it ended): only its count is kept.
147
+ */
113
148
  export interface TaxiDailyReport {
114
149
  timeZone: string;
115
150
  from: string;
116
151
  to: string;
117
152
  days: TaxiDailyTotals[];
153
+ lostRides: TaxiLostRides;
118
154
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Why a passenger called a ride off, when they said. A closed set, because a company reads these as counts and free
3
+ * text would be another unbounded place a passenger's words are kept. `driver-asked` exists because a driver cannot
4
+ * cancel; one who needs to asks the passenger.
5
+ */
6
+ export declare enum TaxiCancellationReason {
7
+ CHANGED_PLANS = "changed-plans",
8
+ WAITED_TOO_LONG = "waited-too-long",
9
+ WRONG_PICKUP = "wrong-pickup",
10
+ FOUND_ANOTHER_RIDE = "found-another-ride",
11
+ DRIVER_ASKED = "driver-asked",
12
+ OTHER = "other"
13
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Why a passenger called a ride off, when they said. A closed set, because a company reads these as counts and free
3
+ * text would be another unbounded place a passenger's words are kept. `driver-asked` exists because a driver cannot
4
+ * cancel; one who needs to asks the passenger.
5
+ */
6
+ export var TaxiCancellationReason;
7
+ (function (TaxiCancellationReason) {
8
+ TaxiCancellationReason["CHANGED_PLANS"] = "changed-plans";
9
+ TaxiCancellationReason["WAITED_TOO_LONG"] = "waited-too-long";
10
+ TaxiCancellationReason["WRONG_PICKUP"] = "wrong-pickup";
11
+ TaxiCancellationReason["FOUND_ANOTHER_RIDE"] = "found-another-ride";
12
+ TaxiCancellationReason["DRIVER_ASKED"] = "driver-asked";
13
+ TaxiCancellationReason["OTHER"] = "other";
14
+ })(TaxiCancellationReason || (TaxiCancellationReason = {}));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Why an `expired` ride ended without a trip. The status alone cannot say, and the three have nothing in common:
3
+ * the passenger's choice, the company's drivers, or the service's own dispatch.
4
+ */
5
+ export declare enum TaxiExpiryKind {
6
+ /** The passenger never accepted the fare before it ran out. */
7
+ QUOTE_NOT_ACCEPTED = "quote-not-accepted",
8
+ /** The search ran and no driver took the ride: too few drivers on shift near the pickup. */
9
+ NO_DRIVER_FOUND = "no-driver-found",
10
+ /** The search could not be started at all, so no driver was ever asked. */
11
+ DISPATCH_FAILED = "dispatch-failed"
12
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Why an `expired` ride ended without a trip. The status alone cannot say, and the three have nothing in common:
3
+ * the passenger's choice, the company's drivers, or the service's own dispatch.
4
+ */
5
+ export var TaxiExpiryKind;
6
+ (function (TaxiExpiryKind) {
7
+ /** The passenger never accepted the fare before it ran out. */
8
+ TaxiExpiryKind["QUOTE_NOT_ACCEPTED"] = "quote-not-accepted";
9
+ /** The search ran and no driver took the ride: too few drivers on shift near the pickup. */
10
+ TaxiExpiryKind["NO_DRIVER_FOUND"] = "no-driver-found";
11
+ /** The search could not be started at all, so no driver was ever asked. */
12
+ TaxiExpiryKind["DISPATCH_FAILED"] = "dispatch-failed";
13
+ })(TaxiExpiryKind || (TaxiExpiryKind = {}));
@@ -38,6 +38,9 @@ export interface Conversation {
38
38
  * Per conversation, not per agent. A shared inbox is shared: two agents looking at the same
39
39
  * queue should see the same numbers, and per-agent unread counts turn "has anyone dealt with
40
40
  * this" into a question the UI cannot answer.
41
+ *
42
+ * An inbound message adds one; {@link MarkConversationReadBody} brings it down to the messages
43
+ * newer than the one an agent was shown. Snoozing, closing and replying leave it alone.
41
44
  */
42
45
  unreadCount: number;
43
46
  /** First ~200 characters of the last message, for the list. Null on an empty conversation. */
@@ -137,3 +140,15 @@ export interface HandoverConversationBody {
137
140
  /** Defaults to the caller. Naming someone else is a handover *to* them. */
138
141
  userId?: Nullable<UUID>;
139
142
  }
143
+ /**
144
+ * `POST /api/v1/conversations/:id/read` — an agent has been shown the thread up to a message.
145
+ *
146
+ * Names the newest message the agent was shown rather than meaning "everything", so a customer
147
+ * message that lands between the thread loading and this call stays unread: the count becomes the
148
+ * inbound messages after that one (in the thread's own order), and never goes up. Answers the
149
+ * conversation.
150
+ */
151
+ export interface MarkConversationReadBody {
152
+ /** The newest message of this conversation the agent was shown. */
153
+ throughMessageId: UUID;
154
+ }
@@ -5,9 +5,13 @@
5
5
  * {@link MessageStatus.NONE} respectively — the states below describe our side of a send, and a
6
6
  * message that arrived has no send to describe.
7
7
  *
8
- * The three post-send states mirror what the messaging platforms report back through their status
8
+ * `delivered` and `read` mirror what the messaging platforms report back through their status
9
9
  * webhooks, and they arrive **through the inbound pipeline** (§11): a provider telling us a
10
10
  * message was read is just another webhook. Nothing polls for them.
11
+ *
12
+ * Conduit's own outcome is different: `unibox-api` asks Conduit how each dispatch it submitted
13
+ * ended. Conduit `delivered` (the provider's API accepted it) becomes {@link MessageStatus.SENT},
14
+ * never `delivered`; Conduit `dead-lettered` or `cancelled` becomes {@link MessageStatus.FAILED}.
11
15
  */
12
16
  export declare enum MessageStatus {
13
17
  /** Not applicable — an internal note. */
@@ -22,7 +26,7 @@ export declare enum MessageStatus {
22
26
  * exactly the moment a provider outage matters.
23
27
  */
24
28
  QUEUED = "queued",
25
- /** The provider accepted it. */
29
+ /** The provider accepted it: Conduit delivered the dispatch, or the provider said so. */
26
30
  SENT = "sent",
27
31
  /** The provider says it reached the contact's device. */
28
32
  DELIVERED = "delivered",
@@ -31,8 +35,9 @@ export declare enum MessageStatus {
31
35
  /**
32
36
  * It will not be sent. Terminal.
33
37
  *
34
- * Set when Conduit dead-letters the dispatch, or when the send is refused outright — an
35
- * inactive channel, a closed messaging window. `failureReason` carries the why, because
38
+ * Set when Conduit dead-letters or cancels the dispatch, or when the send is refused outright — an
39
+ * inactive channel, a closed messaging window. A dead-lettered reply an operator redrives in
40
+ * Conduit and that is then delivered moves on to `sent`. `failureReason` carries the why, because
36
41
  * "failed" alone sends an agent to ask an engineer.
37
42
  */
38
43
  FAILED = "failed"
@@ -5,9 +5,13 @@
5
5
  * {@link MessageStatus.NONE} respectively — the states below describe our side of a send, and a
6
6
  * message that arrived has no send to describe.
7
7
  *
8
- * The three post-send states mirror what the messaging platforms report back through their status
8
+ * `delivered` and `read` mirror what the messaging platforms report back through their status
9
9
  * webhooks, and they arrive **through the inbound pipeline** (§11): a provider telling us a
10
10
  * message was read is just another webhook. Nothing polls for them.
11
+ *
12
+ * Conduit's own outcome is different: `unibox-api` asks Conduit how each dispatch it submitted
13
+ * ended. Conduit `delivered` (the provider's API accepted it) becomes {@link MessageStatus.SENT},
14
+ * never `delivered`; Conduit `dead-lettered` or `cancelled` becomes {@link MessageStatus.FAILED}.
11
15
  */
12
16
  export var MessageStatus;
13
17
  (function (MessageStatus) {
@@ -23,7 +27,7 @@ export var MessageStatus;
23
27
  * exactly the moment a provider outage matters.
24
28
  */
25
29
  MessageStatus["QUEUED"] = "queued";
26
- /** The provider accepted it. */
30
+ /** The provider accepted it: Conduit delivered the dispatch, or the provider said so. */
27
31
  MessageStatus["SENT"] = "sent";
28
32
  /** The provider says it reached the contact's device. */
29
33
  MessageStatus["DELIVERED"] = "delivered";
@@ -32,8 +36,9 @@ export var MessageStatus;
32
36
  /**
33
37
  * It will not be sent. Terminal.
34
38
  *
35
- * Set when Conduit dead-letters the dispatch, or when the send is refused outright — an
36
- * inactive channel, a closed messaging window. `failureReason` carries the why, because
39
+ * Set when Conduit dead-letters or cancels the dispatch, or when the send is refused outright — an
40
+ * inactive channel, a closed messaging window. A dead-lettered reply an operator redrives in
41
+ * Conduit and that is then delivered moves on to `sent`. `failureReason` carries the why, because
37
42
  * "failed" alone sends an agent to ask an engineer.
38
43
  */
39
44
  MessageStatus["FAILED"] = "failed";
@@ -69,6 +69,15 @@ export interface Message {
69
69
  * the other end.
70
70
  */
71
71
  dispatchId: Nullable<UUID>;
72
+ /**
73
+ * The failed reply this one sends again, set only by `POST /conversations/:id/messages/:messageId/resend`.
74
+ *
75
+ * Sending again writes a **new** message rather than re-dispatching the failed one: the failed row stays in the thread
76
+ * as the record of what did not go out and why, and the contact receives the words now, after anything said since.
77
+ * At most one message sends a given reply again, so a client shows "Sent again" on a failed reply that one points at
78
+ * and offers Send again only on a failed reply none does.
79
+ */
80
+ resendOfMessageId: Nullable<UUID>;
72
81
  /**
73
82
  * When the message was said, according to the provider — not when we stored it.
74
83
  *
@@ -115,6 +124,16 @@ export interface SendMessageBody {
115
124
  */
116
125
  idempotencyKey?: Nullable<string>;
117
126
  }
127
+ /**
128
+ * `POST /api/v1/conversations/:id/messages/:messageId/resend` takes no body and answers the new {@link Message}.
129
+ *
130
+ * Only a failed reply can be sent again (`reply-not-failed` otherwise). The new message carries the same words,
131
+ * attachments and author, goes through the channel exactly as a reply does, and is dispatched to Conduit under its own
132
+ * id: the failed reply's key would only give back the dispatch that already failed. Asking twice answers the message
133
+ * the first call wrote. The AI agent's reply is not sent again once a person has taken the conversation over
134
+ * (`handed-over`).
135
+ */
136
+ export type ResendMessageResponse = Message;
118
137
  /**
119
138
  * `POST /api/v1/conversations/:id/notes` — a private note in the thread.
120
139
  *
@@ -25,5 +25,15 @@ export declare enum UniboxRefusal {
25
25
  /** Conduit would not take the reply, which is the channel's connection or operation, not the reply itself. */
26
26
  DISPATCH_REFUSED = "dispatch-refused",
27
27
  /** Conduit could not be reached, so the reply was not handed over. Trying again may work. */
28
- DISPATCH_UNAVAILABLE = "dispatch-unavailable"
28
+ DISPATCH_UNAVAILABLE = "dispatch-unavailable",
29
+ /**
30
+ * Send again was asked of a message that is not a failed reply: it was sent after all, is still on its way, or is
31
+ * not a reply. Carries `currentStatus`.
32
+ */
33
+ REPLY_NOT_FAILED = "reply-not-failed",
34
+ /**
35
+ * Send again was asked of the AI agent's reply in a conversation a person has taken over since, where the AI agent
36
+ * no longer speaks.
37
+ */
38
+ HANDED_OVER = "handed-over"
29
39
  }
@@ -27,4 +27,14 @@ export var UniboxRefusal;
27
27
  UniboxRefusal["DISPATCH_REFUSED"] = "dispatch-refused";
28
28
  /** Conduit could not be reached, so the reply was not handed over. Trying again may work. */
29
29
  UniboxRefusal["DISPATCH_UNAVAILABLE"] = "dispatch-unavailable";
30
+ /**
31
+ * Send again was asked of a message that is not a failed reply: it was sent after all, is still on its way, or is
32
+ * not a reply. Carries `currentStatus`.
33
+ */
34
+ UniboxRefusal["REPLY_NOT_FAILED"] = "reply-not-failed";
35
+ /**
36
+ * Send again was asked of the AI agent's reply in a conversation a person has taken over since, where the AI agent
37
+ * no longer speaks.
38
+ */
39
+ UniboxRefusal["HANDED_OVER"] = "handed-over";
30
40
  })(UniboxRefusal || (UniboxRefusal = {}));
@@ -170,6 +170,13 @@ export declare enum UserPermission {
170
170
  * connections. The connection is looked up in the named company, so it can never reach another company's.
171
171
  */
172
172
  CONDUIT_DISPATCH_SEND_ANY = "conduit:dispatch:send-any",
173
+ /**
174
+ * Read one dispatch of a company the request names in `tenantId`, rather than the token's own. A platform
175
+ * permission, held beside {@link UserPermission.CONDUIT_DISPATCH_READ} only by a service credential in Iveri's
176
+ * operator workspace, so the product that sent a company's message (`unibox-api`) can learn whether Conduit
177
+ * delivered it, dead-lettered it or had it cancelled. Only `GET /dispatches/:id` honours it.
178
+ */
179
+ CONDUIT_DISPATCH_READ_ANY = "conduit:dispatch:read-any",
173
180
  /** Read the tenant's product catalog, including prices and availability. */
174
181
  COMMERCE_CATALOG_READ = "commerce:catalog:read",
175
182
  /** Create, edit, archive or restore products in the tenant's catalog. */
@@ -189,6 +189,13 @@ export var UserPermission;
189
189
  * connections. The connection is looked up in the named company, so it can never reach another company's.
190
190
  */
191
191
  UserPermission["CONDUIT_DISPATCH_SEND_ANY"] = "conduit:dispatch:send-any";
192
+ /**
193
+ * Read one dispatch of a company the request names in `tenantId`, rather than the token's own. A platform
194
+ * permission, held beside {@link UserPermission.CONDUIT_DISPATCH_READ} only by a service credential in Iveri's
195
+ * operator workspace, so the product that sent a company's message (`unibox-api`) can learn whether Conduit
196
+ * delivered it, dead-lettered it or had it cancelled. Only `GET /dispatches/:id` honours it.
197
+ */
198
+ UserPermission["CONDUIT_DISPATCH_READ_ANY"] = "conduit:dispatch:read-any";
192
199
  // ══ commerce-api ═════════════════════════════════════════════════════════
193
200
  // ── Catalog ─────────────────────────────────────────────────────────────
194
201
  /** Read the tenant's product catalog, including prices and availability. */
@@ -874,6 +881,7 @@ export const PLATFORM_PERMISSIONS = Object.freeze([
874
881
  UserPermission.MOBILITY_DISPATCH_CREATE_ANY,
875
882
  UserPermission.MOBILITY_DISPATCH_OPERATE_ANY,
876
883
  UserPermission.CONDUIT_DISPATCH_SEND_ANY,
884
+ UserPermission.CONDUIT_DISPATCH_READ_ANY,
877
885
  UserPermission.UNIBOX_REALTIME_PUBLISH_ANY,
878
886
  UserPermission.UNIBOX_AI_RUN_ANY,
879
887
  UserPermission.DELIVERY_JOB_READ_ANY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iveri/contracts",
3
- "version": "0.152.0",
3
+ "version": "0.154.0",
4
4
  "description": "Wire contracts shared by every Iveri backend and frontend. Zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {