@atproto/api 0.6.13 → 0.6.15
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 +15 -0
- package/LICENSE +1 -1
- package/dist/bsky-agent.d.ts +3 -1
- package/dist/client/lexicons.d.ts +46 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts +19 -1
- package/dist/client/types/app/bsky/feed/threadgate.d.ts +2 -0
- package/dist/index.js +109 -4
- package/dist/index.js.map +2 -2
- package/dist/types.d.ts +3 -0
- package/package.json +6 -6
- package/src/bsky-agent.ts +70 -0
- package/src/client/lexicons.ts +51 -0
- package/src/client/types/app/bsky/actor/defs.ts +50 -0
- package/src/client/types/app/bsky/feed/threadgate.ts +6 -2
- package/src/types.ts +3 -0
- package/tests/bsky-agent.test.ts +491 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atproto/api
|
|
2
2
|
|
|
3
|
+
## 0.6.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1639](https://github.com/bluesky-social/atproto/pull/1639) [`2cc329f2`](https://github.com/bluesky-social/atproto/commit/2cc329f26547217dd94b6bb11ee590d707cbd14f) Thanks [@pfrazee](https://github.com/pfrazee)! - Added new preferences for feed and thread view behaviors.
|
|
8
|
+
|
|
9
|
+
## 0.6.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`b1dc3555`](https://github.com/bluesky-social/atproto/commit/b1dc355504f9f2e047093dc56682b8034518cf80)]:
|
|
14
|
+
- @atproto/syntax@0.1.1
|
|
15
|
+
- @atproto/lexicon@0.2.1
|
|
16
|
+
- @atproto/xrpc@0.3.1
|
|
17
|
+
|
|
3
18
|
## 0.6.13
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/LICENSE
CHANGED
package/dist/bsky-agent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AtpAgent } from './agent';
|
|
2
|
-
import { AppBskyFeedPost, AppBskyActorProfile } from './client';
|
|
2
|
+
import { AppBskyFeedPost, AppBskyActorProfile, AppBskyActorDefs } from './client';
|
|
3
3
|
import { BskyPreferences, BskyLabelPreference } from './types';
|
|
4
4
|
declare global {
|
|
5
5
|
interface Array<T> {
|
|
@@ -75,4 +75,6 @@ export declare class BskyAgent extends AtpAgent {
|
|
|
75
75
|
setPersonalDetails({ birthDate, }: {
|
|
76
76
|
birthDate: string | Date | undefined;
|
|
77
77
|
}): Promise<void>;
|
|
78
|
+
setFeedViewPrefs(feed: string, pref: Omit<AppBskyActorDefs.FeedViewPref, '$type' | 'feed'>): Promise<void>;
|
|
79
|
+
setThreadViewPrefs(pref: Omit<AppBskyActorDefs.ThreadViewPref, '$type'>): Promise<void>;
|
|
78
80
|
}
|
|
@@ -3472,6 +3472,50 @@ export declare const schemaDict: {
|
|
|
3472
3472
|
};
|
|
3473
3473
|
};
|
|
3474
3474
|
};
|
|
3475
|
+
feedViewPref: {
|
|
3476
|
+
type: string;
|
|
3477
|
+
required: string[];
|
|
3478
|
+
properties: {
|
|
3479
|
+
feed: {
|
|
3480
|
+
type: string;
|
|
3481
|
+
description: string;
|
|
3482
|
+
};
|
|
3483
|
+
hideReplies: {
|
|
3484
|
+
type: string;
|
|
3485
|
+
description: string;
|
|
3486
|
+
};
|
|
3487
|
+
hideRepliesByUnfollowed: {
|
|
3488
|
+
type: string;
|
|
3489
|
+
description: string;
|
|
3490
|
+
};
|
|
3491
|
+
hideRepliesByLikeCount: {
|
|
3492
|
+
type: string;
|
|
3493
|
+
description: string;
|
|
3494
|
+
};
|
|
3495
|
+
hideReposts: {
|
|
3496
|
+
type: string;
|
|
3497
|
+
description: string;
|
|
3498
|
+
};
|
|
3499
|
+
hideQuotePosts: {
|
|
3500
|
+
type: string;
|
|
3501
|
+
description: string;
|
|
3502
|
+
};
|
|
3503
|
+
};
|
|
3504
|
+
};
|
|
3505
|
+
threadViewPref: {
|
|
3506
|
+
type: string;
|
|
3507
|
+
properties: {
|
|
3508
|
+
sort: {
|
|
3509
|
+
type: string;
|
|
3510
|
+
description: string;
|
|
3511
|
+
knownValues: string[];
|
|
3512
|
+
};
|
|
3513
|
+
prioritizeFollowedUsers: {
|
|
3514
|
+
type: string;
|
|
3515
|
+
description: string;
|
|
3516
|
+
};
|
|
3517
|
+
};
|
|
3518
|
+
};
|
|
3475
3519
|
};
|
|
3476
3520
|
};
|
|
3477
3521
|
AppBskyActorGetPreferences: {
|
|
@@ -5342,10 +5386,12 @@ export declare const schemaDict: {
|
|
|
5342
5386
|
mentionRule: {
|
|
5343
5387
|
type: string;
|
|
5344
5388
|
description: string;
|
|
5389
|
+
properties: {};
|
|
5345
5390
|
};
|
|
5346
5391
|
followingRule: {
|
|
5347
5392
|
type: string;
|
|
5348
5393
|
description: string;
|
|
5394
|
+
properties: {};
|
|
5349
5395
|
};
|
|
5350
5396
|
listRule: {
|
|
5351
5397
|
type: string;
|
|
@@ -53,7 +53,7 @@ export interface ViewerState {
|
|
|
53
53
|
}
|
|
54
54
|
export declare function isViewerState(v: unknown): v is ViewerState;
|
|
55
55
|
export declare function validateViewerState(v: unknown): ValidationResult;
|
|
56
|
-
export declare type Preferences = (AdultContentPref | ContentLabelPref | SavedFeedsPref | PersonalDetailsPref | {
|
|
56
|
+
export declare type Preferences = (AdultContentPref | ContentLabelPref | SavedFeedsPref | PersonalDetailsPref | FeedViewPref | ThreadViewPref | {
|
|
57
57
|
$type: string;
|
|
58
58
|
[k: string]: unknown;
|
|
59
59
|
})[];
|
|
@@ -83,3 +83,21 @@ export interface PersonalDetailsPref {
|
|
|
83
83
|
}
|
|
84
84
|
export declare function isPersonalDetailsPref(v: unknown): v is PersonalDetailsPref;
|
|
85
85
|
export declare function validatePersonalDetailsPref(v: unknown): ValidationResult;
|
|
86
|
+
export interface FeedViewPref {
|
|
87
|
+
feed: string;
|
|
88
|
+
hideReplies?: boolean;
|
|
89
|
+
hideRepliesByUnfollowed?: boolean;
|
|
90
|
+
hideRepliesByLikeCount?: number;
|
|
91
|
+
hideReposts?: boolean;
|
|
92
|
+
hideQuotePosts?: boolean;
|
|
93
|
+
[k: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
export declare function isFeedViewPref(v: unknown): v is FeedViewPref;
|
|
96
|
+
export declare function validateFeedViewPref(v: unknown): ValidationResult;
|
|
97
|
+
export interface ThreadViewPref {
|
|
98
|
+
sort?: 'oldest' | 'newest' | 'most-likes' | 'random' | (string & {});
|
|
99
|
+
prioritizeFollowedUsers?: boolean;
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
export declare function isThreadViewPref(v: unknown): v is ThreadViewPref;
|
|
103
|
+
export declare function validateThreadViewPref(v: unknown): ValidationResult;
|
|
@@ -11,10 +11,12 @@ export interface Record {
|
|
|
11
11
|
export declare function isRecord(v: unknown): v is Record;
|
|
12
12
|
export declare function validateRecord(v: unknown): ValidationResult;
|
|
13
13
|
export interface MentionRule {
|
|
14
|
+
[k: string]: unknown;
|
|
14
15
|
}
|
|
15
16
|
export declare function isMentionRule(v: unknown): v is MentionRule;
|
|
16
17
|
export declare function validateMentionRule(v: unknown): ValidationResult;
|
|
17
18
|
export interface FollowingRule {
|
|
19
|
+
[k: string]: unknown;
|
|
18
20
|
}
|
|
19
21
|
export declare function isFollowingRule(v: unknown): v is FollowingRule;
|
|
20
22
|
export declare function validateFollowingRule(v: unknown): ValidationResult;
|
package/dist/index.js
CHANGED
|
@@ -14891,7 +14891,7 @@ var lexObject = z.object({
|
|
|
14891
14891
|
description: z.string().optional(),
|
|
14892
14892
|
required: z.string().array().optional(),
|
|
14893
14893
|
nullable: z.string().array().optional(),
|
|
14894
|
-
properties: z.record(z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]))
|
|
14894
|
+
properties: z.record(z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]))
|
|
14895
14895
|
}).strict().superRefine(requiredPropertiesRefinement);
|
|
14896
14896
|
var lexXrpcParameters = z.object({
|
|
14897
14897
|
type: z.literal("params"),
|
|
@@ -19247,7 +19247,9 @@ var schemaDict = {
|
|
|
19247
19247
|
"lex:app.bsky.actor.defs#adultContentPref",
|
|
19248
19248
|
"lex:app.bsky.actor.defs#contentLabelPref",
|
|
19249
19249
|
"lex:app.bsky.actor.defs#savedFeedsPref",
|
|
19250
|
-
"lex:app.bsky.actor.defs#personalDetailsPref"
|
|
19250
|
+
"lex:app.bsky.actor.defs#personalDetailsPref",
|
|
19251
|
+
"lex:app.bsky.actor.defs#feedViewPref",
|
|
19252
|
+
"lex:app.bsky.actor.defs#threadViewPref"
|
|
19251
19253
|
]
|
|
19252
19254
|
}
|
|
19253
19255
|
},
|
|
@@ -19303,6 +19305,50 @@ var schemaDict = {
|
|
|
19303
19305
|
description: "The birth date of the owner of the account."
|
|
19304
19306
|
}
|
|
19305
19307
|
}
|
|
19308
|
+
},
|
|
19309
|
+
feedViewPref: {
|
|
19310
|
+
type: "object",
|
|
19311
|
+
required: ["feed"],
|
|
19312
|
+
properties: {
|
|
19313
|
+
feed: {
|
|
19314
|
+
type: "string",
|
|
19315
|
+
description: "The URI of the feed, or an identifier which describes the feed."
|
|
19316
|
+
},
|
|
19317
|
+
hideReplies: {
|
|
19318
|
+
type: "boolean",
|
|
19319
|
+
description: "Hide replies in the feed."
|
|
19320
|
+
},
|
|
19321
|
+
hideRepliesByUnfollowed: {
|
|
19322
|
+
type: "boolean",
|
|
19323
|
+
description: "Hide replies in the feed if they are not by followed users."
|
|
19324
|
+
},
|
|
19325
|
+
hideRepliesByLikeCount: {
|
|
19326
|
+
type: "integer",
|
|
19327
|
+
description: "Hide replies in the feed if they do not have this number of likes."
|
|
19328
|
+
},
|
|
19329
|
+
hideReposts: {
|
|
19330
|
+
type: "boolean",
|
|
19331
|
+
description: "Hide reposts in the feed."
|
|
19332
|
+
},
|
|
19333
|
+
hideQuotePosts: {
|
|
19334
|
+
type: "boolean",
|
|
19335
|
+
description: "Hide quote posts in the feed."
|
|
19336
|
+
}
|
|
19337
|
+
}
|
|
19338
|
+
},
|
|
19339
|
+
threadViewPref: {
|
|
19340
|
+
type: "object",
|
|
19341
|
+
properties: {
|
|
19342
|
+
sort: {
|
|
19343
|
+
type: "string",
|
|
19344
|
+
description: "Sorting mode.",
|
|
19345
|
+
knownValues: ["oldest", "newest", "most-likes", "random"]
|
|
19346
|
+
},
|
|
19347
|
+
prioritizeFollowedUsers: {
|
|
19348
|
+
type: "boolean",
|
|
19349
|
+
description: "Show followed users at the top of all replies."
|
|
19350
|
+
}
|
|
19351
|
+
}
|
|
19306
19352
|
}
|
|
19307
19353
|
}
|
|
19308
19354
|
},
|
|
@@ -21243,11 +21289,13 @@ var schemaDict = {
|
|
|
21243
21289
|
},
|
|
21244
21290
|
mentionRule: {
|
|
21245
21291
|
type: "object",
|
|
21246
|
-
description: "Allow replies from actors mentioned in your post."
|
|
21292
|
+
description: "Allow replies from actors mentioned in your post.",
|
|
21293
|
+
properties: {}
|
|
21247
21294
|
},
|
|
21248
21295
|
followingRule: {
|
|
21249
21296
|
type: "object",
|
|
21250
|
-
description: "Allow replies from actors you follow."
|
|
21297
|
+
description: "Allow replies from actors you follow.",
|
|
21298
|
+
properties: {}
|
|
21251
21299
|
},
|
|
21252
21300
|
listRule: {
|
|
21253
21301
|
type: "object",
|
|
@@ -24264,19 +24312,23 @@ var defs_exports5 = {};
|
|
|
24264
24312
|
__export(defs_exports5, {
|
|
24265
24313
|
isAdultContentPref: () => isAdultContentPref,
|
|
24266
24314
|
isContentLabelPref: () => isContentLabelPref,
|
|
24315
|
+
isFeedViewPref: () => isFeedViewPref,
|
|
24267
24316
|
isPersonalDetailsPref: () => isPersonalDetailsPref,
|
|
24268
24317
|
isProfileView: () => isProfileView,
|
|
24269
24318
|
isProfileViewBasic: () => isProfileViewBasic,
|
|
24270
24319
|
isProfileViewDetailed: () => isProfileViewDetailed,
|
|
24271
24320
|
isSavedFeedsPref: () => isSavedFeedsPref,
|
|
24321
|
+
isThreadViewPref: () => isThreadViewPref,
|
|
24272
24322
|
isViewerState: () => isViewerState,
|
|
24273
24323
|
validateAdultContentPref: () => validateAdultContentPref,
|
|
24274
24324
|
validateContentLabelPref: () => validateContentLabelPref,
|
|
24325
|
+
validateFeedViewPref: () => validateFeedViewPref,
|
|
24275
24326
|
validatePersonalDetailsPref: () => validatePersonalDetailsPref,
|
|
24276
24327
|
validateProfileView: () => validateProfileView,
|
|
24277
24328
|
validateProfileViewBasic: () => validateProfileViewBasic,
|
|
24278
24329
|
validateProfileViewDetailed: () => validateProfileViewDetailed,
|
|
24279
24330
|
validateSavedFeedsPref: () => validateSavedFeedsPref,
|
|
24331
|
+
validateThreadViewPref: () => validateThreadViewPref,
|
|
24280
24332
|
validateViewerState: () => validateViewerState
|
|
24281
24333
|
});
|
|
24282
24334
|
function isProfileViewBasic(v) {
|
|
@@ -24327,6 +24379,18 @@ function isPersonalDetailsPref(v) {
|
|
|
24327
24379
|
function validatePersonalDetailsPref(v) {
|
|
24328
24380
|
return lexicons.validate("app.bsky.actor.defs#personalDetailsPref", v);
|
|
24329
24381
|
}
|
|
24382
|
+
function isFeedViewPref(v) {
|
|
24383
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.actor.defs#feedViewPref";
|
|
24384
|
+
}
|
|
24385
|
+
function validateFeedViewPref(v) {
|
|
24386
|
+
return lexicons.validate("app.bsky.actor.defs#feedViewPref", v);
|
|
24387
|
+
}
|
|
24388
|
+
function isThreadViewPref(v) {
|
|
24389
|
+
return isObj2(v) && hasProp2(v, "$type") && v.$type === "app.bsky.actor.defs#threadViewPref";
|
|
24390
|
+
}
|
|
24391
|
+
function validateThreadViewPref(v) {
|
|
24392
|
+
return lexicons.validate("app.bsky.actor.defs#threadViewPref", v);
|
|
24393
|
+
}
|
|
24330
24394
|
|
|
24331
24395
|
// src/client/types/app/bsky/actor/profile.ts
|
|
24332
24396
|
var profile_exports = {};
|
|
@@ -29194,6 +29258,17 @@ var LABEL_GROUPS = {
|
|
|
29194
29258
|
};
|
|
29195
29259
|
|
|
29196
29260
|
// src/bsky-agent.ts
|
|
29261
|
+
var FEED_VIEW_PREF_DEFAULTS = {
|
|
29262
|
+
hideReplies: false,
|
|
29263
|
+
hideRepliesByUnfollowed: false,
|
|
29264
|
+
hideRepliesByLikeCount: 0,
|
|
29265
|
+
hideReposts: false,
|
|
29266
|
+
hideQuotePosts: false
|
|
29267
|
+
};
|
|
29268
|
+
var THREAD_VIEW_PREF_DEFAULTS = {
|
|
29269
|
+
sort: "oldest",
|
|
29270
|
+
prioritizeFollowedUsers: true
|
|
29271
|
+
};
|
|
29197
29272
|
var BskyAgent = class extends AtpAgent {
|
|
29198
29273
|
constructor() {
|
|
29199
29274
|
super(...arguments);
|
|
@@ -29348,6 +29423,12 @@ var BskyAgent = class extends AtpAgent {
|
|
|
29348
29423
|
saved: void 0,
|
|
29349
29424
|
pinned: void 0
|
|
29350
29425
|
},
|
|
29426
|
+
feedViewPrefs: {
|
|
29427
|
+
home: {
|
|
29428
|
+
...FEED_VIEW_PREF_DEFAULTS
|
|
29429
|
+
}
|
|
29430
|
+
},
|
|
29431
|
+
threadViewPrefs: { ...THREAD_VIEW_PREF_DEFAULTS },
|
|
29351
29432
|
adultContentEnabled: false,
|
|
29352
29433
|
contentLabels: {},
|
|
29353
29434
|
birthDate: void 0
|
|
@@ -29371,6 +29452,12 @@ var BskyAgent = class extends AtpAgent {
|
|
|
29371
29452
|
if (pref.birthDate) {
|
|
29372
29453
|
prefs.birthDate = new Date(pref.birthDate);
|
|
29373
29454
|
}
|
|
29455
|
+
} else if (defs_exports5.isFeedViewPref(pref) && defs_exports5.validateFeedViewPref(pref).success) {
|
|
29456
|
+
const { $type, feed, ...v } = pref;
|
|
29457
|
+
prefs.feedViewPrefs[pref.feed] = { ...FEED_VIEW_PREF_DEFAULTS, ...v };
|
|
29458
|
+
} else if (defs_exports5.isThreadViewPref(pref) && defs_exports5.validateThreadViewPref(pref).success) {
|
|
29459
|
+
const { $type, ...v } = pref;
|
|
29460
|
+
prefs.threadViewPrefs = { ...prefs.threadViewPrefs, ...v };
|
|
29374
29461
|
}
|
|
29375
29462
|
}
|
|
29376
29463
|
return prefs;
|
|
@@ -29454,6 +29541,24 @@ var BskyAgent = class extends AtpAgent {
|
|
|
29454
29541
|
return prefs.filter((pref) => !defs_exports5.isPersonalDetailsPref(pref)).concat([personalDetailsPref]);
|
|
29455
29542
|
});
|
|
29456
29543
|
}
|
|
29544
|
+
async setFeedViewPrefs(feed, pref) {
|
|
29545
|
+
await updatePreferences(this, (prefs) => {
|
|
29546
|
+
const existing = prefs.findLast((pref2) => defs_exports5.isFeedViewPref(pref2) && defs_exports5.validateFeedViewPref(pref2).success && pref2.feed === feed);
|
|
29547
|
+
if (existing) {
|
|
29548
|
+
pref = { ...existing, ...pref };
|
|
29549
|
+
}
|
|
29550
|
+
return prefs.filter((p) => !defs_exports5.isFeedViewPref(pref) || p.feed !== feed).concat([{ ...pref, $type: "app.bsky.actor.defs#feedViewPref", feed }]);
|
|
29551
|
+
});
|
|
29552
|
+
}
|
|
29553
|
+
async setThreadViewPrefs(pref) {
|
|
29554
|
+
await updatePreferences(this, (prefs) => {
|
|
29555
|
+
const existing = prefs.findLast((pref2) => defs_exports5.isThreadViewPref(pref2) && defs_exports5.validateThreadViewPref(pref2).success);
|
|
29556
|
+
if (existing) {
|
|
29557
|
+
pref = { ...existing, ...pref };
|
|
29558
|
+
}
|
|
29559
|
+
return prefs.filter((p) => !defs_exports5.isThreadViewPref(p)).concat([{ ...pref, $type: "app.bsky.actor.defs#threadViewPref" }]);
|
|
29560
|
+
});
|
|
29561
|
+
}
|
|
29457
29562
|
};
|
|
29458
29563
|
async function updatePreferences(agent, cb) {
|
|
29459
29564
|
const res = await agent.app.bsky.actor.getPreferences({});
|