@atproto/api 0.6.15 → 0.6.16
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 +6 -0
- package/README.md +10 -2
- package/dist/bsky-agent.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +2 -2
- package/dist/moderation/subjects/feed-generator.d.ts +1 -1
- package/dist/moderation/subjects/user-list.d.ts +1 -1
- package/dist/types.d.ts +15 -3
- package/package.json +11 -4
- package/src/agent.ts +0 -1
- package/src/bsky-agent.ts +10 -8
- package/src/client/lexicons.ts +2 -1
- package/src/moderation/subjects/feed-generator.ts +2 -2
- package/src/moderation/subjects/user-list.ts +2 -2
- package/src/moderation/util.ts +1 -5
- package/src/rich-text/sanitization.ts +2 -0
- package/src/types.ts +25 -4
- package/tests/bsky-agent.test.ts +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ModerationSubjectFeedGenerator, ModerationDecision, ModerationOpts } from '../types';
|
|
2
|
-
export declare function decideFeedGenerator(
|
|
2
|
+
export declare function decideFeedGenerator(_subject: ModerationSubjectFeedGenerator, _opts: ModerationOpts): ModerationDecision;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ModerationSubjectUserList, ModerationOpts, ModerationDecision } from '../types';
|
|
2
|
-
export declare function decideUserList(
|
|
2
|
+
export declare function decideUserList(_subject: ModerationSubjectUserList, _opts: ModerationOpts): ModerationDecision;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LabelPreference } from './moderation/types';
|
|
2
|
-
import { AppBskyActorDefs } from './client';
|
|
3
2
|
export declare type AtpSessionEvent = 'create' | 'create-failed' | 'update' | 'expired';
|
|
4
3
|
export interface AtpSessionData {
|
|
5
4
|
refreshJwt: string;
|
|
@@ -34,13 +33,26 @@ export interface AtpAgentGlobalOpts {
|
|
|
34
33
|
fetch: AtpAgentFetchHandler;
|
|
35
34
|
}
|
|
36
35
|
export declare type BskyLabelPreference = LabelPreference | 'show';
|
|
36
|
+
export interface BskyFeedViewPreference {
|
|
37
|
+
hideReplies: boolean;
|
|
38
|
+
hideRepliesByUnfollowed: boolean;
|
|
39
|
+
hideRepliesByLikeCount: number;
|
|
40
|
+
hideReposts: boolean;
|
|
41
|
+
hideQuotePosts: boolean;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
export interface BskyThreadViewPreference {
|
|
45
|
+
sort: string;
|
|
46
|
+
prioritizeFollowedUsers: boolean;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
37
49
|
export interface BskyPreferences {
|
|
38
50
|
feeds: {
|
|
39
51
|
saved?: string[];
|
|
40
52
|
pinned?: string[];
|
|
41
53
|
};
|
|
42
|
-
feedViewPrefs: Record<string,
|
|
43
|
-
threadViewPrefs:
|
|
54
|
+
feedViewPrefs: Record<string, BskyFeedViewPreference>;
|
|
55
|
+
threadViewPrefs: BskyThreadViewPreference;
|
|
44
56
|
adultContentEnabled: boolean;
|
|
45
57
|
contentLabels: Record<string, BskyLabelPreference>;
|
|
46
58
|
birthDate: Date | undefined;
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/api",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"main": "dist/index.js",
|
|
3
|
+
"version": "0.6.16",
|
|
5
4
|
"license": "MIT",
|
|
5
|
+
"description": "Client library for atproto and Bluesky",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"atproto",
|
|
8
|
+
"bluesky",
|
|
9
|
+
"api"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://atproto.com",
|
|
6
12
|
"repository": {
|
|
7
13
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/bluesky-social/atproto
|
|
14
|
+
"url": "https://github.com/bluesky-social/atproto",
|
|
9
15
|
"directory": "packages/api"
|
|
10
16
|
},
|
|
17
|
+
"main": "dist/index.js",
|
|
11
18
|
"dependencies": {
|
|
12
19
|
"multiformats": "^9.9.0",
|
|
13
20
|
"tlds": "^1.234.0",
|
|
@@ -20,7 +27,7 @@
|
|
|
20
27
|
"devDependencies": {
|
|
21
28
|
"common-tags": "^1.8.2",
|
|
22
29
|
"@atproto/lex-cli": "^0.2.1",
|
|
23
|
-
"@atproto/pds": "^0.1.
|
|
30
|
+
"@atproto/pds": "^0.1.16"
|
|
24
31
|
},
|
|
25
32
|
"scripts": {
|
|
26
33
|
"codegen": "pnpm docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
|
package/src/agent.ts
CHANGED
package/src/bsky-agent.ts
CHANGED
|
@@ -6,7 +6,12 @@ import {
|
|
|
6
6
|
AppBskyActorDefs,
|
|
7
7
|
ComAtprotoRepoPutRecord,
|
|
8
8
|
} from './client'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
BskyPreferences,
|
|
11
|
+
BskyLabelPreference,
|
|
12
|
+
BskyFeedViewPreference,
|
|
13
|
+
BskyThreadViewPreference,
|
|
14
|
+
} from './types'
|
|
10
15
|
|
|
11
16
|
const FEED_VIEW_PREF_DEFAULTS = {
|
|
12
17
|
hideReplies: false,
|
|
@@ -311,12 +316,14 @@ export class BskyAgent extends AtpAgent {
|
|
|
311
316
|
AppBskyActorDefs.isFeedViewPref(pref) &&
|
|
312
317
|
AppBskyActorDefs.validateFeedViewPref(pref).success
|
|
313
318
|
) {
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
314
320
|
const { $type, feed, ...v } = pref
|
|
315
321
|
prefs.feedViewPrefs[pref.feed] = { ...FEED_VIEW_PREF_DEFAULTS, ...v }
|
|
316
322
|
} else if (
|
|
317
323
|
AppBskyActorDefs.isThreadViewPref(pref) &&
|
|
318
324
|
AppBskyActorDefs.validateThreadViewPref(pref).success
|
|
319
325
|
) {
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
320
327
|
const { $type, ...v } = pref
|
|
321
328
|
prefs.threadViewPrefs = { ...prefs.threadViewPrefs, ...v }
|
|
322
329
|
}
|
|
@@ -437,10 +444,7 @@ export class BskyAgent extends AtpAgent {
|
|
|
437
444
|
})
|
|
438
445
|
}
|
|
439
446
|
|
|
440
|
-
async setFeedViewPrefs(
|
|
441
|
-
feed: string,
|
|
442
|
-
pref: Omit<AppBskyActorDefs.FeedViewPref, '$type' | 'feed'>,
|
|
443
|
-
) {
|
|
447
|
+
async setFeedViewPrefs(feed: string, pref: Partial<BskyFeedViewPreference>) {
|
|
444
448
|
await updatePreferences(this, (prefs: AppBskyActorDefs.Preferences) => {
|
|
445
449
|
const existing = prefs.findLast(
|
|
446
450
|
(pref) =>
|
|
@@ -459,9 +463,7 @@ export class BskyAgent extends AtpAgent {
|
|
|
459
463
|
})
|
|
460
464
|
}
|
|
461
465
|
|
|
462
|
-
async setThreadViewPrefs(
|
|
463
|
-
pref: Omit<AppBskyActorDefs.ThreadViewPref, '$type'>,
|
|
464
|
-
) {
|
|
466
|
+
async setThreadViewPrefs(pref: Partial<BskyThreadViewPreference>) {
|
|
465
467
|
await updatePreferences(this, (prefs: AppBskyActorDefs.Preferences) => {
|
|
466
468
|
const existing = prefs.findLast(
|
|
467
469
|
(pref) =>
|
package/src/client/lexicons.ts
CHANGED
|
@@ -6838,7 +6838,8 @@ export const schemaDict = {
|
|
|
6838
6838
|
defs: {
|
|
6839
6839
|
main: {
|
|
6840
6840
|
type: 'query',
|
|
6841
|
-
description:
|
|
6841
|
+
description:
|
|
6842
|
+
'DEPRECATED: will be removed soon, please find a feed generator alternative',
|
|
6842
6843
|
parameters: {
|
|
6843
6844
|
type: 'params',
|
|
6844
6845
|
properties: {
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
} from '../types'
|
|
6
6
|
|
|
7
7
|
export function decideFeedGenerator(
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
_subject: ModerationSubjectFeedGenerator,
|
|
9
|
+
_opts: ModerationOpts,
|
|
10
10
|
): ModerationDecision {
|
|
11
11
|
// TODO handle labels applied on the feed generator itself
|
|
12
12
|
return ModerationDecision.noop()
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
} from '../types'
|
|
6
6
|
|
|
7
7
|
export function decideUserList(
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
_subject: ModerationSubjectUserList,
|
|
9
|
+
_opts: ModerationOpts,
|
|
10
10
|
): ModerationDecision {
|
|
11
11
|
// TODO handle labels applied on the list itself
|
|
12
12
|
return ModerationDecision.noop()
|
package/src/moderation/util.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AppBskyEmbedRecord,
|
|
3
|
-
AppBskyEmbedRecordWithMedia,
|
|
4
|
-
AppBskyFeedPost,
|
|
5
|
-
} from '../client'
|
|
1
|
+
import { AppBskyEmbedRecord, AppBskyEmbedRecordWithMedia } from '../client'
|
|
6
2
|
import { ModerationDecision, ModerationUI } from './types'
|
|
7
3
|
|
|
8
4
|
export function takeHighestPriorityDecision(
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { RichText } from './rich-text'
|
|
2
2
|
import { UnicodeString } from './unicode'
|
|
3
3
|
|
|
4
|
+
// this regex is intentionally matching on the zero-with-separator codepoint
|
|
5
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
4
6
|
const EXCESS_SPACE_RE = /[\r\n]([\u00AD\u2060\u200D\u200C\u200B\s]*[\r\n]){2,}/
|
|
5
7
|
const REPLACEMENT_STR = '\n\n'
|
|
6
8
|
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LabelPreference } from './moderation/types'
|
|
2
|
-
import { AppBskyActorDefs } from './client'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Used by the PersistSessionHandler to indicate what change occurred
|
|
@@ -81,15 +80,37 @@ export type BskyLabelPreference = LabelPreference | 'show'
|
|
|
81
80
|
// TEMP we need to permanently convert 'show' to 'ignore', for now we manually convert -prf
|
|
82
81
|
|
|
83
82
|
/**
|
|
84
|
-
* Bluesky preferences
|
|
83
|
+
* Bluesky feed view preferences
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
export interface BskyFeedViewPreference {
|
|
87
|
+
hideReplies: boolean
|
|
88
|
+
hideRepliesByUnfollowed: boolean
|
|
89
|
+
hideRepliesByLikeCount: number
|
|
90
|
+
hideReposts: boolean
|
|
91
|
+
hideQuotePosts: boolean
|
|
92
|
+
[key: string]: any
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Bluesky thread view preferences
|
|
97
|
+
*/
|
|
98
|
+
export interface BskyThreadViewPreference {
|
|
99
|
+
sort: string
|
|
100
|
+
prioritizeFollowedUsers: boolean
|
|
101
|
+
[key: string]: any
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Bluesky preferences
|
|
85
106
|
*/
|
|
86
107
|
export interface BskyPreferences {
|
|
87
108
|
feeds: {
|
|
88
109
|
saved?: string[]
|
|
89
110
|
pinned?: string[]
|
|
90
111
|
}
|
|
91
|
-
feedViewPrefs: Record<string,
|
|
92
|
-
threadViewPrefs:
|
|
112
|
+
feedViewPrefs: Record<string, BskyFeedViewPreference>
|
|
113
|
+
threadViewPrefs: BskyThreadViewPreference
|
|
93
114
|
adultContentEnabled: boolean
|
|
94
115
|
contentLabels: Record<string, BskyLabelPreference>
|
|
95
116
|
birthDate: Date | undefined
|
package/tests/bsky-agent.test.ts
CHANGED
|
@@ -67,7 +67,7 @@ describe('agent', () => {
|
|
|
67
67
|
|
|
68
68
|
let hasConflicted = false
|
|
69
69
|
let ranTwice = false
|
|
70
|
-
await agent.upsertProfile(async (
|
|
70
|
+
await agent.upsertProfile(async (_existing) => {
|
|
71
71
|
if (!hasConflicted) {
|
|
72
72
|
await agent.com.atproto.repo.putRecord({
|
|
73
73
|
repo: agent.session?.did || '',
|
|
@@ -104,7 +104,7 @@ describe('agent', () => {
|
|
|
104
104
|
const profile1 = await agent.getProfile({ actor: agent.session?.did || '' })
|
|
105
105
|
expect(profile1.data.displayName).toBeFalsy()
|
|
106
106
|
|
|
107
|
-
const p = agent.upsertProfile(async (
|
|
107
|
+
const p = agent.upsertProfile(async (_existing) => {
|
|
108
108
|
await agent.com.atproto.repo.putRecord({
|
|
109
109
|
repo: agent.session?.did || '',
|
|
110
110
|
collection: 'app.bsky.actor.profile',
|
|
@@ -130,7 +130,7 @@ describe('agent', () => {
|
|
|
130
130
|
password: 'password',
|
|
131
131
|
})
|
|
132
132
|
|
|
133
|
-
const p = agent.upsertProfile((
|
|
133
|
+
const p = agent.upsertProfile((_existing) => {
|
|
134
134
|
return {
|
|
135
135
|
displayName: { string: 'Bob' },
|
|
136
136
|
} as unknown as AppBskyActorProfile.Record
|