UNPKG

@bscotch/gamemaker-releases

Version:

Utility for combining GameMaker release data into a single feed.

70 lines 2.65 kB
import { z } from 'zod'; import { htmlString } from './utils.js'; export const channels = ['lts', 'stable', 'beta', 'unstable']; export const channelSchema = z.enum(channels); Object.freeze(channels); export const artifactTypes = ['ide', 'runtime']; Object.freeze(artifactTypes); export const rssFeedSchema = z.object({ rss: z.object({ channel: z.object({ title: htmlString(), description: htmlString(), link: z.string(), item: z.preprocess((arg) => { if (!Array.isArray(arg)) { return [arg]; } return arg; }, z.array(z.object({ title: z.string().regex(/^Version \d+\.\d+\.\d+\.\d+$/), pubDate: z.string(), link: z.string().optional(), comments: z.string(), description: htmlString().optional(), }))), }), }), }); export const gameMakerArtifactSchema = z.object({ type: z.enum(artifactTypes), version: z.string().regex(/^\d+\.\d+\.\d+\.\d+$/), channel: channelSchema, summary: z.string().optional(), feedUrl: z.string(), publishedAt: z.string().transform((arg) => new Date(arg).toISOString()), link: z.string().optional(), notesUrl: z.string(), }); export const gameMakerArtifactWithNotesSchema = gameMakerArtifactSchema.extend({ notes: z.object({ since: z.string().nullable(), groups: z.array(z.object({ title: htmlString(), changes: z.array(htmlString()), })), }), }); const gameMakerReleaseBaseSchema = z.object({ channel: channelSchema, publishedAt: z .string() .transform((arg) => new Date(arg).toISOString()) .describe('Date of release for the IDE in this pair'), summary: htmlString().describe('Summary of the release, from the RSS feed for the IDE'), }); export const gameMakerReleaseWithNotesSchema = gameMakerReleaseBaseSchema.extend({ ide: gameMakerArtifactWithNotesSchema.omit({ summary: true }), runtime: gameMakerArtifactWithNotesSchema.omit({ summary: true }), }); export const gameMakerReleaseSchema = gameMakerReleaseBaseSchema.extend({ ide: gameMakerArtifactSchema.omit({ summary: true }), runtime: gameMakerArtifactSchema.omit({ summary: true }), }); export const rawReleaseNoteSchema = z.strictObject({ type: z.enum(artifactTypes).optional(), version: z.string(), release_notes: z.array(z.string()), }); export const rawReleaseNotesCacheSchema = z.record(z.string(), rawReleaseNoteSchema); //# sourceMappingURL=feeds.types.js.map