@jsm-mit/tigi-sharded-package 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/declarations/coordinator/coordinator.did +39 -0
- package/declarations/coordinator/coordinator.did.d.ts +68 -0
- package/declarations/coordinator/coordinator.did.js +23 -0
- package/declarations/core/core.did +240 -53
- package/declarations/core/core.did.d.ts +208 -48
- package/declarations/core/core.did.js +165 -51
- package/declarations/tigi-driver/tigi-driver.did +15 -0
- package/declarations/tigi-driver/tigi-driver.did.d.ts +19 -0
- package/declarations/tigi-driver/tigi-driver.did.js +6 -0
- package/declarations/tigi-simulator/tigi-simulator.did +46 -4
- package/declarations/tigi-simulator/tigi-simulator.did.d.ts +70 -4
- package/declarations/tigi-simulator/tigi-simulator.did.js +39 -10
- package/declarations/worker/worker.did +23 -6
- package/declarations/worker/worker.did.d.ts +18 -6
- package/declarations/worker/worker.did.js +14 -7
- package/dist/actors/profiles-actor.d.ts +20 -1
- package/dist/actors/profiles-actor.d.ts.map +1 -1
- package/dist/actors/profiles-actor.js +46 -12
- package/dist/actors/rides-actor.d.ts +21 -1
- package/dist/actors/rides-actor.d.ts.map +1 -1
- package/dist/actors/rides-actor.js +46 -6
- package/dist/geo.d.ts +5 -0
- package/dist/geo.d.ts.map +1 -1
- package/dist/geo.js +41 -0
- package/dist/group/canister-actor.d.ts +7 -0
- package/dist/group/canister-actor.d.ts.map +1 -1
- package/dist/group/canister-actor.js +18 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/interfaces.d.ts +35 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +20 -2
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +62 -2
- package/package.json +7 -4
package/dist/geo.js
CHANGED
|
@@ -84,6 +84,47 @@ export function decodeGeohashCenter(geohash) {
|
|
|
84
84
|
}
|
|
85
85
|
return { lat: (latMin + latMax) / 2, lng: (lngMin + lngMax) / 2 };
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* P-17: the points of a Google encoded polyline (precision 6 by default); undefined for a
|
|
89
|
+
* text that is not one or a point off the map.
|
|
90
|
+
*/
|
|
91
|
+
export function decodePolyline(text, precision = 6) {
|
|
92
|
+
const scale = 10 ** precision;
|
|
93
|
+
const points = [];
|
|
94
|
+
let index = 0;
|
|
95
|
+
let lat = 0;
|
|
96
|
+
let lng = 0;
|
|
97
|
+
const next = () => {
|
|
98
|
+
let result = 0;
|
|
99
|
+
let shift = 0;
|
|
100
|
+
for (;;) {
|
|
101
|
+
if (index >= text.length || shift > 30)
|
|
102
|
+
return undefined;
|
|
103
|
+
const chunk = text.charCodeAt(index) - 63;
|
|
104
|
+
if (chunk < 0 || chunk > 63)
|
|
105
|
+
return undefined;
|
|
106
|
+
index += 1;
|
|
107
|
+
result |= (chunk & 0x1f) << shift;
|
|
108
|
+
shift += 5;
|
|
109
|
+
if (chunk < 0x20)
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return result & 1 ? ~(result >> 1) : result >> 1;
|
|
113
|
+
};
|
|
114
|
+
while (index < text.length) {
|
|
115
|
+
const dLat = next();
|
|
116
|
+
const dLng = next();
|
|
117
|
+
if (dLat === undefined || dLng === undefined)
|
|
118
|
+
return undefined;
|
|
119
|
+
lat += dLat;
|
|
120
|
+
lng += dLng;
|
|
121
|
+
const point = { lat: lat / scale, lng: lng / scale };
|
|
122
|
+
if (!isValidGeo(point))
|
|
123
|
+
return undefined;
|
|
124
|
+
points.push(point);
|
|
125
|
+
}
|
|
126
|
+
return points;
|
|
127
|
+
}
|
|
87
128
|
function radians(degrees) {
|
|
88
129
|
return (degrees * Math.PI) / 180;
|
|
89
130
|
}
|
|
@@ -88,6 +88,13 @@ export declare function errorCause(errorFromCanister: CanisterErrorRecord): {
|
|
|
88
88
|
errorMessage: unknown;
|
|
89
89
|
logs: LogEntry[];
|
|
90
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* True for a call to a method the canister does not have (IC0536, "has no query method" /
|
|
93
|
+
* "has no update method"): an older canister than the package — e.g. a driver canister
|
|
94
|
+
* without `getRideRoute` (P-19). The agent's error as it comes, or wrapped as
|
|
95
|
+
* `CriticalCanisterError` (`cause.rawError`).
|
|
96
|
+
*/
|
|
97
|
+
export declare function isMethodMissingError(error: unknown): boolean;
|
|
91
98
|
/** The errorKey of a `CanisterError`, or undefined for any other error. */
|
|
92
99
|
export declare function errorKeyOf(error: unknown): string | undefined;
|
|
93
100
|
export declare function canisterError(errorKey: string, errorMessage: string): Error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canister-actor.d.ts","sourceRoot":"","sources":["../../src/group/canister-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAa,KAAK,QAAQ,EAAS,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,0FAA0F;AAC1F,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEvE,qFAAqF;AACrF,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAEzE,MAAM,WAAW,YAAY;IACzB;;;;OAIG;IACH,IAAI,CAAC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,GAAG,OAAO,CAAC,CAAC,CAAC,CAK/F;AAED,6FAA6F;AAC7F,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMjG;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;IAAE,EAAE,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMpI;AAED,yFAAyF;AACzF,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAU7E;AAED,wBAAgB,UAAU,CAAC,iBAAiB,EAAE,mBAAmB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAUhI;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAW5D;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG7D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,KAAK,CAE3E"}
|
|
@@ -151,6 +151,24 @@ export function errorCause(errorFromCanister) {
|
|
|
151
151
|
const errorKey = Object.keys(errorFromCanister.details)[0] ?? "Unknown";
|
|
152
152
|
return { errorKey, errorMessage: errorFromCanister.details[errorKey], logs };
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* True for a call to a method the canister does not have (IC0536, "has no query method" /
|
|
156
|
+
* "has no update method"): an older canister than the package — e.g. a driver canister
|
|
157
|
+
* without `getRideRoute` (P-19). The agent's error as it comes, or wrapped as
|
|
158
|
+
* `CriticalCanisterError` (`cause.rawError`).
|
|
159
|
+
*/
|
|
160
|
+
export function isMethodMissingError(error) {
|
|
161
|
+
if (!(error instanceof Error))
|
|
162
|
+
return false;
|
|
163
|
+
const raw = error.message === "CriticalCanisterError" ? error.cause?.rawError : error;
|
|
164
|
+
if (!(raw instanceof Error) && (typeof raw !== "object" || raw === null))
|
|
165
|
+
return false;
|
|
166
|
+
const code = raw.cause?.code;
|
|
167
|
+
if (code?.rejectErrorCode === "IC0536")
|
|
168
|
+
return true;
|
|
169
|
+
const text = typeof code?.rejectMessage === "string" ? code.rejectMessage : raw instanceof Error ? raw.message : "";
|
|
170
|
+
return /has no (query|update) method/.test(text);
|
|
171
|
+
}
|
|
154
172
|
/** The errorKey of a `CanisterError`, or undefined for any other error. */
|
|
155
173
|
export function errorKeyOf(error) {
|
|
156
174
|
if (!(error instanceof Error) || error.message !== "CanisterError")
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { MAINNET_HOST, STOPPED_RETRY_ATTEMPTS, canisterError, errorKeyOf, isCanisterStoppedError, retrySettings, type GroupOptions, type LogEntry, } from "./group/canister-actor.js";
|
|
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
3
|
export { ProfilesActor, RIDES_PAGE } from "./actors/profiles-actor.js";
|
|
4
4
|
export { TestManagerActor, SIMULATED_DRIVERS } from "./actors/test-manager-actor.js";
|
|
5
5
|
export { DriverCanistersActor, CLAIM_FRAGMENT_KEY, MAX_CLAIM_CODE_CHARS, claimCodeOfHash, claimLinkOf } from "./actors/driver-canisters-actor.js";
|
|
6
6
|
export { ChatPlacesActor, CHAT_CONFIG_TTL_MS, DRIVER_ROOM_PREFIX, MAX_ROOM_ID_CHARS, driverRoomId } from "./chat.js";
|
|
7
|
-
export { cellsWithin, decodeGeohashCenter, distanceMeters, encodeGeohash } from "./geo.js";
|
|
7
|
+
export { cellsWithin, decodeGeohashCenter, decodePolyline, distanceMeters, encodeGeohash } from "./geo.js";
|
|
8
8
|
export type * from "./interfaces.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,QAAQ,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,UAAU,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,KAAK,eAAe,GACvB,MAAM,yBAAyB,CAAC;AACjC,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,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,QAAQ,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,UAAU,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,KAAK,eAAe,GACvB,MAAM,yBAAyB,CAAC;AACjC,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,mBAAmB,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
// WHERE a driver's room is; the fronts use `@jsm-mit/chat-sharded-package` for the messages.
|
|
10
10
|
// The driver's own canister (U-45): `DriverCanistersActor` (the demo lease, its extension,
|
|
11
11
|
// "mine", the one-time claim code and the claim from the canister's own front).
|
|
12
|
-
export { MAINNET_HOST, STOPPED_RETRY_ATTEMPTS, canisterError, errorKeyOf, isCanisterStoppedError, retrySettings, } from "./group/canister-actor.js";
|
|
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
14
|
export { ProfilesActor, RIDES_PAGE } from "./actors/profiles-actor.js";
|
|
15
15
|
export { TestManagerActor, SIMULATED_DRIVERS } from "./actors/test-manager-actor.js";
|
|
16
16
|
export { DriverCanistersActor, CLAIM_FRAGMENT_KEY, MAX_CLAIM_CODE_CHARS, claimCodeOfHash, claimLinkOf } from "./actors/driver-canisters-actor.js";
|
|
17
17
|
export { ChatPlacesActor, CHAT_CONFIG_TTL_MS, DRIVER_ROOM_PREFIX, MAX_ROOM_ID_CHARS, driverRoomId } from "./chat.js";
|
|
18
|
-
export { cellsWithin, decodeGeohashCenter, distanceMeters, encodeGeohash } from "./geo.js";
|
|
18
|
+
export { cellsWithin, decodeGeohashCenter, decodePolyline, distanceMeters, encodeGeohash } from "./geo.js";
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -36,8 +36,13 @@ export interface OfferView {
|
|
|
36
36
|
card: DriverCardView;
|
|
37
37
|
/** The driver's rating 1–5 (e.g. 4.87); undefined for a new driver. */
|
|
38
38
|
driverRating?: number;
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* ZO-22 (2026-10-24, route line): the driver's EXACT position at the offer (P-18) — or,
|
|
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.
|
|
43
|
+
*/
|
|
40
44
|
pin: Geo;
|
|
45
|
+
pinExact: boolean;
|
|
41
46
|
pinGeohash: string;
|
|
42
47
|
etaToPickupSec: number;
|
|
43
48
|
toPickupMeters: number;
|
|
@@ -53,6 +58,15 @@ export interface OfferView {
|
|
|
53
58
|
/** A virtual driver of the simulator (the Test Manager's "TEST" badge, TM-7). */
|
|
54
59
|
simulated: boolean;
|
|
55
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* P-17 (2026-10-24, route line): the driver's route in two legs, to draw on the map — the
|
|
63
|
+
* line from the driver's exact position to the pickup (A), and the ride A → B. Never prices
|
|
64
|
+
* anything: the driver gave it.
|
|
65
|
+
*/
|
|
66
|
+
export interface RouteLineView {
|
|
67
|
+
toPickup: Geo[];
|
|
68
|
+
ride: Geo[];
|
|
69
|
+
}
|
|
56
70
|
export type RequestPhase = "searching" | "waitingForDriver" | "accepted" | "closed";
|
|
57
71
|
export type CloseReason = "offerRejected" | "otherOfferChosen" | "riderGaveUp" | "orderExpired";
|
|
58
72
|
export type RideStatusKind = "accepted" | "driverArrived" | "inProgress" | "completed" | "cancelledByDriver" | "cancelledByRider";
|
|
@@ -136,7 +150,27 @@ export interface RideHistoryEntry {
|
|
|
136
150
|
endedAtMs: number;
|
|
137
151
|
/** None for a cancelled ride (K-N4). */
|
|
138
152
|
price?: Money;
|
|
153
|
+
/** KU-4 (0.5.0): where the ride began ("Skąd"); none for a ride before stage 7 or from an old worker. */
|
|
154
|
+
pickup?: Geo;
|
|
155
|
+
/** KU-4 (0.5.0): where it went ("Dokąd"); none as for `pickup`. */
|
|
156
|
+
destination?: Geo;
|
|
157
|
+
/**
|
|
158
|
+
* KU-5 (0.5.0, core C-23): the rider can rate the driver now with
|
|
159
|
+
* `ProfilesActor.ratePastRideAsyncUnsafe` — a completed ride, within 24 h of its end, not
|
|
160
|
+
* rated yet (from the history or live). False on an old core.
|
|
161
|
+
*/
|
|
162
|
+
ratable: boolean;
|
|
163
|
+
/** KU-5 (0.5.0): the stars the rider gave, when the core knows them (rated from stage 7 on). */
|
|
164
|
+
myRating?: number;
|
|
139
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* KU-5 (0.5.0, core C-23): the answer to `ratePastRideAsyncUnsafe`.
|
|
168
|
+
* - `ok` — counted now (the driver's rating changes once);
|
|
169
|
+
* - `alreadyRated` — rated before (from the history or live after the ride);
|
|
170
|
+
* - `notRatable` — not completed, the 24 h are over, or the ride is not in the core yet (K-9: up to a minute);
|
|
171
|
+
* - `notAuthorized` — not the caller's ride (or the rider is blocked).
|
|
172
|
+
*/
|
|
173
|
+
export type RateRideOutcome = "ok" | "alreadyRated" | "notRatable" | "notAuthorized";
|
|
140
174
|
export interface RideHistoryPage {
|
|
141
175
|
rides: RideHistoryEntry[];
|
|
142
176
|
/** Opaque: the next, older page; undefined at the end. */
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -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;AAE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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
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { CarrierKind as CandidCarrierKind, DriverCard, Money as CandidMoney, RideStatus } from "../declarations/tigi-driver/tigi-driver.did.js";
|
|
1
|
+
import type { CarrierKind as CandidCarrierKind, DriverCard, Money as CandidMoney, RideStatus, RouteLine } from "../declarations/tigi-driver/tigi-driver.did.js";
|
|
2
2
|
import type { OfferView as CandidOfferView, RequestView as CandidRequestView } from "../declarations/worker/worker.did.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RateRideOutcome as CandidRateRideOutcome, RideView as CandidHistoryRide } from "../declarations/core/core.did.js";
|
|
4
|
+
import type { CarrierKind, CloseReason, DriverCardView, Money, OfferView, RateRideOutcome, RequestPhase, RideHistoryEntry, RideStatusView, RouteLineView } from "./interfaces.js";
|
|
4
5
|
export declare const NS_PER_MS = 1000000n;
|
|
5
6
|
export declare function msOf(ns: bigint): number;
|
|
6
7
|
export declare function moneyOf(money: CandidMoney): Money;
|
|
@@ -33,8 +34,25 @@ export interface DriverRef {
|
|
|
33
34
|
driverKey: string;
|
|
34
35
|
}
|
|
35
36
|
export declare function offerIdOf(driverCanister: string, driverKey: string): string;
|
|
37
|
+
/** KU-3: the opaque text of a past ride — its driver canister, driver and request. */
|
|
38
|
+
export declare function rideRefOf(driverCanister: string, driverKey: string, requestId: string): string;
|
|
39
|
+
/** @throws Error with message `CanisterError` (errorKey `InvalidToken`) for a text the package did not make. */
|
|
40
|
+
export declare function rideOfRideRef(rideRef: string): DriverRef & {
|
|
41
|
+
requestId: string;
|
|
42
|
+
};
|
|
43
|
+
/** C-8: a line of the history. The stage-7 fields are absent on an old core (`ratable` = false). */
|
|
44
|
+
export declare function historyEntryOf(entry: CandidHistoryRide): RideHistoryEntry;
|
|
45
|
+
/** C-23: the core's answer to `rateMyRide`, or its error key, as the front shows it. */
|
|
46
|
+
export declare function rateOutcomeOf(answer: CandidRateRideOutcome | {
|
|
47
|
+
errorKey: string | undefined;
|
|
48
|
+
}): RateRideOutcome | undefined;
|
|
36
49
|
export declare function driverOfOfferId(offerId: string): DriverRef;
|
|
37
50
|
export declare function offerOf(offer: CandidOfferView, simulator: string | undefined, host?: string): OfferView;
|
|
51
|
+
/**
|
|
52
|
+
* P-17: the line as the rider draws it — both legs decoded; undefined when a leg is not an
|
|
53
|
+
* encoded polyline or has fewer than two points (the driver gave it: drawn, never trusted).
|
|
54
|
+
*/
|
|
55
|
+
export declare function routeLineOf(line: RouteLine): RouteLineView | undefined;
|
|
38
56
|
/** U-42: the order new offers join the list in — by arrival, then a fixed tie-break. */
|
|
39
57
|
export declare function compareArrival(a: OfferView, b: OfferView): number;
|
|
40
58
|
/**
|
package/dist/mappers.d.ts.map
CHANGED
|
@@ -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,MAAM,gDAAgD,CAAC;
|
|
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,EA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wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,SAAS,EAAE,CAQ7D;AAED,sFAAsF;AACtF,MAAM,WAAW,UAAU;IACvB,qCAAqC;IACrC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,qHAAqH;IACrH,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,CAiBtH;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,YAAY,CAE7D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAMhE"}
|
package/dist/mappers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Candid → the rider's views (interfaces.ts), and the opaque texts that name an offer and
|
|
2
2
|
// a past ride. Pure functions: tested without a replica (tests/test-unit.ts).
|
|
3
|
-
import { decodeGeohashCenter } from "./geo.js";
|
|
3
|
+
import { decodeGeohashCenter, decodePolyline, isValidGeo } from "./geo.js";
|
|
4
4
|
import { isLocalHost, MAINNET_HOST } from "./group/canister-actor.js";
|
|
5
5
|
export const NS_PER_MS = 1000000n;
|
|
6
6
|
export function msOf(ns) {
|
|
@@ -83,6 +83,51 @@ export function decodeToken(token) {
|
|
|
83
83
|
export function offerIdOf(driverCanister, driverKey) {
|
|
84
84
|
return encodeToken({ c: driverCanister, k: driverKey });
|
|
85
85
|
}
|
|
86
|
+
// ----- the rider's history (core C-8, C-23) -----
|
|
87
|
+
/** KU-3: the opaque text of a past ride — its driver canister, driver and request. */
|
|
88
|
+
export function rideRefOf(driverCanister, driverKey, requestId) {
|
|
89
|
+
return encodeToken({ c: driverCanister, k: driverKey, r: requestId });
|
|
90
|
+
}
|
|
91
|
+
/** @throws Error with message `CanisterError` (errorKey `InvalidToken`) for a text the package did not make. */
|
|
92
|
+
export function rideOfRideRef(rideRef) {
|
|
93
|
+
const ref = decodeToken(rideRef);
|
|
94
|
+
if (typeof ref.c !== "string" || typeof ref.k !== "string" || typeof ref.r !== "string")
|
|
95
|
+
throw new Error("CanisterError", { cause: { errorKey: "InvalidToken", errorMessage: "not a ride of this package", logs: [] } });
|
|
96
|
+
return { canister: ref.c, driverKey: ref.k, requestId: ref.r };
|
|
97
|
+
}
|
|
98
|
+
function placeOf(geo) {
|
|
99
|
+
const point = geo?.[0];
|
|
100
|
+
return point !== undefined && isValidGeo(point) ? { lat: point.lat, lng: point.lng } : undefined;
|
|
101
|
+
}
|
|
102
|
+
/** C-8: a line of the history. The stage-7 fields are absent on an old core (`ratable` = false). */
|
|
103
|
+
export function historyEntryOf(entry) {
|
|
104
|
+
const stars = entry.myRating?.[0];
|
|
105
|
+
return {
|
|
106
|
+
rideRef: rideRefOf(entry.driverCanister.toText(), entry.driverKey, entry.requestId),
|
|
107
|
+
requestId: entry.requestId,
|
|
108
|
+
end: Object.keys(entry.end)[0],
|
|
109
|
+
endedAtMs: msOf(entry.endedAtNs),
|
|
110
|
+
price: entry.price[0] === undefined ? undefined : moneyOf(entry.price[0]),
|
|
111
|
+
pickup: placeOf(entry.pickup),
|
|
112
|
+
destination: placeOf(entry.destination),
|
|
113
|
+
ratable: entry.ratable?.[0] === true,
|
|
114
|
+
myRating: stars === undefined ? undefined : stars,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** C-23: the core's answer to `rateMyRide`, or its error key, as the front shows it. */
|
|
118
|
+
export function rateOutcomeOf(answer) {
|
|
119
|
+
if ("rated" in answer)
|
|
120
|
+
return "ok";
|
|
121
|
+
if ("alreadyRated" in answer)
|
|
122
|
+
return "alreadyRated";
|
|
123
|
+
if ("notRatable" in answer)
|
|
124
|
+
return "notRatable";
|
|
125
|
+
if (answer.errorKey === "NotAuthorized")
|
|
126
|
+
return "notAuthorized";
|
|
127
|
+
if (answer.errorKey === "NotFound")
|
|
128
|
+
return "notRatable";
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
86
131
|
export function driverOfOfferId(offerId) {
|
|
87
132
|
const value = decodeToken(offerId);
|
|
88
133
|
if (typeof value.c !== "string" || typeof value.k !== "string")
|
|
@@ -92,11 +137,15 @@ export function driverOfOfferId(offerId) {
|
|
|
92
137
|
// ----- merging the workers' answers -----
|
|
93
138
|
export function offerOf(offer, simulator, host) {
|
|
94
139
|
const canister = offer.driverCanister.toText();
|
|
140
|
+
// ZO-22: the exact position when the worker has it (none from an old worker: `[]`).
|
|
141
|
+
const exact = offer.driverPosition[0];
|
|
142
|
+
const pinExact = exact !== undefined && isValidGeo(exact);
|
|
95
143
|
return {
|
|
96
144
|
offerId: offerIdOf(canister, offer.driverKey),
|
|
97
145
|
card: cardOf(offer.card, canister, host),
|
|
98
146
|
driverRating: offer.driverRating[0] === undefined ? undefined : offer.driverRating[0] / 100,
|
|
99
|
-
pin: decodeGeohashCenter(offer.pinGeohash) ?? { lat: 0, lng: 0 },
|
|
147
|
+
pin: pinExact ? { lat: exact.lat, lng: exact.lng } : (decodeGeohashCenter(offer.pinGeohash) ?? { lat: 0, lng: 0 }),
|
|
148
|
+
pinExact,
|
|
100
149
|
pinGeohash: offer.pinGeohash,
|
|
101
150
|
etaToPickupSec: offer.etaToPickupSec,
|
|
102
151
|
toPickupMeters: offer.toPickupMeters,
|
|
@@ -109,6 +158,17 @@ export function offerOf(offer, simulator, host) {
|
|
|
109
158
|
simulated: simulator !== undefined && canister === simulator,
|
|
110
159
|
};
|
|
111
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* P-17: the line as the rider draws it — both legs decoded; undefined when a leg is not an
|
|
163
|
+
* encoded polyline or has fewer than two points (the driver gave it: drawn, never trusted).
|
|
164
|
+
*/
|
|
165
|
+
export function routeLineOf(line) {
|
|
166
|
+
const toPickup = decodePolyline(line.toPickup);
|
|
167
|
+
const ride = decodePolyline(line.ride);
|
|
168
|
+
if (toPickup === undefined || ride === undefined || toPickup.length < 2 || ride.length < 2)
|
|
169
|
+
return undefined;
|
|
170
|
+
return { toPickup, ride };
|
|
171
|
+
}
|
|
112
172
|
/** U-42: the order new offers join the list in — by arrival, then a fixed tie-break. */
|
|
113
173
|
export function compareArrival(a, b) {
|
|
114
174
|
return a.receivedMs - b.receivedMs || (a.offerId < b.offerId ? -1 : a.offerId > b.offerId ? 1 : 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/tigi-sharded-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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,8 +39,11 @@
|
|
|
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-route-line": "bash scripts/run-tests-local.sh tests/test-route-line.ts",
|
|
43
|
+
"test-ride-history": "bash scripts/run-tests-local.sh tests/test-ride-history.ts",
|
|
44
|
+
"test-router-service": "bash scripts/run-tests-local.sh tests/test-router-service.ts",
|
|
42
45
|
"load-local": "bash scripts/run-load-local.sh",
|
|
43
|
-
"test-e2e": "npm run test-drivers && npm run test-simulator && npm run test-split && npm run test-claim"
|
|
46
|
+
"test-e2e": "npm run test-drivers && npm run test-simulator && npm run test-split && npm run test-claim && npm run test-route-line && npm run test-ride-history"
|
|
44
47
|
},
|
|
45
48
|
"dependencies": {
|
|
46
49
|
"@icp-sdk/core": "^6.1.0"
|
|
@@ -56,11 +59,11 @@
|
|
|
56
59
|
"tigiSharded": {
|
|
57
60
|
"repo": "tigi-sharded",
|
|
58
61
|
"repoUrl": "https://github.com/JSM-Tigi/tigi-sharded",
|
|
59
|
-
"commit": "
|
|
62
|
+
"commit": "45ef3143fba15b541f6a7eeb710791ba95716964"
|
|
60
63
|
},
|
|
61
64
|
"tigiDriverRust": {
|
|
62
65
|
"repo": "tigi-driver-rust",
|
|
63
66
|
"repoUrl": "https://github.com/JSM-Tigi/tigi-driver-rust",
|
|
64
|
-
"commit": "
|
|
67
|
+
"commit": "f7aca49c36c7eddeea623e69f10d15203100a67e"
|
|
65
68
|
}
|
|
66
69
|
}
|