@jsm-mit/tigi-sharded-package 0.9.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.
@@ -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,
@@ -222,7 +226,47 @@ export const idlFactory = ({ IDL }) => {
222
226
  'radiusMeters' : IDL.Nat32,
223
227
  'waiting' : IDL.Nat32,
224
228
  });
225
- const Result_1 = IDL.Variant({ 'ok' : RequestView, 'err' : Error });
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 Result_4 = IDL.Variant({ 'ok' : WorkerStatus, 'err' : Error });
249
- const Result_3 = IDL.Variant({ 'ok' : IDL.Nat, 'err' : Error });
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
- 'chooseOffer' : IDL.Func([OfferRef], [Result_9], []),
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], [Result_2], []),
313
- 'configure' : IDL.Func([ConfigureArgs], [Result_8], []),
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([], [Result_7], ['query']),
379
+ 'getFlowStatus' : IDL.Func([], [Result_8], ['query']),
317
380
  '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], []),
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
- [Result_2],
390
+ [Result_3],
327
391
  ['query'],
328
392
  ),
329
- 'injectTestLoad' : IDL.Func([TestLoadArgs], [Result_2], []),
393
+ 'injectTestLoad' : IDL.Func([TestLoadArgs], [Result_3], []),
330
394
  'isMyArea' : IDL.Func([IDL.Text], [IDL.Bool], ['query']),
331
- 'rateDriver' : IDL.Func([RateDriverArgs], [Result_2], []),
395
+ 'rateDriver' : IDL.Func([RateDriverArgs], [Result_3], []),
332
396
  'rateRider' : IDL.Func([RiderRating], [ProtocolResult], []),
333
- 'refreshOffer' : IDL.Func([OfferRef], [Result_2], []),
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], [Result_2], []),
336
- 'requestRide' : IDL.Func([RequestRideArgs], [Result_1], []),
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;
@@ -2,7 +2,8 @@ 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, RouteLineView } from "../interfaces.js";
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
@@ -219,6 +239,23 @@ export declare class RideRequest {
219
239
  * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
220
240
  */
221
241
  cancelRideAsyncUnsafe(): Promise<void>;
242
+ /**
243
+ * P-20 (D-2): the rider pays by card during the ride — the driver canister makes a Stripe
244
+ * Checkout session on the driver's account; send the rider to `url` while `open`. Again
245
+ * while it stands → the same page. Stripe sends the rider back to `returnUrl` with
246
+ * `card=paid` or `card=cancelled`: call `checkCardPaymentAsyncUnsafe` then.
247
+ * @param returnUrl - https, the rider's page of this ride
248
+ * @throws Error with message `CanisterError` — `invalidData` (the driver takes no cards, the ride has not started, too many tries, a bad `returnUrl`), `expired` (the ride ended), `NoCards` (an older driver canister), `NOT_ACCEPTED`, `notAuthorized`
249
+ * @throws Error with message `CallRefusedAtInspectionStage` — the daily limit of the driver canister
250
+ * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
251
+ */
252
+ startCardPaymentAsyncUnsafe(returnUrl: string): Promise<CardPaymentView>;
253
+ /**
254
+ * P-20: after Stripe sent the rider back — the driver canister asks Stripe now.
255
+ * @throws Error with message `CanisterError` — `notFound` (no card payment started), `NoCards`, `NOT_ACCEPTED`, `notAuthorized`
256
+ * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
257
+ */
258
+ checkCardPaymentAsyncUnsafe(): Promise<CardPaymentView>;
222
259
  /**
223
260
  * U-11, PR-23: the driver's licence, from the acceptance to the end of the ride.
224
261
  * @throws Error with message `CanisterError` — `notFound` (no photo), `notAuthorized` (after the ride), `NOT_ACCEPTED`
@@ -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,SAAS,EAAE,aAAa,EAAE,WAAW,EAAa,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAInI,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAC1C,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,yEAAyE;AACzE,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,qFAAqF;AACrF,eAAO,MAAM,eAAe,OAAQ,CAAC;AACrC;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,+GAA+G;AAC/G,eAAO,MAAM,YAAY,OAAQ,CAAC;AAClC,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAEvC,wFAAwF;AACxF,UAAU,YAAY;IAClB,CAAC,EAAE,CAAC,CA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AAO,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
@@ -437,6 +473,47 @@ export class RideRequest {
437
473
  await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).cancelRide({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
438
474
  this.freshNext = true;
439
475
  }
476
+ /**
477
+ * P-20 (D-2): the rider pays by card during the ride — the driver canister makes a Stripe
478
+ * Checkout session on the driver's account; send the rider to `url` while `open`. Again
479
+ * while it stands → the same page. Stripe sends the rider back to `returnUrl` with
480
+ * `card=paid` or `card=cancelled`: call `checkCardPaymentAsyncUnsafe` then.
481
+ * @param returnUrl - https, the rider's page of this ride
482
+ * @throws Error with message `CanisterError` — `invalidData` (the driver takes no cards, the ride has not started, too many tries, a bad `returnUrl`), `expired` (the ride ended), `NoCards` (an older driver canister), `NOT_ACCEPTED`, `notAuthorized`
483
+ * @throws Error with message `CallRefusedAtInspectionStage` — the daily limit of the driver canister
484
+ * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
485
+ */
486
+ async startCardPaymentAsyncUnsafe(returnUrl) {
487
+ const accepted = await this.acceptedAsyncUnsafe();
488
+ try {
489
+ const payment = await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).startCardPayment({ requestId: this.state.requestId, driverKey: accepted.driverKey, returnUrl }));
490
+ this.freshNext = true;
491
+ return cardPaymentOf(payment);
492
+ }
493
+ catch (err) {
494
+ if (isMethodMissingError(err))
495
+ throw canisterError("NoCards", "the driver canister is older than card payments");
496
+ throw err;
497
+ }
498
+ }
499
+ /**
500
+ * P-20: after Stripe sent the rider back — the driver canister asks Stripe now.
501
+ * @throws Error with message `CanisterError` — `notFound` (no card payment started), `NoCards`, `NOT_ACCEPTED`, `notAuthorized`
502
+ * @throws Error with message `CriticalCanisterError` — the driver canister does not answer
503
+ */
504
+ async checkCardPaymentAsyncUnsafe() {
505
+ const accepted = await this.acceptedAsyncUnsafe();
506
+ try {
507
+ const payment = await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).checkCardPayment({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
508
+ this.freshNext = true;
509
+ return cardPaymentOf(payment);
510
+ }
511
+ catch (err) {
512
+ if (isMethodMissingError(err))
513
+ throw canisterError("NoCards", "the driver canister is older than card payments");
514
+ throw err;
515
+ }
516
+ }
440
517
  /**
441
518
  * U-11, PR-23: the driver's licence, from the acceptance to the end of the ride.
442
519
  * @throws Error with message `CanisterError` — `notFound` (no photo), `notAuthorized` (after the ride), `NOT_ACCEPTED`
@@ -627,5 +704,13 @@ async function getRideOfAsyncUnsafe(identity, options, driver, requestId) {
627
704
  positionAtMs: ride.positionAtNs[0] === undefined ? undefined : msOf(ride.positionAtNs[0]),
628
705
  etaToPickupSec: ride.etaToPickupSec[0],
629
706
  price: moneyOf(ride.price),
707
+ cardAccepted: ride.cardAccepted?.[0] === true,
708
+ cardPayment: ride.cardPayment?.[0] === undefined ? undefined : cardPaymentOf(ride.cardPayment[0]),
630
709
  };
631
710
  }
711
+ /** P-20: the protocol's card payment as the package gives it. */
712
+ function cardPaymentOf(payment) {
713
+ const state = Object.keys(payment.state)[0];
714
+ const failure = "failed" in payment.state ? payment.state.failed : undefined;
715
+ return { state, ...(failure === undefined ? {} : { failure }), amount: moneyOf(payment.amount), url: payment.url[0], updatedAtMs: msOf(payment.updatedAtNs) };
716
+ }
@@ -0,0 +1,100 @@
1
+ import { type GroupOptions } from "../group/canister-actor.js";
2
+ import type { TigiGroup } from "../group/group.js";
3
+ import type { Geo } from "../geo.js";
4
+ import type { ChooseOutcome, DriverCardView, Money } from "../interfaces.js";
5
+ /** ZT-5: the last stage — the package places the request in every worker this far. */
6
+ export declare const SCHEDULED_RADIUS_METERS = 25000;
7
+ /** D-3: at least 1 h, at most 7 days ahead. */
8
+ export declare const SCHEDULED_MIN_AHEAD_MS: number;
9
+ export declare const SCHEDULED_MAX_AHEAD_MS: number;
10
+ /** ZT-19, D-7: the rescue request "as soon as possible" starts this long before the time. */
11
+ export declare const RESCUE_BEFORE_MS: number;
12
+ /** The rider polls a ride at a chosen time this often (nothing is in a hurry here). */
13
+ export declare const SCHEDULED_POLL_MS = 5000;
14
+ export interface ScheduledState {
15
+ v: 1;
16
+ kind: "scheduled";
17
+ requestId: string;
18
+ pickup: Geo;
19
+ destination: Geo;
20
+ riderName: string;
21
+ pickupAtMs: number;
22
+ workers: string[];
23
+ othersClosed?: boolean;
24
+ }
25
+ /** ZT-12: one offer for a ride at a chosen time (no pin: the base is never shown, ZT-1). */
26
+ export interface ScheduledOfferView {
27
+ offerId: string;
28
+ card: DriverCardView;
29
+ driverRating?: number;
30
+ rideMeters: number;
31
+ rideSec: number;
32
+ price: Money;
33
+ receivedMs: number;
34
+ }
35
+ export type ScheduledPhase = "collecting" | "booking" | "booked" | "started" | "rescue" | "closed";
36
+ export interface ScheduledSnapshot {
37
+ requestId: string;
38
+ phase: ScheduledPhase;
39
+ pickupAtMs: number;
40
+ /** ZT-5: the radius of the stage reached, and when the next stage comes. */
41
+ radiusMeters: number;
42
+ nextStageMs?: number;
43
+ /** ZT-11: the offers are taken until then (T−30 min). */
44
+ closesMs: number;
45
+ /** ZT-12: cheapest first. */
46
+ offers: ScheduledOfferView[];
47
+ asked: number;
48
+ waiting: number;
49
+ /** ZT-14, ZT-18: the last choice was refused, or the booked driver gave it up. */
50
+ lastOrderRefused: boolean;
51
+ /** ZT-16: the booked driver. */
52
+ booked?: {
53
+ card: DriverCardView;
54
+ driverRating?: number;
55
+ price: Money;
56
+ };
57
+ /** ZT-19: why the rider is rescued — start a request "as soon as possible" from T−10 min. */
58
+ rescue?: "noChoice" | "driverDropped";
59
+ /** ZT-17: the ride started — `RidesActor.resumeRequest(rideToken)` is its RideRequest. */
60
+ rideToken?: string;
61
+ }
62
+ export declare class ScheduledRide {
63
+ private readonly group;
64
+ private readonly options;
65
+ private readonly state;
66
+ private readonly rideTokenOf;
67
+ /** offerId → the worker that holds it (from the last read). */
68
+ private readonly offerWorkers;
69
+ constructor(group: TigiGroup, options: GroupOptions, state: ScheduledState, rideTokenOf: (requestId: string, pickup: Geo, destination: Geo, riderName: string, accepted: {
70
+ worker: string;
71
+ canister: string;
72
+ driverKey: string;
73
+ }) => string);
74
+ get requestId(): string;
75
+ get pickupAtMs(): number;
76
+ get pickup(): Geo;
77
+ get destination(): Geo;
78
+ /** To keep (e.g. in localStorage) and give to `RidesActor.resumeScheduled` after a reload. */
79
+ get token(): string;
80
+ /** ZT-4: in every worker of the 25 km circle; a worker that already holds another one refuses. */
81
+ placeAsyncUnsafe(workers: string[]): Promise<void>;
82
+ /**
83
+ * ZT-12, ZT-16 … ZT-19: the request over every worker — the furthest phase wins (started,
84
+ * booked, booking, collecting, rescue, closed); offers of the collecting workers, cheapest
85
+ * first. Once one worker booked, the others are closed (`otherOfferChosen`, ZT-21).
86
+ */
87
+ getAsyncUnsafe(): Promise<ScheduledSnapshot>;
88
+ /**
89
+ * ZT-14: "Wybierz" — a booking order to the offer's driver; read the request again for its
90
+ * answer (`booked`, or back to `collecting` with `lastOrderRefused`).
91
+ * @throws Error with message `CanisterError` — `NotFound` (an offer this request does not hold; read it first)
92
+ */
93
+ chooseAsyncUnsafe(offerId: string): Promise<ChooseOutcome>;
94
+ /** ZT-9: ✕ on one offer. */
95
+ rejectAsyncUnsafe(offerId: string): Promise<void>;
96
+ /** ZT-13, ZT-20: the rider gives it up — also a booking (the driver hears it). */
97
+ cancelAsyncUnsafe(): Promise<void>;
98
+ }
99
+ export declare function scheduledStateOf(token: string): ScheduledState;
100
+ //# sourceMappingURL=scheduled-ride.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-ride.d.ts","sourceRoot":"","sources":["../../src/actors/scheduled-ride.ts"],"names":[],"mappings":"AAOA,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG7E,sFAAsF;AACtF,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAC9C,+CAA+C;AAC/C,eAAO,MAAM,sBAAsB,QAAc,CAAC;AAClD,eAAO,MAAM,sBAAsB,QAAuB,CAAC;AAC3D,6FAA6F;AAC7F,eAAO,M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