@atproto/api 0.10.1 → 0.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "license": "MIT",
5
5
  "description": "Client library for atproto and Bluesky",
6
6
  "keywords": [
@@ -21,14 +21,14 @@
21
21
  "typed-emitter": "^2.1.0",
22
22
  "zod": "^3.21.4",
23
23
  "@atproto/common-web": "^0.2.3",
24
- "@atproto/lexicon": "^0.3.1",
25
- "@atproto/syntax": "^0.1.5",
26
- "@atproto/xrpc": "^0.4.1"
24
+ "@atproto/lexicon": "^0.3.2",
25
+ "@atproto/syntax": "^0.2.0",
26
+ "@atproto/xrpc": "^0.4.2"
27
27
  },
28
28
  "devDependencies": {
29
29
  "common-tags": "^1.8.2",
30
- "@atproto/lex-cli": "^0.3.0",
31
- "@atproto/dev-env": "^0.2.33"
30
+ "@atproto/lex-cli": "^0.3.1",
31
+ "@atproto/dev-env": "^0.2.34"
32
32
  },
33
33
  "scripts": {
34
34
  "codegen": "pnpm docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
package/src/bsky-agent.ts CHANGED
@@ -668,24 +668,24 @@ async function updateMutedWords(
668
668
 
669
669
  if (mutedWordsPref && AppBskyActorDefs.isMutedWordsPref(mutedWordsPref)) {
670
670
  if (action === 'upsert' || action === 'update') {
671
- for (const newItem of mutedWords) {
671
+ for (const word of mutedWords) {
672
672
  let foundMatch = false
673
673
 
674
674
  for (const existingItem of mutedWordsPref.items) {
675
- if (existingItem.value === newItem.value) {
675
+ if (existingItem.value === sanitizeMutedWord(word).value) {
676
676
  existingItem.targets =
677
677
  action === 'upsert'
678
678
  ? Array.from(
679
- new Set([...existingItem.targets, ...newItem.targets]),
679
+ new Set([...existingItem.targets, ...word.targets]),
680
680
  )
681
- : newItem.targets
681
+ : word.targets
682
682
  foundMatch = true
683
683
  break
684
684
  }
685
685
  }
686
686
 
687
687
  if (action === 'upsert' && !foundMatch) {
688
- mutedWordsPref.items.push(sanitizeMutedWord(newItem))
688
+ mutedWordsPref.items.push(sanitizeMutedWord(word))
689
689
  }
690
690
  }
691
691
  } else if (action === 'remove') {
@@ -4867,7 +4867,7 @@ export const schemaDict = {
4867
4867
  main: {
4868
4868
  type: 'query',
4869
4869
  description:
4870
- 'Fetch all labels from a labeler created after a certain date. DEPRECATED: use queryLabels or subscribeLabels instead',
4870
+ 'DEPRECATED: use queryLabels or subscribeLabels instead -- Fetch all labels from a labeler created after a certain date.',
4871
4871
  parameters: {
4872
4872
  type: 'params',
4873
4873
  properties: {
@@ -70,27 +70,25 @@ export function detectFacets(text: UnicodeString): Facet[] | undefined {
70
70
  }
71
71
  }
72
72
  {
73
- const re = /(?:^|\s)(#[^\d\s]\S*)(?=\s)?/g
73
+ const re = /(^|\s)#((?!\ufe0f)[^\d\s]\S*)(?=\s)?/g
74
74
  while ((match = re.exec(text.utf16))) {
75
- let [tag] = match
76
- const hasLeadingSpace = /^\s/.test(tag)
75
+ let [, leading, tag] = match
77
76
 
78
77
  tag = tag.trim().replace(/\p{P}+$/gu, '') // strip ending punctuation
79
78
 
80
- // inclusive of #, max of 64 chars
81
- if (tag.length > 66) continue
79
+ if (tag.length === 0 || tag.length > 64) continue
82
80
 
83
- const index = match.index + (hasLeadingSpace ? 1 : 0)
81
+ const index = match.index + leading.length
84
82
 
85
83
  facets.push({
86
84
  index: {
87
85
  byteStart: text.utf16IndexToUtf8Index(index),
88
- byteEnd: text.utf16IndexToUtf8Index(index + tag.length), // inclusive of last char
86
+ byteEnd: text.utf16IndexToUtf8Index(index + 1 + tag.length),
89
87
  },
90
88
  features: [
91
89
  {
92
90
  $type: 'app.bsky.richtext.facet#tag',
93
- tag: tag.replace(/^#/, ''),
91
+ tag: tag,
94
92
  },
95
93
  ],
96
94
  })
@@ -1199,10 +1199,17 @@ describe('agent', () => {
1199
1199
  })
1200
1200
 
1201
1201
  it('upsertMutedWords with #', async () => {
1202
+ await agent.upsertMutedWords([
1203
+ { value: 'hashtag', targets: ['content'] },
1204
+ ])
1202
1205
  await agent.upsertMutedWords([{ value: '#hashtag', targets: ['tag'] }])
1203
1206
  const { mutedWords } = await agent.getPreferences()
1204
1207
  expect(mutedWords.find((m) => m.value === '#hashtag')).toBeFalsy()
1205
- expect(mutedWords.find((m) => m.value === 'hashtag')).toBeTruthy()
1208
+ expect(mutedWords.find((m) => m.value === 'hashtag')).toStrictEqual({
1209
+ value: 'hashtag',
1210
+ targets: ['content', 'tag'],
1211
+ })
1212
+ expect(mutedWords.filter((m) => m.value === 'hashtag').length).toBe(1)
1206
1213
  })
1207
1214
 
1208
1215
  it('updateMutedWord', async () => {
@@ -241,15 +241,16 @@ describe('detectFacets', () => {
241
241
  ['body #1', [], []],
242
242
  ['body #a1', ['a1'], [{ byteStart: 5, byteEnd: 8 }]],
243
243
  ['#', [], []],
244
+ ['#?', [], []],
244
245
  ['text #', [], []],
245
246
  ['text # text', [], []],
246
247
  [
247
- 'body #thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
248
- ['thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
249
- [{ byteStart: 5, byteEnd: 71 }],
248
+ 'body #thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
249
+ ['thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
250
+ [{ byteStart: 5, byteEnd: 70 }],
250
251
  ],
251
252
  [
252
- 'body #thisisa65characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab',
253
+ 'body #thisisa65characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab',
253
254
  [],
254
255
  [],
255
256
  ],
@@ -297,6 +298,17 @@ describe('detectFacets', () => {
297
298
  { byteStart: 17, byteEnd: 22 },
298
299
  ],
299
300
  ],
301
+ ['this #️⃣tag should not be a tag', [], []],
302
+ [
303
+ 'this ##️⃣tag should be a tag',
304
+ ['#️⃣tag'],
305
+ [
306
+ {
307
+ byteStart: 5,
308
+ byteEnd: 16,
309
+ },
310
+ ],
311
+ ],
300
312
  ]
301
313
 
302
314
  for (const [input, tags, indices] of inputs) {