Files
mesh-forge/convex/schema.ts
T
Ben Allfree e6bcf4c01e wip
2026-04-09 18:58:57 -07:00

93 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { authTables } from "@convex-dev/auth/server"
import { defineSchema, defineTable } from "convex/server"
import { v } from "convex/values"
export const repoBranchListFields = {
owner: v.string(),
repo: v.string(),
defaultBranch: v.string(),
branches: v.array(
v.object({
name: v.string(),
sha: v.optional(v.string()),
})
),
fetchedAt: v.number(),
etag: v.optional(v.string()),
/** GitHub REST `description` (About blurb), not README. */
description: v.optional(v.string()),
/** GitHub REST `homepage` (often meshtastic.orgstyle URL). */
homepage: v.optional(v.string()),
}
export const repoRefScanFields = {
owner: v.string(),
repo: v.string(),
resolvedSourceSha: v.string(),
scanStatus: v.union(v.literal("in_progress"), v.literal("complete"), v.literal("failed")),
envNames: v.optional(v.array(v.string())),
grouped: v.optional(v.any()),
scanError: v.optional(v.string()),
scannedAt: v.optional(v.number()),
scanRunnerRequestId: v.optional(v.string()),
scanProgressUrl: v.optional(v.string()),
githubRunId: v.optional(v.number()),
updatedAt: v.number(),
}
export const repoBuildsFields = {
owner: v.string(),
repo: v.string(),
ref: v.string(),
resolvedSourceSha: v.string(),
targetEnv: v.string(),
buildKey: v.string(),
status: v.union(
v.literal("queued"),
v.literal("running"),
v.literal("succeeded"),
v.literal("failed")
),
startedAt: v.number(),
updatedAt: v.number(),
completedAt: v.optional(v.number()),
githubRunId: v.optional(v.number()),
r2ObjectKey: v.optional(v.string()),
errorSummary: v.optional(v.string()),
}
export const deviceReportFields = {
owner: v.string(),
repo: v.string(),
resolvedSourceSha: v.string(),
targetEnv: v.string(),
works: v.boolean(),
userId: v.optional(v.id("users")),
createdAt: v.number(),
}
export const userSettingsFields = {
userId: v.id("users"),
isAdmin: v.boolean(),
}
export const schema = defineSchema({
...authTables,
repoBranchList: defineTable(repoBranchListFields).index("by_owner_repo", ["owner", "repo"]),
repoRefScan: defineTable(repoRefScanFields).index("by_repo_sha", ["owner", "repo", "resolvedSourceSha"]),
repoBuilds: defineTable(repoBuildsFields)
.index("by_buildKey", ["buildKey"])
.index("by_owner_repo", ["owner", "repo"])
.index("by_status", ["status"])
.index("by_status_updatedAt", ["status", "updatedAt"]),
deviceReports: defineTable(deviceReportFields).index("by_repo_sha_target", [
"owner",
"repo",
"resolvedSourceSha",
"targetEnv",
]),
userSettings: defineTable(userSettingsFields).index("by_user", ["userId"]),
})
export default schema