Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 77 lines 2.6 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Sync\SubscribeRepos; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7 8/** 9 * GENERATED CODE - DO NOT EDIT 10 * 11 * Updates the repo to a new state, without necessarily including that state on 12 * the firehose. Used to recover from broken commit streams, data loss 13 * incidents, or in situations where upstream host does not know recent state of 14 * the repository. 15 * 16 * Lexicon: com.atproto.sync.subscribeRepos.sync 17 * Type: object 18 * 19 * @property int $seq The stream sequence number of this message. 20 * @property string $did The account this repo event corresponds to. Must match that in the commit object. 21 * @property string $blocks CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. 22 * @property string $rev The rev of the commit. This value must match that in the commit object. 23 * @property Carbon $time Timestamp of when this message was originally broadcast. 24 * 25 * Constraints: 26 * - Required: seq, did, blocks, rev, time 27 * - did: Format: did 28 * - blocks: Max length: 10000 29 * - time: Format: datetime 30 */ 31class Sync extends Data 32{ 33 /** 34 * @param int $seq The stream sequence number of this message. 35 * @param string $did The account this repo event corresponds to. Must match that in the commit object. 36 * @param string $blocks CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. 37 * @param string $rev The rev of the commit. This value must match that in the commit object. 38 * @param Carbon $time Timestamp of when this message was originally broadcast. 39 */ 40 public function __construct( 41 public readonly int $seq, 42 public readonly string $did, 43 public readonly string $blocks, 44 public readonly string $rev, 45 public readonly Carbon $time 46 ) { 47 } 48 49 /** 50 * Get the lexicon NSID for this data type. 51 * 52 * @return string 53 */ 54 public static function getLexicon(): string 55 { 56 return 'com.atproto.sync.subscribeRepos.sync'; 57 } 58 59 60 /** 61 * Create an instance from an array. 62 * 63 * @param array $data The data array 64 * @return static 65 */ 66 public static function fromArray(array $data): static 67 { 68 return new static( 69 seq: $data['seq'], 70 did: $data['did'], 71 blocks: $data['blocks'], 72 rev: $data['rev'], 73 time: Carbon::parse($data['time']) 74 ); 75 } 76 77}