@jsm-mit/tigi-sharded-package 0.1.0 → 0.2.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 +41 -1
- package/declarations/coordinator/coordinator.did +68 -31
- package/declarations/coordinator/coordinator.did.d.ts +90 -30
- package/declarations/coordinator/coordinator.did.js +55 -31
- package/declarations/core/core.did +104 -38
- package/declarations/core/core.did.d.ts +98 -39
- package/declarations/core/core.did.js +66 -32
- package/dist/actors/profiles-actor.d.ts +9 -1
- package/dist/actors/profiles-actor.d.ts.map +1 -1
- package/dist/actors/profiles-actor.js +16 -0
- package/dist/actors/rides-actor.d.ts +12 -1
- package/dist/actors/rides-actor.d.ts.map +1 -1
- package/dist/actors/rides-actor.js +17 -0
- package/dist/chat.d.ts +51 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +87 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/interfaces.d.ts +19 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -18,6 +18,18 @@ export type BlockTarget = { 'driverCanister' : Principal } |
|
|
|
18
18
|
{ 'driver' : { 'driverKey' : string, 'canister' : Principal } } |
|
|
19
19
|
{ 'rider' : Principal };
|
|
20
20
|
export interface CanisterArgs { 'canister' : Principal }
|
|
21
|
+
export interface ChatConfig {
|
|
22
|
+
'chatCoordinatorId' : Principal,
|
|
23
|
+
'projectId' : string,
|
|
24
|
+
}
|
|
25
|
+
export interface ChatRoomsStatus {
|
|
26
|
+
'failures' : bigint,
|
|
27
|
+
'pending' : bigint,
|
|
28
|
+
'lastError' : [] | [string],
|
|
29
|
+
'config' : [] | [ChatConfig],
|
|
30
|
+
'pendingSinceNs' : [] | [bigint],
|
|
31
|
+
'rooms' : bigint,
|
|
32
|
+
}
|
|
21
33
|
export interface DriverCanister {
|
|
22
34
|
'moduleHash' : [] | [Uint8Array | number[]],
|
|
23
35
|
'owner' : Principal,
|
|
@@ -39,6 +51,14 @@ export interface DriverCanistersPage {
|
|
|
39
51
|
'total' : bigint,
|
|
40
52
|
'canisters' : Array<DriverCanister>,
|
|
41
53
|
}
|
|
54
|
+
export interface DriverRoomView {
|
|
55
|
+
'recipient' : Principal,
|
|
56
|
+
'driverKey' : string,
|
|
57
|
+
'canister' : Principal,
|
|
58
|
+
'lastError' : [] | [string],
|
|
59
|
+
'roomId' : string,
|
|
60
|
+
'synced' : boolean,
|
|
61
|
+
}
|
|
42
62
|
export interface Error { 'details' : ErrorDetails, 'logsJson' : string }
|
|
43
63
|
export type ErrorDetails = { 'InterCanisterConnectionError' : null } |
|
|
44
64
|
{ 'RemoteCanisterError' : string } |
|
|
@@ -79,6 +99,7 @@ export interface Profile {
|
|
|
79
99
|
}
|
|
80
100
|
export interface ProfileEntry { 'principal' : Principal, 'name' : string }
|
|
81
101
|
export interface ProfilesArgs { 'principals' : Array<Principal> }
|
|
102
|
+
export interface Rating { 'sum' : bigint, 'count' : bigint }
|
|
82
103
|
export interface RatingEntry {
|
|
83
104
|
'requestId' : string,
|
|
84
105
|
'side' : RatingSide,
|
|
@@ -98,46 +119,54 @@ export type Result = { 'ok' : bigint } |
|
|
|
98
119
|
{ 'err' : Error };
|
|
99
120
|
export type Result_1 = { 'ok' : Uint8Array | number[] } |
|
|
100
121
|
{ 'err' : Error };
|
|
101
|
-
export type Result_10 = { 'ok' :
|
|
122
|
+
export type Result_10 = { 'ok' : RideBatchResult } |
|
|
123
|
+
{ 'err' : Error };
|
|
124
|
+
export type Result_11 = {
|
|
125
|
+
'ok' : {
|
|
126
|
+
'subjects' : bigint,
|
|
127
|
+
'headSeq' : bigint,
|
|
128
|
+
'lastError' : [] | [string],
|
|
129
|
+
'laggingWorkers' : bigint,
|
|
130
|
+
}
|
|
131
|
+
} |
|
|
102
132
|
{ 'err' : Error };
|
|
103
|
-
export type
|
|
133
|
+
export type Result_12 = { 'ok' : Wiring } |
|
|
104
134
|
{ 'err' : Error };
|
|
105
|
-
export type
|
|
135
|
+
export type Result_13 = { 'ok' : Array<ProfileEntry> } |
|
|
106
136
|
{ 'err' : Error };
|
|
107
|
-
export type
|
|
137
|
+
export type Result_14 = { 'ok' : RidesPage } |
|
|
108
138
|
{ 'err' : Error };
|
|
109
|
-
export type
|
|
139
|
+
export type Result_15 = { 'ok' : [] | [Rating] } |
|
|
110
140
|
{ 'err' : Error };
|
|
111
|
-
export type
|
|
141
|
+
export type Result_16 = { 'ok' : DriverCanister } |
|
|
112
142
|
{ 'err' : Error };
|
|
113
|
-
export type
|
|
143
|
+
export type Result_17 = { 'ok' : FactoryStatus } |
|
|
114
144
|
{ 'err' : Error };
|
|
115
|
-
export type
|
|
145
|
+
export type Result_18 = { 'ok' : [] | [RolloutView] } |
|
|
116
146
|
{ 'err' : Error };
|
|
117
|
-
export type
|
|
147
|
+
export type Result_19 = { 'ok' : ChatRoomsStatus } |
|
|
118
148
|
{ 'err' : Error };
|
|
119
149
|
export type Result_2 = { 'ok' : boolean } |
|
|
120
150
|
{ 'err' : Error };
|
|
151
|
+
export type Result_20 = { 'ok' : Array<Principal> } |
|
|
152
|
+
{ 'err' : Error };
|
|
153
|
+
export type Result_21 = { 'ok' : Principal } |
|
|
154
|
+
{ 'err' : Error };
|
|
155
|
+
export type Result_22 = { 'ok' : WasmInfo } |
|
|
156
|
+
{ 'err' : Error };
|
|
121
157
|
export type Result_3 = { 'ok' : RolloutView } |
|
|
122
158
|
{ 'err' : Error };
|
|
123
159
|
export type Result_4 = { 'ok' : Profile } |
|
|
124
160
|
{ 'err' : Error };
|
|
125
|
-
export type Result_5 = { 'ok' :
|
|
161
|
+
export type Result_5 = { 'ok' : ChatConfig } |
|
|
126
162
|
{ 'err' : Error };
|
|
127
|
-
export type Result_6 = { 'ok' : Array<
|
|
163
|
+
export type Result_6 = { 'ok' : Array<DriverRoomView> } |
|
|
128
164
|
{ 'err' : Error };
|
|
129
|
-
export type Result_7 = { 'ok' :
|
|
165
|
+
export type Result_7 = { 'ok' : DriverCanistersPage } |
|
|
130
166
|
{ 'err' : Error };
|
|
131
|
-
export type Result_8 = { 'ok' :
|
|
167
|
+
export type Result_8 = { 'ok' : Array<Block> } |
|
|
132
168
|
{ 'err' : Error };
|
|
133
|
-
export type Result_9 = {
|
|
134
|
-
'ok' : {
|
|
135
|
-
'subjects' : bigint,
|
|
136
|
-
'headSeq' : bigint,
|
|
137
|
-
'lastError' : [] | [string],
|
|
138
|
-
'laggingWorkers' : bigint,
|
|
139
|
-
}
|
|
140
|
-
} |
|
|
169
|
+
export type Result_9 = { 'ok' : LeaseAnswer } |
|
|
141
170
|
{ 'err' : Error };
|
|
142
171
|
export interface RideBatch {
|
|
143
172
|
'ratings' : Array<RatingEntry>,
|
|
@@ -200,7 +229,7 @@ export interface TigiCore {
|
|
|
200
229
|
/**
|
|
201
230
|
* / Admins: a canister the core controls joins the demo pool (U-35).
|
|
202
231
|
*/
|
|
203
|
-
'addPoolCanister' : ActorMethod<[CanisterArgs],
|
|
232
|
+
'addPoolCanister' : ActorMethod<[CanisterArgs], Result_16>,
|
|
204
233
|
/**
|
|
205
234
|
* / Admins: a driver canister, or one driver in it (`driverKey`), is blocked; the workers
|
|
206
235
|
* / drop it at once (WO-2).
|
|
@@ -215,44 +244,58 @@ export interface TigiCore {
|
|
|
215
244
|
* / Admins: the chunks become THE module of their kind. A new driver wasm is released
|
|
216
245
|
* / (F-11) and its hash goes to the workers.
|
|
217
246
|
*/
|
|
218
|
-
'commitDriverWasm' : ActorMethod<[WasmCommitArgs],
|
|
247
|
+
'commitDriverWasm' : ActorMethod<[WasmCommitArgs], Result_22>,
|
|
219
248
|
/**
|
|
220
249
|
* / Admins, localTest: an empty canister from the core's cycles joins the demo pool.
|
|
221
250
|
*/
|
|
222
|
-
'createLocalPoolCanister' : ActorMethod<[],
|
|
251
|
+
'createLocalPoolCanister' : ActorMethod<[], Result_16>,
|
|
223
252
|
/**
|
|
224
253
|
* / F-2 … F-4, F-10: the caller's own driver canister (localTest: from the core's cycles).
|
|
225
254
|
*/
|
|
226
|
-
'createMyDriverCanister' : ActorMethod<[],
|
|
255
|
+
'createMyDriverCanister' : ActorMethod<[], Result_16>,
|
|
227
256
|
/**
|
|
228
257
|
* / Admins: the simulator, created once (F-18).
|
|
229
258
|
*/
|
|
230
|
-
'ensureSimulator' : ActorMethod<[],
|
|
259
|
+
'ensureSimulator' : ActorMethod<[], Result_21>,
|
|
231
260
|
/**
|
|
232
261
|
* / F-8: 15 min more for the holder of a demo canister.
|
|
233
262
|
*/
|
|
234
|
-
'extendDemoLease' : ActorMethod<[],
|
|
235
|
-
'getAdmins' : ActorMethod<[],
|
|
263
|
+
'extendDemoLease' : ActorMethod<[], Result_16>,
|
|
264
|
+
'getAdmins' : ActorMethod<[], Result_20>,
|
|
265
|
+
/**
|
|
266
|
+
* / For the fronts (through the package): where the chat of this environment is. Null =
|
|
267
|
+
* / no chat here yet. The room of a driver is `ChatRoomFunctions.driverRoomId`.
|
|
268
|
+
*/
|
|
269
|
+
'getChatConfig' : ActorMethod<[], [] | [ChatConfig]>,
|
|
270
|
+
/**
|
|
271
|
+
* / Admins: how far the driver rooms are (C-15).
|
|
272
|
+
*/
|
|
273
|
+
'getChatRoomsStatus' : ActorMethod<[], Result_19>,
|
|
236
274
|
/**
|
|
237
275
|
* / WO-1, WO-2: what the core knows of a canister — for the workers and anybody.
|
|
238
276
|
*/
|
|
239
277
|
'getDriverCanisterStatus' : ActorMethod<[CanisterArgs], DriverCanisterStatus>,
|
|
240
|
-
'getDriverRollout' : ActorMethod<[],
|
|
241
|
-
'getFactoryStatus' : ActorMethod<[],
|
|
278
|
+
'getDriverRollout' : ActorMethod<[], Result_18>,
|
|
279
|
+
'getFactoryStatus' : ActorMethod<[], Result_17>,
|
|
242
280
|
'getLogs' : ActorMethod<[], string>,
|
|
243
281
|
/**
|
|
244
282
|
* / The caller's own canister, or the demo canister the caller holds now.
|
|
245
283
|
*/
|
|
246
|
-
'getMyDriverCanister' : ActorMethod<[],
|
|
284
|
+
'getMyDriverCanister' : ActorMethod<[], Result_16>,
|
|
247
285
|
'getMyProfile' : ActorMethod<[], Result_4>,
|
|
286
|
+
/**
|
|
287
|
+
* / C-16, PF-4: the caller's own rating as a rider (sum and count of stars; null = no
|
|
288
|
+
* / rating yet). Ratings reach the core in the workers' batches, up to a minute late.
|
|
289
|
+
*/
|
|
290
|
+
'getMyRating' : ActorMethod<[], Result_15>,
|
|
248
291
|
/**
|
|
249
292
|
* / C-8: the caller's rides, newest first.
|
|
250
293
|
*/
|
|
251
|
-
'getMyRides' : ActorMethod<[RidesPageArgs],
|
|
294
|
+
'getMyRides' : ActorMethod<[RidesPageArgs], Result_14>,
|
|
252
295
|
/**
|
|
253
296
|
* / C-3: the names of up to MAX_PROFILES_PER_CALL principals; unknown ones are left out.
|
|
254
297
|
*/
|
|
255
|
-
'getProfiles' : ActorMethod<[ProfilesArgs],
|
|
298
|
+
'getProfiles' : ActorMethod<[ProfilesArgs], Result_13>,
|
|
256
299
|
/**
|
|
257
300
|
* / F-11: the driver wasms released so far, oldest first.
|
|
258
301
|
*/
|
|
@@ -264,11 +307,11 @@ export interface TigiCore {
|
|
|
264
307
|
/**
|
|
265
308
|
* / Admins: the coordinator, the workers confirmed so far, the mode.
|
|
266
309
|
*/
|
|
267
|
-
'getWiring' : ActorMethod<[],
|
|
310
|
+
'getWiring' : ActorMethod<[], Result_12>,
|
|
268
311
|
/**
|
|
269
312
|
* / Admins: how far the outbox to the workers is (C-6, C-7).
|
|
270
313
|
*/
|
|
271
|
-
'getWorkerOutbox' : ActorMethod<[],
|
|
314
|
+
'getWorkerOutbox' : ActorMethod<[], Result_11>,
|
|
272
315
|
/**
|
|
273
316
|
* / Workers of the group: the core asks the coordinator once and remembers the worker,
|
|
274
317
|
* / which then gets the network state through the outbox. A worker calls it once after
|
|
@@ -280,15 +323,31 @@ export interface TigiCore {
|
|
|
280
323
|
* / Idempotent: a known requestId and a counted rating count once. Invalid entries are
|
|
281
324
|
* / rejected and logged; the worker drops the whole batch after an ok.
|
|
282
325
|
*/
|
|
283
|
-
'ingestRideBatch' : ActorMethod<[RideBatch],
|
|
326
|
+
'ingestRideBatch' : ActorMethod<[RideBatch], Result_10>,
|
|
327
|
+
/**
|
|
328
|
+
* / C-14: the accounts gate of the chat (U-43). The chat core asks this group's
|
|
329
|
+
* / coordinator WHERE (`accountsCanisterFor` → this core) and asks here: true = an
|
|
330
|
+
* / account with a name exists for the principal and the rider is not blocked.
|
|
331
|
+
*/
|
|
332
|
+
'isUser' : ActorMethod<[Principal], boolean>,
|
|
284
333
|
/**
|
|
285
334
|
* / F-5 … F-7: a demo canister for 15 min (outside prod).
|
|
286
335
|
*/
|
|
287
|
-
'leaseDemoDriverCanister' : ActorMethod<[],
|
|
288
|
-
'listBlocks' : ActorMethod<[PageArgs],
|
|
289
|
-
'listDriverCanisters' : ActorMethod<[PageArgs],
|
|
336
|
+
'leaseDemoDriverCanister' : ActorMethod<[], Result_9>,
|
|
337
|
+
'listBlocks' : ActorMethod<[PageArgs], Result_8>,
|
|
338
|
+
'listDriverCanisters' : ActorMethod<[PageArgs], Result_7>,
|
|
339
|
+
/**
|
|
340
|
+
* / Admins: the driver rooms as the core wants them, 100 a page at most.
|
|
341
|
+
*/
|
|
342
|
+
'listDriverRooms' : ActorMethod<[PageArgs], Result_6>,
|
|
290
343
|
'removeAdmin' : ActorMethod<[PrincipalArgs], Result_2>,
|
|
291
344
|
'resumeDriverRollout' : ActorMethod<[], Result_3>,
|
|
345
|
+
/**
|
|
346
|
+
* / Admins: the chat of this environment — the chat group's coordinator and the project
|
|
347
|
+
* / (whose admin and accounts field are this group's coordinator). Every call sends every
|
|
348
|
+
* / driver room again (a new project, a chat group set up again).
|
|
349
|
+
*/
|
|
350
|
+
'setChatConfig' : ActorMethod<[ChatConfig], Result_5>,
|
|
292
351
|
'setLoggingEnabled' : ActorMethod<[boolean], Result_2>,
|
|
293
352
|
/**
|
|
294
353
|
* / The coordinator only: the balance below which the core asks for cycles.
|
|
@@ -61,7 +61,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
61
61
|
'installedAtNs' : IDL.Opt(IDL.Int),
|
|
62
62
|
'leaseUntilNs' : IDL.Opt(IDL.Int),
|
|
63
63
|
});
|
|
64
|
-
const
|
|
64
|
+
const Result_16 = IDL.Variant({ 'ok' : DriverCanister, 'err' : Error });
|
|
65
65
|
const BlockDriverArgs = IDL.Record({
|
|
66
66
|
'driverKey' : IDL.Opt(IDL.Text),
|
|
67
67
|
'canister' : IDL.Principal,
|
|
@@ -83,18 +83,31 @@ export const idlFactory = ({ IDL }) => {
|
|
|
83
83
|
'size' : IDL.Nat,
|
|
84
84
|
'committedAtNs' : IDL.Int,
|
|
85
85
|
});
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
86
|
+
const Result_22 = IDL.Variant({ 'ok' : WasmInfo, 'err' : Error });
|
|
87
|
+
const Result_21 = IDL.Variant({ 'ok' : IDL.Principal, 'err' : Error });
|
|
88
|
+
const Result_20 = IDL.Variant({
|
|
89
89
|
'ok' : IDL.Vec(IDL.Principal),
|
|
90
90
|
'err' : Error,
|
|
91
91
|
});
|
|
92
|
+
const ChatConfig = IDL.Record({
|
|
93
|
+
'chatCoordinatorId' : IDL.Principal,
|
|
94
|
+
'projectId' : IDL.Text,
|
|
95
|
+
});
|
|
96
|
+
const ChatRoomsStatus = IDL.Record({
|
|
97
|
+
'failures' : IDL.Nat,
|
|
98
|
+
'pending' : IDL.Nat,
|
|
99
|
+
'lastError' : IDL.Opt(IDL.Text),
|
|
100
|
+
'config' : IDL.Opt(ChatConfig),
|
|
101
|
+
'pendingSinceNs' : IDL.Opt(IDL.Int),
|
|
102
|
+
'rooms' : IDL.Nat,
|
|
103
|
+
});
|
|
104
|
+
const Result_19 = IDL.Variant({ 'ok' : ChatRoomsStatus, 'err' : Error });
|
|
92
105
|
const DriverCanisterStatus = IDL.Record({
|
|
93
106
|
'moduleHash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
94
107
|
'blocked' : IDL.Bool,
|
|
95
108
|
'registered' : IDL.Bool,
|
|
96
109
|
});
|
|
97
|
-
const
|
|
110
|
+
const Result_18 = IDL.Variant({ 'ok' : IDL.Opt(RolloutView), 'err' : Error });
|
|
98
111
|
const FactoryStatus = IDL.Record({
|
|
99
112
|
'simulator' : IDL.Opt(IDL.Principal),
|
|
100
113
|
'mode' : Mode,
|
|
@@ -106,13 +119,15 @@ export const idlFactory = ({ IDL }) => {
|
|
|
106
119
|
'driverWasm' : IDL.Opt(WasmInfo),
|
|
107
120
|
'registered' : IDL.Nat,
|
|
108
121
|
});
|
|
109
|
-
const
|
|
122
|
+
const Result_17 = IDL.Variant({ 'ok' : FactoryStatus, 'err' : Error });
|
|
110
123
|
const Profile = IDL.Record({
|
|
111
124
|
'updatedAtNs' : IDL.Int,
|
|
112
125
|
'name' : IDL.Text,
|
|
113
126
|
'createdAtNs' : IDL.Int,
|
|
114
127
|
});
|
|
115
128
|
const Result_4 = IDL.Variant({ 'ok' : Profile, 'err' : Error });
|
|
129
|
+
const Rating = IDL.Record({ 'sum' : IDL.Nat, 'count' : IDL.Nat });
|
|
130
|
+
const Result_15 = IDL.Variant({ 'ok' : IDL.Opt(Rating), 'err' : Error });
|
|
116
131
|
const RidesPageArgs = IDL.Record({
|
|
117
132
|
'beforeIndex' : IDL.Opt(IDL.Nat),
|
|
118
133
|
'limit' : IDL.Nat,
|
|
@@ -136,13 +151,13 @@ export const idlFactory = ({ IDL }) => {
|
|
|
136
151
|
'nextBeforeIndex' : IDL.Opt(IDL.Nat),
|
|
137
152
|
'rides' : IDL.Vec(RideEntry),
|
|
138
153
|
});
|
|
139
|
-
const
|
|
154
|
+
const Result_14 = IDL.Variant({ 'ok' : RidesPage, 'err' : Error });
|
|
140
155
|
const ProfilesArgs = IDL.Record({ 'principals' : IDL.Vec(IDL.Principal) });
|
|
141
156
|
const ProfileEntry = IDL.Record({
|
|
142
157
|
'principal' : IDL.Principal,
|
|
143
158
|
'name' : IDL.Text,
|
|
144
159
|
});
|
|
145
|
-
const
|
|
160
|
+
const Result_13 = IDL.Variant({
|
|
146
161
|
'ok' : IDL.Vec(ProfileEntry),
|
|
147
162
|
'err' : Error,
|
|
148
163
|
});
|
|
@@ -156,8 +171,8 @@ export const idlFactory = ({ IDL }) => {
|
|
|
156
171
|
'knownWorkers' : IDL.Vec(IDL.Principal),
|
|
157
172
|
'coordinator' : IDL.Opt(IDL.Principal),
|
|
158
173
|
});
|
|
159
|
-
const
|
|
160
|
-
const
|
|
174
|
+
const Result_12 = IDL.Variant({ 'ok' : Wiring, 'err' : Error });
|
|
175
|
+
const Result_11 = IDL.Variant({
|
|
161
176
|
'ok' : IDL.Record({
|
|
162
177
|
'subjects' : IDL.Nat,
|
|
163
178
|
'headSeq' : IDL.Nat64,
|
|
@@ -188,12 +203,12 @@ export const idlFactory = ({ IDL }) => {
|
|
|
188
203
|
'rejected' : IDL.Nat,
|
|
189
204
|
'ratingsCounted' : IDL.Nat,
|
|
190
205
|
});
|
|
191
|
-
const
|
|
206
|
+
const Result_10 = IDL.Variant({ 'ok' : RideBatchResult, 'err' : Error });
|
|
192
207
|
const LeaseAnswer = IDL.Variant({
|
|
193
208
|
'busy' : IDL.Record({ 'untilNs' : IDL.Int }),
|
|
194
209
|
'leased' : DriverCanister,
|
|
195
210
|
});
|
|
196
|
-
const
|
|
211
|
+
const Result_9 = IDL.Variant({ 'ok' : LeaseAnswer, 'err' : Error });
|
|
197
212
|
const PageArgs = IDL.Record({ 'offset' : IDL.Nat, 'limit' : IDL.Nat });
|
|
198
213
|
const BlockTarget = IDL.Variant({
|
|
199
214
|
'driverCanister' : IDL.Principal,
|
|
@@ -209,12 +224,25 @@ export const idlFactory = ({ IDL }) => {
|
|
|
209
224
|
'target' : BlockTarget,
|
|
210
225
|
'reason' : IDL.Text,
|
|
211
226
|
});
|
|
212
|
-
const
|
|
227
|
+
const Result_8 = IDL.Variant({ 'ok' : IDL.Vec(Block), 'err' : Error });
|
|
213
228
|
const DriverCanistersPage = IDL.Record({
|
|
214
229
|
'total' : IDL.Nat,
|
|
215
230
|
'canisters' : IDL.Vec(DriverCanister),
|
|
216
231
|
});
|
|
217
|
-
const
|
|
232
|
+
const Result_7 = IDL.Variant({ 'ok' : DriverCanistersPage, 'err' : Error });
|
|
233
|
+
const DriverRoomView = IDL.Record({
|
|
234
|
+
'recipient' : IDL.Principal,
|
|
235
|
+
'driverKey' : IDL.Text,
|
|
236
|
+
'canister' : IDL.Principal,
|
|
237
|
+
'lastError' : IDL.Opt(IDL.Text),
|
|
238
|
+
'roomId' : IDL.Text,
|
|
239
|
+
'synced' : IDL.Bool,
|
|
240
|
+
});
|
|
241
|
+
const Result_6 = IDL.Variant({
|
|
242
|
+
'ok' : IDL.Vec(DriverRoomView),
|
|
243
|
+
'err' : Error,
|
|
244
|
+
});
|
|
245
|
+
const Result_5 = IDL.Variant({ 'ok' : ChatConfig, 'err' : Error });
|
|
218
246
|
const SetProfileArgs = IDL.Record({ 'name' : IDL.Text });
|
|
219
247
|
const UnblockDriverArgs = IDL.Record({
|
|
220
248
|
'driverKey' : IDL.Opt(IDL.Text),
|
|
@@ -231,39 +259,45 @@ export const idlFactory = ({ IDL }) => {
|
|
|
231
259
|
const TigiCore = IDL.Service({
|
|
232
260
|
'abortDriverRollout' : IDL.Func([], [Result_3], []),
|
|
233
261
|
'addAdmin' : IDL.Func([PrincipalArgs], [Result_2], []),
|
|
234
|
-
'addPoolCanister' : IDL.Func([CanisterArgs], [
|
|
262
|
+
'addPoolCanister' : IDL.Func([CanisterArgs], [Result_16], []),
|
|
235
263
|
'blockDriver' : IDL.Func([BlockDriverArgs], [Result_2], []),
|
|
236
264
|
'blockRider' : IDL.Func([BlockRiderArgs], [Result_2], []),
|
|
237
265
|
'clearLogs' : IDL.Func([], [], []),
|
|
238
|
-
'commitDriverWasm' : IDL.Func([WasmCommitArgs], [
|
|
239
|
-
'createLocalPoolCanister' : IDL.Func([], [
|
|
240
|
-
'createMyDriverCanister' : IDL.Func([], [
|
|
241
|
-
'ensureSimulator' : IDL.Func([], [
|
|
242
|
-
'extendDemoLease' : IDL.Func([], [
|
|
243
|
-
'getAdmins' : IDL.Func([], [
|
|
266
|
+
'commitDriverWasm' : IDL.Func([WasmCommitArgs], [Result_22], []),
|
|
267
|
+
'createLocalPoolCanister' : IDL.Func([], [Result_16], []),
|
|
268
|
+
'createMyDriverCanister' : IDL.Func([], [Result_16], []),
|
|
269
|
+
'ensureSimulator' : IDL.Func([], [Result_21], []),
|
|
270
|
+
'extendDemoLease' : IDL.Func([], [Result_16], []),
|
|
271
|
+
'getAdmins' : IDL.Func([], [Result_20], ['query']),
|
|
272
|
+
'getChatConfig' : IDL.Func([], [IDL.Opt(ChatConfig)], ['query']),
|
|
273
|
+
'getChatRoomsStatus' : IDL.Func([], [Result_19], ['query']),
|
|
244
274
|
'getDriverCanisterStatus' : IDL.Func(
|
|
245
275
|
[CanisterArgs],
|
|
246
276
|
[DriverCanisterStatus],
|
|
247
277
|
['query'],
|
|
248
278
|
),
|
|
249
|
-
'getDriverRollout' : IDL.Func([], [
|
|
250
|
-
'getFactoryStatus' : IDL.Func([], [
|
|
279
|
+
'getDriverRollout' : IDL.Func([], [Result_18], ['query']),
|
|
280
|
+
'getFactoryStatus' : IDL.Func([], [Result_17], ['query']),
|
|
251
281
|
'getLogs' : IDL.Func([], [IDL.Text], ['query']),
|
|
252
|
-
'getMyDriverCanister' : IDL.Func([], [
|
|
282
|
+
'getMyDriverCanister' : IDL.Func([], [Result_16], ['query']),
|
|
253
283
|
'getMyProfile' : IDL.Func([], [Result_4], ['query']),
|
|
254
|
-
'
|
|
255
|
-
'
|
|
284
|
+
'getMyRating' : IDL.Func([], [Result_15], ['query']),
|
|
285
|
+
'getMyRides' : IDL.Func([RidesPageArgs], [Result_14], ['query']),
|
|
286
|
+
'getProfiles' : IDL.Func([ProfilesArgs], [Result_13], ['query']),
|
|
256
287
|
'getReleasedDriverWasms' : IDL.Func([], [IDL.Vec(ReleasedWasm)], ['query']),
|
|
257
288
|
'getSimulator' : IDL.Func([], [IDL.Opt(IDL.Principal)], ['query']),
|
|
258
|
-
'getWiring' : IDL.Func([], [
|
|
259
|
-
'getWorkerOutbox' : IDL.Func([], [
|
|
289
|
+
'getWiring' : IDL.Func([], [Result_12], ['query']),
|
|
290
|
+
'getWorkerOutbox' : IDL.Func([], [Result_11], ['query']),
|
|
260
291
|
'helloFromWorker' : IDL.Func([], [Result_2], []),
|
|
261
|
-
'ingestRideBatch' : IDL.Func([RideBatch], [
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
'
|
|
292
|
+
'ingestRideBatch' : IDL.Func([RideBatch], [Result_10], []),
|
|
293
|
+
'isUser' : IDL.Func([IDL.Principal], [IDL.Bool], ['query']),
|
|
294
|
+
'leaseDemoDriverCanister' : IDL.Func([], [Result_9], []),
|
|
295
|
+
'listBlocks' : IDL.Func([PageArgs], [Result_8], ['query']),
|
|
296
|
+
'listDriverCanisters' : IDL.Func([PageArgs], [Result_7], ['query']),
|
|
297
|
+
'listDriverRooms' : IDL.Func([PageArgs], [Result_6], ['query']),
|
|
265
298
|
'removeAdmin' : IDL.Func([PrincipalArgs], [Result_2], []),
|
|
266
299
|
'resumeDriverRollout' : IDL.Func([], [Result_3], []),
|
|
300
|
+
'setChatConfig' : IDL.Func([ChatConfig], [Result_5], []),
|
|
267
301
|
'setLoggingEnabled' : IDL.Func([IDL.Bool], [Result_2], []),
|
|
268
302
|
'setLowCyclesBelow' : IDL.Func([IDL.Nat], [Result_2], []),
|
|
269
303
|
'setMyProfile' : IDL.Func([SetProfileArgs], [Result_4], []),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Identity } from "@icp-sdk/core/agent";
|
|
2
2
|
import { type GroupOptions } from "../group/canister-actor.js";
|
|
3
|
-
import type { Profile, RideHistoryPage } from "../interfaces.js";
|
|
3
|
+
import type { MyRatingView, Profile, RideHistoryPage } from "../interfaces.js";
|
|
4
4
|
/** KU-1: a page of the rider's history. */
|
|
5
5
|
export declare const RIDES_PAGE = 20;
|
|
6
6
|
export declare class ProfilesActor {
|
|
@@ -21,6 +21,14 @@ export declare class ProfilesActor {
|
|
|
21
21
|
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
22
22
|
*/
|
|
23
23
|
setMyProfileAsyncUnsafe(name: string): Promise<Profile>;
|
|
24
|
+
/**
|
|
25
|
+
* C-16, PF-4: the signed-in user's rating as a rider ("★ 4,87"). Ratings reach the core
|
|
26
|
+
* in the workers' batches, up to a minute after the driver rated (K-9).
|
|
27
|
+
* @returns undefined while nobody rated the user ("Brak ocen")
|
|
28
|
+
* @throws Error with message `CanisterError` — `NotAuthorized` (anonymous)
|
|
29
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
30
|
+
*/
|
|
31
|
+
getMyRatingAsyncUnsafe(): Promise<MyRatingView | undefined>;
|
|
24
32
|
/**
|
|
25
33
|
* C-8, KU-1: the rider's rides, newest first, `RIDES_PAGE` a page. A ride reaches the core
|
|
26
34
|
* up to a minute after its end (K-9, KU-2).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles-actor.d.ts","sourceRoot":"","sources":["../../src/actors/profiles-actor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,KAAK,EAAE,OAAO,EAA6B,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles-actor.d.ts","sourceRoot":"","sources":["../../src/actors/profiles-actor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAA6B,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG1G,2CAA2C;AAC3C,eAAO,MAAM,UAAU,KAAK,CAAC;AAkB7B,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;gBAEtB,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,YAAiB;IAIjF;;;;;;OAMG;IACU,uBAAuB,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IASpE;;;;;OAKG;IACU,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpE;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAUxE;;;;;;OAMG;IACU,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;CAS5G"}
|
|
@@ -49,6 +49,22 @@ export class ProfilesActor {
|
|
|
49
49
|
async setMyProfileAsyncUnsafe(name) {
|
|
50
50
|
return profileOf(await executeAsyncUnsafe(async () => (await this.group.coreAsync()).setMyProfile({ name })));
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* C-16, PF-4: the signed-in user's rating as a rider ("★ 4,87"). Ratings reach the core
|
|
54
|
+
* in the workers' batches, up to a minute after the driver rated (K-9).
|
|
55
|
+
* @returns undefined while nobody rated the user ("Brak ocen")
|
|
56
|
+
* @throws Error with message `CanisterError` — `NotAuthorized` (anonymous)
|
|
57
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
58
|
+
*/
|
|
59
|
+
async getMyRatingAsyncUnsafe() {
|
|
60
|
+
const answer = await executeAsyncUnsafe(async () => (await this.group.coreAsync()).getMyRating());
|
|
61
|
+
const rating = answer[0];
|
|
62
|
+
if (rating === undefined || rating.count === 0n)
|
|
63
|
+
return undefined;
|
|
64
|
+
const sum = Number(rating.sum);
|
|
65
|
+
const count = Number(rating.count);
|
|
66
|
+
return { average: Math.round((sum / count) * 100) / 100, count, sum };
|
|
67
|
+
}
|
|
52
68
|
/**
|
|
53
69
|
* C-8, KU-1: the rider's rides, newest first, `RIDES_PAGE` a page. A ride reaches the core
|
|
54
70
|
* up to a minute after its end (K-9, KU-2).
|
|
@@ -2,7 +2,7 @@ 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 { ChooseOutcome, LicenceView, RequestSnapshot, RideView } from "../interfaces.js";
|
|
5
|
+
import type { ChatPlace, ChooseOutcome, LicenceView, RequestSnapshot, RideView } from "../interfaces.js";
|
|
6
6
|
/** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
|
|
7
7
|
export declare const SEARCH_RADIUS_METERS = 3000;
|
|
8
8
|
export declare const WIDE_RADIUS_METERS = 6000;
|
|
@@ -192,6 +192,17 @@ export declare class RideRequest {
|
|
|
192
192
|
* @throws Error with message `CriticalCanisterError` — the driver canister does not answer
|
|
193
193
|
*/
|
|
194
194
|
getLicenceAsyncUnsafe(): Promise<LicenceView>;
|
|
195
|
+
/**
|
|
196
|
+
* U-43, K-12, PR-25: where the chat with the driver of the accepted ride is — give it to
|
|
197
|
+
* `@jsm-mit/chat-sharded-package` (`ChatsActor.openChatAsyncUnsafe({ projectId, roomId })`
|
|
198
|
+
* on `chatCoordinatorId`). The room is the driver's (one per driver, not per ride): the
|
|
199
|
+
* rider has one chat with that driver over all their rides. Show "Napisz do kierowcy"
|
|
200
|
+
* from `accepted` to the end of the ride only.
|
|
201
|
+
* @returns undefined when the environment has no chat, or the driver is simulated (no chat in MVP)
|
|
202
|
+
* @throws Error with message `CanisterError` — `NOT_ACCEPTED` (no driver accepted yet)
|
|
203
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
204
|
+
*/
|
|
205
|
+
getChatPlaceAsyncUnsafe(): Promise<ChatPlace | undefined>;
|
|
195
206
|
/**
|
|
196
207
|
* K-8: the rider rates the driver 1–5 after `completed`, once, within 24 h.
|
|
197
208
|
* @returns false when the rider rated this ride already
|
|
@@ -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,EAA0H,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACvL,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAa,eAAe,EAAE,QAAQ,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,EAA0H,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACvL,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,MAAM,kBAAkB,CAAC;AAIpH,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;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AgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDlE;;;;;;;;;OASG;IACU,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAgBvD;;;;;;OAMG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAStE;;;;;;OAMG;IACU,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvE;;;;;;;;;;;OAWG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiC5E;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,WAAW,CAAC;IAmB3D;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/C;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAKpD;;;;;OAKG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnD;;;;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;IAOnE,4IAA4I;IAC5I,OAAO,CAAC,WAAW;YAML,kBAAkB;YAkBlB,UAAU;IA8DxB,iHAAiH;YACnG,gBAAgB;IAS9B,6FAA6F;YAC/E,UAAU;YASV,kBAAkB;YAalB,mBAAmB;YAOnB,WAAW;CAG5B"}
|
|
@@ -10,6 +10,7 @@ import { canisterError, errorKeyOf, executeAsyncUnsafe, executeProtocolAsyncUnsa
|
|
|
10
10
|
import { TigiGroup } from "../group/group.js";
|
|
11
11
|
import { geohashesByWorker } from "../group/prefixes.js";
|
|
12
12
|
import { cellsWithin, isValidGeo } from "../geo.js";
|
|
13
|
+
import { driverChatPlaceAsyncUnsafe } from "../chat.js";
|
|
13
14
|
import { cardOf, closeReasonOf, decodeToken, driverOfOfferId, encodeToken, mergedPhase, mergeOffers, moneyOf, msOf, offerIdOf, offerOf, phaseOf, placeOffers, rideStatusOf } from "../mappers.js";
|
|
14
15
|
/** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
|
|
15
16
|
export const SEARCH_RADIUS_METERS = 3_000;
|
|
@@ -391,6 +392,22 @@ export class RideRequest {
|
|
|
391
392
|
const licence = await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).getLicence({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
|
|
392
393
|
return { image: Uint8Array.from(licence.image), mimeType: licence.mimeType, documentNumber: licence.documentNumber };
|
|
393
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* U-43, K-12, PR-25: where the chat with the driver of the accepted ride is — give it to
|
|
397
|
+
* `@jsm-mit/chat-sharded-package` (`ChatsActor.openChatAsyncUnsafe({ projectId, roomId })`
|
|
398
|
+
* on `chatCoordinatorId`). The room is the driver's (one per driver, not per ride): the
|
|
399
|
+
* rider has one chat with that driver over all their rides. Show "Napisz do kierowcy"
|
|
400
|
+
* from `accepted` to the end of the ride only.
|
|
401
|
+
* @returns undefined when the environment has no chat, or the driver is simulated (no chat in MVP)
|
|
402
|
+
* @throws Error with message `CanisterError` — `NOT_ACCEPTED` (no driver accepted yet)
|
|
403
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
404
|
+
*/
|
|
405
|
+
async getChatPlaceAsyncUnsafe() {
|
|
406
|
+
const accepted = await this.acceptedAsyncUnsafe();
|
|
407
|
+
if (accepted.canister === (await this.simulatorIdAsync()))
|
|
408
|
+
return undefined;
|
|
409
|
+
return driverChatPlaceAsyncUnsafe(this.group, accepted.canister, accepted.driverKey);
|
|
410
|
+
}
|
|
394
411
|
/**
|
|
395
412
|
* K-8: the rider rates the driver 1–5 after `completed`, once, within 24 h.
|
|
396
413
|
* @returns false when the rider rated this ride already
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Identity } from "@icp-sdk/core/agent";
|
|
2
|
+
import { type GroupOptions } from "./group/canister-actor.js";
|
|
3
|
+
import { TigiGroup } from "./group/group.js";
|
|
4
|
+
import type { ChatPlace } from "./interfaces.js";
|
|
5
|
+
/** A room id of chat-sharded: at most 50 characters, never '/' or '|'. */
|
|
6
|
+
export declare const MAX_ROOM_ID_CHARS = 50;
|
|
7
|
+
export declare const DRIVER_ROOM_PREFIX = "drv-";
|
|
8
|
+
/** The chat config of the core is asked again after this long. */
|
|
9
|
+
export declare const CHAT_CONFIG_TTL_MS = 60000;
|
|
10
|
+
/**
|
|
11
|
+
* C-15: the room of a driver — the core's `ChatRoomFunctions.driverRoomId`, the same rule:
|
|
12
|
+
* "drv-<canister>" for a canister with one driver (`driverKey` = ""),
|
|
13
|
+
* "drv-<canister>-<driverKey>" otherwise; undefined when longer than 50 characters or
|
|
14
|
+
* holding '/' or '|'. The core makes rooms for the canisters of its registry only (one
|
|
15
|
+
* driver each), so a simulated driver has no room (MVP).
|
|
16
|
+
*/
|
|
17
|
+
export declare function driverRoomId(driverCanisterId: string, driverKey?: string): string | undefined;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare function chatConfigOfAsyncUnsafe(group: TigiGroup): Promise<{
|
|
20
|
+
chatCoordinatorId: string;
|
|
21
|
+
projectId: string;
|
|
22
|
+
} | undefined>;
|
|
23
|
+
/** @internal — the place of a driver's room, or undefined (no chat here, no room for this driver). */
|
|
24
|
+
export declare function driverChatPlaceAsyncUnsafe(group: TigiGroup, driverCanisterId: string, driverKey: string): Promise<ChatPlace | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* The chat places of the group, for the fronts — the driver's front (its own room: the
|
|
27
|
+
* chats of its riders) and anybody that knows a driver canister. The rider's front takes
|
|
28
|
+
* the place of its ride from `RideRequest.getChatPlaceAsyncUnsafe` instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ChatPlacesActor {
|
|
31
|
+
private readonly group;
|
|
32
|
+
constructor(coordinatorId: string, identity?: Identity, options?: GroupOptions);
|
|
33
|
+
/**
|
|
34
|
+
* The chat of this environment: the chat group's coordinator and the project.
|
|
35
|
+
* @returns undefined when the environment has no chat yet
|
|
36
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
37
|
+
*/
|
|
38
|
+
getChatConfigAsyncUnsafe(): Promise<{
|
|
39
|
+
chatCoordinatorId: string;
|
|
40
|
+
projectId: string;
|
|
41
|
+
} | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* FK-20: the room of a driver canister (one driver, `driverKey` = ""). The driver's front
|
|
44
|
+
* lists the chats of this room as their recipient and shows only the current rider's.
|
|
45
|
+
* @returns undefined when the environment has no chat yet or the driver has no room
|
|
46
|
+
* @throws Error with message `CanisterError` (errorKey `InvalidData`) — not a principal
|
|
47
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
48
|
+
*/
|
|
49
|
+
getDriverChatPlaceAsyncUnsafe(driverCanisterId: string, driverKey?: string): Promise<ChatPlace | undefined>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,kBAAkB,SAAS,CAAC;AACzC,kEAAkE;AAClE,eA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