@atproto/api 0.13.6 → 0.13.7
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 +11 -0
- package/dist/agent.d.ts +9 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +62 -0
- package/dist/agent.js.map +1 -1
- package/dist/client/lexicons.d.ts +44 -0
- package/dist/client/lexicons.d.ts.map +1 -1
- package/dist/client/lexicons.js +44 -0
- package/dist/client/lexicons.js.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.d.ts +14 -0
- package/dist/client/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/client/types/app/bsky/actor/defs.js +9 -1
- package/dist/client/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/client/types/tools/ozone/moderation/defs.d.ts +2 -0
- package/dist/client/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/client/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/client/types/tools/ozone/moderation/queryStatuses.d.ts +3 -0
- package/dist/client/types/tools/ozone/moderation/queryStatuses.d.ts.map +1 -1
- package/dist/client/types/tools/ozone/moderation/queryStatuses.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/util.d.ts +19 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +17 -1
- package/dist/util.js.map +1 -1
- package/package.json +3 -2
- package/src/agent.ts +80 -1
- package/src/client/lexicons.ts +48 -0
- package/src/client/types/app/bsky/actor/defs.ts +23 -0
- package/src/client/types/tools/ozone/moderation/defs.ts +2 -0
- package/src/client/types/tools/ozone/moderation/queryStatuses.ts +3 -0
- package/src/types.ts +1 -0
- package/src/util.ts +15 -0
- package/tests/bsky-agent.test.ts +91 -0
- package/tests/moderation-prefs.test.ts +4 -0
|
@@ -9,6 +9,9 @@ import { CID } from 'multiformats/cid'
|
|
|
9
9
|
import * as ToolsOzoneModerationDefs from './defs'
|
|
10
10
|
|
|
11
11
|
export interface QueryParams {
|
|
12
|
+
/** All subjects belonging to the account specified in the 'subject' param will be returned. */
|
|
13
|
+
includeAllUserRecords?: boolean
|
|
14
|
+
/** The subject to get the status for. */
|
|
12
15
|
subject?: string
|
|
13
16
|
/** Search subjects by keyword from comments */
|
|
14
17
|
comment?: string
|
package/src/types.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AtUri } from '@atproto/syntax'
|
|
2
2
|
import { TID } from '@atproto/common-web'
|
|
3
|
+
import zod from 'zod'
|
|
3
4
|
|
|
5
|
+
import { Nux } from './client/types/app/bsky/actor/defs'
|
|
4
6
|
import { AppBskyActorDefs } from './client'
|
|
5
7
|
|
|
6
8
|
export function sanitizeMutedWordValue(value: string) {
|
|
@@ -94,3 +96,16 @@ export const asDid = (value: string): Did => {
|
|
|
94
96
|
if (isDid(value)) return value
|
|
95
97
|
throw new TypeError(`Invalid DID: ${value}`)
|
|
96
98
|
}
|
|
99
|
+
|
|
100
|
+
export const nuxSchema = zod
|
|
101
|
+
.object({
|
|
102
|
+
id: zod.string().max(64),
|
|
103
|
+
completed: zod.boolean(),
|
|
104
|
+
data: zod.string().max(300).optional(),
|
|
105
|
+
expiresAt: zod.string().datetime().optional(),
|
|
106
|
+
})
|
|
107
|
+
.strict()
|
|
108
|
+
|
|
109
|
+
export function validateNux(nux: Nux) {
|
|
110
|
+
nuxSchema.parse(nux)
|
|
111
|
+
}
|
package/tests/bsky-agent.test.ts
CHANGED
|
@@ -276,6 +276,7 @@ describe('agent', () => {
|
|
|
276
276
|
bskyAppState: {
|
|
277
277
|
activeProgressGuide: undefined,
|
|
278
278
|
queuedNudges: [],
|
|
279
|
+
nuxs: [],
|
|
279
280
|
},
|
|
280
281
|
})
|
|
281
282
|
|
|
@@ -317,6 +318,7 @@ describe('agent', () => {
|
|
|
317
318
|
bskyAppState: {
|
|
318
319
|
activeProgressGuide: undefined,
|
|
319
320
|
queuedNudges: [],
|
|
321
|
+
nuxs: [],
|
|
320
322
|
},
|
|
321
323
|
})
|
|
322
324
|
|
|
@@ -358,6 +360,7 @@ describe('agent', () => {
|
|
|
358
360
|
bskyAppState: {
|
|
359
361
|
activeProgressGuide: undefined,
|
|
360
362
|
queuedNudges: [],
|
|
363
|
+
nuxs: [],
|
|
361
364
|
},
|
|
362
365
|
})
|
|
363
366
|
|
|
@@ -399,6 +402,7 @@ describe('agent', () => {
|
|
|
399
402
|
bskyAppState: {
|
|
400
403
|
activeProgressGuide: undefined,
|
|
401
404
|
queuedNudges: [],
|
|
405
|
+
nuxs: [],
|
|
402
406
|
},
|
|
403
407
|
})
|
|
404
408
|
|
|
@@ -444,6 +448,7 @@ describe('agent', () => {
|
|
|
444
448
|
bskyAppState: {
|
|
445
449
|
activeProgressGuide: undefined,
|
|
446
450
|
queuedNudges: [],
|
|
451
|
+
nuxs: [],
|
|
447
452
|
},
|
|
448
453
|
})
|
|
449
454
|
|
|
@@ -492,6 +497,7 @@ describe('agent', () => {
|
|
|
492
497
|
bskyAppState: {
|
|
493
498
|
activeProgressGuide: undefined,
|
|
494
499
|
queuedNudges: [],
|
|
500
|
+
nuxs: [],
|
|
495
501
|
},
|
|
496
502
|
})
|
|
497
503
|
|
|
@@ -540,6 +546,7 @@ describe('agent', () => {
|
|
|
540
546
|
bskyAppState: {
|
|
541
547
|
activeProgressGuide: undefined,
|
|
542
548
|
queuedNudges: [],
|
|
549
|
+
nuxs: [],
|
|
543
550
|
},
|
|
544
551
|
})
|
|
545
552
|
|
|
@@ -588,6 +595,7 @@ describe('agent', () => {
|
|
|
588
595
|
bskyAppState: {
|
|
589
596
|
activeProgressGuide: undefined,
|
|
590
597
|
queuedNudges: [],
|
|
598
|
+
nuxs: [],
|
|
591
599
|
},
|
|
592
600
|
})
|
|
593
601
|
|
|
@@ -636,6 +644,7 @@ describe('agent', () => {
|
|
|
636
644
|
bskyAppState: {
|
|
637
645
|
activeProgressGuide: undefined,
|
|
638
646
|
queuedNudges: [],
|
|
647
|
+
nuxs: [],
|
|
639
648
|
},
|
|
640
649
|
})
|
|
641
650
|
|
|
@@ -684,6 +693,7 @@ describe('agent', () => {
|
|
|
684
693
|
bskyAppState: {
|
|
685
694
|
activeProgressGuide: undefined,
|
|
686
695
|
queuedNudges: [],
|
|
696
|
+
nuxs: [],
|
|
687
697
|
},
|
|
688
698
|
})
|
|
689
699
|
|
|
@@ -738,6 +748,7 @@ describe('agent', () => {
|
|
|
738
748
|
bskyAppState: {
|
|
739
749
|
activeProgressGuide: undefined,
|
|
740
750
|
queuedNudges: [],
|
|
751
|
+
nuxs: [],
|
|
741
752
|
},
|
|
742
753
|
})
|
|
743
754
|
|
|
@@ -786,6 +797,7 @@ describe('agent', () => {
|
|
|
786
797
|
bskyAppState: {
|
|
787
798
|
activeProgressGuide: undefined,
|
|
788
799
|
queuedNudges: [],
|
|
800
|
+
nuxs: [],
|
|
789
801
|
},
|
|
790
802
|
})
|
|
791
803
|
|
|
@@ -834,6 +846,7 @@ describe('agent', () => {
|
|
|
834
846
|
bskyAppState: {
|
|
835
847
|
activeProgressGuide: undefined,
|
|
836
848
|
queuedNudges: [],
|
|
849
|
+
nuxs: [],
|
|
837
850
|
},
|
|
838
851
|
})
|
|
839
852
|
|
|
@@ -882,6 +895,7 @@ describe('agent', () => {
|
|
|
882
895
|
bskyAppState: {
|
|
883
896
|
activeProgressGuide: undefined,
|
|
884
897
|
queuedNudges: [],
|
|
898
|
+
nuxs: [],
|
|
885
899
|
},
|
|
886
900
|
})
|
|
887
901
|
|
|
@@ -930,6 +944,7 @@ describe('agent', () => {
|
|
|
930
944
|
bskyAppState: {
|
|
931
945
|
activeProgressGuide: undefined,
|
|
932
946
|
queuedNudges: [],
|
|
947
|
+
nuxs: [],
|
|
933
948
|
},
|
|
934
949
|
})
|
|
935
950
|
|
|
@@ -985,6 +1000,7 @@ describe('agent', () => {
|
|
|
985
1000
|
bskyAppState: {
|
|
986
1001
|
activeProgressGuide: undefined,
|
|
987
1002
|
queuedNudges: [],
|
|
1003
|
+
nuxs: [],
|
|
988
1004
|
},
|
|
989
1005
|
})
|
|
990
1006
|
|
|
@@ -1040,6 +1056,7 @@ describe('agent', () => {
|
|
|
1040
1056
|
bskyAppState: {
|
|
1041
1057
|
activeProgressGuide: undefined,
|
|
1042
1058
|
queuedNudges: [],
|
|
1059
|
+
nuxs: [],
|
|
1043
1060
|
},
|
|
1044
1061
|
})
|
|
1045
1062
|
|
|
@@ -1095,6 +1112,7 @@ describe('agent', () => {
|
|
|
1095
1112
|
bskyAppState: {
|
|
1096
1113
|
activeProgressGuide: undefined,
|
|
1097
1114
|
queuedNudges: [],
|
|
1115
|
+
nuxs: [],
|
|
1098
1116
|
},
|
|
1099
1117
|
})
|
|
1100
1118
|
|
|
@@ -1150,6 +1168,7 @@ describe('agent', () => {
|
|
|
1150
1168
|
bskyAppState: {
|
|
1151
1169
|
activeProgressGuide: undefined,
|
|
1152
1170
|
queuedNudges: [],
|
|
1171
|
+
nuxs: [],
|
|
1153
1172
|
},
|
|
1154
1173
|
})
|
|
1155
1174
|
})
|
|
@@ -1332,6 +1351,7 @@ describe('agent', () => {
|
|
|
1332
1351
|
bskyAppState: {
|
|
1333
1352
|
activeProgressGuide: undefined,
|
|
1334
1353
|
queuedNudges: ['two'],
|
|
1354
|
+
nuxs: [],
|
|
1335
1355
|
},
|
|
1336
1356
|
})
|
|
1337
1357
|
|
|
@@ -1389,6 +1409,7 @@ describe('agent', () => {
|
|
|
1389
1409
|
bskyAppState: {
|
|
1390
1410
|
activeProgressGuide: undefined,
|
|
1391
1411
|
queuedNudges: ['two'],
|
|
1412
|
+
nuxs: [],
|
|
1392
1413
|
},
|
|
1393
1414
|
})
|
|
1394
1415
|
|
|
@@ -1447,6 +1468,7 @@ describe('agent', () => {
|
|
|
1447
1468
|
bskyAppState: {
|
|
1448
1469
|
activeProgressGuide: undefined,
|
|
1449
1470
|
queuedNudges: ['two'],
|
|
1471
|
+
nuxs: [],
|
|
1450
1472
|
},
|
|
1451
1473
|
})
|
|
1452
1474
|
|
|
@@ -1501,6 +1523,7 @@ describe('agent', () => {
|
|
|
1501
1523
|
bskyAppState: {
|
|
1502
1524
|
activeProgressGuide: undefined,
|
|
1503
1525
|
queuedNudges: ['two'],
|
|
1526
|
+
nuxs: [],
|
|
1504
1527
|
},
|
|
1505
1528
|
})
|
|
1506
1529
|
|
|
@@ -1555,6 +1578,7 @@ describe('agent', () => {
|
|
|
1555
1578
|
bskyAppState: {
|
|
1556
1579
|
activeProgressGuide: undefined,
|
|
1557
1580
|
queuedNudges: ['two'],
|
|
1581
|
+
nuxs: [],
|
|
1558
1582
|
},
|
|
1559
1583
|
})
|
|
1560
1584
|
|
|
@@ -1609,6 +1633,7 @@ describe('agent', () => {
|
|
|
1609
1633
|
bskyAppState: {
|
|
1610
1634
|
activeProgressGuide: undefined,
|
|
1611
1635
|
queuedNudges: ['two'],
|
|
1636
|
+
nuxs: [],
|
|
1612
1637
|
},
|
|
1613
1638
|
})
|
|
1614
1639
|
|
|
@@ -1675,6 +1700,7 @@ describe('agent', () => {
|
|
|
1675
1700
|
bskyAppState: {
|
|
1676
1701
|
activeProgressGuide: undefined,
|
|
1677
1702
|
queuedNudges: ['two', 'three'],
|
|
1703
|
+
nuxs: [],
|
|
1678
1704
|
},
|
|
1679
1705
|
})
|
|
1680
1706
|
|
|
@@ -3246,6 +3272,71 @@ describe('agent', () => {
|
|
|
3246
3272
|
})
|
|
3247
3273
|
})
|
|
3248
3274
|
|
|
3275
|
+
describe('nuxs', () => {
|
|
3276
|
+
let agent: BskyAgent
|
|
3277
|
+
|
|
3278
|
+
const nux = {
|
|
3279
|
+
id: 'a',
|
|
3280
|
+
completed: false,
|
|
3281
|
+
data: '{}',
|
|
3282
|
+
expiresAt: new Date(Date.now() + 6e3).toISOString(),
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
beforeAll(async () => {
|
|
3286
|
+
agent = new BskyAgent({ service: network.pds.url })
|
|
3287
|
+
|
|
3288
|
+
await agent.createAccount({
|
|
3289
|
+
handle: 'nuxs.test',
|
|
3290
|
+
email: 'nuxs@test.com',
|
|
3291
|
+
password: 'password',
|
|
3292
|
+
})
|
|
3293
|
+
})
|
|
3294
|
+
|
|
3295
|
+
it('bskyAppUpsertNux', async () => {
|
|
3296
|
+
// never duplicates
|
|
3297
|
+
await agent.bskyAppUpsertNux(nux)
|
|
3298
|
+
await agent.bskyAppUpsertNux(nux)
|
|
3299
|
+
await agent.bskyAppUpsertNux(nux)
|
|
3300
|
+
|
|
3301
|
+
const prefs = await agent.getPreferences()
|
|
3302
|
+
const nuxs = prefs.bskyAppState.nuxs
|
|
3303
|
+
|
|
3304
|
+
expect(nuxs.length).toEqual(1)
|
|
3305
|
+
expect(nuxs.find((n) => n.id === nux.id)).toEqual(nux)
|
|
3306
|
+
})
|
|
3307
|
+
|
|
3308
|
+
it('bskyAppUpsertNux completed', async () => {
|
|
3309
|
+
// never duplicates
|
|
3310
|
+
await agent.bskyAppUpsertNux({
|
|
3311
|
+
...nux,
|
|
3312
|
+
completed: true,
|
|
3313
|
+
})
|
|
3314
|
+
|
|
3315
|
+
const prefs = await agent.getPreferences()
|
|
3316
|
+
const nuxs = prefs.bskyAppState.nuxs
|
|
3317
|
+
|
|
3318
|
+
expect(nuxs.length).toEqual(1)
|
|
3319
|
+
expect(nuxs.find((n) => n.id === nux.id)?.completed).toEqual(true)
|
|
3320
|
+
})
|
|
3321
|
+
|
|
3322
|
+
it('bskyAppRemoveNuxs', async () => {
|
|
3323
|
+
await agent.bskyAppRemoveNuxs([nux.id])
|
|
3324
|
+
|
|
3325
|
+
const prefs = await agent.getPreferences()
|
|
3326
|
+
const nuxs = prefs.bskyAppState.nuxs
|
|
3327
|
+
|
|
3328
|
+
expect(nuxs.length).toEqual(0)
|
|
3329
|
+
})
|
|
3330
|
+
|
|
3331
|
+
it('bskyAppUpsertNux validates nux', async () => {
|
|
3332
|
+
// @ts-expect-error
|
|
3333
|
+
expect(() => agent.bskyAppUpsertNux({ name: 'a' })).rejects.toThrow()
|
|
3334
|
+
expect(() =>
|
|
3335
|
+
agent.bskyAppUpsertNux({ id: 'a', completed: false, foo: 'bar' }),
|
|
3336
|
+
).rejects.toThrow()
|
|
3337
|
+
})
|
|
3338
|
+
})
|
|
3339
|
+
|
|
3249
3340
|
// end
|
|
3250
3341
|
})
|
|
3251
3342
|
})
|
|
@@ -84,6 +84,7 @@ describe('agent', () => {
|
|
|
84
84
|
bskyAppState: {
|
|
85
85
|
activeProgressGuide: undefined,
|
|
86
86
|
queuedNudges: [],
|
|
87
|
+
nuxs: [],
|
|
87
88
|
},
|
|
88
89
|
})
|
|
89
90
|
})
|
|
@@ -133,6 +134,7 @@ describe('agent', () => {
|
|
|
133
134
|
bskyAppState: {
|
|
134
135
|
activeProgressGuide: undefined,
|
|
135
136
|
queuedNudges: [],
|
|
137
|
+
nuxs: [],
|
|
136
138
|
},
|
|
137
139
|
})
|
|
138
140
|
expect(agent.labelers).toStrictEqual(['did:plc:other'])
|
|
@@ -167,6 +169,7 @@ describe('agent', () => {
|
|
|
167
169
|
bskyAppState: {
|
|
168
170
|
activeProgressGuide: undefined,
|
|
169
171
|
queuedNudges: [],
|
|
172
|
+
nuxs: [],
|
|
170
173
|
},
|
|
171
174
|
})
|
|
172
175
|
expect(agent.labelers).toStrictEqual([])
|
|
@@ -223,6 +226,7 @@ describe('agent', () => {
|
|
|
223
226
|
bskyAppState: {
|
|
224
227
|
activeProgressGuide: undefined,
|
|
225
228
|
queuedNudges: [],
|
|
229
|
+
nuxs: [],
|
|
226
230
|
},
|
|
227
231
|
})
|
|
228
232
|
})
|