···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+import { type ValidationResult, BlobRef } from '@atproto/lexicon'
55+import { CID } from 'multiformats/cid'
66+import { validate as _validate } from '../../../lexicons'
77+import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util'
88+99+const is$typed = _is$typed,
1010+ validate = _validate
1111+const id = 'social.drydown.fragrance'
1212+1313+export interface Main {
1414+ $type: 'social.drydown.fragrance'
1515+ /** Fragrance name */
1616+ name: string
1717+ /** AT URI reference to house record (at://did/social.drydown.house/rkey) */
1818+ house: string
1919+ /** Year of release (optional) */
2020+ year?: number
2121+ /** Timestamp when fragrance was created */
2222+ createdAt: string
2323+ /** Timestamp of last update */
2424+ updatedAt?: string
2525+ [k: string]: unknown
2626+}
2727+2828+const hashMain = 'main'
2929+3030+export function isMain<V>(v: V) {
3131+ return is$typed(v, id, hashMain)
3232+}
3333+3434+export function validateMain<V>(v: V) {
3535+ return validate<Main & V>(v, id, hashMain, true)
3636+}
3737+3838+export {
3939+ type Main as Record,
4040+ isMain as isRecord,
4141+ validateMain as validateRecord,
4242+}
+38
src/client/types/social/drydown/house.ts
···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+import { type ValidationResult, BlobRef } from '@atproto/lexicon'
55+import { CID } from 'multiformats/cid'
66+import { validate as _validate } from '../../../lexicons'
77+import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util'
88+99+const is$typed = _is$typed,
1010+ validate = _validate
1111+const id = 'social.drydown.house'
1212+1313+export interface Main {
1414+ $type: 'social.drydown.house'
1515+ /** House/brand name (must be unique per user) */
1616+ name: string
1717+ /** Timestamp when house was created */
1818+ createdAt: string
1919+ /** Timestamp of last update (for name corrections) */
2020+ updatedAt?: string
2121+ [k: string]: unknown
2222+}
2323+2424+const hashMain = 'main'
2525+2626+export function isMain<V>(v: V) {
2727+ return is$typed(v, id, hashMain)
2828+}
2929+3030+export function validateMain<V>(v: V) {
3131+ return validate<Main & V>(v, id, hashMain, true)
3232+}
3333+3434+export {
3535+ type Main as Record,
3636+ isMain as isRecord,
3737+ validateMain as validateRecord,
3838+}
+58
src/client/types/social/drydown/review.ts
···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+import { type ValidationResult, BlobRef } from '@atproto/lexicon'
55+import { CID } from 'multiformats/cid'
66+import { validate as _validate } from '../../../lexicons'
77+import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util'
88+99+const is$typed = _is$typed,
1010+ validate = _validate
1111+const id = 'social.drydown.review'
1212+1313+export interface Main {
1414+ $type: 'social.drydown.review'
1515+ /** Reference to the social.drydown.fragrance record */
1616+ fragrance: string
1717+ /** Timestamp when the review was created */
1818+ createdAt: string
1919+ /** First Impression: How it smells immediately (1-5) */
2020+ openingRating?: number
2121+ /** First Impression: Immediate scent bubble radius (1-5) */
2222+ openingProjection?: number
2323+ /** Mid-Wear: How it smells after settling (1-5) */
2424+ drydownRating?: number
2525+ /** Mid-Wear: Scent bubble radius during mid-wear (1-5) */
2626+ midProjection?: number
2727+ /** Mid-Wear: Trail left behind (1-5) */
2828+ sillage?: number
2929+ /** Final: How it smells at the end (1-5) */
3030+ endRating?: number
3131+ /** Final: Depth and evolution (1-5) */
3232+ complexity?: number
3333+ /** Final: Total duration (1-5) */
3434+ longevity?: number
3535+ /** Final: Holistic 'Gut Score' (1-5) */
3636+ overallRating?: number
3737+ /** Calculated final score * 1000 (e.g. 4250 = 4.25) */
3838+ weightedScore?: number
3939+ /** Written review (max 255 graphemes) */
4040+ text?: string
4141+ [k: string]: unknown
4242+}
4343+4444+const hashMain = 'main'
4545+4646+export function isMain<V>(v: V) {
4747+ return is$typed(v, id, hashMain)
4848+}
4949+5050+export function validateMain<V>(v: V) {
5151+ return validate<Main & V>(v, id, hashMain, true)
5252+}
5353+5454+export {
5555+ type Main as Record,
5656+ isMain as isRecord,
5757+ validateMain as validateRecord,
5858+}
+82
src/client/util.ts
···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+55+import { type ValidationResult } from '@atproto/lexicon'
66+77+export type OmitKey<T, K extends keyof T> = {
88+ [K2 in keyof T as K2 extends K ? never : K2]: T[K2]
99+}
1010+1111+export type $Typed<V, T extends string = string> = V & { $type: T }
1212+export type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>
1313+1414+export type $Type<Id extends string, Hash extends string> = Hash extends 'main'
1515+ ? Id
1616+ : `${Id}#${Hash}`
1717+1818+function isObject<V>(v: V): v is V & object {
1919+ return v != null && typeof v === 'object'
2020+}
2121+2222+function is$type<Id extends string, Hash extends string>(
2323+ $type: unknown,
2424+ id: Id,
2525+ hash: Hash,
2626+): $type is $Type<Id, Hash> {
2727+ return hash === 'main'
2828+ ? $type === id
2929+ : // $type === `${id}#${hash}`
3030+ typeof $type === 'string' &&
3131+ $type.length === id.length + 1 + hash.length &&
3232+ $type.charCodeAt(id.length) === 35 /* '#' */ &&
3333+ $type.startsWith(id) &&
3434+ $type.endsWith(hash)
3535+}
3636+3737+export type $TypedObject<
3838+ V,
3939+ Id extends string,
4040+ Hash extends string,
4141+> = V extends {
4242+ $type: $Type<Id, Hash>
4343+}
4444+ ? V
4545+ : V extends { $type?: string }
4646+ ? V extends { $type?: infer T extends $Type<Id, Hash> }
4747+ ? V & { $type: T }
4848+ : never
4949+ : V & { $type: $Type<Id, Hash> }
5050+5151+export function is$typed<V, Id extends string, Hash extends string>(
5252+ v: V,
5353+ id: Id,
5454+ hash: Hash,
5555+): v is $TypedObject<V, Id, Hash> {
5656+ return isObject(v) && '$type' in v && is$type(v.$type, id, hash)
5757+}
5858+5959+export function maybe$typed<V, Id extends string, Hash extends string>(
6060+ v: V,
6161+ id: Id,
6262+ hash: Hash,
6363+): v is V & object & { $type?: $Type<Id, Hash> } {
6464+ return (
6565+ isObject(v) &&
6666+ ('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)
6767+ )
6868+}
6969+7070+export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>
7171+export type ValidatorParam<V extends Validator> =
7272+ V extends Validator<infer R> ? R : never
7373+7474+/**
7575+ * Utility function that allows to convert a "validate*" utility function into a
7676+ * type predicate.
7777+ */
7878+export function asPredicate<V extends Validator>(validate: V) {
7979+ return function <T>(v: T): v is T & ValidatorParam<V> {
8080+ return validate(v).success
8181+ }
8282+}