@atproto/api 0.10.1 → 0.10.3
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/CHANGELOG.md +27 -0
- package/dist/bsky-agent.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +77 -57
- package/dist/index.js.map +3 -3
- package/dist/util.d.ts +1 -0
- package/package.json +6 -6
- package/src/bsky-agent.ts +97 -74
- package/src/client/lexicons.ts +1 -1
- package/src/index.ts +1 -0
- package/src/rich-text/detection.ts +6 -8
- package/src/util.ts +6 -0
- package/tests/bsky-agent.test.ts +139 -8
- package/tests/rich-text-detection.test.ts +26 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @atproto/api
|
|
2
2
|
|
|
3
|
+
## 0.10.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2247](https://github.com/bluesky-social/atproto/pull/2247) [`2a0ceb818`](https://github.com/bluesky-social/atproto/commit/2a0ceb8180faa17de8061d4fa6c361b57a2005ed) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Fix double sanitization bug when editing muted words.
|
|
8
|
+
|
|
9
|
+
- [#2247](https://github.com/bluesky-social/atproto/pull/2247) [`2a0ceb818`](https://github.com/bluesky-social/atproto/commit/2a0ceb8180faa17de8061d4fa6c361b57a2005ed) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - More sanitization of muted words, including newlines and leading/trailing whitespace
|
|
10
|
+
|
|
11
|
+
- [#2247](https://github.com/bluesky-social/atproto/pull/2247) [`2a0ceb818`](https://github.com/bluesky-social/atproto/commit/2a0ceb8180faa17de8061d4fa6c361b57a2005ed) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Add `sanitizeMutedWordValue` util
|
|
12
|
+
|
|
13
|
+
- [#2247](https://github.com/bluesky-social/atproto/pull/2247) [`2a0ceb818`](https://github.com/bluesky-social/atproto/commit/2a0ceb8180faa17de8061d4fa6c361b57a2005ed) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Handle hash emoji in mute words
|
|
14
|
+
|
|
15
|
+
## 0.10.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#2245](https://github.com/bluesky-social/atproto/pull/2245) [`61b3d2525`](https://github.com/bluesky-social/atproto/commit/61b3d25253353db2da1336004f94e7dc5adb0410) Thanks [@mary-ext](https://github.com/mary-ext)! - Prevent hashtag emoji from being parsed as a tag
|
|
20
|
+
|
|
21
|
+
- [#2218](https://github.com/bluesky-social/atproto/pull/2218) [`43531905c`](https://github.com/bluesky-social/atproto/commit/43531905ce1aec6d36d9be5943782811ecca6e6d) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Fix mute word upsert logic by ensuring we're comparing sanitized word values
|
|
22
|
+
|
|
23
|
+
- [#2245](https://github.com/bluesky-social/atproto/pull/2245) [`61b3d2525`](https://github.com/bluesky-social/atproto/commit/61b3d25253353db2da1336004f94e7dc5adb0410) Thanks [@mary-ext](https://github.com/mary-ext)! - Properly calculate length of tag
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`0c815b964`](https://github.com/bluesky-social/atproto/commit/0c815b964c030aa0f277c40bf9786f130dc320f4)]:
|
|
26
|
+
- @atproto/syntax@0.2.0
|
|
27
|
+
- @atproto/lexicon@0.3.2
|
|
28
|
+
- @atproto/xrpc@0.4.2
|
|
29
|
+
|
|
3
30
|
## 0.10.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/bsky-agent.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export declare class BskyAgent extends AtpAgent {
|
|
|
85
85
|
setFeedViewPrefs(feed: string, pref: Partial<BskyFeedViewPreference>): Promise<void>;
|
|
86
86
|
setThreadViewPrefs(pref: Partial<BskyThreadViewPreference>): Promise<void>;
|
|
87
87
|
setInterestsPref(pref: Partial<BskyInterestsPreference>): Promise<void>;
|
|
88
|
-
upsertMutedWords(
|
|
88
|
+
upsertMutedWords(newMutedWords: AppBskyActorDefs.MutedWord[]): Promise<void>;
|
|
89
89
|
updateMutedWord(mutedWord: AppBskyActorDefs.MutedWord): Promise<void>;
|
|
90
90
|
removeMutedWord(mutedWord: AppBskyActorDefs.MutedWord): Promise<void>;
|
|
91
91
|
hidePost(postUri: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { AtUri } from '@atproto/syntax';
|
|
|
2
2
|
export { BlobRef, lexToJson, stringifyLex, jsonToLex, jsonStringToLex, } from '@atproto/lexicon';
|
|
3
3
|
export { parseLanguage } from '@atproto/common-web';
|
|
4
4
|
export * from './types';
|
|
5
|
+
export * from './util';
|
|
5
6
|
export * from './client';
|
|
6
7
|
export * from './agent';
|
|
7
8
|
export * from './rich-text/rich-text';
|
package/dist/index.js
CHANGED
|
@@ -9076,6 +9076,7 @@ __export(src_exports2, {
|
|
|
9076
9076
|
moderateProfile: () => moderateProfile,
|
|
9077
9077
|
moderateUserList: () => moderateUserList,
|
|
9078
9078
|
parseLanguage: () => parseLanguage,
|
|
9079
|
+
sanitizeMutedWordValue: () => sanitizeMutedWordValue,
|
|
9079
9080
|
sanitizeRichText: () => sanitizeRichText,
|
|
9080
9081
|
stringifyLex: () => stringifyLex
|
|
9081
9082
|
});
|
|
@@ -15383,6 +15384,11 @@ var jsonStringToLex = (val) => {
|
|
|
15383
15384
|
return jsonToLex(JSON.parse(val));
|
|
15384
15385
|
};
|
|
15385
15386
|
|
|
15387
|
+
// src/util.ts
|
|
15388
|
+
function sanitizeMutedWordValue(value) {
|
|
15389
|
+
return value.trim().replace(/^#(?!\ufe0f)/, "").replace(/[\r\n\u00AD\u2060\u200D\u200C\u200B]+/, "");
|
|
15390
|
+
}
|
|
15391
|
+
|
|
15386
15392
|
// ../xrpc/src/types.ts
|
|
15387
15393
|
var errorResponseBody = z.object({
|
|
15388
15394
|
error: z.string().optional(),
|
|
@@ -20411,7 +20417,7 @@ var schemaDict = {
|
|
|
20411
20417
|
defs: {
|
|
20412
20418
|
main: {
|
|
20413
20419
|
type: "query",
|
|
20414
|
-
description: "Fetch all labels from a labeler created after a certain date.
|
|
20420
|
+
description: "DEPRECATED: use queryLabels or subscribeLabels instead -- Fetch all labels from a labeler created after a certain date.",
|
|
20415
20421
|
parameters: {
|
|
20416
20422
|
type: "params",
|
|
20417
20423
|
properties: {
|
|
@@ -30193,23 +30199,22 @@ function detectFacets(text) {
|
|
|
30193
30199
|
}
|
|
30194
30200
|
}
|
|
30195
30201
|
{
|
|
30196
|
-
const re = /(
|
|
30202
|
+
const re = /(^|\s)#((?!\ufe0f)[^\d\s]\S*)(?=\s)?/g;
|
|
30197
30203
|
while (match = re.exec(text.utf16)) {
|
|
30198
|
-
let [tag] = match;
|
|
30199
|
-
const hasLeadingSpace = /^\s/.test(tag);
|
|
30204
|
+
let [, leading, tag] = match;
|
|
30200
30205
|
tag = tag.trim().replace(/\p{P}+$/gu, "");
|
|
30201
|
-
if (tag.length >
|
|
30206
|
+
if (tag.length === 0 || tag.length > 64)
|
|
30202
30207
|
continue;
|
|
30203
|
-
const index = match.index +
|
|
30208
|
+
const index = match.index + leading.length;
|
|
30204
30209
|
facets.push({
|
|
30205
30210
|
index: {
|
|
30206
30211
|
byteStart: text.utf16IndexToUtf8Index(index),
|
|
30207
|
-
byteEnd: text.utf16IndexToUtf8Index(index + tag.length)
|
|
30212
|
+
byteEnd: text.utf16IndexToUtf8Index(index + 1 + tag.length)
|
|
30208
30213
|
},
|
|
30209
30214
|
features: [
|
|
30210
30215
|
{
|
|
30211
30216
|
$type: "app.bsky.richtext.facet#tag",
|
|
30212
|
-
tag
|
|
30217
|
+
tag
|
|
30213
30218
|
}
|
|
30214
30219
|
]
|
|
30215
30220
|
});
|
|
@@ -32228,14 +32233,74 @@ var BskyAgent = class extends AtpAgent {
|
|
|
32228
32233
|
return prefs.filter((p) => !defs_exports5.isInterestsPref(p)).concat([{ ...pref, $type: "app.bsky.actor.defs#interestsPref" }]);
|
|
32229
32234
|
});
|
|
32230
32235
|
}
|
|
32231
|
-
async upsertMutedWords(
|
|
32232
|
-
await
|
|
32236
|
+
async upsertMutedWords(newMutedWords) {
|
|
32237
|
+
await updatePreferences(this, (prefs) => {
|
|
32238
|
+
let mutedWordsPref = prefs.findLast((pref) => defs_exports5.isMutedWordsPref(pref) && defs_exports5.validateMutedWordsPref(pref).success);
|
|
32239
|
+
if (mutedWordsPref && defs_exports5.isMutedWordsPref(mutedWordsPref)) {
|
|
32240
|
+
for (const updatedWord of newMutedWords) {
|
|
32241
|
+
let foundMatch = false;
|
|
32242
|
+
const sanitizedUpdatedValue = sanitizeMutedWordValue(updatedWord.value);
|
|
32243
|
+
if (!sanitizedUpdatedValue)
|
|
32244
|
+
continue;
|
|
32245
|
+
for (const existingItem of mutedWordsPref.items) {
|
|
32246
|
+
if (existingItem.value === sanitizedUpdatedValue) {
|
|
32247
|
+
existingItem.targets = Array.from(/* @__PURE__ */ new Set([...existingItem.targets, ...updatedWord.targets]));
|
|
32248
|
+
foundMatch = true;
|
|
32249
|
+
break;
|
|
32250
|
+
}
|
|
32251
|
+
}
|
|
32252
|
+
if (!foundMatch) {
|
|
32253
|
+
mutedWordsPref.items.push({
|
|
32254
|
+
...updatedWord,
|
|
32255
|
+
value: sanitizedUpdatedValue
|
|
32256
|
+
});
|
|
32257
|
+
}
|
|
32258
|
+
}
|
|
32259
|
+
} else {
|
|
32260
|
+
mutedWordsPref = {
|
|
32261
|
+
items: newMutedWords.map((w) => ({
|
|
32262
|
+
...w,
|
|
32263
|
+
value: sanitizeMutedWordValue(w.value)
|
|
32264
|
+
}))
|
|
32265
|
+
};
|
|
32266
|
+
}
|
|
32267
|
+
return prefs.filter((p) => !defs_exports5.isMutedWordsPref(p)).concat([
|
|
32268
|
+
{ ...mutedWordsPref, $type: "app.bsky.actor.defs#mutedWordsPref" }
|
|
32269
|
+
]);
|
|
32270
|
+
});
|
|
32233
32271
|
}
|
|
32234
32272
|
async updateMutedWord(mutedWord) {
|
|
32235
|
-
await
|
|
32273
|
+
await updatePreferences(this, (prefs) => {
|
|
32274
|
+
let mutedWordsPref = prefs.findLast((pref) => defs_exports5.isMutedWordsPref(pref) && defs_exports5.validateMutedWordsPref(pref).success);
|
|
32275
|
+
if (mutedWordsPref && defs_exports5.isMutedWordsPref(mutedWordsPref)) {
|
|
32276
|
+
for (const existingItem of mutedWordsPref.items) {
|
|
32277
|
+
if (existingItem.value === mutedWord.value) {
|
|
32278
|
+
existingItem.targets = mutedWord.targets;
|
|
32279
|
+
break;
|
|
32280
|
+
}
|
|
32281
|
+
}
|
|
32282
|
+
}
|
|
32283
|
+
return prefs.filter((p) => !defs_exports5.isMutedWordsPref(p)).concat([
|
|
32284
|
+
{ ...mutedWordsPref, $type: "app.bsky.actor.defs#mutedWordsPref" }
|
|
32285
|
+
]);
|
|
32286
|
+
});
|
|
32236
32287
|
}
|
|
32237
32288
|
async removeMutedWord(mutedWord) {
|
|
32238
|
-
await
|
|
32289
|
+
await updatePreferences(this, (prefs) => {
|
|
32290
|
+
let mutedWordsPref = prefs.findLast((pref) => defs_exports5.isMutedWordsPref(pref) && defs_exports5.validateMutedWordsPref(pref).success);
|
|
32291
|
+
if (mutedWordsPref && defs_exports5.isMutedWordsPref(mutedWordsPref)) {
|
|
32292
|
+
for (let i = 0; i < mutedWordsPref.items.length; i++) {
|
|
32293
|
+
const existing = mutedWordsPref.items[i];
|
|
32294
|
+
if (existing.value === mutedWord.value) {
|
|
32295
|
+
mutedWordsPref.items.splice(i, 1);
|
|
32296
|
+
break;
|
|
32297
|
+
}
|
|
32298
|
+
}
|
|
32299
|
+
}
|
|
32300
|
+
return prefs.filter((p) => !defs_exports5.isMutedWordsPref(p)).concat([
|
|
32301
|
+
{ ...mutedWordsPref, $type: "app.bsky.actor.defs#mutedWordsPref" }
|
|
32302
|
+
]);
|
|
32303
|
+
});
|
|
32239
32304
|
}
|
|
32240
32305
|
async hidePost(postUri) {
|
|
32241
32306
|
await updateHiddenPost(this, postUri, "hide");
|
|
@@ -32274,51 +32339,6 @@ async function updateFeedPreferences(agent, cb) {
|
|
|
32274
32339
|
});
|
|
32275
32340
|
return res;
|
|
32276
32341
|
}
|
|
32277
|
-
async function updateMutedWords(agent, mutedWords, action) {
|
|
32278
|
-
const sanitizeMutedWord = (word) => ({
|
|
32279
|
-
value: word.value.replace(/^#/, ""),
|
|
32280
|
-
targets: word.targets
|
|
32281
|
-
});
|
|
32282
|
-
await updatePreferences(agent, (prefs) => {
|
|
32283
|
-
let mutedWordsPref = prefs.findLast((pref) => defs_exports5.isMutedWordsPref(pref) && defs_exports5.validateMutedWordsPref(pref).success);
|
|
32284
|
-
if (mutedWordsPref && defs_exports5.isMutedWordsPref(mutedWordsPref)) {
|
|
32285
|
-
if (action === "upsert" || action === "update") {
|
|
32286
|
-
for (const newItem of mutedWords) {
|
|
32287
|
-
let foundMatch = false;
|
|
32288
|
-
for (const existingItem of mutedWordsPref.items) {
|
|
32289
|
-
if (existingItem.value === newItem.value) {
|
|
32290
|
-
existingItem.targets = action === "upsert" ? Array.from(/* @__PURE__ */ new Set([...existingItem.targets, ...newItem.targets])) : newItem.targets;
|
|
32291
|
-
foundMatch = true;
|
|
32292
|
-
break;
|
|
32293
|
-
}
|
|
32294
|
-
}
|
|
32295
|
-
if (action === "upsert" && !foundMatch) {
|
|
32296
|
-
mutedWordsPref.items.push(sanitizeMutedWord(newItem));
|
|
32297
|
-
}
|
|
32298
|
-
}
|
|
32299
|
-
} else if (action === "remove") {
|
|
32300
|
-
for (const word of mutedWords) {
|
|
32301
|
-
for (let i = 0; i < mutedWordsPref.items.length; i++) {
|
|
32302
|
-
const existing = mutedWordsPref.items[i];
|
|
32303
|
-
if (existing.value === sanitizeMutedWord(word).value) {
|
|
32304
|
-
mutedWordsPref.items.splice(i, 1);
|
|
32305
|
-
break;
|
|
32306
|
-
}
|
|
32307
|
-
}
|
|
32308
|
-
}
|
|
32309
|
-
}
|
|
32310
|
-
} else {
|
|
32311
|
-
if (action === "upsert") {
|
|
32312
|
-
mutedWordsPref = {
|
|
32313
|
-
items: mutedWords.map(sanitizeMutedWord)
|
|
32314
|
-
};
|
|
32315
|
-
}
|
|
32316
|
-
}
|
|
32317
|
-
return prefs.filter((p) => !defs_exports5.isMutedWordsPref(p)).concat([
|
|
32318
|
-
{ ...mutedWordsPref, $type: "app.bsky.actor.defs#mutedWordsPref" }
|
|
32319
|
-
]);
|
|
32320
|
-
});
|
|
32321
|
-
}
|
|
32322
32342
|
async function updateHiddenPost(agent, postUri, action) {
|
|
32323
32343
|
await updatePreferences(agent, (prefs) => {
|
|
32324
32344
|
let pref = prefs.findLast((pref2) => defs_exports5.isHiddenPostsPref(pref2) && defs_exports5.validateHiddenPostsPref(pref2).success);
|