@iveri/contracts 0.151.0 → 0.153.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
@@ -214,7 +214,9 @@ needs a string in the _recipient's_ language. `Locale`, `Namespace`, `Message` w
214
214
  surface the translator panel is written against, with `TranslationStatus` and `VariableType`.
215
215
  `TranslationMemory` (what other messages already say for the same source text) and
216
216
  `TranslationConsistencyPage` (source texts translated more than one way in a locale) are the
217
- translator aids, with `TranslationMatchKind`.
217
+ translator aids, with `TranslationMatchKind`; `GlossaryTerm` (a source word or phrase with its
218
+ preferred translation per locale, or kept as it is) is the third, and a consistency group names the
219
+ glossary term its source text is.
218
220
 
219
221
  `Locale` is a row rather than an enum on purpose — see the type's own note. Nothing in the
220
222
  platform branches on _which_ language a string is in, so encoding the set in a type would make
@@ -322,6 +324,13 @@ Conduit's outbox.
322
324
  `UniboxAgents` under `@iveri/contracts/unibox`, so the inbox picks agents by name.
323
325
  - Version `0.139.0` adds a trainer's notes on a member: `GymTrainerNote`, `GymTrainerNotes`, `SaveGymTrainerNoteRequest`,
324
326
  `GymMyTrainerNote` and the `GymRefusal` member `not-their-trainer` under `@iveri/contracts/gym`.
327
+ - Version `0.153.0` adds `UserPermission.CONDUIT_DISPATCH_READ_ANY` (`conduit:dispatch:read-any`, a platform
328
+ permission) and `MarkConversationReadBody` under `@iveri/contracts/unibox`.
329
+ - Version `0.152.0` adds the glossary shapes under `@iveri/contracts/localization` (`GlossaryTerm`,
330
+ `GlossaryTermTranslation`, `GlossaryTermList`, `CreateGlossaryTermBody`, `UpdateGlossaryTermBody`,
331
+ `TranslationConsistencyGlossary`; `TranslationConsistencyGroup.glossary` and
332
+ `TranslationConsistencyVariant.isPreferred`), and the poll-closed activity kind with how a poll ended under
333
+ `@iveri/contracts/social`.
325
334
  - Version `0.151.0` adds `link` on `InAppNotification`, a path inside the app an inbox row opens.
326
335
  - Version `0.150.0` adds polls on Ezo posts under `@iveri/contracts/social`: `SocialPoll`, `CreateSocialPollRequest`, `VoteSocialPollRequest`,
327
336
  `poll` on `SocialPost` and on creating one, `SocialCaseEvidencePoll` on a case's evidence, and the poll refusals.
@@ -0,0 +1,60 @@
1
+ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
+ import type { Nullable } from '../../type/nil.type.js';
3
+ import type { UUID } from '../../type/uuid.type.js';
4
+ /** How a glossary term is preferably written in one locale. */
5
+ export interface GlossaryTermTranslation {
6
+ /** A tenant locale code, lowercased. Never the source locale: the term itself is the source text. */
7
+ localeCode: string;
8
+ /** Plain text, not ICU: a term is a word or a short phrase, never a message with placeholders. */
9
+ value: string;
10
+ }
11
+ /**
12
+ * One word or short phrase of the source language and how the workspace prefers to translate it.
13
+ *
14
+ * A translator's tool. It informs and never acts: nothing rewrites a translation to match a term,
15
+ * and nothing refuses a save or a release because a translation does not use it. A Russian
16
+ * `Войти` beside a glossary entry reading `Вход` is a question for the translator, not an error.
17
+ */
18
+ export interface GlossaryTerm {
19
+ id: UUID;
20
+ /** As the translator wrote it, in the source locale. Unique in the tenant ignoring case and spacing. */
21
+ term: string;
22
+ /** When to use it, what to avoid. Free text for the next translator. */
23
+ note: Nullable<string>;
24
+ /**
25
+ * Kept as it is in every language — a brand or product name such as `Baasi`. Such a term has
26
+ * no translations; its preferred form in every locale is the term itself.
27
+ */
28
+ doNotTranslate: boolean;
29
+ /** One per locale that has a preferred translation, ordered by locale code. */
30
+ translations: GlossaryTermTranslation[];
31
+ createdAt: IsoDateTime;
32
+ updatedAt: IsoDateTime;
33
+ }
34
+ /**
35
+ * `GET /api/v1/glossary/terms`. The whole glossary, ordered by term.
36
+ *
37
+ * Unpaged on purpose: a workspace keeps hundreds of terms, not millions, and the editor matches
38
+ * every message on screen against all of them. The service refuses a term past its limit rather
39
+ * than letting the list grow past what a client can hold.
40
+ */
41
+ export interface GlossaryTermList {
42
+ items: GlossaryTerm[];
43
+ /** How many terms the workspace may hold. */
44
+ limit: number;
45
+ }
46
+ /** `POST /api/v1/glossary/terms`. */
47
+ export interface CreateGlossaryTermBody {
48
+ term: string;
49
+ note?: Nullable<string>;
50
+ doNotTranslate?: boolean;
51
+ /** Refused alongside `doNotTranslate: true`, which has no translations. */
52
+ translations?: GlossaryTermTranslation[];
53
+ }
54
+ /** `PATCH /api/v1/glossary/terms/:id`. `translations`, when sent, replaces the whole set. */
55
+ export interface UpdateGlossaryTermBody {
56
+ term?: string;
57
+ note?: Nullable<string>;
58
+ doNotTranslate?: boolean;
59
+ translations?: GlossaryTermTranslation[];
60
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from './bundle.type.js';
2
+ export * from './glossary.type.js';
2
3
  export * from './locale.type.js';
3
4
  export * from './message.type.js';
4
5
  export * from './namespace.type.js';
@@ -1,4 +1,5 @@
1
1
  export * from './bundle.type.js';
2
+ export * from './glossary.type.js';
2
3
  export * from './locale.type.js';
3
4
  export * from './message.type.js';
4
5
  export * from './namespace.type.js';
@@ -1,4 +1,6 @@
1
+ import type { Nullable } from '../../type/nil.type.js';
1
2
  import type { Paginated } from '../../type/paginated.type.js';
3
+ import type { UUID } from '../../type/uuid.type.js';
2
4
  import type { TranslationMatchKind } from './translation-match-kind.enum.js';
3
5
  import type { TranslationStatus } from './translation-status.enum.js';
4
6
  /** One message that carries a given translation: where to find it, and how far along it is. */
@@ -49,6 +51,24 @@ export interface TranslationConsistencyVariant {
49
51
  useCount: number;
50
52
  /** At most twenty of the messages, approved ones first. */
51
53
  uses: TranslationUse[];
54
+ /**
55
+ * Whether this spelling is the glossary's preferred translation (whitespace collapsed, case
56
+ * kept). Always false when the group has no glossary term or the term has no translation here.
57
+ */
58
+ isPreferred: boolean;
59
+ }
60
+ /** The glossary term a consistency group's source text is, so the review can start from it. */
61
+ export interface TranslationConsistencyGlossary {
62
+ termId: UUID;
63
+ /** The term as the glossary writes it. */
64
+ term: string;
65
+ doNotTranslate: boolean;
66
+ /**
67
+ * The preferred translation in the report's locale: the term itself when it is not translated,
68
+ * null when the glossary has none for this locale yet.
69
+ */
70
+ preferred: Nullable<string>;
71
+ note: Nullable<string>;
52
72
  }
53
73
  /**
54
74
  * One source text that the workspace translates into one locale in more than one way.
@@ -64,9 +84,16 @@ export interface TranslationConsistencyGroup {
64
84
  messageCount: number;
65
85
  /** Most used first. Always two or more. */
66
86
  variants: TranslationConsistencyVariant[];
87
+ /**
88
+ * The glossary term whose text this source text is, compared ignoring case and spacing, or null.
89
+ * Only a whole source text counts here; a term inside a longer sentence is the editor's to show.
90
+ */
91
+ glossary: Nullable<TranslationConsistencyGlossary>;
67
92
  }
68
93
  /**
69
- * `GET /api/v1/translation-consistency?localeCode=&namespaceKey=`.
94
+ * `GET /api/v1/translation-consistency?localeCode=&namespaceKey=&glossaryOnly=`.
95
+ *
96
+ * `glossaryOnly=true` keeps the groups whose source text is a glossary term.
70
97
  *
71
98
  * Groups ordered by how many messages they touch. With `namespaceKey`, only groups with at least
72
99
  * one message in that namespace — but each group still lists every variant in the workspace,
@@ -13,6 +13,7 @@ export * from './social-member-status.enum.js';
13
13
  export * from './social-member.type.js';
14
14
  export * from './social-moderation-reason.enum.js';
15
15
  export * from './social-moderation.type.js';
16
+ export * from './social-poll-outcome.enum.js';
16
17
  export * from './social-poll.type.js';
17
18
  export * from './social-post.type.js';
18
19
  export * from './social-refusal.enum.js';
@@ -13,6 +13,7 @@ export * from './social-member-status.enum.js';
13
13
  export * from './social-member.type.js';
14
14
  export * from './social-moderation-reason.enum.js';
15
15
  export * from './social-moderation.type.js';
16
+ export * from './social-poll-outcome.enum.js';
16
17
  export * from './social-poll.type.js';
17
18
  export * from './social-post.type.js';
18
19
  export * from './social-refusal.enum.js';
@@ -9,5 +9,7 @@ export declare enum SocialActivityKind {
9
9
  FOLLOW_REQUESTED = "follow-requested",
10
10
  FOLLOW_ACCEPTED = "follow-accepted",
11
11
  /** Staff decided something about this member or what they posted. */
12
- MODERATION_NOTICE = "moderation-notice"
12
+ MODERATION_NOTICE = "moderation-notice",
13
+ /** The member's own poll has closed. Only its author is told, once. */
14
+ POLL_CLOSED = "poll-closed"
13
15
  }
@@ -11,4 +11,6 @@ export var SocialActivityKind;
11
11
  SocialActivityKind["FOLLOW_ACCEPTED"] = "follow-accepted";
12
12
  /** Staff decided something about this member or what they posted. */
13
13
  SocialActivityKind["MODERATION_NOTICE"] = "moderation-notice";
14
+ /** The member's own poll has closed. Only its author is told, once. */
15
+ SocialActivityKind["POLL_CLOSED"] = "poll-closed";
14
16
  })(SocialActivityKind || (SocialActivityKind = {}));
@@ -3,6 +3,16 @@ import type { Nullable } from '../../type/nil.type.js';
3
3
  import type { UUID } from '../../type/uuid.type.js';
4
4
  import type { SocialActivityKind } from './social-activity-kind.enum.js';
5
5
  import type { SocialMemberCard } from './social-member.type.js';
6
+ import type { SocialPollOutcome } from './social-poll-outcome.enum.js';
7
+ /**
8
+ * How the author's poll ended, read when the line is, so it agrees with the post. Names no voter and
9
+ * carries no count beyond what the author already sees on their own poll.
10
+ */
11
+ export interface SocialActivityPollResult {
12
+ outcome: SocialPollOutcome;
13
+ /** The answer with the most votes; null on a tie or when nobody voted. */
14
+ leadingAnswer: Nullable<string>;
15
+ }
6
16
  /** One line of activity, which can stand for many people doing the same thing. */
7
17
  export interface SocialActivityItem {
8
18
  id: UUID;
@@ -16,6 +26,8 @@ export interface SocialActivityItem {
16
26
  excerpt: Nullable<string>;
17
27
  /** For a moderation notice, the decision it announces. */
18
28
  noticeId: Nullable<UUID>;
29
+ /** For a closed poll, how it ended; null on every other kind. */
30
+ pollResult: Nullable<SocialActivityPollResult>;
19
31
  latestAt: IsoDateTime;
20
32
  isRead: boolean;
21
33
  }
@@ -0,0 +1,9 @@
1
+ /** How a closed poll ended, for the line telling its author. */
2
+ export declare enum SocialPollOutcome {
3
+ /** One answer has more votes than any other. */
4
+ LEADER = "leader",
5
+ /** Two or more answers share the most votes. */
6
+ TIE = "tie",
7
+ /** Nobody voted. */
8
+ NO_VOTES = "no-votes"
9
+ }
@@ -0,0 +1,10 @@
1
+ /** How a closed poll ended, for the line telling its author. */
2
+ export var SocialPollOutcome;
3
+ (function (SocialPollOutcome) {
4
+ /** One answer has more votes than any other. */
5
+ SocialPollOutcome["LEADER"] = "leader";
6
+ /** Two or more answers share the most votes. */
7
+ SocialPollOutcome["TIE"] = "tie";
8
+ /** Nobody voted. */
9
+ SocialPollOutcome["NO_VOTES"] = "no-votes";
10
+ })(SocialPollOutcome || (SocialPollOutcome = {}));
@@ -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";
@@ -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.151.0",
3
+ "version": "0.153.0",
4
4
  "description": "Wire contracts shared by every Iveri backend and frontend. Zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {