@jsm-mit/tigi-sharded-package 0.10.0 → 0.12.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.
@@ -3,6 +3,7 @@ import type { ActorMethod } from '@icp-sdk/core/agent';
3
3
  import type { IDL } from '@icp-sdk/core/candid';
4
4
 
5
5
  export interface AreaMap { 'entries' : Array<PrefixEntry>, 'version' : bigint }
6
+ export interface BookingRef { 'requestId' : RequestId, 'driverKey' : DriverKey }
6
7
  export type CarrierKind = { 'other' : string } |
7
8
  { 'taxi' : null } |
8
9
  { 'rideHailing' : null } |
@@ -131,6 +132,7 @@ export interface OfferRef {
131
132
  'driverCanister' : Principal,
132
133
  }
133
134
  export interface OfferView {
135
+ 'freeAtNs' : [] | [bigint],
134
136
  'rideMeters' : number,
135
137
  'driverRating' : [] | [number],
136
138
  'card' : DriverCard,
@@ -164,6 +166,7 @@ export type ProtocolError = { 'expired' : null } |
164
166
  export type ProtocolResult = { 'ok' : null } |
165
167
  { 'err' : ProtocolError };
166
168
  export interface Quote {
169
+ 'freeAtNs' : [] | [bigint],
167
170
  'requestId' : RequestId,
168
171
  'rideMeters' : number,
169
172
  'rideSec' : number,
@@ -180,7 +183,14 @@ export interface QuoteDecline {
180
183
  'driverKey' : DriverKey,
181
184
  }
182
185
  export interface RateDriverArgs { 'requestId' : RequestId, 'stars' : number }
186
+ export interface RegisterBase {
187
+ 'card' : DriverCard,
188
+ 'cardVersion' : number,
189
+ 'geohash' : Geohash,
190
+ 'driverKey' : DriverKey,
191
+ }
183
192
  export interface RegisterDriver {
193
+ 'freeAtNs' : [] | [bigint],
184
194
  'card' : DriverCard,
185
195
  'cardVersion' : number,
186
196
  'geohash' : Geohash,
@@ -226,25 +236,29 @@ export interface RequestView {
226
236
  'radiusMeters' : number,
227
237
  'waiting' : number,
228
238
  }
239
+ export type RescueReason = { 'driverDropped' : null } |
240
+ { 'noChoice' : null };
229
241
  export type Result = { 'ok' : bigint } |
230
242
  { 'err' : Error };
231
- export type Result_1 = { 'ok' : RequestView } |
243
+ export type Result_1 = { 'ok' : ScheduledView } |
244
+ { 'err' : Error };
245
+ export type Result_10 = { 'ok' : ChooseOutcome } |
232
246
  { 'err' : Error };
233
- export type Result_2 = { 'ok' : boolean } |
247
+ export type Result_2 = { 'ok' : RequestView } |
234
248
  { 'err' : Error };
235
- export type Result_3 = { 'ok' : bigint } |
249
+ export type Result_3 = { 'ok' : boolean } |
236
250
  { 'err' : Error };
237
- export type Result_4 = { 'ok' : WorkerStatus } |
251
+ export type Result_4 = { 'ok' : bigint } |
238
252
  { 'err' : Error };
239
- export type Result_5 = { 'ok' : Array<PrefixCount> } |
253
+ export type Result_5 = { 'ok' : WorkerStatus } |
240
254
  { 'err' : Error };
241
- export type Result_6 = { 'ok' : RouteLine } |
255
+ export type Result_6 = { 'ok' : Array<PrefixCount> } |
242
256
  { 'err' : Error };
243
- export type Result_7 = { 'ok' : FlowStatus } |
257
+ export type Result_7 = { 'ok' : RouteLine } |
244
258
  { 'err' : Error };
245
- export type Result_8 = { 'ok' : WorkerConfig } |
259
+ export type Result_8 = { 'ok' : FlowStatus } |
246
260
  { 'err' : Error };
247
- export type Result_9 = { 'ok' : ChooseOutcome } |
261
+ export type Result_9 = { 'ok' : WorkerConfig } |
248
262
  { 'err' : Error };
249
263
  export type RideStatus = { 'completed' : { 'price' : Money } } |
250
264
  { 'cancelledByRider' : null } |
@@ -264,6 +278,48 @@ export interface RiderRating {
264
278
  'driverKey' : DriverKey,
265
279
  }
266
280
  export interface RouteLine { 'ride' : string, 'toPickup' : string }
281
+ export interface ScheduledRideArgs {
282
+ 'destination' : Geo,
283
+ 'requestId' : RequestId,
284
+ 'maxRadiusMeters' : number,
285
+ 'pickup' : Geo,
286
+ 'pickupAtNs' : bigint,
287
+ 'riderName' : string,
288
+ }
289
+ export type ScheduledStateView = { 'rescue' : { 'reason' : RescueReason } } |
290
+ { 'closed' : { 'reason' : CloseReason } } |
291
+ { 'collecting' : null } |
292
+ { 'started' : { 'driverKey' : DriverKey, 'driverCanister' : Principal } } |
293
+ {
294
+ 'booked' : {
295
+ 'driverRating' : [] | [number],
296
+ 'card' : DriverCard,
297
+ 'driverKey' : DriverKey,
298
+ 'driverCanister' : Principal,
299
+ 'price' : Money,
300
+ }
301
+ } |
302
+ {
303
+ 'booking' : {
304
+ 'driverKey' : DriverKey,
305
+ 'answerByNs' : bigint,
306
+ 'driverCanister' : Principal,
307
+ }
308
+ };
309
+ export interface ScheduledView {
310
+ 'nextStageNs' : [] | [bigint],
311
+ 'requestId' : RequestId,
312
+ 'asked' : number,
313
+ 'asOfNs' : bigint,
314
+ 'createdNs' : bigint,
315
+ 'offers' : Array<OfferView>,
316
+ 'state' : ScheduledStateView,
317
+ 'closesNs' : bigint,
318
+ 'pickupAtNs' : bigint,
319
+ 'lastOrderRefused' : boolean,
320
+ 'radiusMeters' : number,
321
+ 'waiting' : number,
322
+ }
267
323
  export interface TestLoadArgs {
268
324
  'reportLevel' : [] | [bigint],
269
325
  'cells' : Array<PrefixCount>,
@@ -279,19 +335,39 @@ export interface TigiWorker {
279
335
  * / from there. Blocks act at once (WO-2); ratings go into offers and orders (P-12).
280
336
  */
281
337
  'applyCoreChanges' : ActorMethod<[CoreChanges], Result>,
338
+ /**
339
+ * / ZT-18 (P-22): the booked driver gives the booking up.
340
+ */
341
+ 'bookingDropped' : ActorMethod<[BookingRef], undefined>,
342
+ /**
343
+ * / ZT-17 (P-22): the booked driver's "Jadę" — the ride starts here as an accepted request.
344
+ */
345
+ 'bookingStarted' : ActorMethod<[BookingRef], ProtocolResult>,
346
+ /**
347
+ * / ZT-13: the rider gives the ride at a chosen time up.
348
+ */
349
+ 'cancelScheduled' : ActorMethod<[RequestRef], Result_3>,
282
350
  /**
283
351
  * / ZO-13, ZO-14, ZO-17.
284
352
  */
285
- 'chooseOffer' : ActorMethod<[OfferRef], Result_9>,
353
+ 'chooseOffer' : ActorMethod<[OfferRef], Result_10>,
354
+ /**
355
+ * / ZT-14: "Wybierz" on an offer for a ride at a chosen time — a booking order.
356
+ */
357
+ 'chooseScheduledOffer' : ActorMethod<[OfferRef], Result_10>,
286
358
  'clearLogs' : ActorMethod<[], undefined>,
287
359
  /**
288
360
  * / ZO-15 (otherOfferChosen after an acceptance in another worker), ZO-18 (riderGaveUp).
289
361
  */
290
- 'closeRequest' : ActorMethod<[CloseRequestArgs], Result_2>,
362
+ 'closeRequest' : ActorMethod<[CloseRequestArgs], Result_3>,
363
+ /**
364
+ * / ZT-21: the copies in the other workers close once one booked.
365
+ */
366
+ 'closeScheduled' : ActorMethod<[CloseRequestArgs], Result_3>,
291
367
  /**
292
368
  * / The coordinator only: the settings it computes for every worker.
293
369
  */
294
- 'configure' : ActorMethod<[ConfigureArgs], Result_8>,
370
+ 'configure' : ActorMethod<[ConfigureArgs], Result_9>,
295
371
  /**
296
372
  * / ZO-6.
297
373
  */
@@ -303,46 +379,50 @@ export interface TigiWorker {
303
379
  /**
304
380
  * / The flow's numbers (scripts, the coordinator's front).
305
381
  */
306
- 'getFlowStatus' : ActorMethod<[], Result_7>,
382
+ 'getFlowStatus' : ActorMethod<[], Result_8>,
307
383
  'getLogs' : ActorMethod<[], string>,
308
384
  /**
309
385
  * / ZO-21 (2026-10-24, route line): the route line of one offer, for the rider of the
310
386
  * / request only (the package asks after a tap on the offer).
311
387
  */
312
- 'getOfferRoute' : ActorMethod<[OfferRef], Result_6>,
388
+ 'getOfferRoute' : ActorMethod<[OfferRef], Result_7>,
313
389
  /**
314
390
  * / The load this worker counts per geohash prefix of the given length (1–6): the
315
391
  * / coordinator picks from it what to give another worker on a split (KO-5).
316
392
  */
317
- 'getPrefixCounts' : ActorMethod<[bigint], Result_5>,
393
+ 'getPrefixCounts' : ActorMethod<[bigint], Result_6>,
318
394
  /**
319
395
  * / ZO-11: the state and the offers (the package polls it every second).
320
396
  */
321
- 'getRequest' : ActorMethod<[RequestRef], Result_1>,
397
+ 'getRequest' : ActorMethod<[RequestRef], Result_2>,
398
+ /**
399
+ * / ZT-12: the state and the offers of a ride at a chosen time.
400
+ */
401
+ 'getScheduled' : ActorMethod<[RequestRef], Result_1>,
322
402
  /**
323
403
  * / The worker's own view of itself — for the coordinator and its front.
324
404
  */
325
- 'getStatus' : ActorMethod<[], Result_4>,
405
+ 'getStatus' : ActorMethod<[], Result_5>,
326
406
  /**
327
407
  * / The coordinator only, before it deletes the worker: what a deleted canister still
328
408
  * / holds is burned.
329
409
  */
330
- 'giveBackCycles' : ActorMethod<[], Result_3>,
410
+ 'giveBackCycles' : ActorMethod<[], Result_4>,
331
411
  /**
332
412
  * / ZO-18: the rider gives up.
333
413
  */
334
- 'giveUp' : ActorMethod<[RequestRef], Result_2>,
414
+ 'giveUp' : ActorMethod<[RequestRef], Result_3>,
335
415
  /**
336
416
  * / WO-20 (stage and the test modes): simulated drivers within 3 km of the point?
337
417
  */
338
- 'hasSimulatedDrivers' : ActorMethod<[HasSimulatedDriversArgs], Result_2>,
418
+ 'hasSimulatedDrivers' : ActorMethod<[HasSimulatedDriversArgs], Result_3>,
339
419
  /**
340
420
  * / The coordinator only, in a test mode only (prod and stage refuse, and so does the
341
421
  * / coordinator): a load put on this worker. The cells' counters grow, and the worker
342
422
  * / reports `reportLevel` as a real minute would — what a local script uses to force a
343
423
  * / split.
344
424
  */
345
- 'injectTestLoad' : ActorMethod<[TestLoadArgs], Result_2>,
425
+ 'injectTestLoad' : ActorMethod<[TestLoadArgs], Result_3>,
346
426
  /**
347
427
  * / WO-3: the geohash lies in this worker's area (by the coordinator's newest map).
348
428
  */
@@ -350,7 +430,7 @@ export interface TigiWorker {
350
430
  /**
351
431
  * / K-8: the rider rates the driver.
352
432
  */
353
- 'rateDriver' : ActorMethod<[RateDriverArgs], Result_2>,
433
+ 'rateDriver' : ActorMethod<[RateDriverArgs], Result_3>,
354
434
  /**
355
435
  * / K-8.
356
436
  */
@@ -358,7 +438,12 @@ export interface TigiWorker {
358
438
  /**
359
439
  * / ZO-10: a stale offer asks its driver again.
360
440
  */
361
- 'refreshOffer' : ActorMethod<[OfferRef], Result_2>,
441
+ 'refreshOffer' : ActorMethod<[OfferRef], Result_3>,
442
+ /**
443
+ * / ZT-1 … ZT-3 (P-21): a driver's base — on a change and once a day, whether the driver
444
+ * / works or not.
445
+ */
446
+ 'registerBase' : ActorMethod<[RegisterBase], ProtocolResult>,
362
447
  /**
363
448
  * / WO-1 … WO-8: a driver reports itself — on a cell change and every 60 s (U-27).
364
449
  */
@@ -366,11 +451,19 @@ export interface TigiWorker {
366
451
  /**
367
452
  * / ZO-12: ✕.
368
453
  */
369
- 'rejectOffer' : ActorMethod<[OfferRef], Result_2>,
454
+ 'rejectOffer' : ActorMethod<[OfferRef], Result_3>,
455
+ /**
456
+ * / ZT-9: ✕ on one offer.
457
+ */
458
+ 'rejectScheduledOffer' : ActorMethod<[OfferRef], Result_3>,
370
459
  /**
371
460
  * / ZO-1 … ZO-4, ZO-8: a request in this worker; the drivers are asked after the answer.
372
461
  */
373
- 'requestRide' : ActorMethod<[RequestRideArgs], Result_1>,
462
+ 'requestRide' : ActorMethod<[RequestRideArgs], Result_2>,
463
+ /**
464
+ * / ZT-4: a ride at a chosen time in this worker (kurs-na-termin.md).
465
+ */
466
+ 'requestScheduled' : ActorMethod<[ScheduledRideArgs], Result_1>,
374
467
  /**
375
468
  * / K-2, K-6, K-7.
376
469
  */
@@ -384,6 +477,10 @@ export interface TigiWorker {
384
477
  * / ZO-9, ZO-10.
385
478
  */
386
479
  'submitQuote' : ActorMethod<[Quote], ProtocolResult>,
480
+ /**
481
+ * / ZT-2 (P-21).
482
+ */
483
+ 'unregisterBase' : ActorMethod<[DriverKey], undefined>,
387
484
  /**
388
485
  * / WO-6.
389
486
  */
@@ -80,6 +80,12 @@ export const idlFactory = ({ IDL }) => {
80
80
  });
81
81
  const Error = IDL.Record({ 'details' : ErrorDetails, 'logsJson' : IDL.Text });
82
82
  const Result = IDL.Variant({ 'ok' : IDL.Nat64, 'err' : Error });
83
+ const BookingRef = IDL.Record({
84
+ 'requestId' : RequestId,
85
+ 'driverKey' : DriverKey,
86
+ });
87
+ const RequestRef = IDL.Record({ 'requestId' : RequestId });
88
+ const Result_3 = IDL.Variant({ 'ok' : IDL.Bool, 'err' : Error });
83
89
  const OfferRef = IDL.Record({
84
90
  'requestId' : RequestId,
85
91
  'driverKey' : DriverKey,
@@ -92,7 +98,7 @@ export const idlFactory = ({ IDL }) => {
92
98
  'ordered' : IDL.Record({ 'answerByNs' : IDL.Nat64 }),
93
99
  'driverNotFree' : IDL.Null,
94
100
  });
95
- const Result_9 = IDL.Variant({ 'ok' : ChooseOutcome, 'err' : Error });
101
+ const Result_10 = IDL.Variant({ 'ok' : ChooseOutcome, 'err' : Error });
96
102
  const CloseReason = IDL.Variant({
97
103
  'offerRejected' : IDL.Null,
98
104
  'otherOfferChosen' : IDL.Null,
@@ -103,7 +109,6 @@ export const idlFactory = ({ IDL }) => {
103
109
  'requestId' : RequestId,
104
110
  'reason' : CloseReason,
105
111
  });
106
- const Result_2 = IDL.Variant({ 'ok' : IDL.Bool, 'err' : Error });
107
112
  const LevelThresholds = IDL.Record({
108
113
  'level1' : IDL.Nat,
109
114
  'level2' : IDL.Nat,
@@ -124,7 +129,7 @@ export const idlFactory = ({ IDL }) => {
124
129
  'load' : LoadThresholds,
125
130
  'lowCyclesBelow' : IDL.Nat,
126
131
  });
127
- const Result_8 = IDL.Variant({ 'ok' : WorkerConfig, 'err' : Error });
132
+ const Result_9 = IDL.Variant({ 'ok' : WorkerConfig, 'err' : Error });
128
133
  const QuoteDecline = IDL.Record({
129
134
  'requestId' : RequestId,
130
135
  'driverKey' : DriverKey,
@@ -150,12 +155,11 @@ export const idlFactory = ({ IDL }) => {
150
155
  'rides' : IDL.Nat,
151
156
  'openRequests' : IDL.Nat,
152
157
  });
153
- const Result_7 = IDL.Variant({ 'ok' : FlowStatus, 'err' : Error });
158
+ const Result_8 = IDL.Variant({ 'ok' : FlowStatus, 'err' : Error });
154
159
  const RouteLine = IDL.Record({ 'ride' : IDL.Text, 'toPickup' : IDL.Text });
155
- const Result_6 = IDL.Variant({ 'ok' : RouteLine, 'err' : Error });
160
+ const Result_7 = IDL.Variant({ 'ok' : RouteLine, 'err' : Error });
156
161
  const PrefixCount = IDL.Record({ 'load' : IDL.Nat, 'prefix' : IDL.Text });
157
- const Result_5 = IDL.Variant({ 'ok' : IDL.Vec(PrefixCount), 'err' : Error });
158
- const RequestRef = IDL.Record({ 'requestId' : RequestId });
162
+ const Result_6 = IDL.Variant({ 'ok' : IDL.Vec(PrefixCount), 'err' : Error });
159
163
  const CarrierKind = IDL.Variant({
160
164
  'other' : IDL.Text,
161
165
  'taxi' : IDL.Null,
@@ -173,6 +177,7 @@ export const idlFactory = ({ IDL }) => {
173
177
  const Money = IDL.Record({ 'currency' : IDL.Text, 'amount' : IDL.Nat64 });
174
178
  const Geo = IDL.Record({ 'lat' : IDL.Float64, 'lng' : IDL.Float64 });
175
179
  const OfferView = IDL.Record({
180
+ 'freeAtNs' : IDL.Opt(IDL.Nat64),
176
181
  'rideMeters' : IDL.Nat32,
177
182
  'driverRating' : IDL.Opt(IDL.Nat16),
178
183
  'card' : DriverCard,
@@ -222,7 +227,47 @@ export const idlFactory = ({ IDL }) => {
222
227
  'radiusMeters' : IDL.Nat32,
223
228
  'waiting' : IDL.Nat32,
224
229
  });
225
- const Result_1 = IDL.Variant({ 'ok' : RequestView, 'err' : Error });
230
+ const Result_2 = IDL.Variant({ 'ok' : RequestView, 'err' : Error });
231
+ const RescueReason = IDL.Variant({
232
+ 'driverDropped' : IDL.Null,
233
+ 'noChoice' : IDL.Null,
234
+ });
235
+ const ScheduledStateView = IDL.Variant({
236
+ 'rescue' : IDL.Record({ 'reason' : RescueReason }),
237
+ 'closed' : IDL.Record({ 'reason' : CloseReason }),
238
+ 'collecting' : IDL.Null,
239
+ 'started' : IDL.Record({
240
+ 'driverKey' : DriverKey,
241
+ 'driverCanister' : IDL.Principal,
242
+ }),
243
+ 'booked' : IDL.Record({
244
+ 'driverRating' : IDL.Opt(IDL.Nat16),
245
+ 'card' : DriverCard,
246
+ 'driverKey' : DriverKey,
247
+ 'driverCanister' : IDL.Principal,
248
+ 'price' : Money,
249
+ }),
250
+ 'booking' : IDL.Record({
251
+ 'driverKey' : DriverKey,
252
+ 'answerByNs' : IDL.Nat64,
253
+ 'driverCanister' : IDL.Principal,
254
+ }),
255
+ });
256
+ const ScheduledView = IDL.Record({
257
+ 'nextStageNs' : IDL.Opt(IDL.Nat64),
258
+ 'requestId' : RequestId,
259
+ 'asked' : IDL.Nat32,
260
+ 'asOfNs' : IDL.Nat64,
261
+ 'createdNs' : IDL.Nat64,
262
+ 'offers' : IDL.Vec(OfferView),
263
+ 'state' : ScheduledStateView,
264
+ 'closesNs' : IDL.Nat64,
265
+ 'pickupAtNs' : IDL.Nat64,
266
+ 'lastOrderRefused' : IDL.Bool,
267
+ 'radiusMeters' : IDL.Nat32,
268
+ 'waiting' : IDL.Nat32,
269
+ });
270
+ const Result_1 = IDL.Variant({ 'ok' : ScheduledView, 'err' : Error });
226
271
  const LoadLevel = IDL.Nat;
227
272
  const LoadReport = IDL.Record({
228
273
  'updateCalls' : IDL.Nat,
@@ -245,8 +290,8 @@ export const idlFactory = ({ IDL }) => {
245
290
  'openRequests' : IDL.Nat,
246
291
  'coordinator' : IDL.Principal,
247
292
  });
248
- const Result_4 = IDL.Variant({ 'ok' : WorkerStatus, 'err' : Error });
249
- const Result_3 = IDL.Variant({ 'ok' : IDL.Nat, 'err' : Error });
293
+ const Result_5 = IDL.Variant({ 'ok' : WorkerStatus, 'err' : Error });
294
+ const Result_4 = IDL.Variant({ 'ok' : IDL.Nat, 'err' : Error });
250
295
  const HasSimulatedDriversArgs = IDL.Record({ 'center' : Geo });
251
296
  const TestLoadArgs = IDL.Record({
252
297
  'reportLevel' : IDL.Opt(IDL.Nat),
@@ -262,7 +307,14 @@ export const idlFactory = ({ IDL }) => {
262
307
  'driverKey' : DriverKey,
263
308
  });
264
309
  const Geohash = IDL.Text;
310
+ const RegisterBase = IDL.Record({
311
+ 'card' : DriverCard,
312
+ 'cardVersion' : IDL.Nat32,
313
+ 'geohash' : Geohash,
314
+ 'driverKey' : DriverKey,
315
+ });
265
316
  const RegisterDriver = IDL.Record({
317
+ 'freeAtNs' : IDL.Opt(IDL.Nat64),
266
318
  'card' : DriverCard,
267
319
  'cardVersion' : IDL.Nat32,
268
320
  'geohash' : Geohash,
@@ -278,6 +330,14 @@ export const idlFactory = ({ IDL }) => {
278
330
  'radiusMeters' : IDL.Nat32,
279
331
  'riderName' : IDL.Text,
280
332
  });
333
+ const ScheduledRideArgs = IDL.Record({
334
+ 'destination' : Geo,
335
+ 'requestId' : RequestId,
336
+ 'maxRadiusMeters' : IDL.Nat32,
337
+ 'pickup' : Geo,
338
+ 'pickupAtNs' : IDL.Nat64,
339
+ 'riderName' : IDL.Text,
340
+ });
281
341
  const RideStatusChange = IDL.Record({
282
342
  'status' : RideStatus,
283
343
  'requestId' : RequestId,
@@ -293,6 +353,7 @@ export const idlFactory = ({ IDL }) => {
293
353
  'version' : IDL.Nat64,
294
354
  });
295
355
  const Quote = IDL.Record({
356
+ 'freeAtNs' : IDL.Opt(IDL.Nat64),
296
357
  'requestId' : RequestId,
297
358
  'rideMeters' : IDL.Nat32,
298
359
  'rideSec' : IDL.Nat32,
@@ -307,36 +368,46 @@ export const idlFactory = ({ IDL }) => {
307
368
  const TigiWorker = IDL.Service({
308
369
  'answerOrder' : IDL.Func([OrderAnswer], [ProtocolResult], []),
309
370
  'applyCoreChanges' : IDL.Func([CoreChanges], [Result], []),
310
- 'chooseOffer' : IDL.Func([OfferRef], [Result_9], []),
371
+ 'bookingDropped' : IDL.Func([BookingRef], [], []),
372
+ 'bookingStarted' : IDL.Func([BookingRef], [ProtocolResult], []),
373
+ 'cancelScheduled' : IDL.Func([RequestRef], [Result_3], []),
374
+ 'chooseOffer' : IDL.Func([OfferRef], [Result_10], []),
375
+ 'chooseScheduledOffer' : IDL.Func([OfferRef], [Result_10], []),
311
376
  'clearLogs' : IDL.Func([], [], []),
312
- 'closeRequest' : IDL.Func([CloseRequestArgs], [Result_2], []),
313
- 'configure' : IDL.Func([ConfigureArgs], [Result_8], []),
377
+ 'closeRequest' : IDL.Func([CloseRequestArgs], [Result_3], []),
378
+ 'closeScheduled' : IDL.Func([CloseRequestArgs], [Result_3], []),
379
+ 'configure' : IDL.Func([ConfigureArgs], [Result_9], []),
314
380
  'declineQuote' : IDL.Func([QuoteDecline], [], []),
315
381
  'getCoreCopyStatus' : IDL.Func([], [CoreCopyStatus], ['query']),
316
- 'getFlowStatus' : IDL.Func([], [Result_7], ['query']),
382
+ 'getFlowStatus' : IDL.Func([], [Result_8], ['query']),
317
383
  'getLogs' : IDL.Func([], [IDL.Text], ['query']),
318
- 'getOfferRoute' : IDL.Func([OfferRef], [Result_6], ['query']),
319
- 'getPrefixCounts' : IDL.Func([IDL.Nat], [Result_5], ['query']),
320
- 'getRequest' : IDL.Func([RequestRef], [Result_1], ['query']),
321
- 'getStatus' : IDL.Func([], [Result_4], ['query']),
322
- 'giveBackCycles' : IDL.Func([], [Result_3], []),
323
- 'giveUp' : IDL.Func([RequestRef], [Result_2], []),
384
+ 'getOfferRoute' : IDL.Func([OfferRef], [Result_7], ['query']),
385
+ 'getPrefixCounts' : IDL.Func([IDL.Nat], [Result_6], ['query']),
386
+ 'getRequest' : IDL.Func([RequestRef], [Result_2], ['query']),
387
+ 'getScheduled' : IDL.Func([RequestRef], [Result_1], ['query']),
388
+ 'getStatus' : IDL.Func([], [Result_5], ['query']),
389
+ 'giveBackCycles' : IDL.Func([], [Result_4], []),
390
+ 'giveUp' : IDL.Func([RequestRef], [Result_3], []),
324
391
  'hasSimulatedDrivers' : IDL.Func(
325
392
  [HasSimulatedDriversArgs],
326
- [Result_2],
393
+ [Result_3],
327
394
  ['query'],
328
395
  ),
329
- 'injectTestLoad' : IDL.Func([TestLoadArgs], [Result_2], []),
396
+ 'injectTestLoad' : IDL.Func([TestLoadArgs], [Result_3], []),
330
397
  'isMyArea' : IDL.Func([IDL.Text], [IDL.Bool], ['query']),
331
- 'rateDriver' : IDL.Func([RateDriverArgs], [Result_2], []),
398
+ 'rateDriver' : IDL.Func([RateDriverArgs], [Result_3], []),
332
399
  'rateRider' : IDL.Func([RiderRating], [ProtocolResult], []),
333
- 'refreshOffer' : IDL.Func([OfferRef], [Result_2], []),
400
+ 'refreshOffer' : IDL.Func([OfferRef], [Result_3], []),
401
+ 'registerBase' : IDL.Func([RegisterBase], [ProtocolResult], []),
334
402
  'registerDriver' : IDL.Func([RegisterDriver], [ProtocolResult], []),
335
- 'rejectOffer' : IDL.Func([OfferRef], [Result_2], []),
336
- 'requestRide' : IDL.Func([RequestRideArgs], [Result_1], []),
403
+ 'rejectOffer' : IDL.Func([OfferRef], [Result_3], []),
404
+ 'rejectScheduledOffer' : IDL.Func([OfferRef], [Result_3], []),
405
+ 'requestRide' : IDL.Func([RequestRideArgs], [Result_2], []),
406
+ 'requestScheduled' : IDL.Func([ScheduledRideArgs], [Result_1], []),
337
407
  'rideStatusChanged' : IDL.Func([RideStatusChange], [ProtocolResult], []),
338
408
  'setAreaMap' : IDL.Func([AreaMap], [Result], []),
339
409
  'submitQuote' : IDL.Func([Quote], [ProtocolResult], []),
410
+ 'unregisterBase' : IDL.Func([DriverKey], [], []),
340
411
  'unregisterDriver' : IDL.Func([DriverKey], [], []),
341
412
  });
342
413
  return TigiWorker;
@@ -3,6 +3,7 @@ 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
5
  import type { CardPaymentView, ChatPlace, ChooseOutcome, LicenceView, RequestSnapshot, RideView, RouteLineView } from "../interfaces.js";
6
+ import { ScheduledRide } from "./scheduled-ride.js";
6
7
  /** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
7
8
  export declare const SEARCH_RADIUS_METERS = 3000;
8
9
  export declare const WIDE_RADIUS_METERS = 6000;
@@ -80,6 +81,25 @@ export declare class RidesActor {
80
81
  * @throws Error with message `CriticalCanisterError` — the network could not be reached
81
82
  */
82
83
  requestRideAsyncUnsafe(args: RequestRideArgs): Promise<RideRequest>;
84
+ /**
85
+ * ZT-4 (kurs-na-termin.md): a ride at a chosen time (1 h … 7 days ahead) in every worker
86
+ * whose area reaches 25 km around the pickup. The workers ask the drivers by their base
87
+ * and widen by themselves; poll the returned ride (`getAsyncUnsafe`, every `SCHEDULED_POLL_MS`).
88
+ * @throws Error with message `CanisterError` — `InvalidData` (`TOO_SOON` / `TOO_FAR` / bad points), `ALREADY_OPEN` (one at a time, D-4), `BLOCKED`, `NotFound` (no worker / no profile)
89
+ * @throws Error with message `CriticalCanisterError` — the network could not be reached
90
+ */
91
+ requestScheduledAsyncUnsafe(args: {
92
+ pickup: Geo;
93
+ destination: Geo;
94
+ pickupAtMs: number;
95
+ riderName?: string;
96
+ }): Promise<ScheduledRide>;
97
+ /**
98
+ * A ride at a chosen time again from its token (`ScheduledRide.token`).
99
+ * @throws Error with message `CanisterError` (errorKey `InvalidToken`) for a text this package did not make
100
+ */
101
+ resumeScheduled(token: string): ScheduledRide;
102
+ private scheduledOf;
83
103
  /**
84
104
  * A request again from its token (`RideRequest.token`), e.g. after a reload of the page.
85
105
  * @throws Error with message `CanisterError` (errorKey `InvalidToken`) for a text this package did not make
@@ -1 +1 @@
1
- {"version":3,"file":"rides-actor.d.ts","sourceRoot":"","sources":["../../src/actors/rides-actor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAgJ,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC7M,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,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CAAC;IAW1E;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,WAAW,CAAC;IAoB3D;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/C;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAOpD;;;;;OAKG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnD;;;;;;;;;OASG;IACU,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAYrF;;;;OAIG;IACU,2BAA2B,IAAI,OAAO,CAAC,eAAe,CAAC;IAYpE;;;;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;IASnE,4IAA4I;IAC5I,OAAO,CAAC,WAAW;YAML,kBAAkB;YA2BlB,UAAU;IA8DxB,iHAAiH;YACnG,gBAAgB;IAS9B,6FAA6F;YAC/E,UAAU;YASV,kBAAkB;YAalB,mBAAmB;YAOnB,WAAW;CAG5B"}
@@ -11,6 +11,7 @@ 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 { ScheduledRide, SCHEDULED_MAX_AHEAD_MS, SCHEDULED_MIN_AHEAD_MS, SCHEDULED_RADIUS_METERS, scheduledStateOf } from "./scheduled-ride.js";
14
15
  import { cardOf, closeReasonOf, decodeToken, driverOfOfferId, encodeToken, fresherRide, freshViews, mergedPhase, mergeOffers, moneyOf, msOf, offerIdOf, offerOf, phaseOf, placeOffers, rideOfRideRef, rideStatusOf, routeLineOf } from "../mappers.js";
15
16
  /** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
16
17
  export const SEARCH_RADIUS_METERS = 3_000;
@@ -95,6 +96,41 @@ export class RidesActor {
95
96
  await request.placeAsyncUnsafe(SEARCH_RADIUS_METERS);
96
97
  return request;
97
98
  }
99
+ /**
100
+ * ZT-4 (kurs-na-termin.md): a ride at a chosen time (1 h … 7 days ahead) in every worker
101
+ * whose area reaches 25 km around the pickup. The workers ask the drivers by their base
102
+ * and widen by themselves; poll the returned ride (`getAsyncUnsafe`, every `SCHEDULED_POLL_MS`).
103
+ * @throws Error with message `CanisterError` — `InvalidData` (`TOO_SOON` / `TOO_FAR` / bad points), `ALREADY_OPEN` (one at a time, D-4), `BLOCKED`, `NotFound` (no worker / no profile)
104
+ * @throws Error with message `CriticalCanisterError` — the network could not be reached
105
+ */
106
+ async requestScheduledAsyncUnsafe(args) {
107
+ if (!isValidGeo(args.pickup) || !isValidGeo(args.destination))
108
+ throw canisterError("InvalidData", "pickup / destination out of range");
109
+ const ahead = args.pickupAtMs - Date.now();
110
+ if (ahead < SCHEDULED_MIN_AHEAD_MS - 60_000)
111
+ throw canisterError("InvalidData", "TOO_SOON: at least 1 h ahead");
112
+ if (ahead > SCHEDULED_MAX_AHEAD_MS)
113
+ throw canisterError("InvalidData", "TOO_FAR: at most 7 days ahead");
114
+ const riderName = args.riderName ?? (await this.riderNameAsyncUnsafe());
115
+ const state = { v: 1, kind: "scheduled", requestId: globalThis.crypto.randomUUID(), pickup: args.pickup, destination: args.destination, riderName, pickupAtMs: args.pickupAtMs, workers: [] };
116
+ const ride = this.scheduledOf(state);
117
+ await ride.placeAsyncUnsafe(await workersForAsync(this.group, args.pickup, SCHEDULED_RADIUS_METERS, false));
118
+ return ride;
119
+ }
120
+ /**
121
+ * A ride at a chosen time again from its token (`ScheduledRide.token`).
122
+ * @throws Error with message `CanisterError` (errorKey `InvalidToken`) for a text this package did not make
123
+ */
124
+ resumeScheduled(token) {
125
+ return this.scheduledOf(scheduledStateOf(token));
126
+ }
127
+ scheduledOf(state) {
128
+ return new ScheduledRide(this.group, this.options, state, (requestId, pickup, destination, riderName, accepted) => {
129
+ // ZT-17: the started ride is an accepted request of its worker — a RideRequest token.
130
+ const started = { v: 1, requestId, pickup, destination, riderName, createdMs: Date.now(), workers: [accepted.worker], widened: true, othersClosed: true, sawOffer: true, accepted };
131
+ return encodeToken(started);
132
+ });
133
+ }
98
134
  /**
99
135
  * A request again from its token (`RideRequest.token`), e.g. after a reload of the page.
100
136
  * @throws Error with message `CanisterError` (errorKey `InvalidToken`) for a text this package did not make
@@ -667,6 +703,8 @@ async function getRideOfAsyncUnsafe(identity, options, driver, requestId) {
667
703
  driverPosition: ride.driverPosition[0],
668
704
  positionAtMs: ride.positionAtNs[0] === undefined ? undefined : msOf(ride.positionAtNs[0]),
669
705
  etaToPickupSec: ride.etaToPickupSec[0],
706
+ // K-N10 (P-23): a queued ride.
707
+ ...(ride.freeAtNs?.[0] === undefined ? {} : { freeAtMs: msOf(ride.freeAtNs[0]) }),
670
708
  price: moneyOf(ride.price),
671
709
  cardAccepted: ride.cardAccepted?.[0] === true,
672
710
  cardPayment: ride.cardPayment?.[0] === undefined ? undefined : cardPaymentOf(ride.cardPayment[0]),