Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

all non-slow types in repo

+36 -17
+36 -17
repo/types.ts
··· 9 9 // Repo nodes 10 10 // --------------- 11 11 12 - const unsignedCommit = z.object({ 13 - did: z.string(), 14 - version: z.literal(3), 15 - data: common.cid, 16 - rev: z.string(), 17 - // `prev` added for backwards compatibility with v2, no requirement of keeping around history 18 - prev: common.cid.nullable(), 19 - }); 20 - export type UnsignedCommit = z.infer<typeof unsignedCommit> & { sig?: never }; 12 + type UnsignedCommitType = z.ZodObject<{ 13 + did: z.ZodString; 14 + version: z.ZodLiteral<3>; 15 + data: typeof common.cid; 16 + rev: z.ZodString; 17 + prev: z.ZodNullable<typeof common.cid>; 18 + }, z.core.$strip>; 19 + export type UnsignedCommit = z.infer<UnsignedCommitType> & { sig?: never }; 21 20 22 - const commit = z.object({ 21 + const commit: CommitType = z.object({ 23 22 did: z.string(), 24 23 version: z.literal(3), 25 24 data: common.cid, 26 25 rev: z.string(), 27 - prev: common.cid.nullable(), 26 + prev: z.nullable(common.cid), 28 27 sig: common.bytes, 29 28 }); 30 - export type Commit = z.infer<typeof commit>; 29 + type CommitType = z.ZodObject<{ 30 + did: z.ZodString; 31 + version: z.ZodLiteral<3>; 32 + data: typeof common.cid; 33 + rev: z.ZodString; 34 + prev: z.ZodNullable<typeof common.cid>; 35 + sig: typeof common.bytes; 36 + }, z.core.$strip>; 37 + export type Commit = z.infer<CommitType>; 31 38 32 - const legacyV2Commit = z.object({ 39 + const legacyV2Commit: LegacyV2CommitType = z.object({ 33 40 did: z.string(), 34 41 version: z.literal(2), 35 42 data: common.cid, 36 43 rev: z.string().optional(), 37 - prev: common.cid.nullable(), 44 + prev: z.nullable(common.cid), 38 45 sig: common.bytes, 39 46 }); 40 - export type LegacyV2Commit = z.infer<typeof legacyV2Commit>; 47 + type LegacyV2CommitType = z.ZodObject<{ 48 + did: z.ZodString; 49 + version: z.ZodLiteral<2>; 50 + data: typeof common.cid; 51 + rev: z.ZodOptional<z.ZodString>; 52 + prev: z.ZodNullable<typeof common.cid>; 53 + sig: typeof common.bytes; 54 + }, z.core.$strip>; 55 + export type LegacyV2Commit = z.infer<LegacyV2CommitType>; 41 56 42 - const versionedCommit = z.discriminatedUnion("version", [ 57 + const versionedCommit: VersionedCommitType = z.discriminatedUnion("version", [ 43 58 commit, 44 59 legacyV2Commit, 45 60 ]); 46 - export type VersionedCommit = z.infer<typeof versionedCommit>; 61 + type VersionedCommitType = z.ZodDiscriminatedUnion< 62 + [CommitType, LegacyV2CommitType], 63 + "version" 64 + >; 65 + export type VersionedCommit = z.infer<VersionedCommitType>; 47 66 48 67 export const schema = { 49 68 ...common,