@awiki/dsh-plugin 0.2.5 → 0.3.0-rc.2
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 +69 -28
- package/README.zh.md +60 -21
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/cordis.patch.yml +0 -8
- package/lib/client.js +6755 -2022
- package/lib/client.js.map +1 -1
- package/lib/index.js +1321 -72
- package/lib/model-proxy-contract.js +8 -1
- package/lib/provider.js +3 -1
- package/lib/{sdk-adapter-DKgkyApB.mjs → sdk-adapter-BIbsJmRj.mjs} +245 -4
- package/lib/typert.host.js +944 -57
- package/lib/typert.remote-client.d.ts +37 -1
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +944 -57
- package/lib/types/client/AwikiGroupAccessNotice.d.ts +12 -0
- package/lib/types/client/AwikiGroupAccessNotice.d.ts.map +1 -0
- package/lib/types/client/AwikiGroupAccessNotice.js +31 -0
- package/lib/types/client/AwikiGroupAccessNotice.js.map +1 -0
- package/lib/types/client/AwikiGroupDetails.d.ts +23 -0
- package/lib/types/client/AwikiGroupDetails.d.ts.map +1 -0
- package/lib/types/client/AwikiGroupDetails.js +144 -0
- package/lib/types/client/AwikiGroupDetails.js.map +1 -0
- package/lib/types/client/AwikiIdentityAccess.d.ts +22 -0
- package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -0
- package/lib/types/client/AwikiIdentityAccess.js +156 -0
- package/lib/types/client/AwikiIdentityAccess.js.map +1 -0
- package/lib/types/client/AwikiIdentityPage.d.ts +11 -0
- package/lib/types/client/AwikiIdentityPage.d.ts.map +1 -0
- package/lib/types/client/AwikiIdentityPage.js +8 -0
- package/lib/types/client/AwikiIdentityPage.js.map +1 -0
- package/lib/types/client/AwikiMail.d.ts +2 -1
- package/lib/types/client/AwikiMail.d.ts.map +1 -1
- package/lib/types/client/AwikiMail.js +157 -33
- package/lib/types/client/AwikiMail.js.map +1 -1
- package/lib/types/client/AwikiOnboarding.d.ts.map +1 -1
- package/lib/types/client/AwikiOnboarding.js +29 -9
- package/lib/types/client/AwikiOnboarding.js.map +1 -1
- package/lib/types/client/AwikiOverlay.d.ts +0 -5
- package/lib/types/client/AwikiOverlay.d.ts.map +1 -1
- package/lib/types/client/AwikiOverlay.js +202 -129
- package/lib/types/client/AwikiOverlay.js.map +1 -1
- package/lib/types/client/AwikiProfileCard.d.ts +9 -0
- package/lib/types/client/AwikiProfileCard.d.ts.map +1 -0
- package/lib/types/client/AwikiProfileCard.js +90 -0
- package/lib/types/client/AwikiProfileCard.js.map +1 -0
- package/lib/types/client/AwikiRecoveryForm.d.ts +27 -0
- package/lib/types/client/AwikiRecoveryForm.d.ts.map +1 -0
- package/lib/types/client/AwikiRecoveryForm.js +152 -0
- package/lib/types/client/AwikiRecoveryForm.js.map +1 -0
- package/lib/types/client/AwikiSettingsSection.d.ts +0 -2
- package/lib/types/client/AwikiSettingsSection.d.ts.map +1 -1
- package/lib/types/client/AwikiSettingsSection.js +18 -16
- package/lib/types/client/AwikiSettingsSection.js.map +1 -1
- package/lib/types/client/MentionText.d.ts +7 -0
- package/lib/types/client/MentionText.d.ts.map +1 -0
- package/lib/types/client/MentionText.js +10 -0
- package/lib/types/client/MentionText.js.map +1 -0
- package/lib/types/client/controller.d.ts +131 -3
- package/lib/types/client/controller.d.ts.map +1 -1
- package/lib/types/client/controller.js +908 -29
- package/lib/types/client/controller.js.map +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +24 -4
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/mail-list-cache.d.ts +15 -0
- package/lib/types/client/mail-list-cache.d.ts.map +1 -0
- package/lib/types/client/mail-list-cache.js +212 -0
- package/lib/types/client/mail-list-cache.js.map +1 -0
- package/lib/types/client/mentions.d.ts +51 -0
- package/lib/types/client/mentions.d.ts.map +1 -0
- package/lib/types/client/mentions.js +165 -0
- package/lib/types/client/mentions.js.map +1 -0
- package/lib/types/client/model-proxy-controller.d.ts +4 -0
- package/lib/types/client/model-proxy-controller.d.ts.map +1 -1
- package/lib/types/client/model-proxy-controller.js +68 -3
- package/lib/types/client/model-proxy-controller.js.map +1 -1
- package/lib/types/client/recharge-availability.d.ts +1 -1
- package/lib/types/client/recharge-availability.d.ts.map +1 -1
- package/lib/types/client/recharge-availability.js +1 -1
- package/lib/types/client/recharge-availability.js.map +1 -1
- package/lib/types/client/settings-locales.d.ts +1 -1
- package/lib/types/client/settings-locales.d.ts.map +1 -1
- package/lib/types/client/settings-locales.js +14 -8
- package/lib/types/client/settings-locales.js.map +1 -1
- package/lib/types/client/slots.d.ts +27 -2
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/conversation-preferences.d.ts +20 -0
- package/lib/types/conversation-preferences.d.ts.map +1 -0
- package/lib/types/conversation-preferences.js +294 -0
- package/lib/types/conversation-preferences.js.map +1 -0
- package/lib/types/index.d.ts +45 -6
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +562 -23
- package/lib/types/index.js.map +1 -1
- package/lib/types/model-proxy-contract.d.ts +6 -0
- package/lib/types/model-proxy-contract.d.ts.map +1 -1
- package/lib/types/model-proxy-contract.js +6 -0
- package/lib/types/model-proxy-contract.js.map +1 -1
- package/lib/types/provider-api.d.ts +29 -1
- package/lib/types/provider-api.d.ts.map +1 -1
- package/lib/types/provider.d.ts.map +1 -1
- package/lib/types/provider.js +2 -0
- package/lib/types/provider.js.map +1 -1
- package/lib/types/sdk-adapter.d.ts +18 -1
- package/lib/types/sdk-adapter.d.ts.map +1 -1
- package/lib/types/sdk-adapter.js +277 -4
- package/lib/types/sdk-adapter.js.map +1 -1
- package/lib/types/sent-mail-store.d.ts +22 -0
- package/lib/types/sent-mail-store.d.ts.map +1 -0
- package/lib/types/sent-mail-store.js +246 -0
- package/lib/types/sent-mail-store.js.map +1 -0
- package/lib/types/types.d.ts +183 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +15 -26
- package/lib/model-proxy.js +0 -383
- package/lib/types/client/model-account-settings-availability.d.ts +0 -4
- package/lib/types/client/model-account-settings-availability.d.ts.map +0 -1
- package/lib/types/client/model-account-settings-availability.js +0 -4
- package/lib/types/client/model-account-settings-availability.js.map +0 -1
- package/lib/types/model-proxy.d.ts +0 -14
- package/lib/types/model-proxy.d.ts.map +0 -1
- package/lib/types/model-proxy.js +0 -371
- package/lib/types/model-proxy.js.map +0 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** Browser-safe contracts for the loopback AWiki-hosted DeepSeek proxy channel. */
|
|
3
3
|
const AWIKI_MODEL_PROXY_RPC_CHANNEL = "/awiki-model-proxy";
|
|
4
4
|
const AWIKI_MODEL_PROXY_RPC_ENDPOINTS = {
|
|
5
|
+
capability: "capability",
|
|
5
6
|
status: "status",
|
|
6
7
|
usage: "usage",
|
|
7
8
|
setEnabled: "set-enabled",
|
|
@@ -9,6 +10,12 @@ const AWIKI_MODEL_PROXY_RPC_ENDPOINTS = {
|
|
|
9
10
|
rechargeStatus: "recharge-status",
|
|
10
11
|
closeRecharge: "close-recharge"
|
|
11
12
|
};
|
|
13
|
+
function decodeModelProxyCapability(value) {
|
|
14
|
+
return isRecord(value) && value.available === true && value.protocol === 1 ? {
|
|
15
|
+
available: true,
|
|
16
|
+
protocol: 1
|
|
17
|
+
} : void 0;
|
|
18
|
+
}
|
|
12
19
|
function decodeModelProxyStatus(value) {
|
|
13
20
|
if (!isRecord(value) || typeof value.enabled !== "boolean") return void 0;
|
|
14
21
|
const account = decodeAccount(value.account);
|
|
@@ -86,4 +93,4 @@ function isRecord(value) {
|
|
|
86
93
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
87
94
|
}
|
|
88
95
|
//#endregion
|
|
89
|
-
export { AWIKI_MODEL_PROXY_RPC_CHANNEL, AWIKI_MODEL_PROXY_RPC_ENDPOINTS, decodeCloseRechargeResult, decodeModelProxyStatus, decodeModelProxyUsage, decodeRechargeOrder };
|
|
96
|
+
export { AWIKI_MODEL_PROXY_RPC_CHANNEL, AWIKI_MODEL_PROXY_RPC_ENDPOINTS, decodeCloseRechargeResult, decodeModelProxyCapability, decodeModelProxyStatus, decodeModelProxyUsage, decodeRechargeOrder };
|
package/lib/provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as RustSdkAdapter } from "./sdk-adapter-
|
|
1
|
+
import { t as RustSdkAdapter } from "./sdk-adapter-BIbsJmRj.mjs";
|
|
2
2
|
import { openImCoreNodeClient } from "@awiki/im-core-node";
|
|
3
3
|
//#region lib/types/provider.js
|
|
4
4
|
/** Production AWiki provider backed by the versioned Rust IM Core Node bridge. */
|
|
@@ -17,6 +17,8 @@ function apply(ctx) {
|
|
|
17
17
|
mailServiceEndpoint: options.mailServiceUrl,
|
|
18
18
|
anpServiceEndpoint: options.messageServiceUrl,
|
|
19
19
|
anpServiceDid: options.messageServiceDid,
|
|
20
|
+
multiDeviceHandleRecoveryEnabled: true,
|
|
21
|
+
multiDeviceAudience: "awiki-user-service",
|
|
20
22
|
externalHttpAllowInsecureLoopbackForTesting: options.allowInsecureLoopbackForTesting
|
|
21
23
|
}))), "awiki Rust SDK client");
|
|
22
24
|
}
|
|
@@ -15,7 +15,9 @@ const RUST_FAILURE_CODES = {
|
|
|
15
15
|
handle_unavailable: "handle-unavailable",
|
|
16
16
|
not_found: "not-found",
|
|
17
17
|
permission_denied: "forbidden",
|
|
18
|
-
|
|
18
|
+
group_not_member: "group-membership-required",
|
|
19
|
+
group_identity_stale: "group-identity-stale",
|
|
20
|
+
auth_revoked: "identity-recovery-required",
|
|
19
21
|
conflict: "conflict",
|
|
20
22
|
join_required: "handle-unavailable",
|
|
21
23
|
state_in_use: "conflict",
|
|
@@ -99,6 +101,11 @@ function uint32(value) {
|
|
|
99
101
|
if (!Number.isSafeInteger(value) || value < 0 || value > 4294967295) fail();
|
|
100
102
|
return value;
|
|
101
103
|
}
|
|
104
|
+
function recoveryE2eeGroupCount(impact) {
|
|
105
|
+
if (typeof impact !== "object" || impact === null) fail();
|
|
106
|
+
const value = impact;
|
|
107
|
+
return uint32(value.unsupportedE2eeGroupCount !== void 0 ? value.unsupportedE2eeGroupCount : value.unsupportedE2EeGroupCount);
|
|
108
|
+
}
|
|
102
109
|
function boolean(value) {
|
|
103
110
|
if (typeof value !== "boolean") fail();
|
|
104
111
|
return value;
|
|
@@ -188,6 +195,49 @@ function identity(value) {
|
|
|
188
195
|
registeredAt: safeInteger(value.registeredAtMs)
|
|
189
196
|
};
|
|
190
197
|
}
|
|
198
|
+
function profile(value) {
|
|
199
|
+
return {
|
|
200
|
+
did: required(value.did),
|
|
201
|
+
...value.handle === void 0 ? {} : { handle: value.handle },
|
|
202
|
+
displayName: value.displayName?.trim() ?? "",
|
|
203
|
+
bio: value.bio ?? "",
|
|
204
|
+
tags: [...value.tags],
|
|
205
|
+
...value.updatedAt === void 0 ? {} : { updatedAt: value.updatedAt }
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function mentionPayload(value) {
|
|
209
|
+
if (value.content.kind !== "payload" || value.content.payloadJson === void 0) return void 0;
|
|
210
|
+
let parsed;
|
|
211
|
+
try {
|
|
212
|
+
parsed = JSON.parse(value.content.payloadJson);
|
|
213
|
+
} catch {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (typeof parsed !== "object" || parsed === null || !("text" in parsed) || typeof parsed.text !== "string") return void 0;
|
|
217
|
+
const text = parsed.text;
|
|
218
|
+
if (!("mentions" in parsed) || !Array.isArray(parsed.mentions)) return { text };
|
|
219
|
+
const length = Array.from(text).length;
|
|
220
|
+
const mentions = [];
|
|
221
|
+
for (const raw of parsed.mentions) {
|
|
222
|
+
if (typeof raw !== "object" || raw === null || !("id" in raw) || typeof raw.id !== "string" || raw.id.trim() === "" || !("range" in raw) || typeof raw.range !== "object" || raw.range === null || !("start" in raw.range) || !Number.isSafeInteger(raw.range.start) || !("end" in raw.range) || !Number.isSafeInteger(raw.range.end) || !("unit" in raw.range) || raw.range.unit !== "unicode_code_point" || raw.range.start < 0 || raw.range.end <= raw.range.start || raw.range.end > length || !("target" in raw) || typeof raw.target !== "object" || raw.target === null || !("kind" in raw.target) || raw.target.kind !== "human" || !("did" in raw.target) || typeof raw.target.did !== "string" || !raw.target.did.startsWith("did:")) return { text };
|
|
223
|
+
const displayName = "display_name" in raw.target && typeof raw.target.display_name === "string" ? raw.target.display_name : void 0;
|
|
224
|
+
mentions.push({
|
|
225
|
+
id: raw.id,
|
|
226
|
+
start: raw.range.start,
|
|
227
|
+
end: raw.range.end,
|
|
228
|
+
did: raw.target.did,
|
|
229
|
+
...displayName === void 0 ? {} : { displayName }
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const ordered = [...mentions].sort((left, right) => left.start - right.start || left.end - right.end);
|
|
233
|
+
if (ordered.some((item, index) => index > 0 && item.start < ordered[index - 1].end)) return { text };
|
|
234
|
+
const characters = Array.from(text);
|
|
235
|
+
if (ordered.some((item) => !characters.slice(item.start, item.end).join("").startsWith("@"))) return { text };
|
|
236
|
+
return ordered.length === 0 ? { text } : {
|
|
237
|
+
text,
|
|
238
|
+
mentions: ordered
|
|
239
|
+
};
|
|
240
|
+
}
|
|
191
241
|
/** Copy one native attachment and normalize its decimal/digest encodings. */
|
|
192
242
|
function attachment(value) {
|
|
193
243
|
return {
|
|
@@ -206,12 +256,13 @@ function preview(value) {
|
|
|
206
256
|
const fileName = value.content.attachment?.fileName;
|
|
207
257
|
return fileName === void 0 ? void 0 : `[附件] ${fileName}`;
|
|
208
258
|
}
|
|
259
|
+
case "payload": return mentionPayload(value)?.text;
|
|
209
260
|
default: return;
|
|
210
261
|
}
|
|
211
262
|
}
|
|
212
263
|
/** Provider-only protocol events are not part of the browser's text/attachment history contract. */
|
|
213
264
|
function displayableMessage(value) {
|
|
214
|
-
return value.content.kind === "text" || value.content.kind === "attachment";
|
|
265
|
+
return value.content.kind === "text" || value.content.kind === "attachment" || mentionPayload(value) !== void 0;
|
|
215
266
|
}
|
|
216
267
|
/** Copy one native page and brand its opaque cursor for the Host API. */
|
|
217
268
|
function page(value, copy) {
|
|
@@ -340,6 +391,18 @@ var RustSdkAdapter = class {
|
|
|
340
391
|
}
|
|
341
392
|
};
|
|
342
393
|
}
|
|
394
|
+
case "payload": {
|
|
395
|
+
const parsed = mentionPayload(value);
|
|
396
|
+
if (parsed === void 0) fail();
|
|
397
|
+
return {
|
|
398
|
+
...common,
|
|
399
|
+
content: {
|
|
400
|
+
kind: "text",
|
|
401
|
+
text: parsed.text,
|
|
402
|
+
...parsed.mentions === void 0 ? {} : { mentions: parsed.mentions }
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
}
|
|
343
406
|
default: fail();
|
|
344
407
|
}
|
|
345
408
|
}
|
|
@@ -382,12 +445,37 @@ var RustSdkAdapter = class {
|
|
|
382
445
|
unreadCount: 0
|
|
383
446
|
};
|
|
384
447
|
}
|
|
448
|
+
groupSnapshot(value) {
|
|
449
|
+
return {
|
|
450
|
+
groupDid: required(value.did),
|
|
451
|
+
conversationId: required(value.conversationId),
|
|
452
|
+
title: required(value.title),
|
|
453
|
+
...value.description === void 0 ? {} : { description: value.description },
|
|
454
|
+
...value.myRole === void 0 ? {} : { myRole: value.myRole },
|
|
455
|
+
...value.membershipStatus === void 0 ? {} : { membershipStatus: value.membershipStatus },
|
|
456
|
+
...value.memberCount === void 0 ? {} : { memberCount: value.memberCount }
|
|
457
|
+
};
|
|
458
|
+
}
|
|
385
459
|
groupMember(value) {
|
|
386
460
|
return {
|
|
387
461
|
did: required(value.did),
|
|
388
462
|
...value.handle === void 0 ? {} : { handle: value.handle }
|
|
389
463
|
};
|
|
390
464
|
}
|
|
465
|
+
groupMemberRecord(value, profile) {
|
|
466
|
+
return {
|
|
467
|
+
...value.membershipId === void 0 ? {} : { membershipId: value.membershipId },
|
|
468
|
+
...value.peerPersonaId === void 0 ? {} : { peerPersonaId: value.peerPersonaId },
|
|
469
|
+
...value.did === void 0 ? {} : { did: value.did },
|
|
470
|
+
...value.credentialDid === void 0 ? {} : { credentialDid: value.credentialDid },
|
|
471
|
+
...value.handle === void 0 ? {} : { handle: value.handle },
|
|
472
|
+
...profile?.displayName === void 0 ? {} : { displayName: profile.displayName },
|
|
473
|
+
...value.role === void 0 ? {} : { role: value.role },
|
|
474
|
+
...value.status === void 0 ? {} : { status: value.status },
|
|
475
|
+
...value.joinedAt === void 0 ? {} : { joinedAt: value.joinedAt },
|
|
476
|
+
...value.subjectType === void 0 ? {} : { subjectType: value.subjectType }
|
|
477
|
+
};
|
|
478
|
+
}
|
|
391
479
|
listenerConversation(value) {
|
|
392
480
|
const common = {
|
|
393
481
|
id: required(value.id),
|
|
@@ -430,7 +518,7 @@ var RustSdkAdapter = class {
|
|
|
430
518
|
return this.run(async (client) => {
|
|
431
519
|
const result = await client.syncNow({ reason });
|
|
432
520
|
if (result.status === "idle" || result.status === "changed") return;
|
|
433
|
-
if (result.status === "auth_revoked") fail("
|
|
521
|
+
if (result.status === "auth_revoked") fail("identity-recovery-required");
|
|
434
522
|
fail("network");
|
|
435
523
|
});
|
|
436
524
|
}
|
|
@@ -506,6 +594,59 @@ var RustSdkAdapter = class {
|
|
|
506
594
|
updateDisplayName(request) {
|
|
507
595
|
return this.run(async (client) => identity(await client.updateDisplayName(request.displayName)));
|
|
508
596
|
}
|
|
597
|
+
getProfile() {
|
|
598
|
+
return this.run(async (client) => profile(await client.getProfile()));
|
|
599
|
+
}
|
|
600
|
+
updateProfile(request) {
|
|
601
|
+
return this.run(async (client) => profile(await client.updateProfile({
|
|
602
|
+
displayName: request.displayName,
|
|
603
|
+
bio: request.bio,
|
|
604
|
+
tags: [...request.tags]
|
|
605
|
+
})));
|
|
606
|
+
}
|
|
607
|
+
recoveryProgress(value) {
|
|
608
|
+
return {
|
|
609
|
+
operationId: required(value.operationId),
|
|
610
|
+
fullHandle: required(value.fullHandle),
|
|
611
|
+
...value.previousDid === void 0 ? {} : { previousDid: value.previousDid },
|
|
612
|
+
currentDid: required(value.currentDid),
|
|
613
|
+
phase: value.phase,
|
|
614
|
+
...value.failureCode === void 0 ? {} : { failureCode: value.failureCode },
|
|
615
|
+
retryable: boolean(value.retryable),
|
|
616
|
+
localOrdinaryDataWillMigrate: boolean(value.impact.localOrdinaryDataWillMigrate),
|
|
617
|
+
otherDevicesMustRejoin: boolean(value.impact.otherDevicesMustRejoin),
|
|
618
|
+
unsupportedE2eeGroupCount: recoveryE2eeGroupCount(value.impact),
|
|
619
|
+
unsupportedDidOnlyGroupCount: uint32(value.impact.unsupportedDidOnlyGroupCount)
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
sendRecoveryOtp(request) {
|
|
623
|
+
return this.run(async (client) => {
|
|
624
|
+
const value = await client.requestHandleRecoveryOtp(request);
|
|
625
|
+
return {
|
|
626
|
+
operationId: required(value.operationId),
|
|
627
|
+
fullHandle: required(value.fullHandle),
|
|
628
|
+
retryAfterSeconds: value.retryAfterSeconds,
|
|
629
|
+
retryAt: value.retryAt
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
prepareRecovery(request) {
|
|
634
|
+
return this.run(async (client) => this.recoveryProgress(await client.prepareHandleRecovery(request)));
|
|
635
|
+
}
|
|
636
|
+
activateRecovery(request) {
|
|
637
|
+
return this.run(async (client) => this.recoveryProgress(await client.activateHandleRecovery(request)));
|
|
638
|
+
}
|
|
639
|
+
getRecoveryStatus(request) {
|
|
640
|
+
return this.run(async (client) => this.recoveryProgress(await client.getHandleRecoveryStatus(request)));
|
|
641
|
+
}
|
|
642
|
+
resumeRecovery(request) {
|
|
643
|
+
return this.run(async (client) => this.recoveryProgress(await client.resumeHandleRecovery(request)));
|
|
644
|
+
}
|
|
645
|
+
discardRecovery(request) {
|
|
646
|
+
return this.run(async (client) => {
|
|
647
|
+
await client.discardHandleRecovery(request);
|
|
648
|
+
});
|
|
649
|
+
}
|
|
509
650
|
resolvePeer(peer) {
|
|
510
651
|
return this.run(async (client) => {
|
|
511
652
|
const value = await client.resolvePeer(peer);
|
|
@@ -526,6 +667,83 @@ var RustSdkAdapter = class {
|
|
|
526
667
|
member
|
|
527
668
|
})));
|
|
528
669
|
}
|
|
670
|
+
getGroup(groupDid) {
|
|
671
|
+
return this.run(async (client) => this.groupSnapshot(await client.getGroup({ groupDid: String(groupDid) })));
|
|
672
|
+
}
|
|
673
|
+
joinGroup(groupDid) {
|
|
674
|
+
return this.run(async (client) => this.groupSnapshot(await client.joinGroup({ groupDid: String(groupDid) })));
|
|
675
|
+
}
|
|
676
|
+
leaveGroup(groupDid) {
|
|
677
|
+
return this.run((client) => client.leaveGroup({ groupDid: String(groupDid) }));
|
|
678
|
+
}
|
|
679
|
+
listGroupMembers(request) {
|
|
680
|
+
return this.run(async (client) => {
|
|
681
|
+
const value = await client.listGroupMembers({
|
|
682
|
+
groupDid: String(request.groupDid),
|
|
683
|
+
...request.cursor === void 0 ? {} : { cursor: String(request.cursor) },
|
|
684
|
+
...request.limit === void 0 ? {} : { limit: request.limit }
|
|
685
|
+
});
|
|
686
|
+
const peers = [...new Set(value.items.flatMap((member) => member.did ?? member.handle ?? []))];
|
|
687
|
+
const profiles = peers.length === 0 ? [] : await client.hydrateDisplayProfiles({ peers });
|
|
688
|
+
const byPeer = /* @__PURE__ */ new Map();
|
|
689
|
+
for (const [index, profile] of profiles.entries()) {
|
|
690
|
+
const requested = peers[index];
|
|
691
|
+
if (requested !== void 0) byPeer.set(requested, profile);
|
|
692
|
+
if (profile.did !== void 0) byPeer.set(profile.did, profile);
|
|
693
|
+
if (profile.handle !== void 0) byPeer.set(profile.handle, profile);
|
|
694
|
+
}
|
|
695
|
+
return {
|
|
696
|
+
items: value.items.map((item) => this.groupMemberRecord(item, byPeer.get(item.did ?? "") ?? byPeer.get(item.handle ?? ""))),
|
|
697
|
+
...value.total === void 0 ? {} : { total: value.total },
|
|
698
|
+
...value.nextCursor === void 0 ? {} : { nextCursor: value.nextCursor },
|
|
699
|
+
hasMore: value.hasMore,
|
|
700
|
+
...value.pageGroup === void 0 ? {} : { pageGroup: value.pageGroup },
|
|
701
|
+
...value.groupStateVersion === void 0 ? {} : { groupStateVersion: value.groupStateVersion },
|
|
702
|
+
warnings: [...value.warnings]
|
|
703
|
+
};
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
removeGroupMember(groupDid, member) {
|
|
707
|
+
return this.run(async (client) => this.groupMember(await client.removeGroupMember({
|
|
708
|
+
groupDid: String(groupDid),
|
|
709
|
+
member
|
|
710
|
+
})));
|
|
711
|
+
}
|
|
712
|
+
resumeGroupRebindRecovery() {
|
|
713
|
+
return this.run(async (client) => {
|
|
714
|
+
const value = await client.resumeGroupRebindRecovery(100);
|
|
715
|
+
const journal = value;
|
|
716
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
717
|
+
for (const item of journal.items ?? []) {
|
|
718
|
+
const { groupDid: rawGroupDid, layer: rawLayer, phase: rawPhase } = item;
|
|
719
|
+
if (typeof rawGroupDid !== "string" || typeof rawLayer !== "string" || typeof rawPhase !== "string" || typeof item.blocked !== "boolean") throw new TypeError("invalid group recovery item");
|
|
720
|
+
const groupDid = required(rawGroupDid);
|
|
721
|
+
const layer = required(rawLayer);
|
|
722
|
+
const phase = required(rawPhase);
|
|
723
|
+
if (layer !== "p4" && layer !== "p6") throw new TypeError("invalid group recovery item");
|
|
724
|
+
if (phase === "complete") continue;
|
|
725
|
+
const status = item.blocked || phase === "blocked" ? "blocked" : "pending";
|
|
726
|
+
if (statuses.get(groupDid) !== "blocked") statuses.set(groupDid, status);
|
|
727
|
+
}
|
|
728
|
+
for (const group of journal.sendPausedGroups ?? []) {
|
|
729
|
+
if (typeof group !== "string") throw new TypeError("invalid paused recovery group");
|
|
730
|
+
const groupDid = required(group);
|
|
731
|
+
if (!statuses.has(groupDid)) statuses.set(groupDid, "pending");
|
|
732
|
+
}
|
|
733
|
+
const items = [...statuses].map(([groupDid, status]) => ({
|
|
734
|
+
groupDid,
|
|
735
|
+
status
|
|
736
|
+
}));
|
|
737
|
+
const hasJournal = journal.items !== void 0 || journal.sendPausedGroups !== void 0;
|
|
738
|
+
return {
|
|
739
|
+
processed: uint32(value.processed),
|
|
740
|
+
completed: uint32(value.completed),
|
|
741
|
+
pending: hasJournal ? items.filter((item) => item.status === "pending").length : uint32(value.pending),
|
|
742
|
+
blocked: hasJournal ? items.filter((item) => item.status === "blocked").length : uint32(value.blocked),
|
|
743
|
+
items
|
|
744
|
+
};
|
|
745
|
+
});
|
|
746
|
+
}
|
|
529
747
|
listConversations(request) {
|
|
530
748
|
return this.run(async (client) => {
|
|
531
749
|
const conversations = await client.listConversations(request);
|
|
@@ -567,8 +785,31 @@ var RustSdkAdapter = class {
|
|
|
567
785
|
sendText(request) {
|
|
568
786
|
return this.run(async (client) => {
|
|
569
787
|
const clientMessageId = browserMessageId(request.idempotencyKey);
|
|
788
|
+
const conversationId = await this.conversationId(client, request.target);
|
|
789
|
+
if (request.mentions !== void 0 && request.mentions.length > 0) return this.message(await client.sendPayload({
|
|
790
|
+
conversationId,
|
|
791
|
+
payloadJson: JSON.stringify({
|
|
792
|
+
text: request.text,
|
|
793
|
+
mentions: request.mentions.map((mention) => ({
|
|
794
|
+
id: mention.id,
|
|
795
|
+
range: {
|
|
796
|
+
start: mention.start,
|
|
797
|
+
end: mention.end,
|
|
798
|
+
unit: "unicode_code_point"
|
|
799
|
+
},
|
|
800
|
+
target: {
|
|
801
|
+
kind: "human",
|
|
802
|
+
did: mention.did,
|
|
803
|
+
...mention.displayName === void 0 ? {} : { display_name: mention.displayName }
|
|
804
|
+
},
|
|
805
|
+
mention_role: "addressee"
|
|
806
|
+
}))
|
|
807
|
+
}),
|
|
808
|
+
...clientMessageId === void 0 ? {} : { clientMessageId },
|
|
809
|
+
idempotencyKey: request.idempotencyKey
|
|
810
|
+
}));
|
|
570
811
|
return this.message(await client.sendText({
|
|
571
|
-
conversationId
|
|
812
|
+
conversationId,
|
|
572
813
|
text: request.text,
|
|
573
814
|
...clientMessageId === void 0 ? {} : { clientMessageId },
|
|
574
815
|
idempotencyKey: request.idempotencyKey
|