@jsm-mit/tigi-sharded-package 0.10.0 → 0.11.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 +5 -0
- package/declarations/tigi-driver/tigi-driver.did +18 -0
- package/declarations/tigi-driver/tigi-driver.did.d.ts +16 -0
- package/declarations/tigi-driver/tigi-driver.did.js +2 -0
- package/declarations/tigi-simulator/tigi-simulator.did +6 -0
- package/declarations/tigi-simulator/tigi-simulator.did.d.ts +10 -0
- package/declarations/tigi-simulator/tigi-simulator.did.js +2 -0
- package/declarations/worker/worker.did +116 -25
- package/declarations/worker/worker.did.d.ts +119 -25
- package/declarations/worker/worker.did.js +94 -26
- package/dist/actors/rides-actor.d.ts +20 -0
- package/dist/actors/rides-actor.d.ts.map +1 -1
- package/dist/actors/rides-actor.js +36 -0
- package/dist/actors/scheduled-ride.d.ts +100 -0
- package/dist/actors/scheduled-ride.d.ts.map +1 -0
- package/dist/actors/scheduled-ride.js +179 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +4 -3
|
@@ -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 } |
|
|
@@ -180,6 +181,12 @@ export interface QuoteDecline {
|
|
|
180
181
|
'driverKey' : DriverKey,
|
|
181
182
|
}
|
|
182
183
|
export interface RateDriverArgs { 'requestId' : RequestId, 'stars' : number }
|
|
184
|
+
export interface RegisterBase {
|
|
185
|
+
'card' : DriverCard,
|
|
186
|
+
'cardVersion' : number,
|
|
187
|
+
'geohash' : Geohash,
|
|
188
|
+
'driverKey' : DriverKey,
|
|
189
|
+
}
|
|
183
190
|
export interface RegisterDriver {
|
|
184
191
|
'card' : DriverCard,
|
|
185
192
|
'cardVersion' : number,
|
|
@@ -226,25 +233,29 @@ export interface RequestView {
|
|
|
226
233
|
'radiusMeters' : number,
|
|
227
234
|
'waiting' : number,
|
|
228
235
|
}
|
|
236
|
+
export type RescueReason = { 'driverDropped' : null } |
|
|
237
|
+
{ 'noChoice' : null };
|
|
229
238
|
export type Result = { 'ok' : bigint } |
|
|
230
239
|
{ 'err' : Error };
|
|
231
|
-
export type Result_1 = { 'ok' :
|
|
240
|
+
export type Result_1 = { 'ok' : ScheduledView } |
|
|
241
|
+
{ 'err' : Error };
|
|
242
|
+
export type Result_10 = { 'ok' : ChooseOutcome } |
|
|
232
243
|
{ 'err' : Error };
|
|
233
|
-
export type Result_2 = { 'ok' :
|
|
244
|
+
export type Result_2 = { 'ok' : RequestView } |
|
|
234
245
|
{ 'err' : Error };
|
|
235
|
-
export type Result_3 = { 'ok' :
|
|
246
|
+
export type Result_3 = { 'ok' : boolean } |
|
|
236
247
|
{ 'err' : Error };
|
|
237
|
-
export type Result_4 = { 'ok' :
|
|
248
|
+
export type Result_4 = { 'ok' : bigint } |
|
|
238
249
|
{ 'err' : Error };
|
|
239
|
-
export type Result_5 = { 'ok' :
|
|
250
|
+
export type Result_5 = { 'ok' : WorkerStatus } |
|
|
240
251
|
{ 'err' : Error };
|
|
241
|
-
export type Result_6 = { 'ok' :
|
|
252
|
+
export type Result_6 = { 'ok' : Array<PrefixCount> } |
|
|
242
253
|
{ 'err' : Error };
|
|
243
|
-
export type Result_7 = { 'ok' :
|
|
254
|
+
export type Result_7 = { 'ok' : RouteLine } |
|
|
244
255
|
{ 'err' : Error };
|
|
245
|
-
export type Result_8 = { 'ok' :
|
|
256
|
+
export type Result_8 = { 'ok' : FlowStatus } |
|
|
246
257
|
{ 'err' : Error };
|
|
247
|
-
export type Result_9 = { 'ok' :
|
|
258
|
+
export type Result_9 = { 'ok' : WorkerConfig } |
|
|
248
259
|
{ 'err' : Error };
|
|
249
260
|
export type RideStatus = { 'completed' : { 'price' : Money } } |
|
|
250
261
|
{ 'cancelledByRider' : null } |
|
|
@@ -264,6 +275,48 @@ export interface RiderRating {
|
|
|
264
275
|
'driverKey' : DriverKey,
|
|
265
276
|
}
|
|
266
277
|
export interface RouteLine { 'ride' : string, 'toPickup' : string }
|
|
278
|
+
export interface ScheduledRideArgs {
|
|
279
|
+
'destination' : Geo,
|
|
280
|
+
'requestId' : RequestId,
|
|
281
|
+
'maxRadiusMeters' : number,
|
|
282
|
+
'pickup' : Geo,
|
|
283
|
+
'pickupAtNs' : bigint,
|
|
284
|
+
'riderName' : string,
|
|
285
|
+
}
|
|
286
|
+
export type ScheduledStateView = { 'rescue' : { 'reason' : RescueReason } } |
|
|
287
|
+
{ 'closed' : { 'reason' : CloseReason } } |
|
|
288
|
+
{ 'collecting' : null } |
|
|
289
|
+
{ 'started' : { 'driverKey' : DriverKey, 'driverCanister' : Principal } } |
|
|
290
|
+
{
|
|
291
|
+
'booked' : {
|
|
292
|
+
'driverRating' : [] | [number],
|
|
293
|
+
'card' : DriverCard,
|
|
294
|
+
'driverKey' : DriverKey,
|
|
295
|
+
'driverCanister' : Principal,
|
|
296
|
+
'price' : Money,
|
|
297
|
+
}
|
|
298
|
+
} |
|
|
299
|
+
{
|
|
300
|
+
'booking' : {
|
|
301
|
+
'driverKey' : DriverKey,
|
|
302
|
+
'answerByNs' : bigint,
|
|
303
|
+
'driverCanister' : Principal,
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
export interface ScheduledView {
|
|
307
|
+
'nextStageNs' : [] | [bigint],
|
|
308
|
+
'requestId' : RequestId,
|
|
309
|
+
'asked' : number,
|
|
310
|
+
'asOfNs' : bigint,
|
|
311
|
+
'createdNs' : bigint,
|
|
312
|
+
'offers' : Array<OfferView>,
|
|
313
|
+
'state' : ScheduledStateView,
|
|
314
|
+
'closesNs' : bigint,
|
|
315
|
+
'pickupAtNs' : bigint,
|
|
316
|
+
'lastOrderRefused' : boolean,
|
|
317
|
+
'radiusMeters' : number,
|
|
318
|
+
'waiting' : number,
|
|
319
|
+
}
|
|
267
320
|
export interface TestLoadArgs {
|
|
268
321
|
'reportLevel' : [] | [bigint],
|
|
269
322
|
'cells' : Array<PrefixCount>,
|
|
@@ -279,19 +332,39 @@ export interface TigiWorker {
|
|
|
279
332
|
* / from there. Blocks act at once (WO-2); ratings go into offers and orders (P-12).
|
|
280
333
|
*/
|
|
281
334
|
'applyCoreChanges' : ActorMethod<[CoreChanges], Result>,
|
|
335
|
+
/**
|
|
336
|
+
* / ZT-18 (P-22): the booked driver gives the booking up.
|
|
337
|
+
*/
|
|
338
|
+
'bookingDropped' : ActorMethod<[BookingRef], undefined>,
|
|
339
|
+
/**
|
|
340
|
+
* / ZT-17 (P-22): the booked driver's "Jadę" — the ride starts here as an accepted request.
|
|
341
|
+
*/
|
|
342
|
+
'bookingStarted' : ActorMethod<[BookingRef], ProtocolResult>,
|
|
343
|
+
/**
|
|
344
|
+
* / ZT-13: the rider gives the ride at a chosen time up.
|
|
345
|
+
*/
|
|
346
|
+
'cancelScheduled' : ActorMethod<[RequestRef], Result_3>,
|
|
282
347
|
/**
|
|
283
348
|
* / ZO-13, ZO-14, ZO-17.
|
|
284
349
|
*/
|
|
285
|
-
'chooseOffer' : ActorMethod<[OfferRef],
|
|
350
|
+
'chooseOffer' : ActorMethod<[OfferRef], Result_10>,
|
|
351
|
+
/**
|
|
352
|
+
* / ZT-14: "Wybierz" on an offer for a ride at a chosen time — a booking order.
|
|
353
|
+
*/
|
|
354
|
+
'chooseScheduledOffer' : ActorMethod<[OfferRef], Result_10>,
|
|
286
355
|
'clearLogs' : ActorMethod<[], undefined>,
|
|
287
356
|
/**
|
|
288
357
|
* / ZO-15 (otherOfferChosen after an acceptance in another worker), ZO-18 (riderGaveUp).
|
|
289
358
|
*/
|
|
290
|
-
'closeRequest' : ActorMethod<[CloseRequestArgs],
|
|
359
|
+
'closeRequest' : ActorMethod<[CloseRequestArgs], Result_3>,
|
|
360
|
+
/**
|
|
361
|
+
* / ZT-21: the copies in the other workers close once one booked.
|
|
362
|
+
*/
|
|
363
|
+
'closeScheduled' : ActorMethod<[CloseRequestArgs], Result_3>,
|
|
291
364
|
/**
|
|
292
365
|
* / The coordinator only: the settings it computes for every worker.
|
|
293
366
|
*/
|
|
294
|
-
'configure' : ActorMethod<[ConfigureArgs],
|
|
367
|
+
'configure' : ActorMethod<[ConfigureArgs], Result_9>,
|
|
295
368
|
/**
|
|
296
369
|
* / ZO-6.
|
|
297
370
|
*/
|
|
@@ -303,46 +376,50 @@ export interface TigiWorker {
|
|
|
303
376
|
/**
|
|
304
377
|
* / The flow's numbers (scripts, the coordinator's front).
|
|
305
378
|
*/
|
|
306
|
-
'getFlowStatus' : ActorMethod<[],
|
|
379
|
+
'getFlowStatus' : ActorMethod<[], Result_8>,
|
|
307
380
|
'getLogs' : ActorMethod<[], string>,
|
|
308
381
|
/**
|
|
309
382
|
* / ZO-21 (2026-10-24, route line): the route line of one offer, for the rider of the
|
|
310
383
|
* / request only (the package asks after a tap on the offer).
|
|
311
384
|
*/
|
|
312
|
-
'getOfferRoute' : ActorMethod<[OfferRef],
|
|
385
|
+
'getOfferRoute' : ActorMethod<[OfferRef], Result_7>,
|
|
313
386
|
/**
|
|
314
387
|
* / The load this worker counts per geohash prefix of the given length (1–6): the
|
|
315
388
|
* / coordinator picks from it what to give another worker on a split (KO-5).
|
|
316
389
|
*/
|
|
317
|
-
'getPrefixCounts' : ActorMethod<[bigint],
|
|
390
|
+
'getPrefixCounts' : ActorMethod<[bigint], Result_6>,
|
|
318
391
|
/**
|
|
319
392
|
* / ZO-11: the state and the offers (the package polls it every second).
|
|
320
393
|
*/
|
|
321
|
-
'getRequest' : ActorMethod<[RequestRef],
|
|
394
|
+
'getRequest' : ActorMethod<[RequestRef], Result_2>,
|
|
395
|
+
/**
|
|
396
|
+
* / ZT-12: the state and the offers of a ride at a chosen time.
|
|
397
|
+
*/
|
|
398
|
+
'getScheduled' : ActorMethod<[RequestRef], Result_1>,
|
|
322
399
|
/**
|
|
323
400
|
* / The worker's own view of itself — for the coordinator and its front.
|
|
324
401
|
*/
|
|
325
|
-
'getStatus' : ActorMethod<[],
|
|
402
|
+
'getStatus' : ActorMethod<[], Result_5>,
|
|
326
403
|
/**
|
|
327
404
|
* / The coordinator only, before it deletes the worker: what a deleted canister still
|
|
328
405
|
* / holds is burned.
|
|
329
406
|
*/
|
|
330
|
-
'giveBackCycles' : ActorMethod<[],
|
|
407
|
+
'giveBackCycles' : ActorMethod<[], Result_4>,
|
|
331
408
|
/**
|
|
332
409
|
* / ZO-18: the rider gives up.
|
|
333
410
|
*/
|
|
334
|
-
'giveUp' : ActorMethod<[RequestRef],
|
|
411
|
+
'giveUp' : ActorMethod<[RequestRef], Result_3>,
|
|
335
412
|
/**
|
|
336
413
|
* / WO-20 (stage and the test modes): simulated drivers within 3 km of the point?
|
|
337
414
|
*/
|
|
338
|
-
'hasSimulatedDrivers' : ActorMethod<[HasSimulatedDriversArgs],
|
|
415
|
+
'hasSimulatedDrivers' : ActorMethod<[HasSimulatedDriversArgs], Result_3>,
|
|
339
416
|
/**
|
|
340
417
|
* / The coordinator only, in a test mode only (prod and stage refuse, and so does the
|
|
341
418
|
* / coordinator): a load put on this worker. The cells' counters grow, and the worker
|
|
342
419
|
* / reports `reportLevel` as a real minute would — what a local script uses to force a
|
|
343
420
|
* / split.
|
|
344
421
|
*/
|
|
345
|
-
'injectTestLoad' : ActorMethod<[TestLoadArgs],
|
|
422
|
+
'injectTestLoad' : ActorMethod<[TestLoadArgs], Result_3>,
|
|
346
423
|
/**
|
|
347
424
|
* / WO-3: the geohash lies in this worker's area (by the coordinator's newest map).
|
|
348
425
|
*/
|
|
@@ -350,7 +427,7 @@ export interface TigiWorker {
|
|
|
350
427
|
/**
|
|
351
428
|
* / K-8: the rider rates the driver.
|
|
352
429
|
*/
|
|
353
|
-
'rateDriver' : ActorMethod<[RateDriverArgs],
|
|
430
|
+
'rateDriver' : ActorMethod<[RateDriverArgs], Result_3>,
|
|
354
431
|
/**
|
|
355
432
|
* / K-8.
|
|
356
433
|
*/
|
|
@@ -358,7 +435,12 @@ export interface TigiWorker {
|
|
|
358
435
|
/**
|
|
359
436
|
* / ZO-10: a stale offer asks its driver again.
|
|
360
437
|
*/
|
|
361
|
-
'refreshOffer' : ActorMethod<[OfferRef],
|
|
438
|
+
'refreshOffer' : ActorMethod<[OfferRef], Result_3>,
|
|
439
|
+
/**
|
|
440
|
+
* / ZT-1 … ZT-3 (P-21): a driver's base — on a change and once a day, whether the driver
|
|
441
|
+
* / works or not.
|
|
442
|
+
*/
|
|
443
|
+
'registerBase' : ActorMethod<[RegisterBase], ProtocolResult>,
|
|
362
444
|
/**
|
|
363
445
|
* / WO-1 … WO-8: a driver reports itself — on a cell change and every 60 s (U-27).
|
|
364
446
|
*/
|
|
@@ -366,11 +448,19 @@ export interface TigiWorker {
|
|
|
366
448
|
/**
|
|
367
449
|
* / ZO-12: ✕.
|
|
368
450
|
*/
|
|
369
|
-
'rejectOffer' : ActorMethod<[OfferRef],
|
|
451
|
+
'rejectOffer' : ActorMethod<[OfferRef], Result_3>,
|
|
452
|
+
/**
|
|
453
|
+
* / ZT-9: ✕ on one offer.
|
|
454
|
+
*/
|
|
455
|
+
'rejectScheduledOffer' : ActorMethod<[OfferRef], Result_3>,
|
|
370
456
|
/**
|
|
371
457
|
* / ZO-1 … ZO-4, ZO-8: a request in this worker; the drivers are asked after the answer.
|
|
372
458
|
*/
|
|
373
|
-
'requestRide' : ActorMethod<[RequestRideArgs],
|
|
459
|
+
'requestRide' : ActorMethod<[RequestRideArgs], Result_2>,
|
|
460
|
+
/**
|
|
461
|
+
* / ZT-4: a ride at a chosen time in this worker (kurs-na-termin.md).
|
|
462
|
+
*/
|
|
463
|
+
'requestScheduled' : ActorMethod<[ScheduledRideArgs], Result_1>,
|
|
374
464
|
/**
|
|
375
465
|
* / K-2, K-6, K-7.
|
|
376
466
|
*/
|
|
@@ -384,6 +474,10 @@ export interface TigiWorker {
|
|
|
384
474
|
* / ZO-9, ZO-10.
|
|
385
475
|
*/
|
|
386
476
|
'submitQuote' : ActorMethod<[Quote], ProtocolResult>,
|
|
477
|
+
/**
|
|
478
|
+
* / ZT-2 (P-21).
|
|
479
|
+
*/
|
|
480
|
+
'unregisterBase' : ActorMethod<[DriverKey], undefined>,
|
|
387
481
|
/**
|
|
388
482
|
* / WO-6.
|
|
389
483
|
*/
|
|
@@ -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
|
|
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
|
|
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
|
|
158
|
+
const Result_8 = IDL.Variant({ 'ok' : FlowStatus, 'err' : Error });
|
|
154
159
|
const RouteLine = IDL.Record({ 'ride' : IDL.Text, 'toPickup' : IDL.Text });
|
|
155
|
-
const
|
|
160
|
+
const Result_7 = IDL.Variant({ 'ok' : RouteLine, 'err' : Error });
|
|
156
161
|
const PrefixCount = IDL.Record({ 'load' : IDL.Nat, 'prefix' : IDL.Text });
|
|
157
|
-
const
|
|
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,
|
|
@@ -222,7 +226,47 @@ export const idlFactory = ({ IDL }) => {
|
|
|
222
226
|
'radiusMeters' : IDL.Nat32,
|
|
223
227
|
'waiting' : IDL.Nat32,
|
|
224
228
|
});
|
|
225
|
-
const
|
|
229
|
+
const Result_2 = IDL.Variant({ 'ok' : RequestView, 'err' : Error });
|
|
230
|
+
const RescueReason = IDL.Variant({
|
|
231
|
+
'driverDropped' : IDL.Null,
|
|
232
|
+
'noChoice' : IDL.Null,
|
|
233
|
+
});
|
|
234
|
+
const ScheduledStateView = IDL.Variant({
|
|
235
|
+
'rescue' : IDL.Record({ 'reason' : RescueReason }),
|
|
236
|
+
'closed' : IDL.Record({ 'reason' : CloseReason }),
|
|
237
|
+
'collecting' : IDL.Null,
|
|
238
|
+
'started' : IDL.Record({
|
|
239
|
+
'driverKey' : DriverKey,
|
|
240
|
+
'driverCanister' : IDL.Principal,
|
|
241
|
+
}),
|
|
242
|
+
'booked' : IDL.Record({
|
|
243
|
+
'driverRating' : IDL.Opt(IDL.Nat16),
|
|
244
|
+
'card' : DriverCard,
|
|
245
|
+
'driverKey' : DriverKey,
|
|
246
|
+
'driverCanister' : IDL.Principal,
|
|
247
|
+
'price' : Money,
|
|
248
|
+
}),
|
|
249
|
+
'booking' : IDL.Record({
|
|
250
|
+
'driverKey' : DriverKey,
|
|
251
|
+
'answerByNs' : IDL.Nat64,
|
|
252
|
+
'driverCanister' : IDL.Principal,
|
|
253
|
+
}),
|
|
254
|
+
});
|
|
255
|
+
const ScheduledView = IDL.Record({
|
|
256
|
+
'nextStageNs' : IDL.Opt(IDL.Nat64),
|
|
257
|
+
'requestId' : RequestId,
|
|
258
|
+
'asked' : IDL.Nat32,
|
|
259
|
+
'asOfNs' : IDL.Nat64,
|
|
260
|
+
'createdNs' : IDL.Nat64,
|
|
261
|
+
'offers' : IDL.Vec(OfferView),
|
|
262
|
+
'state' : ScheduledStateView,
|
|
263
|
+
'closesNs' : IDL.Nat64,
|
|
264
|
+
'pickupAtNs' : IDL.Nat64,
|
|
265
|
+
'lastOrderRefused' : IDL.Bool,
|
|
266
|
+
'radiusMeters' : IDL.Nat32,
|
|
267
|
+
'waiting' : IDL.Nat32,
|
|
268
|
+
});
|
|
269
|
+
const Result_1 = IDL.Variant({ 'ok' : ScheduledView, 'err' : Error });
|
|
226
270
|
const LoadLevel = IDL.Nat;
|
|
227
271
|
const LoadReport = IDL.Record({
|
|
228
272
|
'updateCalls' : IDL.Nat,
|
|
@@ -245,8 +289,8 @@ export const idlFactory = ({ IDL }) => {
|
|
|
245
289
|
'openRequests' : IDL.Nat,
|
|
246
290
|
'coordinator' : IDL.Principal,
|
|
247
291
|
});
|
|
248
|
-
const
|
|
249
|
-
const
|
|
292
|
+
const Result_5 = IDL.Variant({ 'ok' : WorkerStatus, 'err' : Error });
|
|
293
|
+
const Result_4 = IDL.Variant({ 'ok' : IDL.Nat, 'err' : Error });
|
|
250
294
|
const HasSimulatedDriversArgs = IDL.Record({ 'center' : Geo });
|
|
251
295
|
const TestLoadArgs = IDL.Record({
|
|
252
296
|
'reportLevel' : IDL.Opt(IDL.Nat),
|
|
@@ -262,6 +306,12 @@ export const idlFactory = ({ IDL }) => {
|
|
|
262
306
|
'driverKey' : DriverKey,
|
|
263
307
|
});
|
|
264
308
|
const Geohash = IDL.Text;
|
|
309
|
+
const RegisterBase = IDL.Record({
|
|
310
|
+
'card' : DriverCard,
|
|
311
|
+
'cardVersion' : IDL.Nat32,
|
|
312
|
+
'geohash' : Geohash,
|
|
313
|
+
'driverKey' : DriverKey,
|
|
314
|
+
});
|
|
265
315
|
const RegisterDriver = IDL.Record({
|
|
266
316
|
'card' : DriverCard,
|
|
267
317
|
'cardVersion' : IDL.Nat32,
|
|
@@ -278,6 +328,14 @@ export const idlFactory = ({ IDL }) => {
|
|
|
278
328
|
'radiusMeters' : IDL.Nat32,
|
|
279
329
|
'riderName' : IDL.Text,
|
|
280
330
|
});
|
|
331
|
+
const ScheduledRideArgs = IDL.Record({
|
|
332
|
+
'destination' : Geo,
|
|
333
|
+
'requestId' : RequestId,
|
|
334
|
+
'maxRadiusMeters' : IDL.Nat32,
|
|
335
|
+
'pickup' : Geo,
|
|
336
|
+
'pickupAtNs' : IDL.Nat64,
|
|
337
|
+
'riderName' : IDL.Text,
|
|
338
|
+
});
|
|
281
339
|
const RideStatusChange = IDL.Record({
|
|
282
340
|
'status' : RideStatus,
|
|
283
341
|
'requestId' : RequestId,
|
|
@@ -307,36 +365,46 @@ export const idlFactory = ({ IDL }) => {
|
|
|
307
365
|
const TigiWorker = IDL.Service({
|
|
308
366
|
'answerOrder' : IDL.Func([OrderAnswer], [ProtocolResult], []),
|
|
309
367
|
'applyCoreChanges' : IDL.Func([CoreChanges], [Result], []),
|
|
310
|
-
'
|
|
368
|
+
'bookingDropped' : IDL.Func([BookingRef], [], []),
|
|
369
|
+
'bookingStarted' : IDL.Func([BookingRef], [ProtocolResult], []),
|
|
370
|
+
'cancelScheduled' : IDL.Func([RequestRef], [Result_3], []),
|
|
371
|
+
'chooseOffer' : IDL.Func([OfferRef], [Result_10], []),
|
|
372
|
+
'chooseScheduledOffer' : IDL.Func([OfferRef], [Result_10], []),
|
|
311
373
|
'clearLogs' : IDL.Func([], [], []),
|
|
312
|
-
'closeRequest' : IDL.Func([CloseRequestArgs], [
|
|
313
|
-
'
|
|
374
|
+
'closeRequest' : IDL.Func([CloseRequestArgs], [Result_3], []),
|
|
375
|
+
'closeScheduled' : IDL.Func([CloseRequestArgs], [Result_3], []),
|
|
376
|
+
'configure' : IDL.Func([ConfigureArgs], [Result_9], []),
|
|
314
377
|
'declineQuote' : IDL.Func([QuoteDecline], [], []),
|
|
315
378
|
'getCoreCopyStatus' : IDL.Func([], [CoreCopyStatus], ['query']),
|
|
316
|
-
'getFlowStatus' : IDL.Func([], [
|
|
379
|
+
'getFlowStatus' : IDL.Func([], [Result_8], ['query']),
|
|
317
380
|
'getLogs' : IDL.Func([], [IDL.Text], ['query']),
|
|
318
|
-
'getOfferRoute' : IDL.Func([OfferRef], [
|
|
319
|
-
'getPrefixCounts' : IDL.Func([IDL.Nat], [
|
|
320
|
-
'getRequest' : IDL.Func([RequestRef], [
|
|
321
|
-
'
|
|
322
|
-
'
|
|
323
|
-
'
|
|
381
|
+
'getOfferRoute' : IDL.Func([OfferRef], [Result_7], ['query']),
|
|
382
|
+
'getPrefixCounts' : IDL.Func([IDL.Nat], [Result_6], ['query']),
|
|
383
|
+
'getRequest' : IDL.Func([RequestRef], [Result_2], ['query']),
|
|
384
|
+
'getScheduled' : IDL.Func([RequestRef], [Result_1], ['query']),
|
|
385
|
+
'getStatus' : IDL.Func([], [Result_5], ['query']),
|
|
386
|
+
'giveBackCycles' : IDL.Func([], [Result_4], []),
|
|
387
|
+
'giveUp' : IDL.Func([RequestRef], [Result_3], []),
|
|
324
388
|
'hasSimulatedDrivers' : IDL.Func(
|
|
325
389
|
[HasSimulatedDriversArgs],
|
|
326
|
-
[
|
|
390
|
+
[Result_3],
|
|
327
391
|
['query'],
|
|
328
392
|
),
|
|
329
|
-
'injectTestLoad' : IDL.Func([TestLoadArgs], [
|
|
393
|
+
'injectTestLoad' : IDL.Func([TestLoadArgs], [Result_3], []),
|
|
330
394
|
'isMyArea' : IDL.Func([IDL.Text], [IDL.Bool], ['query']),
|
|
331
|
-
'rateDriver' : IDL.Func([RateDriverArgs], [
|
|
395
|
+
'rateDriver' : IDL.Func([RateDriverArgs], [Result_3], []),
|
|
332
396
|
'rateRider' : IDL.Func([RiderRating], [ProtocolResult], []),
|
|
333
|
-
'refreshOffer' : IDL.Func([OfferRef], [
|
|
397
|
+
'refreshOffer' : IDL.Func([OfferRef], [Result_3], []),
|
|
398
|
+
'registerBase' : IDL.Func([RegisterBase], [ProtocolResult], []),
|
|
334
399
|
'registerDriver' : IDL.Func([RegisterDriver], [ProtocolResult], []),
|
|
335
|
-
'rejectOffer' : IDL.Func([OfferRef], [
|
|
336
|
-
'
|
|
400
|
+
'rejectOffer' : IDL.Func([OfferRef], [Result_3], []),
|
|
401
|
+
'rejectScheduledOffer' : IDL.Func([OfferRef], [Result_3], []),
|
|
402
|
+
'requestRide' : IDL.Func([RequestRideArgs], [Result_2], []),
|
|
403
|
+
'requestScheduled' : IDL.Func([ScheduledRideArgs], [Result_1], []),
|
|
337
404
|
'rideStatusChanged' : IDL.Func([RideStatusChange], [ProtocolResult], []),
|
|
338
405
|
'setAreaMap' : IDL.Func([AreaMap], [Result], []),
|
|
339
406
|
'submitQuote' : IDL.Func([Quote], [ProtocolResult], []),
|
|
407
|
+
'unregisterBase' : IDL.Func([DriverKey], [], []),
|
|
340
408
|
'unregisterDriver' : IDL.Func([DriverKey], [], []),
|
|
341
409
|
});
|
|
342
410
|
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,EAAa,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
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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O,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvE;;;;;;;;;;;OAWG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkC5E;;;;;;;;;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;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
|