@atproto/api 0.10.0 → 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/CHANGELOG.md +21 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/lexicons.d.ts +27 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts +1 -1
- package/dist/client/types/com/atproto/admin/updateAccountPassword.d.ts +18 -0
- package/dist/index.js +369 -325
- package/dist/index.js.map +3 -3
- package/package.json +6 -6
- package/src/bsky-agent.ts +5 -5
- package/src/client/index.ts +13 -0
- package/src/client/lexicons.ts +32 -1
- package/src/client/types/app/bsky/actor/defs.ts +2 -0
- package/src/client/types/com/atproto/admin/updateAccountPassword.ts +33 -0
- package/src/rich-text/detection.ts +6 -8
- package/tests/bsky-agent.test.ts +8 -1
- package/tests/rich-text-detection.test.ts +16 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/api",
|
|
3
|
-
"version": "0.10.
|
|
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.
|
|
25
|
-
"@atproto/syntax": "^0.
|
|
26
|
-
"@atproto/xrpc": "^0.4.
|
|
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.
|
|
31
|
-
"@atproto/dev-env": "^0.2.
|
|
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
|
|
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 ===
|
|
675
|
+
if (existingItem.value === sanitizeMutedWord(word).value) {
|
|
676
676
|
existingItem.targets =
|
|
677
677
|
action === 'upsert'
|
|
678
678
|
? Array.from(
|
|
679
|
-
new Set([...existingItem.targets, ...
|
|
679
|
+
new Set([...existingItem.targets, ...word.targets]),
|
|
680
680
|
)
|
|
681
|
-
:
|
|
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(
|
|
688
|
+
mutedWordsPref.items.push(sanitizeMutedWord(word))
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
} else if (action === 'remove') {
|
package/src/client/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRep
|
|
|
29
29
|
import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
|
|
30
30
|
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
|
|
31
31
|
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
|
|
32
|
+
import * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword'
|
|
32
33
|
import * as ComAtprotoAdminUpdateCommunicationTemplate from './types/com/atproto/admin/updateCommunicationTemplate'
|
|
33
34
|
import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus'
|
|
34
35
|
import * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials'
|
|
@@ -182,6 +183,7 @@ export * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRep
|
|
|
182
183
|
export * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
|
|
183
184
|
export * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
|
|
184
185
|
export * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
|
|
186
|
+
export * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword'
|
|
185
187
|
export * as ComAtprotoAdminUpdateCommunicationTemplate from './types/com/atproto/admin/updateCommunicationTemplate'
|
|
186
188
|
export * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus'
|
|
187
189
|
export * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials'
|
|
@@ -654,6 +656,17 @@ export class ComAtprotoAdminNS {
|
|
|
654
656
|
})
|
|
655
657
|
}
|
|
656
658
|
|
|
659
|
+
updateAccountPassword(
|
|
660
|
+
data?: ComAtprotoAdminUpdateAccountPassword.InputSchema,
|
|
661
|
+
opts?: ComAtprotoAdminUpdateAccountPassword.CallOptions,
|
|
662
|
+
): Promise<ComAtprotoAdminUpdateAccountPassword.Response> {
|
|
663
|
+
return this._service.xrpc
|
|
664
|
+
.call('com.atproto.admin.updateAccountPassword', opts?.qp, data, opts)
|
|
665
|
+
.catch((e) => {
|
|
666
|
+
throw ComAtprotoAdminUpdateAccountPassword.toKnownErr(e)
|
|
667
|
+
})
|
|
668
|
+
}
|
|
669
|
+
|
|
657
670
|
updateCommunicationTemplate(
|
|
658
671
|
data?: ComAtprotoAdminUpdateCommunicationTemplate.InputSchema,
|
|
659
672
|
opts?: ComAtprotoAdminUpdateCommunicationTemplate.CallOptions,
|
package/src/client/lexicons.ts
CHANGED
|
@@ -1863,6 +1863,33 @@ export const schemaDict = {
|
|
|
1863
1863
|
},
|
|
1864
1864
|
},
|
|
1865
1865
|
},
|
|
1866
|
+
ComAtprotoAdminUpdateAccountPassword: {
|
|
1867
|
+
lexicon: 1,
|
|
1868
|
+
id: 'com.atproto.admin.updateAccountPassword',
|
|
1869
|
+
defs: {
|
|
1870
|
+
main: {
|
|
1871
|
+
type: 'procedure',
|
|
1872
|
+
description:
|
|
1873
|
+
'Update the password for a user account as an administrator.',
|
|
1874
|
+
input: {
|
|
1875
|
+
encoding: 'application/json',
|
|
1876
|
+
schema: {
|
|
1877
|
+
type: 'object',
|
|
1878
|
+
required: ['did', 'password'],
|
|
1879
|
+
properties: {
|
|
1880
|
+
did: {
|
|
1881
|
+
type: 'string',
|
|
1882
|
+
format: 'did',
|
|
1883
|
+
},
|
|
1884
|
+
password: {
|
|
1885
|
+
type: 'string',
|
|
1886
|
+
},
|
|
1887
|
+
},
|
|
1888
|
+
},
|
|
1889
|
+
},
|
|
1890
|
+
},
|
|
1891
|
+
},
|
|
1892
|
+
},
|
|
1866
1893
|
ComAtprotoAdminUpdateCommunicationTemplate: {
|
|
1867
1894
|
lexicon: 1,
|
|
1868
1895
|
id: 'com.atproto.admin.updateCommunicationTemplate',
|
|
@@ -4840,7 +4867,7 @@ export const schemaDict = {
|
|
|
4840
4867
|
main: {
|
|
4841
4868
|
type: 'query',
|
|
4842
4869
|
description:
|
|
4843
|
-
'Fetch all labels from a labeler created after a certain date.
|
|
4870
|
+
'DEPRECATED: use queryLabels or subscribeLabels instead -- Fetch all labels from a labeler created after a certain date.',
|
|
4844
4871
|
parameters: {
|
|
4845
4872
|
type: 'params',
|
|
4846
4873
|
properties: {
|
|
@@ -5075,6 +5102,8 @@ export const schemaDict = {
|
|
|
5075
5102
|
'lex:app.bsky.actor.defs#feedViewPref',
|
|
5076
5103
|
'lex:app.bsky.actor.defs#threadViewPref',
|
|
5077
5104
|
'lex:app.bsky.actor.defs#interestsPref',
|
|
5105
|
+
'lex:app.bsky.actor.defs#mutedWordsPref',
|
|
5106
|
+
'lex:app.bsky.actor.defs#hiddenPostsPref',
|
|
5078
5107
|
],
|
|
5079
5108
|
},
|
|
5080
5109
|
},
|
|
@@ -8860,6 +8889,8 @@ export const ids = {
|
|
|
8860
8889
|
ComAtprotoAdminSendEmail: 'com.atproto.admin.sendEmail',
|
|
8861
8890
|
ComAtprotoAdminUpdateAccountEmail: 'com.atproto.admin.updateAccountEmail',
|
|
8862
8891
|
ComAtprotoAdminUpdateAccountHandle: 'com.atproto.admin.updateAccountHandle',
|
|
8892
|
+
ComAtprotoAdminUpdateAccountPassword:
|
|
8893
|
+
'com.atproto.admin.updateAccountPassword',
|
|
8863
8894
|
ComAtprotoAdminUpdateCommunicationTemplate:
|
|
8864
8895
|
'com.atproto.admin.updateCommunicationTemplate',
|
|
8865
8896
|
ComAtprotoAdminUpdateSubjectStatus: 'com.atproto.admin.updateSubjectStatus',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { Headers, XRPCError } from '@atproto/xrpc'
|
|
5
|
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
|
|
6
|
+
import { isObj, hasProp } from '../../../../util'
|
|
7
|
+
import { lexicons } from '../../../../lexicons'
|
|
8
|
+
import { CID } from 'multiformats/cid'
|
|
9
|
+
|
|
10
|
+
export interface QueryParams {}
|
|
11
|
+
|
|
12
|
+
export interface InputSchema {
|
|
13
|
+
did: string
|
|
14
|
+
password: string
|
|
15
|
+
[k: string]: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CallOptions {
|
|
19
|
+
headers?: Headers
|
|
20
|
+
qp?: QueryParams
|
|
21
|
+
encoding: 'application/json'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Response {
|
|
25
|
+
success: boolean
|
|
26
|
+
headers: Headers
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function toKnownErr(e: any) {
|
|
30
|
+
if (e instanceof XRPCError) {
|
|
31
|
+
}
|
|
32
|
+
return e
|
|
33
|
+
}
|
|
@@ -70,27 +70,25 @@ export function detectFacets(text: UnicodeString): Facet[] | undefined {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
{
|
|
73
|
-
const re = /(
|
|
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
|
-
|
|
81
|
-
if (tag.length > 66) continue
|
|
79
|
+
if (tag.length === 0 || tag.length > 64) continue
|
|
82
80
|
|
|
83
|
-
const index = match.index +
|
|
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),
|
|
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
|
|
91
|
+
tag: tag,
|
|
94
92
|
},
|
|
95
93
|
],
|
|
96
94
|
})
|
package/tests/bsky-agent.test.ts
CHANGED
|
@@ -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')).
|
|
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 #
|
|
248
|
-
['
|
|
249
|
-
[{ byteStart: 5, byteEnd:
|
|
248
|
+
'body #thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
249
|
+
['thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
|
|
250
|
+
[{ byteStart: 5, byteEnd: 70 }],
|
|
250
251
|
],
|
|
251
252
|
[
|
|
252
|
-
'body #
|
|
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) {
|