45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { Type, type Static } from "@sinclair/typebox";
|
|
|
|
const stableResourcePattern = "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,119}$";
|
|
|
|
export const RecentAssetKindSchema = Type.Union(
|
|
[Type.Literal("static_sticker"), Type.Literal("text_template")],
|
|
{ $id: "RecentAssetKind" },
|
|
);
|
|
|
|
export const RecentAssetItemSchema = Type.Object(
|
|
{
|
|
asset_id: Type.String({ maxLength: 120, pattern: stableResourcePattern }),
|
|
asset_kind: Type.Ref(RecentAssetKindSchema),
|
|
resource_version: Type.String({ maxLength: 120, pattern: stableResourcePattern }),
|
|
},
|
|
{ additionalProperties: false, $id: "RecentAssetItem" },
|
|
);
|
|
|
|
export const RecentAssetQuerySchema = Type.Object(
|
|
{ asset_kind: Type.Ref(RecentAssetKindSchema) },
|
|
{ additionalProperties: false, $id: "RecentAssetQuery" },
|
|
);
|
|
|
|
export const RecentAssetListResponseSchema = Type.Object(
|
|
{ items: Type.Array(Type.Ref(RecentAssetItemSchema), { maxItems: 12 }) },
|
|
{ additionalProperties: false, $id: "RecentAssetListResponse" },
|
|
);
|
|
|
|
export const RecentAssetRecordRequestSchema = Type.Object(
|
|
{
|
|
asset_id: Type.String({ maxLength: 120, pattern: stableResourcePattern }),
|
|
asset_kind: Type.Ref(RecentAssetKindSchema),
|
|
resource_version: Type.String({ maxLength: 120, pattern: stableResourcePattern }),
|
|
},
|
|
{ additionalProperties: false, $id: "RecentAssetRecordRequest" },
|
|
);
|
|
|
|
export const RecentAssetRecordResponseSchema = Type.Object(
|
|
{ status: Type.Literal("recorded") },
|
|
{ additionalProperties: false, $id: "RecentAssetRecordResponse" },
|
|
);
|
|
|
|
export type RecentAssetQuery = Static<typeof RecentAssetQuerySchema>;
|
|
export type RecentAssetRecordRequest = Static<typeof RecentAssetRecordRequestSchema>;
|