@jsm-mit/tigi-sharded-package 0.3.0 → 0.5.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.
Files changed (37) hide show
  1. package/README.md +16 -2
  2. package/declarations/coordinator/coordinator.did +39 -0
  3. package/declarations/coordinator/coordinator.did.d.ts +68 -0
  4. package/declarations/coordinator/coordinator.did.js +23 -0
  5. package/declarations/core/core.did +240 -53
  6. package/declarations/core/core.did.d.ts +208 -48
  7. package/declarations/core/core.did.js +165 -51
  8. package/declarations/tigi-driver/tigi-driver.did +15 -0
  9. package/declarations/tigi-driver/tigi-driver.did.d.ts +19 -0
  10. package/declarations/tigi-driver/tigi-driver.did.js +6 -0
  11. package/declarations/tigi-simulator/tigi-simulator.did +46 -4
  12. package/declarations/tigi-simulator/tigi-simulator.did.d.ts +70 -4
  13. package/declarations/tigi-simulator/tigi-simulator.did.js +39 -10
  14. package/declarations/worker/worker.did +23 -6
  15. package/declarations/worker/worker.did.d.ts +18 -6
  16. package/declarations/worker/worker.did.js +14 -7
  17. package/dist/actors/profiles-actor.d.ts +20 -1
  18. package/dist/actors/profiles-actor.d.ts.map +1 -1
  19. package/dist/actors/profiles-actor.js +46 -12
  20. package/dist/actors/rides-actor.d.ts +21 -1
  21. package/dist/actors/rides-actor.d.ts.map +1 -1
  22. package/dist/actors/rides-actor.js +46 -6
  23. package/dist/geo.d.ts +5 -0
  24. package/dist/geo.d.ts.map +1 -1
  25. package/dist/geo.js +41 -0
  26. package/dist/group/canister-actor.d.ts +7 -0
  27. package/dist/group/canister-actor.d.ts.map +1 -1
  28. package/dist/group/canister-actor.js +18 -0
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -2
  32. package/dist/interfaces.d.ts +35 -1
  33. package/dist/interfaces.d.ts.map +1 -1
  34. package/dist/mappers.d.ts +20 -2
  35. package/dist/mappers.d.ts.map +1 -1
  36. package/dist/mappers.js +62 -2
  37. package/package.json +7 -4
@@ -70,6 +70,26 @@ export const idlFactory = ({ IDL }) => {
70
70
  'driverPosition' : IDL.Opt(Geo),
71
71
  });
72
72
  const RideAnswer = IDL.Variant({ 'ok' : RideView, 'err' : ProtocolError });
73
+ const RouteLine = IDL.Record({ 'ride' : IDL.Text, 'toPickup' : IDL.Text });
74
+ const RouteAnswer = IDL.Variant({ 'ok' : RouteLine, 'err' : ProtocolError });
75
+ const RouteTaskView = IDL.Record({
76
+ 'untilNs' : IDL.Nat64,
77
+ 'destination' : Geo,
78
+ 'requestId' : IDL.Text,
79
+ 'from' : Geo,
80
+ 'pickup' : Geo,
81
+ 'driverKey' : IDL.Text,
82
+ });
83
+ const SimulatorError = IDL.Variant({
84
+ 'RemoteCanisterError' : IDL.Text,
85
+ 'NotFound' : IDL.Null,
86
+ 'NotAuthorized' : IDL.Text,
87
+ 'InvalidData' : IDL.Text,
88
+ });
89
+ const Result = IDL.Variant({
90
+ 'Ok' : IDL.Vec(RouteTaskView),
91
+ 'Err' : SimulatorError,
92
+ });
73
93
  const Event = IDL.Record({
74
94
  'atNs' : IDL.Nat64,
75
95
  'kind' : IDL.Text,
@@ -82,6 +102,7 @@ export const idlFactory = ({ IDL }) => {
82
102
  'liveDrivers' : IDL.Nat64,
83
103
  'events' : IDL.Vec(Event),
84
104
  'drivers' : IDL.Nat64,
105
+ 'router' : IDL.Opt(IDL.Principal),
85
106
  'rides' : IDL.Nat64,
86
107
  });
87
108
  const HttpRequest = IDL.Record({
@@ -128,17 +149,12 @@ export const idlFactory = ({ IDL }) => {
128
149
  'riderName' : IDL.Text,
129
150
  'rider' : IDL.Principal,
130
151
  });
152
+ const SetRouterArgs = IDL.Record({ 'router' : IDL.Opt(IDL.Principal) });
153
+ const Result_1 = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : SimulatorError });
131
154
  const SpeedUpArgs = IDL.Record({
132
155
  'requestId' : IDL.Text,
133
156
  'factor' : IDL.Nat8,
134
157
  });
135
- const SimulatorError = IDL.Variant({
136
- 'RemoteCanisterError' : IDL.Text,
137
- 'NotFound' : IDL.Null,
138
- 'NotAuthorized' : IDL.Text,
139
- 'InvalidData' : IDL.Text,
140
- });
141
- const Result = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : SimulatorError });
142
158
  const SpawnArgs = IDL.Record({ 'center' : Geo, 'count' : IDL.Opt(IDL.Nat8) });
143
159
  const SpawnResult = IDL.Record({
144
160
  'problems' : IDL.Vec(IDL.Text),
@@ -146,19 +162,32 @@ export const idlFactory = ({ IDL }) => {
146
162
  'registered' : IDL.Nat32,
147
163
  'validUntilNs' : IDL.Nat64,
148
164
  });
149
- const Result_1 = IDL.Variant({ 'Ok' : SpawnResult, 'Err' : SimulatorError });
165
+ const Result_2 = IDL.Variant({ 'Ok' : SpawnResult, 'Err' : SimulatorError });
166
+ const SimRouteResult = IDL.Record({
167
+ 'requestId' : IDL.Text,
168
+ 'rideMeters' : IDL.Nat32,
169
+ 'rideSec' : IDL.Nat32,
170
+ 'routeLine' : IDL.Opt(RouteLine),
171
+ 'driverKey' : IDL.Text,
172
+ 'toPickupSec' : IDL.Nat32,
173
+ 'toPickupMeters' : IDL.Nat32,
174
+ });
150
175
  return IDL.Service({
151
176
  'cancelRide' : IDL.Func([RideRef], [ProtocolAnswer], []),
152
177
  'getLicence' : IDL.Func([RideRef], [LicenceAnswer], ['query']),
153
178
  'getRide' : IDL.Func([RideRef], [RideAnswer], ['query']),
179
+ 'getRideRoute' : IDL.Func([RideRef], [RouteAnswer], ['query']),
180
+ 'getRouteTasks' : IDL.Func([], [Result], ['query']),
154
181
  'getStatus' : IDL.Func([], [SimulatorStatus], ['query']),
155
182
  'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']),
156
183
  'protocolVersion' : IDL.Func([], [IDL.Nat32], ['query']),
157
184
  'quoteRequest' : IDL.Func([QuoteRequest], [ProtocolAnswer], []),
158
185
  'requestClosed' : IDL.Func([RequestClosed], [], []),
159
186
  'rideOrder' : IDL.Func([RideOrder], [ProtocolAnswer], []),
160
- 'setSpeedUp' : IDL.Func([SpeedUpArgs], [Result], []),
161
- 'spawnDrivers' : IDL.Func([SpawnArgs], [Result_1], []),
187
+ 'setRouter' : IDL.Func([SetRouterArgs], [Result_1], []),
188
+ 'setSpeedUp' : IDL.Func([SpeedUpArgs], [Result_1], []),
189
+ 'spawnDrivers' : IDL.Func([SpawnArgs], [Result_2], []),
190
+ 'submitRoute' : IDL.Func([SimRouteResult], [Result_1], []),
162
191
  });
163
192
  };
164
193
  export const init = ({ IDL }) => {
@@ -28,19 +28,22 @@ type TigiWorker =
28
28
  /// from there. Blocks act at once (WO-2); ratings go into offers and orders (P-12).
29
29
  applyCoreChanges: (batch: CoreChanges) -> (Result);
30
30
  /// ZO-13, ZO-14, ZO-17.
31
- chooseOffer: (ref: OfferRef) -> (Result_8);
31
+ chooseOffer: (ref: OfferRef) -> (Result_9);
32
32
  clearLogs: () -> ();
33
33
  /// ZO-15 (otherOfferChosen after an acceptance in another worker), ZO-18 (riderGaveUp).
34
34
  closeRequest: (args: CloseRequestArgs) -> (Result_2);
35
35
  /// The coordinator only: the settings it computes for every worker.
36
- configure: (args: ConfigureArgs) -> (Result_7);
36
+ configure: (args: ConfigureArgs) -> (Result_8);
37
37
  /// ZO-6.
38
38
  declineQuote: (decline: QuoteDecline) -> ();
39
39
  /// What this worker holds of the core's network state.
40
40
  getCoreCopyStatus: () -> (CoreCopyStatus) query;
41
41
  /// The flow's numbers (scripts, the coordinator's front).
42
- getFlowStatus: () -> (Result_6) query;
42
+ getFlowStatus: () -> (Result_7) query;
43
43
  getLogs: () -> (text) query;
44
+ /// ZO-21 (2026-10-24, route line): the route line of one offer, for the rider of the
45
+ /// request only (the package asks after a tap on the offer).
46
+ getOfferRoute: (ref: OfferRef) -> (Result_6) query;
44
47
  /// The load this worker counts per geohash prefix of the given length (1–6): the
45
48
  /// coordinator picks from it what to give another worker on a split (KO-5).
46
49
  getPrefixCounts: (length: nat) -> (Result_5) query;
@@ -89,6 +92,11 @@ type TestLoadArgs =
89
92
  cells: vec PrefixCount;
90
93
  reportLevel: opt nat;
91
94
  };
95
+ type RouteLine =
96
+ record {
97
+ ride: text;
98
+ toPickup: text;
99
+ };
92
100
  type RiderRating =
93
101
  record {
94
102
  driverKey: DriverKey;
@@ -111,21 +119,26 @@ type RideStatus =
111
119
  driverArrived;
112
120
  inProgress;
113
121
  };
114
- type Result_8 =
122
+ type Result_9 =
115
123
  variant {
116
124
  err: Error;
117
125
  ok: ChooseOutcome;
118
126
  };
119
- type Result_7 =
127
+ type Result_8 =
120
128
  variant {
121
129
  err: Error;
122
130
  ok: WorkerConfig;
123
131
  };
124
- type Result_6 =
132
+ type Result_7 =
125
133
  variant {
126
134
  err: Error;
127
135
  ok: FlowStatus;
128
136
  };
137
+ type Result_6 =
138
+ variant {
139
+ err: Error;
140
+ ok: RouteLine;
141
+ };
129
142
  type Result_5 =
130
143
  variant {
131
144
  err: Error;
@@ -217,11 +230,13 @@ type QuoteDecline =
217
230
  type Quote =
218
231
  record {
219
232
  driverKey: DriverKey;
233
+ driverPosition: opt Geo;
220
234
  etaToPickupSec: nat32;
221
235
  price: Money;
222
236
  requestId: RequestId;
223
237
  rideMeters: nat32;
224
238
  rideSec: nat32;
239
+ routeLine: opt RouteLine;
225
240
  toPickupMeters: nat32;
226
241
  validUntilNs: nat64;
227
242
  };
@@ -262,6 +277,7 @@ type OfferView =
262
277
  card: DriverCard;
263
278
  driverCanister: principal;
264
279
  driverKey: DriverKey;
280
+ driverPosition: opt Geo;
265
281
  driverRating: opt nat16;
266
282
  etaToPickupSec: nat32;
267
283
  pinGeohash: text;
@@ -335,6 +351,7 @@ type FlowStatus =
335
351
  openRequests: nat;
336
352
  outboxPending: nat;
337
353
  rides: nat;
354
+ usagePending: opt nat;
338
355
  };
339
356
  type ErrorDetails =
340
357
  variant {
@@ -85,6 +85,7 @@ export type ErrorDetails = { 'InterCanisterConnectionError' : null } |
85
85
  { 'ReturnsNull' : null };
86
86
  export interface FlowStatus {
87
87
  'helloDone' : boolean,
88
+ 'usagePending' : [] | [bigint],
88
89
  'activeRides' : bigint,
89
90
  'knownDriverCanisters' : bigint,
90
91
  'liveDrivers' : bigint,
@@ -141,6 +142,7 @@ export interface OfferView {
141
142
  'driverCanister' : Principal,
142
143
  'price' : Money,
143
144
  'etaToPickupSec' : number,
145
+ 'driverPosition' : [] | [Geo],
144
146
  'toPickupMeters' : number,
145
147
  'validUntilNs' : bigint,
146
148
  }
@@ -165,9 +167,11 @@ export interface Quote {
165
167
  'requestId' : RequestId,
166
168
  'rideMeters' : number,
167
169
  'rideSec' : number,
170
+ 'routeLine' : [] | [RouteLine],
168
171
  'driverKey' : DriverKey,
169
172
  'price' : Money,
170
173
  'etaToPickupSec' : number,
174
+ 'driverPosition' : [] | [Geo],
171
175
  'toPickupMeters' : number,
172
176
  'validUntilNs' : bigint,
173
177
  }
@@ -232,11 +236,13 @@ export type Result_4 = { 'ok' : WorkerStatus } |
232
236
  { 'err' : Error };
233
237
  export type Result_5 = { 'ok' : Array<PrefixCount> } |
234
238
  { 'err' : Error };
235
- export type Result_6 = { 'ok' : FlowStatus } |
239
+ export type Result_6 = { 'ok' : RouteLine } |
236
240
  { 'err' : Error };
237
- export type Result_7 = { 'ok' : WorkerConfig } |
241
+ export type Result_7 = { 'ok' : FlowStatus } |
238
242
  { 'err' : Error };
239
- export type Result_8 = { 'ok' : ChooseOutcome } |
243
+ export type Result_8 = { 'ok' : WorkerConfig } |
244
+ { 'err' : Error };
245
+ export type Result_9 = { 'ok' : ChooseOutcome } |
240
246
  { 'err' : Error };
241
247
  export type RideStatus = { 'completed' : { 'price' : Money } } |
242
248
  { 'cancelledByRider' : null } |
@@ -255,6 +261,7 @@ export interface RiderRating {
255
261
  'stars' : number,
256
262
  'driverKey' : DriverKey,
257
263
  }
264
+ export interface RouteLine { 'ride' : string, 'toPickup' : string }
258
265
  export interface TestLoadArgs {
259
266
  'reportLevel' : [] | [bigint],
260
267
  'cells' : Array<PrefixCount>,
@@ -273,7 +280,7 @@ export interface TigiWorker {
273
280
  /**
274
281
  * / ZO-13, ZO-14, ZO-17.
275
282
  */
276
- 'chooseOffer' : ActorMethod<[OfferRef], Result_8>,
283
+ 'chooseOffer' : ActorMethod<[OfferRef], Result_9>,
277
284
  'clearLogs' : ActorMethod<[], undefined>,
278
285
  /**
279
286
  * / ZO-15 (otherOfferChosen after an acceptance in another worker), ZO-18 (riderGaveUp).
@@ -282,7 +289,7 @@ export interface TigiWorker {
282
289
  /**
283
290
  * / The coordinator only: the settings it computes for every worker.
284
291
  */
285
- 'configure' : ActorMethod<[ConfigureArgs], Result_7>,
292
+ 'configure' : ActorMethod<[ConfigureArgs], Result_8>,
286
293
  /**
287
294
  * / ZO-6.
288
295
  */
@@ -294,8 +301,13 @@ export interface TigiWorker {
294
301
  /**
295
302
  * / The flow's numbers (scripts, the coordinator's front).
296
303
  */
297
- 'getFlowStatus' : ActorMethod<[], Result_6>,
304
+ 'getFlowStatus' : ActorMethod<[], Result_7>,
298
305
  'getLogs' : ActorMethod<[], string>,
306
+ /**
307
+ * / ZO-21 (2026-10-24, route line): the route line of one offer, for the rider of the
308
+ * / request only (the package asks after a tap on the offer).
309
+ */
310
+ 'getOfferRoute' : ActorMethod<[OfferRef], Result_6>,
299
311
  /**
300
312
  * / The load this worker counts per geohash prefix of the given length (1–6): the
301
313
  * / coordinator picks from it what to give another worker on a split (KO-5).
@@ -92,7 +92,7 @@ export const idlFactory = ({ IDL }) => {
92
92
  'ordered' : IDL.Record({ 'answerByNs' : IDL.Nat64 }),
93
93
  'driverNotFree' : IDL.Null,
94
94
  });
95
- const Result_8 = IDL.Variant({ 'ok' : ChooseOutcome, 'err' : Error });
95
+ const Result_9 = IDL.Variant({ 'ok' : ChooseOutcome, 'err' : Error });
96
96
  const CloseReason = IDL.Variant({
97
97
  'offerRejected' : IDL.Null,
98
98
  'otherOfferChosen' : IDL.Null,
@@ -124,7 +124,7 @@ export const idlFactory = ({ IDL }) => {
124
124
  'load' : LoadThresholds,
125
125
  'lowCyclesBelow' : IDL.Nat,
126
126
  });
127
- const Result_7 = IDL.Variant({ 'ok' : WorkerConfig, 'err' : Error });
127
+ const Result_8 = IDL.Variant({ 'ok' : WorkerConfig, 'err' : Error });
128
128
  const QuoteDecline = IDL.Record({
129
129
  'requestId' : RequestId,
130
130
  'driverKey' : DriverKey,
@@ -140,6 +140,7 @@ export const idlFactory = ({ IDL }) => {
140
140
  });
141
141
  const FlowStatus = IDL.Record({
142
142
  'helloDone' : IDL.Bool,
143
+ 'usagePending' : IDL.Opt(IDL.Nat),
143
144
  'activeRides' : IDL.Nat,
144
145
  'knownDriverCanisters' : IDL.Nat,
145
146
  'liveDrivers' : IDL.Nat,
@@ -149,7 +150,9 @@ export const idlFactory = ({ IDL }) => {
149
150
  'rides' : IDL.Nat,
150
151
  'openRequests' : IDL.Nat,
151
152
  });
152
- const Result_6 = IDL.Variant({ 'ok' : FlowStatus, 'err' : Error });
153
+ const Result_7 = IDL.Variant({ 'ok' : FlowStatus, 'err' : Error });
154
+ const RouteLine = IDL.Record({ 'ride' : IDL.Text, 'toPickup' : IDL.Text });
155
+ const Result_6 = IDL.Variant({ 'ok' : RouteLine, 'err' : Error });
153
156
  const PrefixCount = IDL.Record({ 'load' : IDL.Nat, 'prefix' : IDL.Text });
154
157
  const Result_5 = IDL.Variant({ 'ok' : IDL.Vec(PrefixCount), 'err' : Error });
155
158
  const RequestRef = IDL.Record({ 'requestId' : RequestId });
@@ -168,6 +171,7 @@ export const idlFactory = ({ IDL }) => {
168
171
  'hasLicencePhoto' : IDL.Bool,
169
172
  });
170
173
  const Money = IDL.Record({ 'currency' : IDL.Text, 'amount' : IDL.Nat64 });
174
+ const Geo = IDL.Record({ 'lat' : IDL.Float64, 'lng' : IDL.Float64 });
171
175
  const OfferView = IDL.Record({
172
176
  'rideMeters' : IDL.Nat32,
173
177
  'driverRating' : IDL.Opt(IDL.Nat16),
@@ -180,6 +184,7 @@ export const idlFactory = ({ IDL }) => {
180
184
  'driverCanister' : IDL.Principal,
181
185
  'price' : Money,
182
186
  'etaToPickupSec' : IDL.Nat32,
187
+ 'driverPosition' : IDL.Opt(Geo),
183
188
  'toPickupMeters' : IDL.Nat32,
184
189
  'validUntilNs' : IDL.Nat64,
185
190
  });
@@ -241,7 +246,6 @@ export const idlFactory = ({ IDL }) => {
241
246
  });
242
247
  const Result_4 = IDL.Variant({ 'ok' : WorkerStatus, 'err' : Error });
243
248
  const Result_3 = IDL.Variant({ 'ok' : IDL.Nat, 'err' : Error });
244
- const Geo = IDL.Record({ 'lat' : IDL.Float64, 'lng' : IDL.Float64 });
245
249
  const HasSimulatedDriversArgs = IDL.Record({ 'center' : Geo });
246
250
  const TestLoadArgs = IDL.Record({
247
251
  'reportLevel' : IDL.Opt(IDL.Nat),
@@ -290,23 +294,26 @@ export const idlFactory = ({ IDL }) => {
290
294
  'requestId' : RequestId,
291
295
  'rideMeters' : IDL.Nat32,
292
296
  'rideSec' : IDL.Nat32,
297
+ 'routeLine' : IDL.Opt(RouteLine),
293
298
  'driverKey' : DriverKey,
294
299
  'price' : Money,
295
300
  'etaToPickupSec' : IDL.Nat32,
301
+ 'driverPosition' : IDL.Opt(Geo),
296
302
  'toPickupMeters' : IDL.Nat32,
297
303
  'validUntilNs' : IDL.Nat64,
298
304
  });
299
305
  const TigiWorker = IDL.Service({
300
306
  'answerOrder' : IDL.Func([OrderAnswer], [ProtocolResult], []),
301
307
  'applyCoreChanges' : IDL.Func([CoreChanges], [Result], []),
302
- 'chooseOffer' : IDL.Func([OfferRef], [Result_8], []),
308
+ 'chooseOffer' : IDL.Func([OfferRef], [Result_9], []),
303
309
  'clearLogs' : IDL.Func([], [], []),
304
310
  'closeRequest' : IDL.Func([CloseRequestArgs], [Result_2], []),
305
- 'configure' : IDL.Func([ConfigureArgs], [Result_7], []),
311
+ 'configure' : IDL.Func([ConfigureArgs], [Result_8], []),
306
312
  'declineQuote' : IDL.Func([QuoteDecline], [], []),
307
313
  'getCoreCopyStatus' : IDL.Func([], [CoreCopyStatus], ['query']),
308
- 'getFlowStatus' : IDL.Func([], [Result_6], ['query']),
314
+ 'getFlowStatus' : IDL.Func([], [Result_7], ['query']),
309
315
  'getLogs' : IDL.Func([], [IDL.Text], ['query']),
316
+ 'getOfferRoute' : IDL.Func([OfferRef], [Result_6], ['query']),
310
317
  'getPrefixCounts' : IDL.Func([IDL.Nat], [Result_5], ['query']),
311
318
  'getRequest' : IDL.Func([RequestRef], [Result_1], ['query']),
312
319
  'getStatus' : IDL.Func([], [Result_4], ['query']),
@@ -1,6 +1,6 @@
1
1
  import type { Identity } from "@icp-sdk/core/agent";
2
2
  import { type GroupOptions } from "../group/canister-actor.js";
3
- import type { MyRatingView, Profile, RideHistoryPage } from "../interfaces.js";
3
+ import type { MyRatingView, Profile, RateRideOutcome, RideHistoryEntry, RideHistoryPage } from "../interfaces.js";
4
4
  /** KU-1: a page of the rider's history. */
5
5
  export declare const RIDES_PAGE = 20;
6
6
  export declare class ProfilesActor {
@@ -37,5 +37,24 @@ export declare class ProfilesActor {
37
37
  * @throws Error with message `CriticalCanisterError` — the core could not be reached
38
38
  */
39
39
  getMyRidesAsyncUnsafe(cursor?: string, limit?: number): Promise<RideHistoryPage>;
40
+ /**
41
+ * C-8, KU-4 (0.5.0): one line of the rider's history by its `rideRef` — for the details
42
+ * screen after a reload (Skąd, Dokąd) and to show the stars after a rating.
43
+ * @returns undefined while the ride is not in the core yet (K-9, KU-2: up to a minute)
44
+ * @throws Error with message `CanisterError` — `NotAuthorized` (anonymous, another rider's ride), `InvalidToken`
45
+ * @throws Error with message `CriticalCanisterError` — the core could not be reached
46
+ */
47
+ getMyRideAsyncUnsafe(rideRef: string): Promise<RideHistoryEntry | undefined>;
48
+ /**
49
+ * KU-5 (0.5.0, core C-23): the rider rates the driver of a past ride, 1–5 stars, no
50
+ * comment (U-33). Only a completed ride, within 24 h of its end, once — a rating given
51
+ * live after the ride (`RideRequest.rateDriverAsyncUnsafe`) counts as the one. Show the
52
+ * stars only when `RideHistoryEntry.ratable`.
53
+ * @returns `ok` | `alreadyRated` | `notRatable` | `notAuthorized` (see `RateRideOutcome`)
54
+ * @throws Error with message `CanisterError` — `InvalidData` (stars outside 1–5), `InvalidToken`
55
+ * @throws Error with message `CallRefusedAtInspectionStage` — anonymous, or the daily limit (20, shared with the profile)
56
+ * @throws Error with message `CriticalCanisterError` — the core could not be reached
57
+ */
58
+ ratePastRideAsyncUnsafe(rideRef: string, stars: number): Promise<RateRideOutcome>;
40
59
  }
41
60
  //# sourceMappingURL=profiles-actor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles-actor.d.ts","sourceRoot":"","sources":["../../src/actors/profiles-actor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAA6B,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG1G,2CAA2C;AAC3C,eAAO,MAAM,UAAU,KAAK,CAAC;AAkB7B,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;gBAEtB,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,YAAiB;IAIjF;;;;;;OAMG;IACU,uBAAuB,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IASpE;;;;;OAKG;IACU,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpE;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAUxE;;;;;;OAMG;IACU,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;CAS5G"}
1
+ {"version":3,"file":"profiles-actor.d.ts","sourceRoot":"","sources":["../../src/actors/profiles-actor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAiD,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE9G,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGlH,2CAA2C;AAC3C,eAAO,MAAM,UAAU,KAAK,CAAC;AAQ7B,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;gBAEtB,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,YAAiB;IAIjF;;;;;;OAMG;IACU,uBAAuB,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IASpE;;;;;OAKG;IACU,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpE;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAUxE;;;;;;OAMG;IACU,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAUzG;;;;;;OAMG;IACU,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAUzF;;;;;;;;;OASG;IACU,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAajG"}
@@ -1,23 +1,14 @@
1
1
  // The rider's account and history in the core (core.md C-2, C-3, C-8; U-20, U-21). The core
2
2
  // is found through the coordinator (sharding.md): the consumer gives the coordinator's id.
3
- import { errorKeyOf, executeAsyncUnsafe } from "../group/canister-actor.js";
3
+ import { canisterError, errorKeyOf, executeAsyncUnsafe } from "../group/canister-actor.js";
4
4
  import { TigiGroup } from "../group/group.js";
5
- import { decodeToken, encodeToken, moneyOf, msOf } from "../mappers.js";
5
+ import { decodeToken, encodeToken, historyEntryOf, rateOutcomeOf, rideOfRideRef } from "../mappers.js";
6
6
  /** KU-1: a page of the rider's history. */
7
7
  export const RIDES_PAGE = 20;
8
8
  const NS_PER_MS_INT = 1000000n;
9
9
  function profileOf(profile) {
10
10
  return { name: profile.name, createdMs: Number(profile.createdAtNs / NS_PER_MS_INT), updatedMs: Number(profile.updatedAtNs / NS_PER_MS_INT) };
11
11
  }
12
- function entryOf(entry) {
13
- return {
14
- rideRef: encodeToken({ c: entry.driverCanister.toText(), k: entry.driverKey, r: entry.requestId }),
15
- requestId: entry.requestId,
16
- end: Object.keys(entry.end)[0],
17
- endedAtMs: msOf(entry.endedAtNs),
18
- price: entry.price[0] === undefined ? undefined : moneyOf(entry.price[0]),
19
- };
20
- }
21
12
  export class ProfilesActor {
22
13
  group;
23
14
  constructor(coordinatorId, identity, options = {}) {
@@ -76,8 +67,51 @@ export class ProfilesActor {
76
67
  const beforeIndex = cursor === undefined ? [] : [BigInt(decodeToken(cursor).b)];
77
68
  const page = await executeAsyncUnsafe(async () => (await this.group.coreAsync()).getMyRides({ beforeIndex: beforeIndex, limit: BigInt(limit) }));
78
69
  return {
79
- rides: page.rides.map(entryOf),
70
+ rides: page.rides.map(historyEntryOf),
80
71
  nextCursor: page.nextBeforeIndex[0] === undefined ? undefined : encodeToken({ b: page.nextBeforeIndex[0].toString() }),
81
72
  };
82
73
  }
74
+ /**
75
+ * C-8, KU-4 (0.5.0): one line of the rider's history by its `rideRef` — for the details
76
+ * screen after a reload (Skąd, Dokąd) and to show the stars after a rating.
77
+ * @returns undefined while the ride is not in the core yet (K-9, KU-2: up to a minute)
78
+ * @throws Error with message `CanisterError` — `NotAuthorized` (anonymous, another rider's ride), `InvalidToken`
79
+ * @throws Error with message `CriticalCanisterError` — the core could not be reached
80
+ */
81
+ async getMyRideAsyncUnsafe(rideRef) {
82
+ const ride = rideOfRideRef(rideRef);
83
+ try {
84
+ return historyEntryOf(await executeAsyncUnsafe(async () => (await this.group.coreAsync()).getMyRide({ requestId: ride.requestId })));
85
+ }
86
+ catch (err) {
87
+ if (errorKeyOf(err) === "NotFound")
88
+ return undefined;
89
+ throw err;
90
+ }
91
+ }
92
+ /**
93
+ * KU-5 (0.5.0, core C-23): the rider rates the driver of a past ride, 1–5 stars, no
94
+ * comment (U-33). Only a completed ride, within 24 h of its end, once — a rating given
95
+ * live after the ride (`RideRequest.rateDriverAsyncUnsafe`) counts as the one. Show the
96
+ * stars only when `RideHistoryEntry.ratable`.
97
+ * @returns `ok` | `alreadyRated` | `notRatable` | `notAuthorized` (see `RateRideOutcome`)
98
+ * @throws Error with message `CanisterError` — `InvalidData` (stars outside 1–5), `InvalidToken`
99
+ * @throws Error with message `CallRefusedAtInspectionStage` — anonymous, or the daily limit (20, shared with the profile)
100
+ * @throws Error with message `CriticalCanisterError` — the core could not be reached
101
+ */
102
+ async ratePastRideAsyncUnsafe(rideRef, stars) {
103
+ const ride = rideOfRideRef(rideRef);
104
+ if (!Number.isInteger(stars) || stars < 1 || stars > 5)
105
+ throw canisterError("InvalidData", "stars: 1 to 5");
106
+ try {
107
+ const answer = await executeAsyncUnsafe(async () => (await this.group.coreAsync()).rateMyRide({ requestId: ride.requestId, stars }));
108
+ return rateOutcomeOf(answer) ?? "notRatable";
109
+ }
110
+ catch (err) {
111
+ const outcome = rateOutcomeOf({ errorKey: errorKeyOf(err) });
112
+ if (outcome !== undefined)
113
+ return outcome;
114
+ throw err;
115
+ }
116
+ }
83
117
  }
@@ -2,7 +2,7 @@ import type { Identity } from "@icp-sdk/core/agent";
2
2
  import { type GroupOptions } from "../group/canister-actor.js";
3
3
  import { TigiGroup } from "../group/group.js";
4
4
  import { type Geo } from "../geo.js";
5
- import type { ChatPlace, ChooseOutcome, LicenceView, RequestSnapshot, RideView } from "../interfaces.js";
5
+ import type { ChatPlace, ChooseOutcome, LicenceView, RequestSnapshot, RideView, RouteLineView } from "../interfaces.js";
6
6
  /** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
7
7
  export declare const SEARCH_RADIUS_METERS = 3000;
8
8
  export declare const WIDE_RADIUS_METERS = 6000;
@@ -159,6 +159,26 @@ export declare class RideRequest {
159
159
  * @throws Error with message `CriticalCanisterError` — the worker could not be reached
160
160
  */
161
161
  chooseOfferAsyncUnsafe(offerId: string): Promise<ChooseOutcome>;
162
+ /**
163
+ * ZO-21 (2026-10-24, route line): the driver's route of one offer, to draw when the rider
164
+ * taps it — from the driver's exact position to the pickup, then the ride (P-17). One
165
+ * query per tap: the lines are not in the polled snapshot.
166
+ * @returns undefined when the offer has no line: an older driver canister or worker, a
167
+ * line the network dropped (too big, not valid), the offer past its time or gone, or its
168
+ * worker upgraded since (the line lives in the worker's heap only, WO-22)
169
+ * @throws Error with message `CanisterError` — `NotAuthorized` (not your request), `NotFound` (an offer this request does not hold), `InvalidToken`
170
+ * @throws Error with message `CriticalCanisterError` — the worker could not be reached
171
+ */
172
+ getOfferRouteAsyncUnsafe(offerId: string): Promise<RouteLineView | undefined>;
173
+ /**
174
+ * K-13 (2026-10-24, route line): the line of the accepted ride, while it is active — read
175
+ * once (it does not change), not in `getRideAsyncUnsafe`, which is polled (P-19).
176
+ * @returns undefined when the ride has no line (the quote had none), has ended, or the
177
+ * driver canister is older than the line (no `getRideRoute`)
178
+ * @throws Error with message `CanisterError` — `NOT_ACCEPTED` (no driver accepted yet), `notAuthorized` (not the rider of the ride)
179
+ * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
180
+ */
181
+ getRideRouteAsyncUnsafe(): Promise<RouteLineView | undefined>;
162
182
  /**
163
183
  * K-5, U-42: "Szukaj ponownie" after "Kierowca anulował kurs" — a NEW request with the
164
184
  * same pickup, destination and rider name (a new `requestId`; the old request ended with
@@ -1 +1 @@
1
- {"version":3,"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AC;IAStE;;;;;;OAMG;IACU,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvE;;;;;;;;;;;OAWG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiC5E;;;;;;;;;OASG;IACU,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAW1F;;;;;;;OAOG;IACU,uBAAuB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAW1E;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,WAAW,CAAC;IAmB3D;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/C;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAKpD;;;;;OAKG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnD;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC;IAO1D;;;;;;;;;OASG;IACU,uBAAuB,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAOtE;;;;;;OAMG;IACU,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOnE,4IAA4I;IAC5I,OAAO,CAAC,WAAW;YAML,kBAAkB;YAkBlB,UAAU;IA8DxB,iHAAiH;YACnG,gBAAgB;IAS9B,6FAA6F;YAC/E,UAAU;YASV,kBAAkB;YAalB,mBAAmB;YAOnB,WAAW;CAG5B"}
@@ -6,12 +6,12 @@
6
6
  // driver canister: a request is a `RideRequest`, an offer an `offerId`.
7
7
  import { Principal } from "@icp-sdk/core/principal";
8
8
  import { idlFactory as driverIdl } from "../../declarations/tigi-driver/tigi-driver.did.js";
9
- import { canisterError, errorKeyOf, executeAsyncUnsafe, executeProtocolAsyncUnsafe, MAINNET_HOST, rawActorAsync, transportAsync } from "../group/canister-actor.js";
9
+ import { canisterError, errorKeyOf, executeAsyncUnsafe, executeProtocolAsyncUnsafe, isMethodMissingError, MAINNET_HOST, rawActorAsync, transportAsync } from "../group/canister-actor.js";
10
10
  import { TigiGroup } from "../group/group.js";
11
11
  import { geohashesByWorker } from "../group/prefixes.js";
12
12
  import { cellsWithin, isValidGeo } from "../geo.js";
13
13
  import { driverChatPlaceAsyncUnsafe } from "../chat.js";
14
- import { cardOf, closeReasonOf, decodeToken, driverOfOfferId, encodeToken, mergedPhase, mergeOffers, moneyOf, msOf, offerIdOf, offerOf, phaseOf, placeOffers, rideStatusOf } from "../mappers.js";
14
+ import { cardOf, closeReasonOf, decodeToken, driverOfOfferId, encodeToken, mergedPhase, mergeOffers, moneyOf, msOf, offerIdOf, offerOf, phaseOf, placeOffers, rideOfRideRef, rideStatusOf, routeLineOf } from "../mappers.js";
15
15
  /** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
16
16
  export const SEARCH_RADIUS_METERS = 3_000;
17
17
  export const WIDE_RADIUS_METERS = 6_000;
@@ -110,10 +110,8 @@ export class RidesActor {
110
110
  * @throws Error with message `CriticalCanisterError` — the driver canister does not answer ("brak połączenia z kierowcą")
111
111
  */
112
112
  async getPastRideAsyncUnsafe(rideRef) {
113
- const ref = decodeToken(rideRef);
114
- if (typeof ref.c !== "string" || typeof ref.k !== "string" || typeof ref.r !== "string")
115
- throw canisterError("InvalidToken", "not a ride of this package");
116
- return getRideOfAsyncUnsafe(this.identity, this.options, { canister: ref.c, driverKey: ref.k }, ref.r);
113
+ const ref = rideOfRideRef(rideRef);
114
+ return getRideOfAsyncUnsafe(this.identity, this.options, { canister: ref.canister, driverKey: ref.driverKey }, ref.requestId);
117
115
  }
118
116
  async riderNameAsyncUnsafe() {
119
117
  try {
@@ -328,6 +326,48 @@ export class RideRequest {
328
326
  this.choosing = false;
329
327
  }
330
328
  }
329
+ /**
330
+ * ZO-21 (2026-10-24, route line): the driver's route of one offer, to draw when the rider
331
+ * taps it — from the driver's exact position to the pickup, then the ride (P-17). One
332
+ * query per tap: the lines are not in the polled snapshot.
333
+ * @returns undefined when the offer has no line: an older driver canister or worker, a
334
+ * line the network dropped (too big, not valid), the offer past its time or gone, or its
335
+ * worker upgraded since (the line lives in the worker's heap only, WO-22)
336
+ * @throws Error with message `CanisterError` — `NotAuthorized` (not your request), `NotFound` (an offer this request does not hold), `InvalidToken`
337
+ * @throws Error with message `CriticalCanisterError` — the worker could not be reached
338
+ */
339
+ async getOfferRouteAsyncUnsafe(offerId) {
340
+ try {
341
+ const line = await this.onOfferAsyncUnsafe(offerId, (actor, ref) => actor.getOfferRoute(ref));
342
+ return routeLineOf(line);
343
+ }
344
+ catch (err) {
345
+ // A held offer without a line; an older worker without the method.
346
+ if ((errorKeyOf(err) === "NotFound" && this.offerWorkers.has(offerId)) || isMethodMissingError(err))
347
+ return undefined;
348
+ throw err;
349
+ }
350
+ }
351
+ /**
352
+ * K-13 (2026-10-24, route line): the line of the accepted ride, while it is active — read
353
+ * once (it does not change), not in `getRideAsyncUnsafe`, which is polled (P-19).
354
+ * @returns undefined when the ride has no line (the quote had none), has ended, or the
355
+ * driver canister is older than the line (no `getRideRoute`)
356
+ * @throws Error with message `CanisterError` — `NOT_ACCEPTED` (no driver accepted yet), `notAuthorized` (not the rider of the ride)
357
+ * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
358
+ */
359
+ async getRideRouteAsyncUnsafe() {
360
+ const accepted = await this.acceptedAsyncUnsafe();
361
+ try {
362
+ const line = await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).getRideRoute({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
363
+ return routeLineOf(line);
364
+ }
365
+ catch (err) {
366
+ if (errorKeyOf(err) === "notFound" || isMethodMissingError(err))
367
+ return undefined;
368
+ throw err;
369
+ }
370
+ }
331
371
  /**
332
372
  * K-5, U-42: "Szukaj ponownie" after "Kierowca anulował kurs" — a NEW request with the
333
373
  * same pickup, destination and rider name (a new `requestId`; the old request ended with
package/dist/geo.d.ts CHANGED
@@ -7,6 +7,11 @@ export declare function isValidGeo(geo: Geo): boolean;
7
7
  export declare function encodeGeohash(geo: Geo, precision: number): string;
8
8
  /** The centre of the cell of a geohash; undefined for a character outside the alphabet. */
9
9
  export declare function decodeGeohashCenter(geohash: string): Geo | undefined;
10
+ /**
11
+ * P-17: the points of a Google encoded polyline (precision 6 by default); undefined for a
12
+ * text that is not one or a point off the map.
13
+ */
14
+ export declare function decodePolyline(text: string, precision?: number): Geo[] | undefined;
10
15
  /** Great-circle distance (haversine). */
11
16
  export declare function distanceMeters(a: Geo, b: Geo): number;
12
17
  /**
package/dist/geo.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAID,eAAO,MAAM,mBAAmB,UAAY,CAAC;AAO7C,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAE5C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAyCjE;AAED,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CA2BpE;AAMD,yCAAyC;AACzC,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAkCvE"}
1
+ {"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,GAAG;IAChB,GAAG,EAAE,MA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