@iveri/contracts 0.96.0 → 0.97.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
@@ -219,6 +219,19 @@ What a company running a taxi service reads in its own panel: `TaxiRideStatus`,
219
219
  - **A day's totals are the rides requested on it**, so `completed` can never exceed `requested`, and the panel names the
220
220
  time zone the days were cut in.
221
221
 
222
+ ### `api/delivery/` → `@iveri/contracts/delivery`
223
+
224
+ What a company running a delivery service reads in its own panel, shaped like Taxi's: `DeliveryJobStatus`, the live
225
+ board (`DeliveryBoard`, `DeliveryBoardJob`), each courier's work since a moment (`DeliveryCourierActivityList`), its
226
+ senders (`DeliverySendersPage`), its fee settings (`DeliveryFeeSettings`, `UpdateDeliveryFeeSettingsRequest`) and its
227
+ daily totals (`DeliveryDailyReport`).
228
+
229
+ - **A job the company asked for itself has no sender** (`senderUserId: null`), as a shop shipping its own orders does;
230
+ it is on the board and in the totals, and in nobody's row of the senders list.
231
+ - **Proof is a yes or no and the recipient's name.** The photograph is private evidence and is never in these shapes.
232
+ - **`expired` folds quote-expired into no courier found, and `failed` stays apart**, because a refused request is a
233
+ fault on Iveri's side rather than the company's.
234
+
222
235
  ### Why the wire shapes moved here
223
236
 
224
237
  `conduit-admin-web` hand-transcribed all of it, carefully and with comments. It still drifted:
@@ -0,0 +1,128 @@
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 { DeliveryJobStatus } from './delivery-job-status.enum.js';
6
+ /** A stop as the sender gave it. There is no address search, so it is coordinates only. */
7
+ export interface DeliveryPoint {
8
+ latitude: number;
9
+ longitude: number;
10
+ }
11
+ /**
12
+ * One job as the company running the delivery 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 job's location is
15
+ * past the retention window, which differs from never having one. People are identifiers: the panel names them from
16
+ * identity's public profile.
17
+ */
18
+ export interface DeliveryBoardJob {
19
+ id: UUID;
20
+ status: DeliveryJobStatus;
21
+ /** Null when the company asked for the delivery itself, as a shop shipping its own orders does. */
22
+ senderUserId: Nullable<UUID>;
23
+ /** The Mobility worker carrying it, once a courier accepted. */
24
+ courierWorkerId: Nullable<UUID>;
25
+ /** The courier as a person; briefly null after acceptance while Delivery resolves the worker. */
26
+ courierUserId: Nullable<UUID>;
27
+ pickup: Nullable<DeliveryPoint>;
28
+ dropoff: Nullable<DeliveryPoint>;
29
+ /** A straight-line floor, never a final charge. */
30
+ quotedFeeMinor: number;
31
+ quotedFeeCurrency: string;
32
+ quotedDistanceMeters: number;
33
+ createdAt: IsoDateTime;
34
+ assignedAt: Nullable<IsoDateTime>;
35
+ pickedUpAt: Nullable<IsoDateTime>;
36
+ inTransitAt: Nullable<IsoDateTime>;
37
+ deliveredAt: Nullable<IsoDateTime>;
38
+ cancelledAt: Nullable<IsoDateTime>;
39
+ /** Whether the courier left proof. The photograph itself is private evidence and is never on the board. */
40
+ hasProof: boolean;
41
+ /** The name the courier entered for whoever took the parcel; null without proof or past its retention window. */
42
+ recipientName: Nullable<string>;
43
+ }
44
+ /**
45
+ * `GET /company/board?since=`: what is happening now, and what finished since `since` (the start of the company's
46
+ * day, which only the panel knows). Each list is capped and newest first.
47
+ */
48
+ export interface DeliveryBoard {
49
+ since: IsoDateTime;
50
+ /** Looking for a courier, assigned, picked up or in transit. Waiting quotes are not work yet. */
51
+ active: DeliveryBoardJob[];
52
+ /** Delivered, cancelled, expired, quote-expired or failed since `since`. */
53
+ finished: DeliveryBoardJob[];
54
+ }
55
+ /** One courier's work since a moment, keyed by their Mobility worker. Couriers with no jobs are absent. */
56
+ export interface DeliveryCourierActivity {
57
+ workerId: UUID;
58
+ deliveredJobs: number;
59
+ lastDeliveredAt: Nullable<IsoDateTime>;
60
+ /** The job they are carrying now, if any. */
61
+ activeJobId: Nullable<UUID>;
62
+ activeJobStatus: Nullable<DeliveryJobStatus>;
63
+ }
64
+ /** `GET /company/couriers/activity?since=`. */
65
+ export interface DeliveryCourierActivityList {
66
+ since: IsoDateTime;
67
+ couriers: DeliveryCourierActivity[];
68
+ }
69
+ /**
70
+ * Somebody who has asked this company to carry something. Named by the panel from identity. Jobs the company asked
71
+ * for itself have no sender and are not anybody's here.
72
+ */
73
+ export interface DeliverySenderSummary {
74
+ userId: UUID;
75
+ /** Every job they asked for, including quotes they never accepted. */
76
+ jobs: number;
77
+ deliveredJobs: number;
78
+ lastJobAt: IsoDateTime;
79
+ }
80
+ /** `GET /company/senders`, most recent sender first. */
81
+ export type DeliverySendersPage = Paginated<DeliverySenderSummary>;
82
+ /**
83
+ * What a quote costs: `base + round(metres × perKilometre / 1000)`, in minor units of `currency`. The distance is a
84
+ * straight line, so the quote stays a floor whatever these are set to.
85
+ */
86
+ export interface DeliveryFeeSettings {
87
+ currency: string;
88
+ baseFeeMinor: number;
89
+ perKilometreMinor: number;
90
+ /** True while the company has never set its own prices and the service's defaults apply. */
91
+ isDefault: boolean;
92
+ updatedAt: Nullable<IsoDateTime>;
93
+ }
94
+ /** `PUT /company/fee-settings`. Applies to quotes made afterwards; a quote already given keeps its price. */
95
+ export interface UpdateDeliveryFeeSettingsRequest {
96
+ currency: string;
97
+ baseFeeMinor: number;
98
+ perKilometreMinor: number;
99
+ }
100
+ /** Quoted fees of a day's delivered jobs in one currency. Quoted, not earned: nothing settles a fee yet. */
101
+ export interface DeliveryQuotedFeeTotal {
102
+ currency: string;
103
+ quotedFeeMinor: number;
104
+ }
105
+ /**
106
+ * One day of the jobs requested on it, in the report's time zone: how many were asked for, and how those ended. A job
107
+ * requested late and delivered after midnight counts on the day it was asked for.
108
+ */
109
+ export interface DeliveryDailyTotals {
110
+ /** `YYYY-MM-DD`. */
111
+ date: string;
112
+ requested: number;
113
+ delivered: number;
114
+ cancelled: number;
115
+ /** No courier was found, or the sender let the quote run out. */
116
+ expired: number;
117
+ /** Mobility refused the request: a fault on Iveri's side rather than the company's. */
118
+ failed: number;
119
+ /** Sum of the quoted fees of that day's delivered jobs, per currency. */
120
+ deliveredQuotedFees: DeliveryQuotedFeeTotal[];
121
+ }
122
+ /** `GET /company/reports/daily?days=&timeZone=`: oldest day first, every day present, zeroes included. */
123
+ export interface DeliveryDailyReport {
124
+ timeZone: string;
125
+ from: string;
126
+ to: string;
127
+ days: DeliveryDailyTotals[];
128
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Where a delivery job stands. `delivery-api` owns the lifecycle; this is its wire vocabulary, so a company's panel and
3
+ * Iveri's backoffice can label a job without restating it.
4
+ */
5
+ export declare enum DeliveryJobStatus {
6
+ /** Priced and waiting for the sender to accept it. */
7
+ QUOTED = "quoted",
8
+ /** Confirmed, and looking for a courier. */
9
+ DISPATCHING = "dispatching",
10
+ /** A courier accepted and is on the way to the pickup. */
11
+ COURIER_ASSIGNED = "courier-assigned",
12
+ /** The courier has the parcel. */
13
+ PICKED_UP = "picked-up",
14
+ /** The parcel is on its way to the drop-off. */
15
+ IN_TRANSIT = "in-transit",
16
+ /** Handed over, with the recipient's name and a photograph as proof. */
17
+ DELIVERED = "delivered",
18
+ /** The sender never accepted the quote before it ran out. */
19
+ QUOTE_EXPIRED = "quote-expired",
20
+ /** Mobility found no courier. */
21
+ EXPIRED = "expired",
22
+ /** Mobility refused the request outright; the job never reached a courier. */
23
+ FAILED = "failed",
24
+ CANCELLED = "cancelled"
25
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Where a delivery job stands. `delivery-api` owns the lifecycle; this is its wire vocabulary, so a company's panel and
3
+ * Iveri's backoffice can label a job without restating it.
4
+ */
5
+ export var DeliveryJobStatus;
6
+ (function (DeliveryJobStatus) {
7
+ /** Priced and waiting for the sender to accept it. */
8
+ DeliveryJobStatus["QUOTED"] = "quoted";
9
+ /** Confirmed, and looking for a courier. */
10
+ DeliveryJobStatus["DISPATCHING"] = "dispatching";
11
+ /** A courier accepted and is on the way to the pickup. */
12
+ DeliveryJobStatus["COURIER_ASSIGNED"] = "courier-assigned";
13
+ /** The courier has the parcel. */
14
+ DeliveryJobStatus["PICKED_UP"] = "picked-up";
15
+ /** The parcel is on its way to the drop-off. */
16
+ DeliveryJobStatus["IN_TRANSIT"] = "in-transit";
17
+ /** Handed over, with the recipient's name and a photograph as proof. */
18
+ DeliveryJobStatus["DELIVERED"] = "delivered";
19
+ /** The sender never accepted the quote before it ran out. */
20
+ DeliveryJobStatus["QUOTE_EXPIRED"] = "quote-expired";
21
+ /** Mobility found no courier. */
22
+ DeliveryJobStatus["EXPIRED"] = "expired";
23
+ /** Mobility refused the request outright; the job never reached a courier. */
24
+ DeliveryJobStatus["FAILED"] = "failed";
25
+ DeliveryJobStatus["CANCELLED"] = "cancelled";
26
+ })(DeliveryJobStatus || (DeliveryJobStatus = {}));
@@ -0,0 +1,2 @@
1
+ export * from './delivery-admin.type.js';
2
+ export * from './delivery-job-status.enum.js';
@@ -0,0 +1,2 @@
1
+ export * from './delivery-admin.type.js';
2
+ export * from './delivery-job-status.enum.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iveri/contracts",
3
- "version": "0.96.0",
3
+ "version": "0.97.0",
4
4
  "description": "Wire contracts shared by every Iveri backend and frontend. Zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -84,6 +84,10 @@
84
84
  "types": "./dist/api/taxi/index.d.ts",
85
85
  "default": "./dist/api/taxi/index.js"
86
86
  },
87
+ "./delivery": {
88
+ "types": "./dist/api/delivery/index.d.ts",
89
+ "default": "./dist/api/delivery/index.js"
90
+ },
87
91
  "./billing": {
88
92
  "types": "./dist/api/billing/index.d.ts",
89
93
  "default": "./dist/api/billing/index.js"