@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.
@@ -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,MAAM,gBAAgB,QAAc,CAAC;AAC5C,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC3B,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IAC/B,OAA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,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,cAAc,EACrB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;IAGpL,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,MAAM,IAAI,GAAG,CAEvB;IAED,IAAW,WAAW,IAAI,GAAG,CAE5B;IAED,8FAA8F;IAC9F,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,kGAAkG;IACrF,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB/D;;;;OAIG;IACU,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAqEzD;;;;OAIG;IACU,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IASvE,4BAA4B;IACf,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,kFAAkF;IACrE,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAKlD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAI9D"}
@@ -0,0 +1,179 @@
1
+ // A ride at a chosen time (tigi-sharded/high-level-design/kurs-na-termin.md, ZT-*): one
2
+ // request in every worker whose area reaches 25 km around the pickup, under one requestId.
3
+ // The workers ask the drivers by their base and grow the radius themselves (3 → 25 km), so
4
+ // the rider may close the page: `RidesActor.resumeScheduled(token)` brings it back.
5
+ import { Principal } from "@icp-sdk/core/principal";
6
+ import { canisterError, errorKeyOf } from "../group/canister-actor.js";
7
+ import { cardOf, decodeToken, driverOfOfferId, encodeToken, moneyOf, msOf, offerIdOf } from "../mappers.js";
8
+ /** ZT-5: the last stage — the package places the request in every worker this far. */
9
+ export const SCHEDULED_RADIUS_METERS = 25_000;
10
+ /** D-3: at least 1 h, at most 7 days ahead. */
11
+ export const SCHEDULED_MIN_AHEAD_MS = 60 * 60_000;
12
+ export const SCHEDULED_MAX_AHEAD_MS = 7 * 24 * 60 * 60_000;
13
+ /** ZT-19, D-7: the rescue request "as soon as possible" starts this long before the time. */
14
+ export const RESCUE_BEFORE_MS = 10 * 60_000;
15
+ /** The rider polls a ride at a chosen time this often (nothing is in a hurry here). */
16
+ export const SCHEDULED_POLL_MS = 5_000;
17
+ const PHASE_ORDER = ["started", "booked", "booking", "collecting", "rescue", "closed"];
18
+ function phaseOf(state) {
19
+ return Object.keys(state)[0];
20
+ }
21
+ export class ScheduledRide {
22
+ group;
23
+ options;
24
+ state;
25
+ rideTokenOf;
26
+ /** offerId → the worker that holds it (from the last read). */
27
+ offerWorkers = new Map();
28
+ constructor(group, options, state, rideTokenOf) {
29
+ this.group = group;
30
+ this.options = options;
31
+ this.state = state;
32
+ this.rideTokenOf = rideTokenOf;
33
+ }
34
+ get requestId() {
35
+ return this.state.requestId;
36
+ }
37
+ get pickupAtMs() {
38
+ return this.state.pickupAtMs;
39
+ }
40
+ get pickup() {
41
+ return this.state.pickup;
42
+ }
43
+ get destination() {
44
+ return this.state.destination;
45
+ }
46
+ /** To keep (e.g. in localStorage) and give to `RidesActor.resumeScheduled` after a reload. */
47
+ get token() {
48
+ return encodeToken(this.state);
49
+ }
50
+ /** ZT-4: in every worker of the 25 km circle; a worker that already holds another one refuses. */
51
+ async placeAsyncUnsafe(workers) {
52
+ const results = await Promise.allSettled(workers.map(async (worker) => {
53
+ await this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.requestScheduled({
54
+ requestId: this.state.requestId,
55
+ pickup: this.state.pickup,
56
+ destination: this.state.destination,
57
+ riderName: this.state.riderName,
58
+ pickupAtNs: BigInt(this.state.pickupAtMs) * 1000000n,
59
+ maxRadiusMeters: SCHEDULED_RADIUS_METERS,
60
+ }));
61
+ return worker;
62
+ }));
63
+ const placed = results.flatMap((result) => (result.status === "fulfilled" ? [result.value] : []));
64
+ const failed = results.flatMap((result) => (result.status === "rejected" ? [result.reason] : []));
65
+ this.state.workers = placed;
66
+ if (placed.length === 0 || failed.some((error) => /ALREADY_OPEN|BLOCKED|TOO_SOON|TOO_FAR/.test(String(error.cause?.errorMessage ?? "")))) {
67
+ await Promise.allSettled(placed.map((worker) => this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.cancelScheduled({ requestId: this.state.requestId }))));
68
+ throw failed[0] ?? canisterError("NotFound", "no worker serves this area");
69
+ }
70
+ }
71
+ /**
72
+ * ZT-12, ZT-16 … ZT-19: the request over every worker — the furthest phase wins (started,
73
+ * booked, booking, collecting, rescue, closed); offers of the collecting workers, cheapest
74
+ * first. Once one worker booked, the others are closed (`otherOfferChosen`, ZT-21).
75
+ */
76
+ async getAsyncUnsafe() {
77
+ const results = await Promise.allSettled(this.state.workers.map(async (worker) => ({ worker, view: await this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.getScheduled({ requestId: this.state.requestId })) })));
78
+ const views = results.flatMap((result) => (result.status === "fulfilled" ? [result.value] : []));
79
+ if (views.length === 0) {
80
+ const failed = results.find((result) => result.status === "rejected");
81
+ throw failed?.status === "rejected" ? failed.reason : canisterError("NotFound", "the request is in no worker");
82
+ }
83
+ let lead = views[0];
84
+ for (const entry of views) {
85
+ if (PHASE_ORDER.indexOf(phaseOf(entry.view.state)) < PHASE_ORDER.indexOf(phaseOf(lead.view.state)))
86
+ lead = entry;
87
+ }
88
+ const phase = phaseOf(lead.view.state);
89
+ this.offerWorkers.clear();
90
+ const offers = [];
91
+ if (phase === "collecting") {
92
+ for (const { worker, view } of views) {
93
+ for (const offer of view.offers) {
94
+ const canister = offer.driverCanister.toText();
95
+ const offerId = offerIdOf(canister, offer.driverKey);
96
+ this.offerWorkers.set(offerId, worker);
97
+ const rating = offer.driverRating[0];
98
+ offers.push({
99
+ offerId,
100
+ card: cardOf(offer.card, canister, this.options.host),
101
+ ...(rating === undefined ? {} : { driverRating: rating / 100 }),
102
+ rideMeters: offer.rideMeters,
103
+ rideSec: offer.rideSec,
104
+ price: moneyOf(offer.price),
105
+ receivedMs: msOf(offer.receivedNs),
106
+ });
107
+ }
108
+ }
109
+ offers.sort((a, b) => a.price.amount - b.price.amount || a.receivedMs - b.receivedMs);
110
+ }
111
+ // ZT-21: one worker booked — the copies elsewhere stop collecting.
112
+ if ((phase === "booked" || phase === "started") && !this.state.othersClosed) {
113
+ const others = views.filter((entry) => entry !== lead && phaseOf(entry.view.state) === "collecting").map((entry) => entry.worker);
114
+ await Promise.allSettled(others.map((worker) => this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.closeScheduled({ requestId: this.state.requestId, reason: { otherOfferChosen: null } }))));
115
+ this.state.othersClosed = true;
116
+ }
117
+ const state = lead.view.state;
118
+ const snapshot = {
119
+ requestId: this.state.requestId,
120
+ phase,
121
+ pickupAtMs: msOf(lead.view.pickupAtNs),
122
+ radiusMeters: Math.max(...views.map((entry) => entry.view.radiusMeters)),
123
+ closesMs: msOf(lead.view.closesNs),
124
+ offers,
125
+ asked: views.reduce((sum, entry) => sum + entry.view.asked, 0),
126
+ waiting: views.reduce((sum, entry) => sum + entry.view.waiting, 0),
127
+ lastOrderRefused: lead.view.lastOrderRefused,
128
+ };
129
+ const next = lead.view.nextStageNs[0];
130
+ if (next !== undefined)
131
+ snapshot.nextStageMs = msOf(next);
132
+ if ("booked" in state) {
133
+ const rating = state.booked.driverRating[0];
134
+ snapshot.booked = { card: cardOf(state.booked.card, state.booked.driverCanister.toText(), this.options.host), ...(rating === undefined ? {} : { driverRating: rating / 100 }), price: moneyOf(state.booked.price) };
135
+ }
136
+ if ("rescue" in state)
137
+ snapshot.rescue = Object.keys(state.rescue.reason)[0];
138
+ if ("started" in state) {
139
+ snapshot.rideToken = this.rideTokenOf(this.state.requestId, this.state.pickup, this.state.destination, this.state.riderName, { worker: lead.worker, canister: state.started.driverCanister.toText(), driverKey: state.started.driverKey });
140
+ }
141
+ return snapshot;
142
+ }
143
+ /**
144
+ * ZT-14: "Wybierz" — a booking order to the offer's driver; read the request again for its
145
+ * answer (`booked`, or back to `collecting` with `lastOrderRefused`).
146
+ * @throws Error with message `CanisterError` — `NotFound` (an offer this request does not hold; read it first)
147
+ */
148
+ async chooseAsyncUnsafe(offerId) {
149
+ const worker = this.offerWorkers.get(offerId);
150
+ if (worker === undefined)
151
+ throw canisterError("NotFound", "an offer of the last read only");
152
+ const driver = driverOfOfferId(offerId);
153
+ const outcome = await this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.chooseScheduledOffer({ requestId: this.state.requestId, driverCanister: Principal.fromText(driver.canister), driverKey: driver.driverKey }));
154
+ if ("ordered" in outcome)
155
+ return { kind: "ordered", answerByMs: msOf(outcome.ordered.answerByNs) };
156
+ return { kind: Object.keys(outcome)[0] };
157
+ }
158
+ /** ZT-9: ✕ on one offer. */
159
+ async rejectAsyncUnsafe(offerId) {
160
+ const worker = this.offerWorkers.get(offerId);
161
+ if (worker === undefined)
162
+ return;
163
+ const driver = driverOfOfferId(offerId);
164
+ await this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.rejectScheduledOffer({ requestId: this.state.requestId, driverCanister: Principal.fromText(driver.canister), driverKey: driver.driverKey }));
165
+ }
166
+ /** ZT-13, ZT-20: the rider gives it up — also a booking (the driver hears it). */
167
+ async cancelAsyncUnsafe() {
168
+ const results = await Promise.allSettled(this.state.workers.map((worker) => this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.cancelScheduled({ requestId: this.state.requestId }))));
169
+ const failed = results.find((result) => result.status === "rejected" && errorKeyOf(result.reason) === undefined);
170
+ if (failed?.status === "rejected")
171
+ throw failed.reason;
172
+ }
173
+ }
174
+ export function scheduledStateOf(token) {
175
+ const state = decodeToken(token);
176
+ if (state.v !== 1 || state.kind !== "scheduled" || typeof state.requestId !== "string" || !Array.isArray(state.workers))
177
+ throw canisterError("InvalidToken", "not a ride at a chosen time of this package");
178
+ return state;
179
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export { MAINNET_HOST, STOPPED_RETRY_ATTEMPTS, canisterError, errorKeyOf, isCanisterStoppedError, isMethodMissingError, retrySettings, type GroupOptions, type LogEntry, } from "./group/canister-actor.js";
2
2
  export { RidesActor, RideRequest, refusalKeyOf, REFRESH_WAIT_MS, REQUEST_POLL_MS, RIDE_POLL_MS, RIDE_POLL_NEAR_MS, SEARCH_RADIUS_METERS, WIDE_RADIUS_METERS, WIDEN_AFTER_MS, type RequestRideArgs, } from "./actors/rides-actor.js";
3
+ export { ScheduledRide, RESCUE_BEFORE_MS, SCHEDULED_MAX_AHEAD_MS, SCHEDULED_MIN_AHEAD_MS, SCHEDULED_POLL_MS, SCHEDULED_RADIUS_METERS, type ScheduledOfferView, type ScheduledPhase, type ScheduledSnapshot, } from "./actors/scheduled-ride.js";
3
4
  export { ProfilesActor, RIDES_PAGE } from "./actors/profiles-actor.js";
4
5
  export { TestManagerActor, SIMULATED_DRIVERS } from "./actors/test-manager-actor.js";
5
6
  export { DriverCanistersActor, CLAIM_FRAGMENT_KEY, MAX_CLAIM_CODE_CHARS, claimCodeOfHash, claimLinkOf } from "./actors/driver-canisters-actor.js";
6
7
  export { ChatPlacesActor, CHAT_CONFIG_TTL_MS, DRIVER_ROOM_PREFIX, MAX_ROOM_ID_CHARS, driverRoomId } from "./chat.js";
7
8
  export { cellsWithin, decodeGeohashCenter, decodePolyline, distanceMeters, encodeGeohash } from "./geo.js";
9
+ export { etaToPickupNowSec } from "./mappers.js";
8
10
  export type * from "./interfaces.js";
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,O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ACb,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAClJ,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACrH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,mBAAmB,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -11,8 +11,10 @@
11
11
  // "mine", the one-time claim code and the claim from the canister's own front).
12
12
  export { MAINNET_HOST, STOPPED_RETRY_ATTEMPTS, canisterError, errorKeyOf, isCanisterStoppedError, isMethodMissingError, retrySettings, } from "./group/canister-actor.js";
13
13
  export { RidesActor, RideRequest, refusalKeyOf, REFRESH_WAIT_MS, REQUEST_POLL_MS, RIDE_POLL_MS, RIDE_POLL_NEAR_MS, SEARCH_RADIUS_METERS, WIDE_RADIUS_METERS, WIDEN_AFTER_MS, } from "./actors/rides-actor.js";
14
+ export { ScheduledRide, RESCUE_BEFORE_MS, SCHEDULED_MAX_AHEAD_MS, SCHEDULED_MIN_AHEAD_MS, SCHEDULED_POLL_MS, SCHEDULED_RADIUS_METERS, } from "./actors/scheduled-ride.js";
14
15
  export { ProfilesActor, RIDES_PAGE } from "./actors/profiles-actor.js";
15
16
  export { TestManagerActor, SIMULATED_DRIVERS } from "./actors/test-manager-actor.js";
16
17
  export { DriverCanistersActor, CLAIM_FRAGMENT_KEY, MAX_CLAIM_CODE_CHARS, claimCodeOfHash, claimLinkOf } from "./actors/driver-canisters-actor.js";
17
18
  export { ChatPlacesActor, CHAT_CONFIG_TTL_MS, DRIVER_ROOM_PREFIX, MAX_ROOM_ID_CHARS, driverRoomId } from "./chat.js";
18
19
  export { cellsWithin, decodeGeohashCenter, decodePolyline, distanceMeters, encodeGeohash } from "./geo.js";
20
+ export { etaToPickupNowSec } from "./mappers.js";
@@ -39,12 +39,24 @@ export interface OfferView {
39
39
  /**
40
40
  * ZO-22 (2026-10-24, route line): the driver's EXACT position at the offer (P-18) — or,
41
41
  * from an old driver canister or after an upgrade of its worker, the centre of the
42
- * driver's geohash7 cell (~150 m, U-40); `pinExact` tells which.
42
+ * driver's geohash7 cell (~150 m, U-40); `pinExact` tells which. ZO-N26 (P-23): none for
43
+ * a driver finishing a ride (`freeAtMs`) — the pin would show the other rider's B.
43
44
  */
44
- pin: Geo;
45
+ pin?: Geo;
45
46
  pinExact: boolean;
46
47
  pinGeohash: string;
48
+ /**
49
+ * Seconds to the pickup from the offer's time (`validUntilMs` − 60 s). For a driver
50
+ * finishing a ride it holds the rest of that ride: see `etaToPickupNowSec`.
51
+ */
47
52
  etaToPickupSec: number;
53
+ /**
54
+ * ZO-N26 (P-23): the driver finishes another ride by then (with 2 min of margin) and
55
+ * comes after it — show "kończy kurs" and count `etaToPickupNowSec` down.
56
+ */
57
+ freeAtMs?: number;
58
+ /** ZO-N26: the drive from the end of that ride to the pickup (the rest of the eta). */
59
+ toPickupAfterFreeSec?: number;
48
60
  toPickupMeters: number;
49
61
  rideMeters: number;
50
62
  rideSec: number;
@@ -61,7 +73,8 @@ export interface OfferView {
61
73
  /**
62
74
  * P-17 (2026-10-24, route line): the driver's route in two legs, to draw on the map — the
63
75
  * line from the driver's exact position to the pickup (A), and the ride A → B. Never prices
64
- * anything: the driver gave it.
76
+ * anything: the driver gave it. P-23: `toPickup` is empty for a driver finishing a ride (no
77
+ * leg from the other rider's B).
65
78
  */
66
79
  export interface RouteLineView {
67
80
  toPickup: Geo[];
@@ -127,6 +140,11 @@ export interface RideView {
127
140
  driverPosition?: Geo;
128
141
  positionAtMs?: number;
129
142
  etaToPickupSec?: number;
143
+ /**
144
+ * K-N10 (P-23): a queued ride — the driver ends the previous one by then; meanwhile no
145
+ * `driverPosition`, and `etaToPickupSec` holds the rest of that ride and the drive.
146
+ */
147
+ freeAtMs?: number;
130
148
  price: Money;
131
149
  /** P-20: the driver takes cards — show "Zapłać kartą" once the ride is `inProgress`. False for an older driver canister. */
132
150
  cardAccepted: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,wEAAwE;AACxE,MAAM,WAAW,KAAK;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC;AAE7E,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,eAAe,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhF;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACtB,6EAA6E;IAC7E,OAA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,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACtB,kDAAkD;IAClD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB;AAID;;;GAGG;AACH;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,wFAAwF;IACxF,cAAc,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,oGAAoG;AACpG,MAAM,WAAW,aAAa;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,kBAAkB,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/dist/mappers.d.ts CHANGED
@@ -48,9 +48,15 @@ export declare function rateOutcomeOf(answer: CandidRateRideOutcome | {
48
48
  }): RateRideOutcome | undefined;
49
49
  export declare function driverOfOfferId(offerId: string): DriverRef;
50
50
  export declare function offerOf(offer: CandidOfferView, simulator: string | undefined, host?: string): OfferView;
51
+ /**
52
+ * ZO-N26 (P-23): the seconds to the pickup now — for a driver finishing a ride, the rest of
53
+ * that ride counts down to 0, then the drive after it stays; otherwise the offer's eta.
54
+ */
55
+ export declare function etaToPickupNowSec(offer: Pick<OfferView, "etaToPickupSec" | "freeAtMs" | "toPickupAfterFreeSec">, nowMs: number): number;
51
56
  /**
52
57
  * P-17: the line as the rider draws it — both legs decoded; undefined when a leg is not an
53
58
  * encoded polyline or has fewer than two points (the driver gave it: drawn, never trusted).
59
+ * P-23: an empty `toPickup` (a driver finishing a ride) is no leg — `toPickup: []`.
54
60
  */
55
61
  export declare function routeLineOf(line: RouteLine): RouteLineView | undefined;
56
62
  /** U-42: the order new offers join the list in — by arrival, then a fixed tie-break. */
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,UAAU,EAAE,KAAK,IAAI,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAChK,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC3H,OAAO,KAAK,EAAE,eAAe,IAAI,qBAAqB,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAEhI,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAW,gBAAgB,EAAkB,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrN,eAAO,MAAM,SAAS,WAAa,CAAC;AAEpC,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,KAAK,CAEjD;AAED,wBAAgB,SAAS,CAAC,IAAI,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,CAAC,CAAA;CAAE,EAAE,CActM;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAalF"}
package/dist/mappers.js CHANGED
@@ -140,14 +140,19 @@ export function offerOf(offer, simulator, host) {
140
140
  // ZO-22: the exact position when the worker has it (none from an old worker: `[]`).
141
141
  const exact = offer.driverPosition[0];
142
142
  const pinExact = exact !== undefined && isValidGeo(exact);
143
+ // ZO-N26 (P-23): a driver finishing a ride — no pin, the eta in two parts.
144
+ const freeAtNs = offer.freeAtNs?.[0];
145
+ const freeAtMs = freeAtNs === undefined ? undefined : msOf(freeAtNs);
146
+ const pin = pinExact ? { lat: exact.lat, lng: exact.lng } : freeAtMs !== undefined ? undefined : (decodeGeohashCenter(offer.pinGeohash) ?? { lat: 0, lng: 0 });
143
147
  return {
144
148
  offerId: offerIdOf(canister, offer.driverKey),
145
149
  card: cardOf(offer.card, canister, host),
146
150
  driverRating: offer.driverRating[0] === undefined ? undefined : offer.driverRating[0] / 100,
147
- pin: pinExact ? { lat: exact.lat, lng: exact.lng } : (decodeGeohashCenter(offer.pinGeohash) ?? { lat: 0, lng: 0 }),
151
+ ...(pin === undefined ? {} : { pin }),
148
152
  pinExact,
149
153
  pinGeohash: offer.pinGeohash,
150
154
  etaToPickupSec: offer.etaToPickupSec,
155
+ ...(freeAtMs === undefined ? {} : { freeAtMs, toPickupAfterFreeSec: afterFreeSec(offer.etaToPickupSec, freeAtMs, msOf(offer.validUntilNs) - OFFER_VALID_MS) }),
151
156
  toPickupMeters: offer.toPickupMeters,
152
157
  rideMeters: offer.rideMeters,
153
158
  rideSec: offer.rideSec,
@@ -158,14 +163,30 @@ export function offerOf(offer, simulator, host) {
158
163
  simulated: simulator !== undefined && canister === simulator,
159
164
  };
160
165
  }
166
+ /** P-23: an offer is valid this long from its time (U-39). */
167
+ const OFFER_VALID_MS = 60_000;
168
+ /** ZO-N26: the drive after the other ride — the eta at `quotedAtMs` less that ride's rest. */
169
+ function afterFreeSec(etaSec, freeAtMs, quotedAtMs) {
170
+ return Math.max(0, etaSec - Math.ceil(Math.max(0, freeAtMs - quotedAtMs) / 1000));
171
+ }
172
+ /**
173
+ * ZO-N26 (P-23): the seconds to the pickup now — for a driver finishing a ride, the rest of
174
+ * that ride counts down to 0, then the drive after it stays; otherwise the offer's eta.
175
+ */
176
+ export function etaToPickupNowSec(offer, nowMs) {
177
+ if (offer.freeAtMs === undefined || offer.toPickupAfterFreeSec === undefined)
178
+ return offer.etaToPickupSec;
179
+ return Math.ceil(Math.max(0, offer.freeAtMs - nowMs) / 1000) + offer.toPickupAfterFreeSec;
180
+ }
161
181
  /**
162
182
  * P-17: the line as the rider draws it — both legs decoded; undefined when a leg is not an
163
183
  * encoded polyline or has fewer than two points (the driver gave it: drawn, never trusted).
184
+ * P-23: an empty `toPickup` (a driver finishing a ride) is no leg — `toPickup: []`.
164
185
  */
165
186
  export function routeLineOf(line) {
166
- const toPickup = decodePolyline(line.toPickup);
187
+ const toPickup = line.toPickup === "" ? [] : decodePolyline(line.toPickup);
167
188
  const ride = decodePolyline(line.ride);
168
- if (toPickup === undefined || ride === undefined || toPickup.length < 2 || ride.length < 2)
189
+ if (toPickup === undefined || ride === undefined || (toPickup.length < 2 && line.toPickup !== "") || ride.length < 2)
169
190
  return undefined;
170
191
  return { toPickup, ride };
171
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsm-mit/tigi-sharded-package",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "The one package of the Tigi network group: takes the coordinator's id and hides the coordinator, the core and the workers — for a consumer the group is one canister; plus the rider's few driver-canister endpoints (U-14).",
5
5
  "homepage": "https://github.com/JSM-Tigi/tigi-sharded/tree/master/package#readme",
6
6
  "repository": {
@@ -39,6 +39,7 @@
39
39
  "test-drivers": "bash scripts/run-tests-local.sh tests/test-drivers.ts",
40
40
  "test-split": "bash scripts/run-tests-local.sh tests/test-split.ts",
41
41
  "test-claim": "bash scripts/run-tests-local.sh tests/test-claim.ts",
42
+ "test-scheduled": "bash scripts/run-tests-local.sh tests/test-scheduled.ts",
42
43
  "test-route-line": "bash scripts/run-tests-local.sh tests/test-route-line.ts",
43
44
  "test-ride-history": "bash scripts/run-tests-local.sh tests/test-ride-history.ts",
44
45
  "test-router-service": "bash scripts/run-tests-local.sh tests/test-router-service.ts",
@@ -59,11 +60,11 @@
59
60
  "tigiSharded": {
60
61
  "repo": "tigi-sharded",
61
62
  "repoUrl": "https://github.com/JSM-Tigi/tigi-sharded",
62
- "commit": "8289506ee9ebe2c9496f713cb8bb34e6bd241755"
63
+ "commit": "c2bb281e890aa5c4b47cb3d6f5ad33c6aa511b21"
63
64
  },
64
65
  "tigiDriverRust": {
65
66
  "repo": "tigi-driver-rust",
66
67
  "repoUrl": "https://github.com/JSM-Tigi/tigi-driver-rust",
67
- "commit": "0e075f25fdddac1c828ec1a53bf03c8eff58a004"
68
+ "commit": "794ef65f7d17a78fc24d239c63f1a580afb2b491"
68
69
  }
69
70
  }