@atproto/api 0.20.23 → 0.20.25

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +22 -16
  3. package/definitions/labels.json +0 -170
  4. package/docs/moderation.md +0 -260
  5. package/jest.config.cjs +0 -23
  6. package/jest.d.ts +0 -20
  7. package/jest.setup.ts +0 -97
  8. package/scripts/code/labels.mjs +0 -77
  9. package/scripts/generate-code.mjs +0 -4
  10. package/src/age-assurance.test.ts +0 -218
  11. package/src/age-assurance.ts +0 -137
  12. package/src/agent.ts +0 -1645
  13. package/src/atp-agent.ts +0 -570
  14. package/src/bsky-agent.ts +0 -14
  15. package/src/const.ts +0 -1
  16. package/src/index.ts +0 -44
  17. package/src/mocker.ts +0 -220
  18. package/src/moderation/decision.ts +0 -389
  19. package/src/moderation/index.ts +0 -69
  20. package/src/moderation/mutewords.ts +0 -170
  21. package/src/moderation/subjects/account.ts +0 -44
  22. package/src/moderation/subjects/feed-generator.ts +0 -24
  23. package/src/moderation/subjects/notification.ts +0 -25
  24. package/src/moderation/subjects/post.ts +0 -433
  25. package/src/moderation/subjects/profile.ts +0 -26
  26. package/src/moderation/subjects/status.ts +0 -27
  27. package/src/moderation/subjects/user-list.ts +0 -48
  28. package/src/moderation/types.ts +0 -191
  29. package/src/moderation/ui.ts +0 -21
  30. package/src/moderation/util.ts +0 -111
  31. package/src/predicate.ts +0 -52
  32. package/src/rich-text/detection.ts +0 -146
  33. package/src/rich-text/rich-text.ts +0 -418
  34. package/src/rich-text/sanitization.ts +0 -42
  35. package/src/rich-text/unicode.ts +0 -47
  36. package/src/rich-text/util.ts +0 -15
  37. package/src/session-manager.ts +0 -5
  38. package/src/types.ts +0 -165
  39. package/src/util.ts +0 -96
  40. package/tests/atp-agent.test.ts +0 -3863
  41. package/tests/dispatcher.test.ts +0 -527
  42. package/tests/errors.test.ts +0 -29
  43. package/tests/moderation-behaviors.test.ts +0 -951
  44. package/tests/moderation-custom-labels.test.ts +0 -334
  45. package/tests/moderation-mutewords.test.ts +0 -1299
  46. package/tests/moderation-prefs.test.ts +0 -402
  47. package/tests/moderation-quoteposts.test.ts +0 -277
  48. package/tests/moderation.test.ts +0 -739
  49. package/tests/rich-text-detection.test.ts +0 -456
  50. package/tests/rich-text-sanitization.test.ts +0 -216
  51. package/tests/rich-text.test.ts +0 -705
  52. package/tests/util/echo-server.ts +0 -37
  53. package/tests/util/moderation-behavior.ts +0 -268
  54. package/tsconfig.build.json +0 -9
  55. package/tsconfig.build.tsbuildinfo +0 -1
  56. package/tsconfig.json +0 -7
  57. package/tsconfig.tests.json +0 -10
package/src/util.ts DELETED
@@ -1,96 +0,0 @@
1
- import { z } from 'zod'
2
- import { AtUri } from '@atproto/syntax'
3
- import { AppBskyActorDefs } from './client/index.js'
4
- import { Nux } from './client/types/app/bsky/actor/defs.js'
5
-
6
- export function sanitizeMutedWordValue(value: string) {
7
- return (
8
- value
9
- .trim()
10
- .replace(/^#(?!\ufe0f)/, '')
11
- // eslint-disable-next-line no-misleading-character-class
12
- .replace(/[\r\n\u00AD\u2060\u200D\u200C\u200B]+/, '')
13
- )
14
- }
15
-
16
- export function savedFeedsToUriArrays(
17
- savedFeeds: AppBskyActorDefs.SavedFeed[],
18
- ): {
19
- pinned: string[]
20
- saved: string[]
21
- } {
22
- const pinned: string[] = []
23
- const saved: string[] = []
24
-
25
- for (const feed of savedFeeds) {
26
- if (feed.pinned) {
27
- pinned.push(feed.value)
28
- // saved in v1 includes pinned
29
- saved.push(feed.value)
30
- } else {
31
- saved.push(feed.value)
32
- }
33
- }
34
-
35
- return {
36
- pinned,
37
- saved,
38
- }
39
- }
40
-
41
- /**
42
- * Get the type of a saved feed, used by deprecated methods for backwards
43
- * compat. Should not be used moving forward. *Invalid URIs will throw.*
44
- *
45
- * @param uri - The AT URI of the saved feed
46
- */
47
- export function getSavedFeedType(
48
- uri: string,
49
- ): AppBskyActorDefs.SavedFeed['type'] {
50
- const urip = new AtUri(uri)
51
-
52
- switch (urip.collection) {
53
- case 'app.bsky.feed.generator':
54
- return 'feed'
55
- case 'app.bsky.graph.list':
56
- return 'list'
57
- default:
58
- return 'unknown'
59
- }
60
- }
61
-
62
- export function validateSavedFeed(savedFeed: AppBskyActorDefs.SavedFeed) {
63
- if (!savedFeed.id) {
64
- throw new Error('Saved feed must have an `id` - use a TID')
65
- }
66
-
67
- if (['feed', 'list'].includes(savedFeed.type)) {
68
- const uri = new AtUri(savedFeed.value)
69
- const isFeed = uri.collection === 'app.bsky.feed.generator'
70
- const isList = uri.collection === 'app.bsky.graph.list'
71
-
72
- if (savedFeed.type === 'feed' && !isFeed) {
73
- throw new Error(
74
- `Saved feed of type 'feed' must be a feed, got ${uri.collection}`,
75
- )
76
- }
77
- if (savedFeed.type === 'list' && !isList) {
78
- throw new Error(
79
- `Saved feed of type 'list' must be a list, got ${uri.collection}`,
80
- )
81
- }
82
- }
83
- }
84
-
85
- export const nuxSchema = z
86
- .object({
87
- id: z.string().max(64),
88
- completed: z.boolean(),
89
- data: z.string().max(300).optional(),
90
- expiresAt: z.string().datetime().optional(),
91
- })
92
- .strict()
93
-
94
- export function validateNux(nux: Nux) {
95
- nuxSchema.parse(nux)
96
- }