@atproto/api 0.18.14 → 0.18.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/agent.d.ts +9 -0
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +35 -0
  5. package/dist/agent.js.map +1 -1
  6. package/dist/client/index.d.ts +18 -0
  7. package/dist/client/index.d.ts.map +1 -1
  8. package/dist/client/index.js +49 -8
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/client/lexicons.d.ts +744 -2
  11. package/dist/client/lexicons.d.ts.map +1 -1
  12. package/dist/client/lexicons.js +384 -0
  13. package/dist/client/lexicons.js.map +1 -1
  14. package/dist/client/types/app/bsky/actor/defs.d.ts +11 -1
  15. package/dist/client/types/app/bsky/actor/defs.d.ts.map +1 -1
  16. package/dist/client/types/app/bsky/actor/defs.js +9 -0
  17. package/dist/client/types/app/bsky/actor/defs.js.map +1 -1
  18. package/dist/client/types/app/bsky/draft/createDraft.d.ts +29 -0
  19. package/dist/client/types/app/bsky/draft/createDraft.d.ts.map +1 -0
  20. package/dist/client/types/app/bsky/draft/createDraft.js +26 -0
  21. package/dist/client/types/app/bsky/draft/createDraft.js.map +1 -0
  22. package/dist/client/types/app/bsky/draft/defs.d.ts +106 -0
  23. package/dist/client/types/app/bsky/draft/defs.d.ts.map +1 -0
  24. package/dist/client/types/app/bsky/draft/defs.js +97 -0
  25. package/dist/client/types/app/bsky/draft/defs.js.map +1 -0
  26. package/dist/client/types/app/bsky/draft/deleteDraft.d.ts +20 -0
  27. package/dist/client/types/app/bsky/draft/deleteDraft.d.ts.map +1 -0
  28. package/dist/client/types/app/bsky/draft/deleteDraft.js +11 -0
  29. package/dist/client/types/app/bsky/draft/deleteDraft.js.map +1 -0
  30. package/dist/client/types/app/bsky/draft/getDrafts.d.ts +25 -0
  31. package/dist/client/types/app/bsky/draft/getDrafts.d.ts.map +1 -0
  32. package/dist/client/types/app/bsky/draft/getDrafts.js +11 -0
  33. package/dist/client/types/app/bsky/draft/getDrafts.js.map +1 -0
  34. package/dist/client/types/app/bsky/draft/updateDraft.d.ts +21 -0
  35. package/dist/client/types/app/bsky/draft/updateDraft.d.ts.map +1 -0
  36. package/dist/client/types/app/bsky/draft/updateDraft.js +11 -0
  37. package/dist/client/types/app/bsky/draft/updateDraft.js.map +1 -0
  38. package/dist/predicate.d.ts +1 -0
  39. package/dist/predicate.d.ts.map +1 -1
  40. package/dist/predicate.js +2 -1
  41. package/dist/predicate.js.map +1 -1
  42. package/dist/types.d.ts +4 -0
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js.map +1 -1
  45. package/package.json +3 -3
  46. package/src/agent.ts +44 -0
  47. package/src/client/index.ts +57 -0
  48. package/src/client/lexicons.ts +394 -0
  49. package/src/client/types/app/bsky/actor/defs.ts +20 -0
  50. package/src/client/types/app/bsky/draft/createDraft.ts +55 -0
  51. package/src/client/types/app/bsky/draft/defs.ts +208 -0
  52. package/src/client/types/app/bsky/draft/deleteDraft.ts +38 -0
  53. package/src/client/types/app/bsky/draft/getDrafts.ts +43 -0
  54. package/src/client/types/app/bsky/draft/updateDraft.ts +39 -0
  55. package/src/predicate.ts +3 -0
  56. package/src/types.ts +4 -0
  57. package/tests/atp-agent.test.ts +180 -0
  58. package/tests/moderation-prefs.test.ts +16 -0
  59. package/tsconfig.build.tsbuildinfo +1 -1
@@ -411,6 +411,7 @@ export const schemaDict = {
411
411
  'lex:app.bsky.actor.defs#labelersPref',
412
412
  'lex:app.bsky.actor.defs#postInteractionSettingsPref',
413
413
  'lex:app.bsky.actor.defs#verificationPrefs',
414
+ 'lex:app.bsky.actor.defs#liveEventPreferences',
414
415
  ],
415
416
  },
416
417
  },
@@ -775,6 +776,25 @@ export const schemaDict = {
775
776
  },
776
777
  },
777
778
  },
779
+ liveEventPreferences: {
780
+ type: 'object',
781
+ description: 'Preferences for live events.',
782
+ properties: {
783
+ hiddenFeedIds: {
784
+ description:
785
+ 'A list of feed IDs that the user has hidden from live events.',
786
+ type: 'array',
787
+ items: {
788
+ type: 'string',
789
+ },
790
+ },
791
+ hideAllFeeds: {
792
+ description: 'Whether to hide all feeds from live events.',
793
+ type: 'boolean',
794
+ default: false,
795
+ },
796
+ },
797
+ },
778
798
  postInteractionSettingsPref: {
779
799
  type: 'object',
780
800
  description:
@@ -2218,6 +2238,375 @@ export const schemaDict = {
2218
2238
  },
2219
2239
  },
2220
2240
  },
2241
+ AppBskyDraftCreateDraft: {
2242
+ lexicon: 1,
2243
+ id: 'app.bsky.draft.createDraft',
2244
+ defs: {
2245
+ main: {
2246
+ type: 'procedure',
2247
+ description:
2248
+ 'Inserts a draft using private storage (stash). An upper limit of drafts might be enforced. Requires authentication.',
2249
+ input: {
2250
+ encoding: 'application/json',
2251
+ schema: {
2252
+ type: 'object',
2253
+ required: ['draft'],
2254
+ properties: {
2255
+ draft: {
2256
+ type: 'ref',
2257
+ ref: 'lex:app.bsky.draft.defs#draft',
2258
+ },
2259
+ },
2260
+ },
2261
+ },
2262
+ output: {
2263
+ encoding: 'application/json',
2264
+ schema: {
2265
+ type: 'object',
2266
+ required: ['id'],
2267
+ properties: {
2268
+ id: {
2269
+ type: 'string',
2270
+ description: 'The ID of the created draft.',
2271
+ },
2272
+ },
2273
+ },
2274
+ },
2275
+ errors: [
2276
+ {
2277
+ name: 'DraftLimitReached',
2278
+ description:
2279
+ 'Trying to insert a new draft when the limit was already reached.',
2280
+ },
2281
+ ],
2282
+ },
2283
+ },
2284
+ },
2285
+ AppBskyDraftDefs: {
2286
+ lexicon: 1,
2287
+ id: 'app.bsky.draft.defs',
2288
+ defs: {
2289
+ draftWithId: {
2290
+ description:
2291
+ 'A draft with an identifier, used to store drafts in private storage (stash).',
2292
+ type: 'object',
2293
+ required: ['id', 'draft'],
2294
+ properties: {
2295
+ id: {
2296
+ description: 'A TID to be used as a draft identifier.',
2297
+ type: 'string',
2298
+ format: 'tid',
2299
+ },
2300
+ draft: {
2301
+ type: 'ref',
2302
+ ref: 'lex:app.bsky.draft.defs#draft',
2303
+ },
2304
+ },
2305
+ },
2306
+ draft: {
2307
+ description: 'A draft containing an array of draft posts.',
2308
+ type: 'object',
2309
+ required: ['posts'],
2310
+ properties: {
2311
+ posts: {
2312
+ description: 'Array of draft posts that compose this draft.',
2313
+ type: 'array',
2314
+ minLength: 1,
2315
+ maxLength: 100,
2316
+ items: {
2317
+ type: 'ref',
2318
+ ref: 'lex:app.bsky.draft.defs#draftPost',
2319
+ },
2320
+ },
2321
+ langs: {
2322
+ type: 'array',
2323
+ description:
2324
+ 'Indicates human language of posts primary text content.',
2325
+ maxLength: 3,
2326
+ items: {
2327
+ type: 'string',
2328
+ format: 'language',
2329
+ },
2330
+ },
2331
+ postgateEmbeddingRules: {
2332
+ description:
2333
+ 'Embedding rules for the postgates to be created when this draft is published.',
2334
+ type: 'array',
2335
+ maxLength: 5,
2336
+ items: {
2337
+ type: 'union',
2338
+ refs: ['lex:app.bsky.feed.postgate#disableRule'],
2339
+ },
2340
+ },
2341
+ threadgateAllow: {
2342
+ description:
2343
+ 'Allow-rules for the threadgate to be created when this draft is published.',
2344
+ type: 'array',
2345
+ maxLength: 5,
2346
+ items: {
2347
+ type: 'union',
2348
+ refs: [
2349
+ 'lex:app.bsky.feed.threadgate#mentionRule',
2350
+ 'lex:app.bsky.feed.threadgate#followerRule',
2351
+ 'lex:app.bsky.feed.threadgate#followingRule',
2352
+ 'lex:app.bsky.feed.threadgate#listRule',
2353
+ ],
2354
+ },
2355
+ },
2356
+ },
2357
+ },
2358
+ draftPost: {
2359
+ description: 'One of the posts that compose a draft.',
2360
+ type: 'object',
2361
+ required: ['text'],
2362
+ properties: {
2363
+ text: {
2364
+ type: 'string',
2365
+ maxLength: 3000,
2366
+ maxGraphemes: 300,
2367
+ description: 'The primary post content.',
2368
+ },
2369
+ labels: {
2370
+ type: 'union',
2371
+ description:
2372
+ 'Self-label values for this post. Effectively content warnings.',
2373
+ refs: ['lex:com.atproto.label.defs#selfLabels'],
2374
+ },
2375
+ embedImages: {
2376
+ type: 'array',
2377
+ items: {
2378
+ type: 'ref',
2379
+ ref: 'lex:app.bsky.draft.defs#draftEmbedImage',
2380
+ },
2381
+ maxLength: 4,
2382
+ },
2383
+ embedVideos: {
2384
+ type: 'array',
2385
+ items: {
2386
+ type: 'ref',
2387
+ ref: 'lex:app.bsky.draft.defs#draftEmbedVideo',
2388
+ },
2389
+ maxLength: 1,
2390
+ },
2391
+ embedExternals: {
2392
+ type: 'array',
2393
+ items: {
2394
+ type: 'ref',
2395
+ ref: 'lex:app.bsky.draft.defs#draftEmbedExternal',
2396
+ },
2397
+ maxLength: 1,
2398
+ },
2399
+ embedRecords: {
2400
+ type: 'array',
2401
+ items: {
2402
+ type: 'ref',
2403
+ ref: 'lex:app.bsky.draft.defs#draftEmbedRecord',
2404
+ },
2405
+ maxLength: 1,
2406
+ },
2407
+ },
2408
+ },
2409
+ draftView: {
2410
+ description: 'View to present drafts data to users.',
2411
+ type: 'object',
2412
+ required: ['id', 'draft', 'createdAt', 'updatedAt'],
2413
+ properties: {
2414
+ id: {
2415
+ description: 'A TID to be used as a draft identifier.',
2416
+ type: 'string',
2417
+ format: 'tid',
2418
+ },
2419
+ draft: {
2420
+ type: 'ref',
2421
+ ref: 'lex:app.bsky.draft.defs#draft',
2422
+ },
2423
+ createdAt: {
2424
+ description: 'The time the draft was created.',
2425
+ type: 'string',
2426
+ format: 'datetime',
2427
+ },
2428
+ updatedAt: {
2429
+ description: 'The time the draft was last updated.',
2430
+ type: 'string',
2431
+ format: 'datetime',
2432
+ },
2433
+ },
2434
+ },
2435
+ draftEmbedLocalRef: {
2436
+ type: 'object',
2437
+ required: ['path'],
2438
+ properties: {
2439
+ path: {
2440
+ type: 'string',
2441
+ description:
2442
+ 'Local, on-device ref to file to be embedded. Embeds are currently device-bound for drafts.',
2443
+ minLength: 1,
2444
+ maxLength: 1024,
2445
+ },
2446
+ },
2447
+ },
2448
+ draftEmbedCaption: {
2449
+ type: 'object',
2450
+ required: ['lang', 'content'],
2451
+ properties: {
2452
+ lang: {
2453
+ type: 'string',
2454
+ format: 'language',
2455
+ },
2456
+ content: {
2457
+ type: 'string',
2458
+ maxLength: 10000,
2459
+ },
2460
+ },
2461
+ },
2462
+ draftEmbedImage: {
2463
+ type: 'object',
2464
+ required: ['localRef'],
2465
+ properties: {
2466
+ localRef: {
2467
+ type: 'ref',
2468
+ ref: 'lex:app.bsky.draft.defs#draftEmbedLocalRef',
2469
+ },
2470
+ alt: {
2471
+ type: 'string',
2472
+ maxGraphemes: 2000,
2473
+ },
2474
+ },
2475
+ },
2476
+ draftEmbedVideo: {
2477
+ type: 'object',
2478
+ required: ['localRef'],
2479
+ properties: {
2480
+ localRef: {
2481
+ type: 'ref',
2482
+ ref: 'lex:app.bsky.draft.defs#draftEmbedLocalRef',
2483
+ },
2484
+ alt: {
2485
+ type: 'string',
2486
+ maxGraphemes: 2000,
2487
+ },
2488
+ captions: {
2489
+ type: 'array',
2490
+ items: {
2491
+ type: 'ref',
2492
+ ref: 'lex:app.bsky.draft.defs#draftEmbedCaption',
2493
+ },
2494
+ maxLength: 20,
2495
+ },
2496
+ },
2497
+ },
2498
+ draftEmbedExternal: {
2499
+ type: 'object',
2500
+ required: ['uri'],
2501
+ properties: {
2502
+ uri: {
2503
+ type: 'string',
2504
+ format: 'uri',
2505
+ },
2506
+ },
2507
+ },
2508
+ draftEmbedRecord: {
2509
+ type: 'object',
2510
+ required: ['record'],
2511
+ properties: {
2512
+ record: {
2513
+ type: 'ref',
2514
+ ref: 'lex:com.atproto.repo.strongRef',
2515
+ },
2516
+ },
2517
+ },
2518
+ },
2519
+ },
2520
+ AppBskyDraftDeleteDraft: {
2521
+ lexicon: 1,
2522
+ id: 'app.bsky.draft.deleteDraft',
2523
+ defs: {
2524
+ main: {
2525
+ type: 'procedure',
2526
+ description: 'Deletes a draft by ID. Requires authentication.',
2527
+ input: {
2528
+ encoding: 'application/json',
2529
+ schema: {
2530
+ type: 'object',
2531
+ required: ['id'],
2532
+ properties: {
2533
+ id: {
2534
+ type: 'string',
2535
+ format: 'tid',
2536
+ },
2537
+ },
2538
+ },
2539
+ },
2540
+ },
2541
+ },
2542
+ },
2543
+ AppBskyDraftGetDrafts: {
2544
+ lexicon: 1,
2545
+ id: 'app.bsky.draft.getDrafts',
2546
+ defs: {
2547
+ main: {
2548
+ type: 'query',
2549
+ description: 'Gets views of user drafts. Requires authentication.',
2550
+ parameters: {
2551
+ type: 'params',
2552
+ properties: {
2553
+ limit: {
2554
+ type: 'integer',
2555
+ minimum: 1,
2556
+ maximum: 100,
2557
+ default: 50,
2558
+ },
2559
+ cursor: {
2560
+ type: 'string',
2561
+ },
2562
+ },
2563
+ },
2564
+ output: {
2565
+ encoding: 'application/json',
2566
+ schema: {
2567
+ type: 'object',
2568
+ required: ['drafts'],
2569
+ properties: {
2570
+ cursor: {
2571
+ type: 'string',
2572
+ },
2573
+ drafts: {
2574
+ type: 'array',
2575
+ items: {
2576
+ type: 'ref',
2577
+ ref: 'lex:app.bsky.draft.defs#draftView',
2578
+ },
2579
+ },
2580
+ },
2581
+ },
2582
+ },
2583
+ },
2584
+ },
2585
+ },
2586
+ AppBskyDraftUpdateDraft: {
2587
+ lexicon: 1,
2588
+ id: 'app.bsky.draft.updateDraft',
2589
+ defs: {
2590
+ main: {
2591
+ type: 'procedure',
2592
+ description:
2593
+ "Updates a draft using private storage (stash). If the draft ID points to a non-existing ID, the update will be silently ignored. This is done because updates don't enforce draft limit, so it accepts all writes, but will ignore invalid ones. Requires authentication.",
2594
+ input: {
2595
+ encoding: 'application/json',
2596
+ schema: {
2597
+ type: 'object',
2598
+ required: ['draft'],
2599
+ properties: {
2600
+ draft: {
2601
+ type: 'ref',
2602
+ ref: 'lex:app.bsky.draft.defs#draftWithId',
2603
+ },
2604
+ },
2605
+ },
2606
+ },
2607
+ },
2608
+ },
2609
+ },
2221
2610
  AppBskyEmbedDefs: {
2222
2611
  lexicon: 1,
2223
2612
  id: 'app.bsky.embed.defs',
@@ -20128,6 +20517,11 @@ export const ids = {
20128
20517
  AppBskyContactStartPhoneVerification:
20129
20518
  'app.bsky.contact.startPhoneVerification',
20130
20519
  AppBskyContactVerifyPhone: 'app.bsky.contact.verifyPhone',
20520
+ AppBskyDraftCreateDraft: 'app.bsky.draft.createDraft',
20521
+ AppBskyDraftDefs: 'app.bsky.draft.defs',
20522
+ AppBskyDraftDeleteDraft: 'app.bsky.draft.deleteDraft',
20523
+ AppBskyDraftGetDrafts: 'app.bsky.draft.getDrafts',
20524
+ AppBskyDraftUpdateDraft: 'app.bsky.draft.updateDraft',
20131
20525
  AppBskyEmbedDefs: 'app.bsky.embed.defs',
20132
20526
  AppBskyEmbedExternal: 'app.bsky.embed.external',
20133
20527
  AppBskyEmbedImages: 'app.bsky.embed.images',
@@ -269,6 +269,7 @@ export type Preferences = (
269
269
  | $Typed<LabelersPref>
270
270
  | $Typed<PostInteractionSettingsPref>
271
271
  | $Typed<VerificationPrefs>
272
+ | $Typed<LiveEventPreferences>
272
273
  | { $type: string }
273
274
  )[]
274
275
 
@@ -618,6 +619,25 @@ export function validateVerificationPrefs<V>(v: V) {
618
619
  return validate<VerificationPrefs & V>(v, id, hashVerificationPrefs)
619
620
  }
620
621
 
622
+ /** Preferences for live events. */
623
+ export interface LiveEventPreferences {
624
+ $type?: 'app.bsky.actor.defs#liveEventPreferences'
625
+ /** A list of feed IDs that the user has hidden from live events. */
626
+ hiddenFeedIds?: string[]
627
+ /** Whether to hide all feeds from live events. */
628
+ hideAllFeeds: boolean
629
+ }
630
+
631
+ const hashLiveEventPreferences = 'liveEventPreferences'
632
+
633
+ export function isLiveEventPreferences<V>(v: V) {
634
+ return is$typed(v, id, hashLiveEventPreferences)
635
+ }
636
+
637
+ export function validateLiveEventPreferences<V>(v: V) {
638
+ return validate<LiveEventPreferences & V>(v, id, hashLiveEventPreferences)
639
+ }
640
+
621
641
  /** Default post interaction settings for the account. These values should be applied as default values when creating new posts. These refs should mirror the threadgate and postgate records exactly. */
622
642
  export interface PostInteractionSettingsPref {
623
643
  $type?: 'app.bsky.actor.defs#postInteractionSettingsPref'
@@ -0,0 +1,55 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { HeadersMap, XRPCError } from '@atproto/xrpc'
5
+ import { type ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { CID } from 'multiformats/cid'
7
+ import { validate as _validate } from '../../../../lexicons'
8
+ import {
9
+ type $Typed,
10
+ is$typed as _is$typed,
11
+ type OmitKey,
12
+ } from '../../../../util'
13
+ import type * as AppBskyDraftDefs from './defs.js'
14
+
15
+ const is$typed = _is$typed,
16
+ validate = _validate
17
+ const id = 'app.bsky.draft.createDraft'
18
+
19
+ export type QueryParams = {}
20
+
21
+ export interface InputSchema {
22
+ draft: AppBskyDraftDefs.Draft
23
+ }
24
+
25
+ export interface OutputSchema {
26
+ /** The ID of the created draft. */
27
+ id: string
28
+ }
29
+
30
+ export interface CallOptions {
31
+ signal?: AbortSignal
32
+ headers?: HeadersMap
33
+ qp?: QueryParams
34
+ encoding?: 'application/json'
35
+ }
36
+
37
+ export interface Response {
38
+ success: boolean
39
+ headers: HeadersMap
40
+ data: OutputSchema
41
+ }
42
+
43
+ export class DraftLimitReachedError extends XRPCError {
44
+ constructor(src: XRPCError) {
45
+ super(src.status, src.error, src.message, src.headers, { cause: src })
46
+ }
47
+ }
48
+
49
+ export function toKnownErr(e: any) {
50
+ if (e instanceof XRPCError) {
51
+ if (e.error === 'DraftLimitReached') return new DraftLimitReachedError(e)
52
+ }
53
+
54
+ return e
55
+ }
@@ -0,0 +1,208 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { type ValidationResult, BlobRef } from '@atproto/lexicon'
5
+ import { CID } from 'multiformats/cid'
6
+ import { validate as _validate } from '../../../../lexicons'
7
+ import {
8
+ type $Typed,
9
+ is$typed as _is$typed,
10
+ type OmitKey,
11
+ } from '../../../../util'
12
+ import type * as AppBskyFeedPostgate from '../feed/postgate.js'
13
+ import type * as AppBskyFeedThreadgate from '../feed/threadgate.js'
14
+ import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs.js'
15
+ import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js'
16
+
17
+ const is$typed = _is$typed,
18
+ validate = _validate
19
+ const id = 'app.bsky.draft.defs'
20
+
21
+ /** A draft with an identifier, used to store drafts in private storage (stash). */
22
+ export interface DraftWithId {
23
+ $type?: 'app.bsky.draft.defs#draftWithId'
24
+ /** A TID to be used as a draft identifier. */
25
+ id: string
26
+ draft: Draft
27
+ }
28
+
29
+ const hashDraftWithId = 'draftWithId'
30
+
31
+ export function isDraftWithId<V>(v: V) {
32
+ return is$typed(v, id, hashDraftWithId)
33
+ }
34
+
35
+ export function validateDraftWithId<V>(v: V) {
36
+ return validate<DraftWithId & V>(v, id, hashDraftWithId)
37
+ }
38
+
39
+ /** A draft containing an array of draft posts. */
40
+ export interface Draft {
41
+ $type?: 'app.bsky.draft.defs#draft'
42
+ /** Array of draft posts that compose this draft. */
43
+ posts: DraftPost[]
44
+ /** Indicates human language of posts primary text content. */
45
+ langs?: string[]
46
+ /** Embedding rules for the postgates to be created when this draft is published. */
47
+ postgateEmbeddingRules?: (
48
+ | $Typed<AppBskyFeedPostgate.DisableRule>
49
+ | { $type: string }
50
+ )[]
51
+ /** Allow-rules for the threadgate to be created when this draft is published. */
52
+ threadgateAllow?: (
53
+ | $Typed<AppBskyFeedThreadgate.MentionRule>
54
+ | $Typed<AppBskyFeedThreadgate.FollowerRule>
55
+ | $Typed<AppBskyFeedThreadgate.FollowingRule>
56
+ | $Typed<AppBskyFeedThreadgate.ListRule>
57
+ | { $type: string }
58
+ )[]
59
+ }
60
+
61
+ const hashDraft = 'draft'
62
+
63
+ export function isDraft<V>(v: V) {
64
+ return is$typed(v, id, hashDraft)
65
+ }
66
+
67
+ export function validateDraft<V>(v: V) {
68
+ return validate<Draft & V>(v, id, hashDraft)
69
+ }
70
+
71
+ /** One of the posts that compose a draft. */
72
+ export interface DraftPost {
73
+ $type?: 'app.bsky.draft.defs#draftPost'
74
+ /** The primary post content. */
75
+ text: string
76
+ labels?: $Typed<ComAtprotoLabelDefs.SelfLabels> | { $type: string }
77
+ embedImages?: DraftEmbedImage[]
78
+ embedVideos?: DraftEmbedVideo[]
79
+ embedExternals?: DraftEmbedExternal[]
80
+ embedRecords?: DraftEmbedRecord[]
81
+ }
82
+
83
+ const hashDraftPost = 'draftPost'
84
+
85
+ export function isDraftPost<V>(v: V) {
86
+ return is$typed(v, id, hashDraftPost)
87
+ }
88
+
89
+ export function validateDraftPost<V>(v: V) {
90
+ return validate<DraftPost & V>(v, id, hashDraftPost)
91
+ }
92
+
93
+ /** View to present drafts data to users. */
94
+ export interface DraftView {
95
+ $type?: 'app.bsky.draft.defs#draftView'
96
+ /** A TID to be used as a draft identifier. */
97
+ id: string
98
+ draft: Draft
99
+ /** The time the draft was created. */
100
+ createdAt: string
101
+ /** The time the draft was last updated. */
102
+ updatedAt: string
103
+ }
104
+
105
+ const hashDraftView = 'draftView'
106
+
107
+ export function isDraftView<V>(v: V) {
108
+ return is$typed(v, id, hashDraftView)
109
+ }
110
+
111
+ export function validateDraftView<V>(v: V) {
112
+ return validate<DraftView & V>(v, id, hashDraftView)
113
+ }
114
+
115
+ export interface DraftEmbedLocalRef {
116
+ $type?: 'app.bsky.draft.defs#draftEmbedLocalRef'
117
+ /** Local, on-device ref to file to be embedded. Embeds are currently device-bound for drafts. */
118
+ path: string
119
+ }
120
+
121
+ const hashDraftEmbedLocalRef = 'draftEmbedLocalRef'
122
+
123
+ export function isDraftEmbedLocalRef<V>(v: V) {
124
+ return is$typed(v, id, hashDraftEmbedLocalRef)
125
+ }
126
+
127
+ export function validateDraftEmbedLocalRef<V>(v: V) {
128
+ return validate<DraftEmbedLocalRef & V>(v, id, hashDraftEmbedLocalRef)
129
+ }
130
+
131
+ export interface DraftEmbedCaption {
132
+ $type?: 'app.bsky.draft.defs#draftEmbedCaption'
133
+ lang: string
134
+ content: string
135
+ }
136
+
137
+ const hashDraftEmbedCaption = 'draftEmbedCaption'
138
+
139
+ export function isDraftEmbedCaption<V>(v: V) {
140
+ return is$typed(v, id, hashDraftEmbedCaption)
141
+ }
142
+
143
+ export function validateDraftEmbedCaption<V>(v: V) {
144
+ return validate<DraftEmbedCaption & V>(v, id, hashDraftEmbedCaption)
145
+ }
146
+
147
+ export interface DraftEmbedImage {
148
+ $type?: 'app.bsky.draft.defs#draftEmbedImage'
149
+ localRef: DraftEmbedLocalRef
150
+ alt?: string
151
+ }
152
+
153
+ const hashDraftEmbedImage = 'draftEmbedImage'
154
+
155
+ export function isDraftEmbedImage<V>(v: V) {
156
+ return is$typed(v, id, hashDraftEmbedImage)
157
+ }
158
+
159
+ export function validateDraftEmbedImage<V>(v: V) {
160
+ return validate<DraftEmbedImage & V>(v, id, hashDraftEmbedImage)
161
+ }
162
+
163
+ export interface DraftEmbedVideo {
164
+ $type?: 'app.bsky.draft.defs#draftEmbedVideo'
165
+ localRef: DraftEmbedLocalRef
166
+ alt?: string
167
+ captions?: DraftEmbedCaption[]
168
+ }
169
+
170
+ const hashDraftEmbedVideo = 'draftEmbedVideo'
171
+
172
+ export function isDraftEmbedVideo<V>(v: V) {
173
+ return is$typed(v, id, hashDraftEmbedVideo)
174
+ }
175
+
176
+ export function validateDraftEmbedVideo<V>(v: V) {
177
+ return validate<DraftEmbedVideo & V>(v, id, hashDraftEmbedVideo)
178
+ }
179
+
180
+ export interface DraftEmbedExternal {
181
+ $type?: 'app.bsky.draft.defs#draftEmbedExternal'
182
+ uri: string
183
+ }
184
+
185
+ const hashDraftEmbedExternal = 'draftEmbedExternal'
186
+
187
+ export function isDraftEmbedExternal<V>(v: V) {
188
+ return is$typed(v, id, hashDraftEmbedExternal)
189
+ }
190
+
191
+ export function validateDraftEmbedExternal<V>(v: V) {
192
+ return validate<DraftEmbedExternal & V>(v, id, hashDraftEmbedExternal)
193
+ }
194
+
195
+ export interface DraftEmbedRecord {
196
+ $type?: 'app.bsky.draft.defs#draftEmbedRecord'
197
+ record: ComAtprotoRepoStrongRef.Main
198
+ }
199
+
200
+ const hashDraftEmbedRecord = 'draftEmbedRecord'
201
+
202
+ export function isDraftEmbedRecord<V>(v: V) {
203
+ return is$typed(v, id, hashDraftEmbedRecord)
204
+ }
205
+
206
+ export function validateDraftEmbedRecord<V>(v: V) {
207
+ return validate<DraftEmbedRecord & V>(v, id, hashDraftEmbedRecord)
208
+ }