@atproto/bsky 0.0.79 → 0.0.81

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 (114) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/app/bsky/feed/getQuotes.d.ts.map +1 -1
  3. package/dist/api/app/bsky/feed/getQuotes.js +3 -1
  4. package/dist/api/app/bsky/feed/getQuotes.js.map +1 -1
  5. package/dist/config.d.ts +4 -0
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +12 -0
  8. package/dist/config.js.map +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +8 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/lexicon/index.d.ts +11 -0
  13. package/dist/lexicon/index.d.ts.map +1 -1
  14. package/dist/lexicon/index.js +32 -1
  15. package/dist/lexicon/index.js.map +1 -1
  16. package/dist/lexicon/lexicons.d.ts +346 -18
  17. package/dist/lexicon/lexicons.d.ts.map +1 -1
  18. package/dist/lexicon/lexicons.js +364 -24
  19. package/dist/lexicon/lexicons.js.map +1 -1
  20. package/dist/lexicon/types/app/bsky/embed/defs.d.ts +13 -0
  21. package/dist/lexicon/types/app/bsky/embed/defs.d.ts.map +1 -0
  22. package/dist/lexicon/types/app/bsky/embed/defs.js +16 -0
  23. package/dist/lexicon/types/app/bsky/embed/defs.js.map +1 -0
  24. package/dist/lexicon/types/app/bsky/embed/images.d.ts +3 -10
  25. package/dist/lexicon/types/app/bsky/embed/images.d.ts.map +1 -1
  26. package/dist/lexicon/types/app/bsky/embed/images.js +1 -11
  27. package/dist/lexicon/types/app/bsky/embed/images.js.map +1 -1
  28. package/dist/lexicon/types/app/bsky/embed/record.d.ts +2 -1
  29. package/dist/lexicon/types/app/bsky/embed/record.d.ts.map +1 -1
  30. package/dist/lexicon/types/app/bsky/embed/record.js.map +1 -1
  31. package/dist/lexicon/types/app/bsky/embed/recordWithMedia.d.ts +3 -2
  32. package/dist/lexicon/types/app/bsky/embed/recordWithMedia.d.ts.map +1 -1
  33. package/dist/lexicon/types/app/bsky/embed/recordWithMedia.js.map +1 -1
  34. package/dist/lexicon/types/app/bsky/embed/video.d.ts +33 -0
  35. package/dist/lexicon/types/app/bsky/embed/video.d.ts.map +1 -0
  36. package/dist/lexicon/types/app/bsky/embed/video.js +35 -0
  37. package/dist/lexicon/types/app/bsky/embed/video.js.map +1 -0
  38. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +2 -1
  39. package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
  40. package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
  41. package/dist/lexicon/types/app/bsky/feed/post.d.ts +2 -1
  42. package/dist/lexicon/types/app/bsky/feed/post.d.ts.map +1 -1
  43. package/dist/lexicon/types/app/bsky/feed/post.js.map +1 -1
  44. package/dist/lexicon/types/app/bsky/video/defs.d.ts +19 -0
  45. package/dist/lexicon/types/app/bsky/video/defs.d.ts.map +1 -0
  46. package/dist/lexicon/types/app/bsky/video/defs.js +16 -0
  47. package/dist/lexicon/types/app/bsky/video/defs.js.map +1 -0
  48. package/dist/lexicon/types/app/bsky/video/getJobStatus.d.ts +36 -0
  49. package/dist/lexicon/types/app/bsky/video/getJobStatus.d.ts.map +1 -0
  50. package/dist/lexicon/types/app/bsky/video/getJobStatus.js +3 -0
  51. package/dist/lexicon/types/app/bsky/video/getJobStatus.js.map +1 -0
  52. package/dist/lexicon/types/app/bsky/video/getUploadLimits.d.ts +38 -0
  53. package/dist/lexicon/types/app/bsky/video/getUploadLimits.d.ts.map +1 -0
  54. package/dist/lexicon/types/app/bsky/video/getUploadLimits.js +3 -0
  55. package/dist/lexicon/types/app/bsky/video/getUploadLimits.js.map +1 -0
  56. package/dist/lexicon/types/app/bsky/video/uploadVideo.d.ts +41 -0
  57. package/dist/lexicon/types/app/bsky/video/uploadVideo.d.ts.map +1 -0
  58. package/dist/lexicon/types/app/bsky/video/uploadVideo.js +3 -0
  59. package/dist/lexicon/types/app/bsky/video/uploadVideo.js.map +1 -0
  60. package/dist/lexicon/types/com/atproto/repo/applyWrites.d.ts +38 -4
  61. package/dist/lexicon/types/com/atproto/repo/applyWrites.d.ts.map +1 -1
  62. package/dist/lexicon/types/com/atproto/repo/applyWrites.js +31 -1
  63. package/dist/lexicon/types/com/atproto/repo/applyWrites.js.map +1 -1
  64. package/dist/lexicon/types/com/atproto/repo/createRecord.d.ts +5 -2
  65. package/dist/lexicon/types/com/atproto/repo/createRecord.d.ts.map +1 -1
  66. package/dist/lexicon/types/com/atproto/repo/defs.d.ts +12 -0
  67. package/dist/lexicon/types/com/atproto/repo/defs.d.ts.map +1 -0
  68. package/dist/lexicon/types/com/atproto/repo/defs.js +16 -0
  69. package/dist/lexicon/types/com/atproto/repo/defs.js.map +1 -0
  70. package/dist/lexicon/types/com/atproto/repo/deleteRecord.d.ts +14 -2
  71. package/dist/lexicon/types/com/atproto/repo/deleteRecord.d.ts.map +1 -1
  72. package/dist/lexicon/types/com/atproto/repo/putRecord.d.ts +5 -2
  73. package/dist/lexicon/types/com/atproto/repo/putRecord.d.ts.map +1 -1
  74. package/dist/views/index.d.ts +5 -2
  75. package/dist/views/index.d.ts.map +1 -1
  76. package/dist/views/index.js +24 -1
  77. package/dist/views/index.js.map +1 -1
  78. package/dist/views/types.d.ts +5 -2
  79. package/dist/views/types.d.ts.map +1 -1
  80. package/dist/views/types.js +3 -1
  81. package/dist/views/types.js.map +1 -1
  82. package/dist/views/util.d.ts +15 -0
  83. package/dist/views/util.d.ts.map +1 -1
  84. package/dist/views/util.js +42 -1
  85. package/dist/views/util.js.map +1 -1
  86. package/package.json +4 -4
  87. package/src/api/app/bsky/feed/getQuotes.ts +4 -1
  88. package/src/config.ts +17 -0
  89. package/src/index.ts +10 -1
  90. package/src/lexicon/index.ts +46 -0
  91. package/src/lexicon/lexicons.ts +367 -25
  92. package/src/lexicon/types/app/bsky/embed/defs.ts +26 -0
  93. package/src/lexicon/types/app/bsky/embed/images.ts +3 -21
  94. package/src/lexicon/types/app/bsky/embed/record.ts +2 -0
  95. package/src/lexicon/types/app/bsky/embed/recordWithMedia.ts +3 -0
  96. package/src/lexicon/types/app/bsky/embed/video.ts +67 -0
  97. package/src/lexicon/types/app/bsky/feed/defs.ts +2 -0
  98. package/src/lexicon/types/app/bsky/feed/post.ts +2 -0
  99. package/src/lexicon/types/app/bsky/video/defs.ts +32 -0
  100. package/src/lexicon/types/app/bsky/video/getJobStatus.ts +46 -0
  101. package/src/lexicon/types/app/bsky/video/getUploadLimits.ts +47 -0
  102. package/src/lexicon/types/app/bsky/video/uploadVideo.ts +48 -0
  103. package/src/lexicon/types/com/atproto/repo/applyWrites.ts +70 -3
  104. package/src/lexicon/types/com/atproto/repo/createRecord.ts +5 -2
  105. package/src/lexicon/types/com/atproto/repo/defs.ts +25 -0
  106. package/src/lexicon/types/com/atproto/repo/deleteRecord.ts +13 -1
  107. package/src/lexicon/types/com/atproto/repo/putRecord.ts +5 -2
  108. package/src/views/index.ts +30 -3
  109. package/src/views/types.ts +16 -1
  110. package/src/views/util.ts +24 -0
  111. package/tests/_util.ts +9 -0
  112. package/tests/views/__snapshots__/posts.test.ts.snap +190 -0
  113. package/tests/views/posts.test.ts +75 -0
  114. package/tests/views/quotes.test.ts +15 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
5
+ import { lexicons } from '../../../../lexicons'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { CID } from 'multiformats/cid'
8
+ import * as AppBskyEmbedDefs from './defs'
9
+
10
+ export interface Main {
11
+ video: BlobRef
12
+ captions?: Caption[]
13
+ /** Alt text description of the video, for accessibility. */
14
+ alt?: string
15
+ aspectRatio?: AppBskyEmbedDefs.AspectRatio
16
+ [k: string]: unknown
17
+ }
18
+
19
+ export function isMain(v: unknown): v is Main {
20
+ return (
21
+ isObj(v) &&
22
+ hasProp(v, '$type') &&
23
+ (v.$type === 'app.bsky.embed.video#main' ||
24
+ v.$type === 'app.bsky.embed.video')
25
+ )
26
+ }
27
+
28
+ export function validateMain(v: unknown): ValidationResult {
29
+ return lexicons.validate('app.bsky.embed.video#main', v)
30
+ }
31
+
32
+ export interface Caption {
33
+ lang: string
34
+ file: BlobRef
35
+ [k: string]: unknown
36
+ }
37
+
38
+ export function isCaption(v: unknown): v is Caption {
39
+ return (
40
+ isObj(v) &&
41
+ hasProp(v, '$type') &&
42
+ v.$type === 'app.bsky.embed.video#caption'
43
+ )
44
+ }
45
+
46
+ export function validateCaption(v: unknown): ValidationResult {
47
+ return lexicons.validate('app.bsky.embed.video#caption', v)
48
+ }
49
+
50
+ export interface View {
51
+ cid: string
52
+ playlist: string
53
+ thumbnail?: string
54
+ alt?: string
55
+ aspectRatio?: AppBskyEmbedDefs.AspectRatio
56
+ [k: string]: unknown
57
+ }
58
+
59
+ export function isView(v: unknown): v is View {
60
+ return (
61
+ isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.video#view'
62
+ )
63
+ }
64
+
65
+ export function validateView(v: unknown): ValidationResult {
66
+ return lexicons.validate('app.bsky.embed.video#view', v)
67
+ }
@@ -7,6 +7,7 @@ import { isObj, hasProp } from '../../../../util'
7
7
  import { CID } from 'multiformats/cid'
8
8
  import * as AppBskyActorDefs from '../actor/defs'
9
9
  import * as AppBskyEmbedImages from '../embed/images'
10
+ import * as AppBskyEmbedVideo from '../embed/video'
10
11
  import * as AppBskyEmbedExternal from '../embed/external'
11
12
  import * as AppBskyEmbedRecord from '../embed/record'
12
13
  import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia'
@@ -21,6 +22,7 @@ export interface PostView {
21
22
  record: {}
22
23
  embed?:
23
24
  | AppBskyEmbedImages.View
25
+ | AppBskyEmbedVideo.View
24
26
  | AppBskyEmbedExternal.View
25
27
  | AppBskyEmbedRecord.View
26
28
  | AppBskyEmbedRecordWithMedia.View
@@ -7,6 +7,7 @@ import { isObj, hasProp } from '../../../../util'
7
7
  import { CID } from 'multiformats/cid'
8
8
  import * as AppBskyRichtextFacet from '../richtext/facet'
9
9
  import * as AppBskyEmbedImages from '../embed/images'
10
+ import * as AppBskyEmbedVideo from '../embed/video'
10
11
  import * as AppBskyEmbedExternal from '../embed/external'
11
12
  import * as AppBskyEmbedRecord from '../embed/record'
12
13
  import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia'
@@ -23,6 +24,7 @@ export interface Record {
23
24
  reply?: ReplyRef
24
25
  embed?:
25
26
  | AppBskyEmbedImages.Main
27
+ | AppBskyEmbedVideo.Main
26
28
  | AppBskyEmbedExternal.Main
27
29
  | AppBskyEmbedRecord.Main
28
30
  | AppBskyEmbedRecordWithMedia.Main
@@ -0,0 +1,32 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
5
+ import { lexicons } from '../../../../lexicons'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { CID } from 'multiformats/cid'
8
+
9
+ export interface JobStatus {
10
+ jobId: string
11
+ did: string
12
+ /** The state of the video processing job. All values not listed as a known value indicate that the job is in process. */
13
+ state: 'JOB_STATE_COMPLETED' | 'JOB_STATE_FAILED' | (string & {})
14
+ /** Progress within the current processing state. */
15
+ progress?: number
16
+ blob?: BlobRef
17
+ error?: string
18
+ message?: string
19
+ [k: string]: unknown
20
+ }
21
+
22
+ export function isJobStatus(v: unknown): v is JobStatus {
23
+ return (
24
+ isObj(v) &&
25
+ hasProp(v, '$type') &&
26
+ v.$type === 'app.bsky.video.defs#jobStatus'
27
+ )
28
+ }
29
+
30
+ export function validateJobStatus(v: unknown): ValidationResult {
31
+ return lexicons.validate('app.bsky.video.defs#jobStatus', v)
32
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import express from 'express'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { lexicons } from '../../../../lexicons'
7
+ import { isObj, hasProp } from '../../../../util'
8
+ import { CID } from 'multiformats/cid'
9
+ import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as AppBskyVideoDefs from './defs'
11
+
12
+ export interface QueryParams {
13
+ jobId: string
14
+ }
15
+
16
+ export type InputSchema = undefined
17
+
18
+ export interface OutputSchema {
19
+ jobStatus: AppBskyVideoDefs.JobStatus
20
+ [k: string]: unknown
21
+ }
22
+
23
+ export type HandlerInput = undefined
24
+
25
+ export interface HandlerSuccess {
26
+ encoding: 'application/json'
27
+ body: OutputSchema
28
+ headers?: { [key: string]: string }
29
+ }
30
+
31
+ export interface HandlerError {
32
+ status: number
33
+ message?: string
34
+ }
35
+
36
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
37
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
38
+ auth: HA
39
+ params: QueryParams
40
+ input: HandlerInput
41
+ req: express.Request
42
+ res: express.Response
43
+ }
44
+ export type Handler<HA extends HandlerAuth = never> = (
45
+ ctx: HandlerReqCtx<HA>,
46
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,47 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import express from 'express'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { lexicons } from '../../../../lexicons'
7
+ import { isObj, hasProp } from '../../../../util'
8
+ import { CID } from 'multiformats/cid'
9
+ import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export type InputSchema = undefined
14
+
15
+ export interface OutputSchema {
16
+ canUpload: boolean
17
+ remainingDailyVideos?: number
18
+ remainingDailyBytes?: number
19
+ message?: string
20
+ error?: string
21
+ [k: string]: unknown
22
+ }
23
+
24
+ export type HandlerInput = undefined
25
+
26
+ export interface HandlerSuccess {
27
+ encoding: 'application/json'
28
+ body: OutputSchema
29
+ headers?: { [key: string]: string }
30
+ }
31
+
32
+ export interface HandlerError {
33
+ status: number
34
+ message?: string
35
+ }
36
+
37
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
38
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
39
+ auth: HA
40
+ params: QueryParams
41
+ input: HandlerInput
42
+ req: express.Request
43
+ res: express.Response
44
+ }
45
+ export type Handler<HA extends HandlerAuth = never> = (
46
+ ctx: HandlerReqCtx<HA>,
47
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -0,0 +1,48 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import express from 'express'
5
+ import stream from 'stream'
6
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { isObj, hasProp } from '../../../../util'
9
+ import { CID } from 'multiformats/cid'
10
+ import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
11
+ import * as AppBskyVideoDefs from './defs'
12
+
13
+ export interface QueryParams {}
14
+
15
+ export type InputSchema = string | Uint8Array | Blob
16
+
17
+ export interface OutputSchema {
18
+ jobStatus: AppBskyVideoDefs.JobStatus
19
+ [k: string]: unknown
20
+ }
21
+
22
+ export interface HandlerInput {
23
+ encoding: 'video/mp4'
24
+ body: stream.Readable
25
+ }
26
+
27
+ export interface HandlerSuccess {
28
+ encoding: 'application/json'
29
+ body: OutputSchema
30
+ headers?: { [key: string]: string }
31
+ }
32
+
33
+ export interface HandlerError {
34
+ status: number
35
+ message?: string
36
+ }
37
+
38
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
39
+ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
40
+ auth: HA
41
+ params: QueryParams
42
+ input: HandlerInput
43
+ req: express.Request
44
+ res: express.Response
45
+ }
46
+ export type Handler<HA extends HandlerAuth = never> = (
47
+ ctx: HandlerReqCtx<HA>,
48
+ ) => Promise<HandlerOutput> | HandlerOutput
@@ -7,32 +7,45 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { isObj, hasProp } from '../../../../util'
8
8
  import { CID } from 'multiformats/cid'
9
9
  import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ComAtprotoRepoDefs from './defs'
10
11
 
11
12
  export interface QueryParams {}
12
13
 
13
14
  export interface InputSchema {
14
15
  /** The handle or DID of the repo (aka, current account). */
15
16
  repo: string
16
- /** Can be set to 'false' to skip Lexicon schema validation of record data, for all operations. */
17
- validate: boolean
17
+ /** Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons. */
18
+ validate?: boolean
18
19
  writes: (Create | Update | Delete)[]
19
20
  /** If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. */
20
21
  swapCommit?: string
21
22
  [k: string]: unknown
22
23
  }
23
24
 
25
+ export interface OutputSchema {
26
+ commit?: ComAtprotoRepoDefs.CommitMeta
27
+ results?: (CreateResult | UpdateResult | DeleteResult)[]
28
+ [k: string]: unknown
29
+ }
30
+
24
31
  export interface HandlerInput {
25
32
  encoding: 'application/json'
26
33
  body: InputSchema
27
34
  }
28
35
 
36
+ export interface HandlerSuccess {
37
+ encoding: 'application/json'
38
+ body: OutputSchema
39
+ headers?: { [key: string]: string }
40
+ }
41
+
29
42
  export interface HandlerError {
30
43
  status: number
31
44
  message?: string
32
45
  error?: 'InvalidSwap'
33
46
  }
34
47
 
35
- export type HandlerOutput = HandlerError | void
48
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
36
49
  export type HandlerReqCtx<HA extends HandlerAuth = never> = {
37
50
  auth: HA
38
51
  params: QueryParams
@@ -102,3 +115,57 @@ export function isDelete(v: unknown): v is Delete {
102
115
  export function validateDelete(v: unknown): ValidationResult {
103
116
  return lexicons.validate('com.atproto.repo.applyWrites#delete', v)
104
117
  }
118
+
119
+ export interface CreateResult {
120
+ uri: string
121
+ cid: string
122
+ validationStatus?: 'valid' | 'unknown' | (string & {})
123
+ [k: string]: unknown
124
+ }
125
+
126
+ export function isCreateResult(v: unknown): v is CreateResult {
127
+ return (
128
+ isObj(v) &&
129
+ hasProp(v, '$type') &&
130
+ v.$type === 'com.atproto.repo.applyWrites#createResult'
131
+ )
132
+ }
133
+
134
+ export function validateCreateResult(v: unknown): ValidationResult {
135
+ return lexicons.validate('com.atproto.repo.applyWrites#createResult', v)
136
+ }
137
+
138
+ export interface UpdateResult {
139
+ uri: string
140
+ cid: string
141
+ validationStatus?: 'valid' | 'unknown' | (string & {})
142
+ [k: string]: unknown
143
+ }
144
+
145
+ export function isUpdateResult(v: unknown): v is UpdateResult {
146
+ return (
147
+ isObj(v) &&
148
+ hasProp(v, '$type') &&
149
+ v.$type === 'com.atproto.repo.applyWrites#updateResult'
150
+ )
151
+ }
152
+
153
+ export function validateUpdateResult(v: unknown): ValidationResult {
154
+ return lexicons.validate('com.atproto.repo.applyWrites#updateResult', v)
155
+ }
156
+
157
+ export interface DeleteResult {
158
+ [k: string]: unknown
159
+ }
160
+
161
+ export function isDeleteResult(v: unknown): v is DeleteResult {
162
+ return (
163
+ isObj(v) &&
164
+ hasProp(v, '$type') &&
165
+ v.$type === 'com.atproto.repo.applyWrites#deleteResult'
166
+ )
167
+ }
168
+
169
+ export function validateDeleteResult(v: unknown): ValidationResult {
170
+ return lexicons.validate('com.atproto.repo.applyWrites#deleteResult', v)
171
+ }
@@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { isObj, hasProp } from '../../../../util'
8
8
  import { CID } from 'multiformats/cid'
9
9
  import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ComAtprotoRepoDefs from './defs'
10
11
 
11
12
  export interface QueryParams {}
12
13
 
@@ -17,8 +18,8 @@ export interface InputSchema {
17
18
  collection: string
18
19
  /** The Record Key. */
19
20
  rkey?: string
20
- /** Can be set to 'false' to skip Lexicon schema validation of record data. */
21
- validate: boolean
21
+ /** Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. */
22
+ validate?: boolean
22
23
  /** The record itself. Must contain a $type field. */
23
24
  record: {}
24
25
  /** Compare and swap with the previous commit by CID. */
@@ -29,6 +30,8 @@ export interface InputSchema {
29
30
  export interface OutputSchema {
30
31
  uri: string
31
32
  cid: string
33
+ commit?: ComAtprotoRepoDefs.CommitMeta
34
+ validationStatus?: 'valid' | 'unknown' | (string & {})
32
35
  [k: string]: unknown
33
36
  }
34
37
 
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
5
+ import { lexicons } from '../../../../lexicons'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { CID } from 'multiformats/cid'
8
+
9
+ export interface CommitMeta {
10
+ cid: string
11
+ rev: string
12
+ [k: string]: unknown
13
+ }
14
+
15
+ export function isCommitMeta(v: unknown): v is CommitMeta {
16
+ return (
17
+ isObj(v) &&
18
+ hasProp(v, '$type') &&
19
+ v.$type === 'com.atproto.repo.defs#commitMeta'
20
+ )
21
+ }
22
+
23
+ export function validateCommitMeta(v: unknown): ValidationResult {
24
+ return lexicons.validate('com.atproto.repo.defs#commitMeta', v)
25
+ }
@@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { isObj, hasProp } from '../../../../util'
8
8
  import { CID } from 'multiformats/cid'
9
9
  import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ComAtprotoRepoDefs from './defs'
10
11
 
11
12
  export interface QueryParams {}
12
13
 
@@ -24,18 +25,29 @@ export interface InputSchema {
24
25
  [k: string]: unknown
25
26
  }
26
27
 
28
+ export interface OutputSchema {
29
+ commit?: ComAtprotoRepoDefs.CommitMeta
30
+ [k: string]: unknown
31
+ }
32
+
27
33
  export interface HandlerInput {
28
34
  encoding: 'application/json'
29
35
  body: InputSchema
30
36
  }
31
37
 
38
+ export interface HandlerSuccess {
39
+ encoding: 'application/json'
40
+ body: OutputSchema
41
+ headers?: { [key: string]: string }
42
+ }
43
+
32
44
  export interface HandlerError {
33
45
  status: number
34
46
  message?: string
35
47
  error?: 'InvalidSwap'
36
48
  }
37
49
 
38
- export type HandlerOutput = HandlerError | void
50
+ export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
39
51
  export type HandlerReqCtx<HA extends HandlerAuth = never> = {
40
52
  auth: HA
41
53
  params: QueryParams
@@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { isObj, hasProp } from '../../../../util'
8
8
  import { CID } from 'multiformats/cid'
9
9
  import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
10
+ import * as ComAtprotoRepoDefs from './defs'
10
11
 
11
12
  export interface QueryParams {}
12
13
 
@@ -17,8 +18,8 @@ export interface InputSchema {
17
18
  collection: string
18
19
  /** The Record Key. */
19
20
  rkey: string
20
- /** Can be set to 'false' to skip Lexicon schema validation of record data. */
21
- validate: boolean
21
+ /** Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. */
22
+ validate?: boolean
22
23
  /** The record to write. */
23
24
  record: {}
24
25
  /** Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation */
@@ -31,6 +32,8 @@ export interface InputSchema {
31
32
  export interface OutputSchema {
32
33
  uri: string
33
34
  cid: string
35
+ commit?: ComAtprotoRepoDefs.CommitMeta
36
+ validationStatus?: 'valid' | 'unknown' | (string & {})
34
37
  [k: string]: unknown
35
38
  }
36
39
 
@@ -28,7 +28,12 @@ import {
28
28
  StarterPackView,
29
29
  StarterPackViewBasic,
30
30
  } from '../lexicon/types/app/bsky/graph/defs'
31
- import { parseThreadGate, parsePostgate, cidFromBlobJson } from './util'
31
+ import {
32
+ parseThreadGate,
33
+ cidFromBlobJson,
34
+ VideoUriBuilder,
35
+ parsePostgate,
36
+ } from './util'
32
37
  import { uriToDid as creatorFromUri } from '../util/uris'
33
38
  import { isListRule } from '../lexicon/types/app/bsky/feed/threadgate'
34
39
  import { isSelfLabels } from '../lexicon/types/com/atproto/label/defs'
@@ -50,10 +55,13 @@ import {
50
55
  RecordEmbedViewInternal,
51
56
  RecordWithMedia,
52
57
  RecordWithMediaView,
58
+ VideoEmbed,
59
+ VideoEmbedView,
53
60
  isExternalEmbed,
54
61
  isImagesEmbed,
55
62
  isRecordEmbed,
56
63
  isRecordWithMedia,
64
+ isVideoEmbed,
57
65
  } from './types'
58
66
  import { Label } from '../hydration/label'
59
67
  import { FeedItem, Post, Repost } from '../hydration/feed'
@@ -66,7 +74,10 @@ import { Notification } from '../proto/bsky_pb'
66
74
  import { postUriToThreadgateUri, postUriToPostgateUri } from '../util/uris'
67
75
 
68
76
  export class Views {
69
- constructor(public imgUriBuilder: ImageUriBuilder) {}
77
+ constructor(
78
+ public imgUriBuilder: ImageUriBuilder,
79
+ public videoUriBuilder: VideoUriBuilder,
80
+ ) {}
70
81
 
71
82
  // Actor
72
83
  // ------------
@@ -841,6 +852,8 @@ export class Views {
841
852
  ): EmbedView | undefined {
842
853
  if (isImagesEmbed(embed)) {
843
854
  return this.imagesEmbed(creatorFromUri(postUri), embed)
855
+ } else if (isVideoEmbed(embed)) {
856
+ return this.videoEmbed(creatorFromUri(postUri), embed)
844
857
  } else if (isExternalEmbed(embed)) {
845
858
  return this.externalEmbed(creatorFromUri(postUri), embed)
846
859
  } else if (isRecordEmbed(embed)) {
@@ -873,6 +886,18 @@ export class Views {
873
886
  }
874
887
  }
875
888
 
889
+ videoEmbed(did: string, embed: VideoEmbed): VideoEmbedView {
890
+ const cid = cidFromBlobJson(embed.video)
891
+ return {
892
+ $type: 'app.bsky.embed.video#view',
893
+ cid,
894
+ playlist: this.videoUriBuilder.playlist({ did, cid }),
895
+ thumbnail: this.videoUriBuilder.thumbnail({ did, cid }),
896
+ alt: embed.alt,
897
+ aspectRatio: embed.aspectRatio,
898
+ }
899
+ }
900
+
876
901
  externalEmbed(did: string, embed: ExternalEmbed): ExternalEmbedView {
877
902
  const { uri, title, description, thumb } = embed.external
878
903
  return {
@@ -1027,9 +1052,11 @@ export class Views {
1027
1052
  depth: number,
1028
1053
  ): RecordWithMediaView | undefined {
1029
1054
  const creator = creatorFromUri(postUri)
1030
- let mediaEmbed: ImagesEmbedView | ExternalEmbedView
1055
+ let mediaEmbed: ImagesEmbedView | VideoEmbedView | ExternalEmbedView
1031
1056
  if (isImagesEmbed(embed.media)) {
1032
1057
  mediaEmbed = this.imagesEmbed(creator, embed.media)
1058
+ } else if (isVideoEmbed(embed.media)) {
1059
+ mediaEmbed = this.videoEmbed(creator, embed.media)
1033
1060
  } else if (isExternalEmbed(embed.media)) {
1034
1061
  mediaEmbed = this.externalEmbed(creator, embed.media)
1035
1062
  } else {
@@ -2,6 +2,10 @@ import {
2
2
  Main as ImagesEmbed,
3
3
  View as ImagesEmbedView,
4
4
  } from '../lexicon/types/app/bsky/embed/images'
5
+ import {
6
+ Main as VideoEmbed,
7
+ View as VideoEmbedView,
8
+ } from '../lexicon/types/app/bsky/embed/video'
5
9
  import {
6
10
  Main as ExternalEmbed,
7
11
  View as ExternalEmbedView,
@@ -29,6 +33,11 @@ export type {
29
33
  View as ImagesEmbedView,
30
34
  } from '../lexicon/types/app/bsky/embed/images'
31
35
  export { isMain as isImagesEmbed } from '../lexicon/types/app/bsky/embed/images'
36
+ export type {
37
+ Main as VideoEmbed,
38
+ View as VideoEmbedView,
39
+ } from '../lexicon/types/app/bsky/embed/video'
40
+ export { isMain as isVideoEmbed } from '../lexicon/types/app/bsky/embed/video'
32
41
  export type {
33
42
  Main as ExternalEmbed,
34
43
  View as ExternalEmbedView,
@@ -59,10 +68,16 @@ export type { ListView } from '../lexicon/types/app/bsky/graph/defs'
59
68
 
60
69
  export type { Notification as NotificationView } from '../lexicon/types/app/bsky/notification/listNotifications'
61
70
 
62
- export type Embed = ImagesEmbed | ExternalEmbed | RecordEmbed | RecordWithMedia
71
+ export type Embed =
72
+ | ImagesEmbed
73
+ | VideoEmbed
74
+ | ExternalEmbed
75
+ | RecordEmbed
76
+ | RecordWithMedia
63
77
 
64
78
  export type EmbedView =
65
79
  | ImagesEmbedView
80
+ | VideoEmbedView
66
81
  | ExternalEmbedView
67
82
  | RecordEmbedView
68
83
  | RecordWithMediaView
package/src/views/util.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as util from 'node:util'
1
2
  import { BlobRef } from '@atproto/lexicon'
2
3
  import { Record as PostRecord } from '../lexicon/types/app/bsky/feed/post'
3
4
  import {
@@ -92,3 +93,26 @@ type ParsedPostgate = {
92
93
  canEmbed: boolean
93
94
  }
94
95
  }
96
+
97
+ export class VideoUriBuilder {
98
+ constructor(
99
+ private opts: {
100
+ playlistUrlPattern: string // e.g. https://hostname/vid/%s/%s/playlist.m3u8
101
+ thumbnailUrlPattern: string // e.g. https://hostname/vid/%s/%s/thumbnail.jpg
102
+ },
103
+ ) {}
104
+ playlist({ did, cid }: { did: string; cid: string }) {
105
+ return util.format(
106
+ this.opts.playlistUrlPattern,
107
+ encodeURIComponent(did),
108
+ encodeURIComponent(cid),
109
+ )
110
+ }
111
+ thumbnail({ did, cid }: { did: string; cid: string }) {
112
+ return util.format(
113
+ this.opts.thumbnailUrlPattern,
114
+ encodeURIComponent(did),
115
+ encodeURIComponent(cid),
116
+ )
117
+ }
118
+ }
package/tests/_util.ts CHANGED
@@ -80,6 +80,15 @@ export const forSnapshot = (obj: unknown) => {
80
80
  const [, did, cid] = match
81
81
  return str.replace(did, take(users, did)).replace(cid, take(cids, cid))
82
82
  }
83
+ if (str.match(/\/vid\/did%3Aplc%3A[^/]+\/[^/]+\/[^/]+$/)) {
84
+ // Match video urls
85
+ const match = str.match(/\/vid\/(did%3Aplc%3A[^/]+)\/([^/]+)\/[^/]+$/)
86
+ if (!match) return str
87
+ const [, did, cid] = match
88
+ return str
89
+ .replace(did, take(users, decodeURIComponent(did)))
90
+ .replace(cid, take(cids, cid))
91
+ }
83
92
  let isCid: boolean
84
93
  try {
85
94
  CID.parse(str)