@tldraw/tlschema
Version:
A tiny little drawing app (schema).
8 lines (7 loc) • 1.5 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/assets/TLBaseAsset.ts"],
"sourcesContent": ["import { BaseRecord } from '@tldraw/store'\nimport { JsonObject } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { TLAssetId } from '../records/TLAsset'\n\n/** @public */\nexport interface TLBaseAsset<Type extends string, Props> extends BaseRecord<'asset', TLAssetId> {\n\ttype: Type\n\tprops: Props\n\tmeta: JsonObject\n}\n\n/**\n * A validator for asset record type Ids.\n *\n * @public */\nexport const assetIdValidator = idValidator<TLAssetId>('asset')\n\n/**\n * Create a validator for an asset record type.\n *\n * @param type - The type of the asset\n * @param props - The validator for the asset's props\n *\n * @public */\nexport function createAssetValidator<Type extends string, Props extends JsonObject>(\n\ttype: Type,\n\tprops: T.Validator<Props>\n) {\n\treturn T.object<{\n\t\tid: TLAssetId\n\t\ttypeName: 'asset'\n\t\ttype: Type\n\t\tprops: Props\n\t\tmeta: JsonObject\n\t}>({\n\t\tid: assetIdValidator,\n\t\ttypeName: T.literal('asset'),\n\t\ttype: T.literal(type),\n\t\tprops,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n}\n"],
"mappings": "AAEA,SAAS,SAAS;AAClB,SAAS,mBAAmB;AAcrB,MAAM,mBAAmB,YAAuB,OAAO;AASvD,SAAS,qBACf,MACA,OACC;AACD,SAAO,EAAE,OAMN;AAAA,IACF,IAAI;AAAA,IACJ,UAAU,EAAE,QAAQ,OAAO;AAAA,IAC3B,MAAM,EAAE,QAAQ,IAAI;AAAA,IACpB;AAAA,IACA,MAAM,EAAE;AAAA,EACT,CAAC;AACF;",
"names": []
}