@iveri/contracts 0.92.0 → 0.94.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
@@ -207,6 +207,18 @@ Three shapes here are decisions rather than descriptions, and each is pinned by
207
207
  A template holds message **keys**, never text — the wording lives in `iveri-localization-api`, so
208
208
  there is one place with ICU validation, a review gate and Georgian, rather than two.
209
209
 
210
+ ### `api/taxi/` → `@iveri/contracts/taxi`
211
+
212
+ What a company running a taxi service reads in its own panel: `TaxiRideStatus`, the live board (`TaxiBoard`,
213
+ `TaxiBoardRide`), each driver's work since a moment (`TaxiDriverActivityList`), its passengers
214
+ (`TaxiPassengersPage`), its fare settings (`TaxiFareSettings`, `UpdateTaxiFareSettingsRequest`) and its daily totals
215
+ (`TaxiDailyReport`). The passenger's and driver's own ride shapes stay in `taxi-api` until a second consumer needs them.
216
+
217
+ - **A fare is a quote and stays one.** The distance is a straight line, so every figure is a floor, and the daily
218
+ report sums quoted fares of completed rides, never earnings: nothing settles a fare yet.
219
+ - **A day's totals are the rides requested on it**, so `completed` can never exceed `requested`, and the panel names the
220
+ time zone the days were cut in.
221
+
210
222
  ### Why the wire shapes moved here
211
223
 
212
224
  `conduit-admin-web` hand-transcribed all of it, carefully and with comments. It still drifted:
@@ -9,3 +9,4 @@ export * from './mobility-service-type.enum.js';
9
9
  export * from './mobility-worker-rating.type.js';
10
10
  export * from './mobility-worker-status.enum.js';
11
11
  export * from './mobility-worker.type.js';
12
+ export * from './mobility-backoffice.type.js';
@@ -9,3 +9,4 @@ export * from './mobility-service-type.enum.js';
9
9
  export * from './mobility-worker-rating.type.js';
10
10
  export * from './mobility-worker-status.enum.js';
11
11
  export * from './mobility-worker.type.js';
12
+ export * from './mobility-backoffice.type.js';
@@ -0,0 +1,20 @@
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
+ /**
5
+ * One company's workers of one service type, for a product's backoffice. Counts only: who they are stays with the
6
+ * company.
7
+ */
8
+ export interface MobilityBackofficeWorkerCount {
9
+ tenantId: UUID;
10
+ /** Enrolled workers, suspended ones included. */
11
+ workers: number;
12
+ /** Active workers who are available or busy right now. */
13
+ onShift: number;
14
+ /** When any of them last changed, which is how a product dates the company's last activity. */
15
+ lastChangedAt: Nullable<IsoDateTime>;
16
+ }
17
+ /** `GET /api/v1/backoffice/workers?serviceType=`: every company with a worker of that type. */
18
+ export interface MobilityBackofficeWorkerCounts {
19
+ items: MobilityBackofficeWorkerCount[];
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
+ import type { Nullable } from '../../type/nil.type.js';
3
+ import type { Paginated } from '../../type/paginated.type.js';
4
+ import type { UUID } from '../../type/uuid.type.js';
5
+ /**
6
+ * One number a product reports about a company, or about all of them. `key` is a stable, lower-case word the
7
+ * product's backoffice turns into a label (`people`, `bookings`, `orders`), so a product adds a figure without a
8
+ * contracts release.
9
+ */
10
+ export interface BackofficeMetric {
11
+ key: string;
12
+ value: number;
13
+ }
14
+ /** A product's totals across every company that uses it. */
15
+ export interface BackofficeOverview {
16
+ tenantCount: number;
17
+ metrics: BackofficeMetric[];
18
+ }
19
+ /** One company as a product sees it: its figures and when it last did anything. Names come from identity. */
20
+ export interface BackofficeTenantSummary {
21
+ tenantId: UUID;
22
+ metrics: BackofficeMetric[];
23
+ lastActivityAt: Nullable<IsoDateTime>;
24
+ }
25
+ export type BackofficeTenantsPage = Paginated<BackofficeTenantSummary>;
26
+ /**
27
+ * A record support may need to see, read-only: an order, a booking, a ride, an employee. `kind` and `status` are
28
+ * stable words the backoffice labels; `title` is the company's own text (a name, a number) and is shown as written.
29
+ * Never pay, identity numbers, health records or the words of a message.
30
+ */
31
+ export interface BackofficeRecord {
32
+ id: UUID;
33
+ kind: string;
34
+ title: string;
35
+ status: Nullable<string>;
36
+ at: IsoDateTime;
37
+ }
38
+ export interface BackofficeTenantDetail {
39
+ tenantId: UUID;
40
+ metrics: BackofficeMetric[];
41
+ lastActivityAt: Nullable<IsoDateTime>;
42
+ /** The newest records, at most 50. */
43
+ recent: BackofficeRecord[];
44
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ export * from './backoffice.type.js';
1
2
  export * from './iveri-product.enum.js';
2
3
  export * from './licence-kind.enum.js';
3
4
  export * from './licence-status.enum.js';
@@ -1,3 +1,4 @@
1
+ export * from './backoffice.type.js';
1
2
  export * from './iveri-product.enum.js';
2
3
  export * from './licence-kind.enum.js';
3
4
  export * from './licence-status.enum.js';
@@ -0,0 +1,2 @@
1
+ export * from './taxi-admin.type.js';
2
+ export * from './taxi-ride-status.enum.js';
@@ -0,0 +1,2 @@
1
+ export * from './taxi-admin.type.js';
2
+ export * from './taxi-ride-status.enum.js';
@@ -0,0 +1,118 @@
1
+ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
+ import type { Nullable } from '../../type/nil.type.js';
3
+ import type { Paginated } from '../../type/paginated.type.js';
4
+ import type { UUID } from '../../type/uuid.type.js';
5
+ import type { TaxiRideStatus } from './taxi-ride-status.enum.js';
6
+ /** A place as the passenger gave it. There is no address search, so it is coordinates only. */
7
+ export interface TaxiPoint {
8
+ latitude: number;
9
+ longitude: number;
10
+ }
11
+ /**
12
+ * One ride as the company running the taxi service sees it on its board.
13
+ *
14
+ * The company sees its own customers' stops; Iveri's backoffice never does. A stop is null once the ride's location is
15
+ * past the retention window, which differs from never having one. People are identifiers: the panel
16
+ * names them from identity's public profile.
17
+ */
18
+ export interface TaxiBoardRide {
19
+ id: UUID;
20
+ status: TaxiRideStatus;
21
+ passengerUserId: UUID;
22
+ /** The Mobility worker driving it, once a driver accepted. */
23
+ driverWorkerId: Nullable<UUID>;
24
+ /** The driver as a person; briefly null after acceptance while Taxi resolves the worker. */
25
+ driverUserId: Nullable<UUID>;
26
+ pickup: Nullable<TaxiPoint>;
27
+ dropoff: Nullable<TaxiPoint>;
28
+ /** A straight-line floor, never a final charge. */
29
+ quotedFareMinor: number;
30
+ quotedFareCurrency: string;
31
+ quotedDistanceMeters: number;
32
+ /** When the passenger wants collecting, for a ride booked ahead. */
33
+ scheduledFor: Nullable<IsoDateTime>;
34
+ createdAt: IsoDateTime;
35
+ driverArrivingAt: Nullable<IsoDateTime>;
36
+ startedAt: Nullable<IsoDateTime>;
37
+ completedAt: Nullable<IsoDateTime>;
38
+ cancelledAt: Nullable<IsoDateTime>;
39
+ }
40
+ /**
41
+ * `GET /company/board?since=`: what is happening now, and what finished since `since` (the start of the company's
42
+ * day, which only the panel knows). Each list is capped and newest first.
43
+ */
44
+ export interface TaxiBoard {
45
+ since: IsoDateTime;
46
+ /** Looking for a driver, assigned, on the way, or carrying a passenger. Waiting quotes are not work yet. */
47
+ active: TaxiBoardRide[];
48
+ /** Completed, cancelled or expired since `since`. */
49
+ finished: TaxiBoardRide[];
50
+ }
51
+ /** One driver's work since a moment, keyed by their Mobility worker. Workers with no rides are absent. */
52
+ export interface TaxiDriverActivity {
53
+ workerId: UUID;
54
+ completedRides: number;
55
+ lastCompletedAt: Nullable<IsoDateTime>;
56
+ /** The ride they are on now, if any. */
57
+ activeRideId: Nullable<UUID>;
58
+ activeRideStatus: Nullable<TaxiRideStatus>;
59
+ }
60
+ /** `GET /company/drivers/activity?since=`. */
61
+ export interface TaxiDriverActivityList {
62
+ since: IsoDateTime;
63
+ drivers: TaxiDriverActivity[];
64
+ }
65
+ /** Somebody who has asked this company for a ride. Named by the panel from identity. */
66
+ export interface TaxiPassengerSummary {
67
+ userId: UUID;
68
+ /** Every ride they asked for, including quotes they never accepted. */
69
+ rides: number;
70
+ completedRides: number;
71
+ lastRideAt: IsoDateTime;
72
+ }
73
+ /** `GET /company/passengers`, most recent rider first. */
74
+ export type TaxiPassengersPage = Paginated<TaxiPassengerSummary>;
75
+ /**
76
+ * What a quote costs: `base + round(metres × perKilometre / 1000)`, in minor units of `currency`. The distance is a
77
+ * straight line, so the quote stays a floor whatever these are set to.
78
+ */
79
+ export interface TaxiFareSettings {
80
+ currency: string;
81
+ baseFareMinor: number;
82
+ perKilometreMinor: number;
83
+ /** True while the company has never set its own prices and the service's defaults apply. */
84
+ isDefault: boolean;
85
+ updatedAt: Nullable<IsoDateTime>;
86
+ }
87
+ /** `PUT /company/fare-settings`. Applies to quotes made afterwards; a quote already given keeps its price. */
88
+ export interface UpdateTaxiFareSettingsRequest {
89
+ currency: string;
90
+ baseFareMinor: number;
91
+ perKilometreMinor: number;
92
+ }
93
+ /** Quoted fares of a day's completed rides in one currency. Quoted, not earned: nothing settles a fare yet. */
94
+ export interface TaxiQuotedFareTotal {
95
+ currency: string;
96
+ quotedFareMinor: number;
97
+ }
98
+ /**
99
+ * One day of the rides requested on it, in the report's time zone: how many were asked for, and how those ended.
100
+ * A ride requested late and finished after midnight counts on the day it was asked for.
101
+ */
102
+ export interface TaxiDailyTotals {
103
+ /** `YYYY-MM-DD`. */
104
+ date: string;
105
+ requested: number;
106
+ completed: number;
107
+ cancelled: number;
108
+ expired: number;
109
+ /** Sum of the quoted fares of that day's completed rides, per currency. */
110
+ completedQuotedFares: TaxiQuotedFareTotal[];
111
+ }
112
+ /** `GET /company/reports/daily?days=&timeZone=`: oldest day first, every day present, zeroes included. */
113
+ export interface TaxiDailyReport {
114
+ timeZone: string;
115
+ from: string;
116
+ to: string;
117
+ days: TaxiDailyTotals[];
118
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Where a taxi ride stands. `taxi-api` owns the lifecycle; this is its wire vocabulary, so a company's panel and
3
+ * Iveri's backoffice can label a ride without restating it.
4
+ */
5
+ export declare enum TaxiRideStatus {
6
+ /** Priced and waiting for the passenger to accept the fare. */
7
+ QUOTED = "quoted",
8
+ /** Confirmed, and looking for a driver (or booked ahead and waiting to look). */
9
+ DISPATCHING = "dispatching",
10
+ /** A driver accepted. */
11
+ DRIVER_ASSIGNED = "driver-assigned",
12
+ /** The driver is on their way to the pickup. */
13
+ DRIVER_ARRIVING = "driver-arriving",
14
+ /** The passenger is in the car. */
15
+ IN_PROGRESS = "in-progress",
16
+ COMPLETED = "completed",
17
+ CANCELLED = "cancelled",
18
+ /** Nobody took it before the quote or the search ran out of time. */
19
+ EXPIRED = "expired"
20
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Where a taxi ride stands. `taxi-api` owns the lifecycle; this is its wire vocabulary, so a company's panel and
3
+ * Iveri's backoffice can label a ride without restating it.
4
+ */
5
+ export var TaxiRideStatus;
6
+ (function (TaxiRideStatus) {
7
+ /** Priced and waiting for the passenger to accept the fare. */
8
+ TaxiRideStatus["QUOTED"] = "quoted";
9
+ /** Confirmed, and looking for a driver (or booked ahead and waiting to look). */
10
+ TaxiRideStatus["DISPATCHING"] = "dispatching";
11
+ /** A driver accepted. */
12
+ TaxiRideStatus["DRIVER_ASSIGNED"] = "driver-assigned";
13
+ /** The driver is on their way to the pickup. */
14
+ TaxiRideStatus["DRIVER_ARRIVING"] = "driver-arriving";
15
+ /** The passenger is in the car. */
16
+ TaxiRideStatus["IN_PROGRESS"] = "in-progress";
17
+ TaxiRideStatus["COMPLETED"] = "completed";
18
+ TaxiRideStatus["CANCELLED"] = "cancelled";
19
+ /** Nobody took it before the quote or the search ran out of time. */
20
+ TaxiRideStatus["EXPIRED"] = "expired";
21
+ })(TaxiRideStatus || (TaxiRideStatus = {}));
@@ -626,7 +626,12 @@ export declare enum UserPermission {
626
626
  * Ask whether a company's licence for one product is live. Held by the products' own service credentials, so a
627
627
  * product can refuse a company whose licence has ended without reading anything else about it.
628
628
  */
629
- PLATFORM_LICENCE_CHECK = "platform:licence:check"
629
+ PLATFORM_LICENCE_CHECK = "platform:licence:check",
630
+ /**
631
+ * Read one product's view across every company: who uses it, how much, and the records support needs to answer a
632
+ * question. Never pay, identity numbers, health records or messages. Each product's backoffice routes need it.
633
+ */
634
+ PLATFORM_BACKOFFICE_READ = "platform:backoffice:read"
630
635
  }
631
636
  /**
632
637
  * The permissions that act across companies. They are granted only inside Iveri's own operator workspace, which each
@@ -694,6 +694,11 @@ export var UserPermission;
694
694
  * product can refuse a company whose licence has ended without reading anything else about it.
695
695
  */
696
696
  UserPermission["PLATFORM_LICENCE_CHECK"] = "platform:licence:check";
697
+ /**
698
+ * Read one product's view across every company: who uses it, how much, and the records support needs to answer a
699
+ * question. Never pay, identity numbers, health records or messages. Each product's backoffice routes need it.
700
+ */
701
+ UserPermission["PLATFORM_BACKOFFICE_READ"] = "platform:backoffice:read";
697
702
  })(UserPermission || (UserPermission = {}));
698
703
  /**
699
704
  * The permissions that act across companies. They are granted only inside Iveri's own operator workspace, which each
@@ -706,6 +711,7 @@ export const PLATFORM_PERMISSIONS = Object.freeze([
706
711
  UserPermission.PLATFORM_LICENCE_READ,
707
712
  UserPermission.PLATFORM_LICENCE_MANAGE,
708
713
  UserPermission.PLATFORM_LICENCE_CHECK,
714
+ UserPermission.PLATFORM_BACKOFFICE_READ,
709
715
  ]);
710
716
  /** Whether a permission acts across companies, and so may only be held in Iveri's operator workspace. */
711
717
  export function isPlatformPermission(permission) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iveri/contracts",
3
- "version": "0.92.0",
3
+ "version": "0.94.0",
4
4
  "description": "Wire contracts shared by every Iveri backend and frontend. Zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -80,6 +80,10 @@
80
80
  "types": "./dist/api/platform/index.d.ts",
81
81
  "default": "./dist/api/platform/index.js"
82
82
  },
83
+ "./taxi": {
84
+ "types": "./dist/api/taxi/index.d.ts",
85
+ "default": "./dist/api/taxi/index.js"
86
+ },
83
87
  "./package.json": "./package.json"
84
88
  },
85
89
  "sideEffects": false,