Parse and validate AT Protocol Lexicons with DTO generation for Laravel
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 * Represents an update of repository state. Note that empty commits are
12 * allowed, which include no repo data changes, but an update to rev and
13 * signature.
14 *
15 * Lexicon: com.atproto.sync.subscribeRepos.commit
16 * Type: object
17 *
18 * @property int $seq The stream sequence number of this message.
19 * @property bool $rebase DEPRECATED -- unused
20 * @property bool $tooBig DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.
21 * @property string $repo The repo this event comes from. Note that all other message types name this field 'did'.
22 * @property string $commit Repo commit object CID.
23 * @property string $rev The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.
24 * @property string $since The rev of the last emitted commit from this repo (if any).
25 * @property string $blocks CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.
26 * @property array $ops
27 * @property array<string> $blobs
28 * @property string|null $prevData The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.
29 * @property Carbon $time Timestamp of when this message was originally broadcast.
30 *
31 * Constraints:
32 * - Required: seq, rebase, tooBig, repo, commit, rev, since, blocks, ops, blobs, time
33 * - repo: Format: did
34 * - rev: Format: tid
35 * - since: Format: tid
36 * - blocks: Max length: 2000000
37 * - ops: Max length: 200
38 * - time: Format: datetime
39 */
40class Commit extends Data
41{
42 /**
43 * @param int $seq The stream sequence number of this message.
44 * @param bool $rebase DEPRECATED -- unused
45 * @param bool $tooBig DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.
46 * @param string $repo The repo this event comes from. Note that all other message types name this field 'did'.
47 * @param string $commit Repo commit object CID.
48 * @param string $rev The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.
49 * @param string $since The rev of the last emitted commit from this repo (if any).
50 * @param string $blocks CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.
51 * @param Carbon $time Timestamp of when this message was originally broadcast.
52 * @param string|null $prevData The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.
53 */
54 public function __construct(
55 public readonly int $seq,
56 public readonly bool $rebase,
57 public readonly bool $tooBig,
58 public readonly string $repo,
59 public readonly string $commit,
60 public readonly string $rev,
61 public readonly string $since,
62 public readonly string $blocks,
63 public readonly array $ops,
64 public readonly array $blobs,
65 public readonly Carbon $time,
66 public readonly ?string $prevData = null
67 ) {
68 }
69
70 /**
71 * Get the lexicon NSID for this data type.
72 *
73 * @return string
74 */
75 public static function getLexicon(): string
76 {
77 return 'com.atproto.sync.subscribeRepos.commit';
78 }
79
80
81 /**
82 * Create an instance from an array.
83 *
84 * @param array $data The data array
85 * @return static
86 */
87 public static function fromArray(array $data): static
88 {
89 return new static(
90 seq: $data['seq'],
91 rebase: $data['rebase'],
92 tooBig: $data['tooBig'],
93 repo: $data['repo'],
94 commit: $data['commit'],
95 rev: $data['rev'],
96 since: $data['since'],
97 blocks: $data['blocks'],
98 ops: $data['ops'] ?? [],
99 blobs: $data['blobs'],
100 time: Carbon::parse($data['time']),
101 prevData: $data['prevData'] ?? null
102 );
103 }
104
105}