MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / validateJobFileShape

Function validateJobFileShape

src/job-config.ts:129–153  ·  view source on GitHub ↗
(
  value: unknown,
  sourceLabel: string,
)

Source from the content-addressed store, hash-verified

127}
128
129export function validateJobFileShape(
130 value: unknown,
131 sourceLabel: string,
132): asserts value is JobFile {
133 if (!value || typeof value !== "object") {
134 throw new Error(`Invalid job config from ${sourceLabel}: expected a JSON object`);
135 }
136
137 const jobFile = value as Record<string, unknown>;
138 if (!Array.isArray(jobFile.jobs)) {
139 throw new Error(`Invalid job config from ${sourceLabel}: "jobs" must be an array`);
140 }
141
142 const ids = new Set<string>();
143 jobFile.jobs.forEach((job, index) => {
144 validateScheduledJobConfig(job, sourceLabel, index);
145 const normalizedId = job.id.trim().toLowerCase();
146 if (ids.has(normalizedId)) {
147 throw new Error(
148 `Invalid job config from ${sourceLabel}: duplicate job id "${job.id}" is not allowed`,
149 );
150 }
151 ids.add(normalizedId);
152 });
153}
154
155function normalizeJobFile(jobFile: JobFile): JobFile {
156 return {

Callers 2

loadJobFileFunction · 0.85
saveJobFileFunction · 0.85

Calls 1

Tested by

no test coverage detected