Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api-server/api-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ describe("API Documentation Endpoint", () => {

it("should include all required paths", () => {
const validJobTypes: JobType[] = [
"notion:fetch",
"notion:fetch-all",
"fetch-one",
"fetch-all",
"notion:count-pages",
"notion:translate",
"notion:status-translation",
Expand Down Expand Up @@ -353,8 +353,8 @@ describe("API Documentation Endpoint", () => {

it("should define Job schema", () => {
const validJobTypes: JobType[] = [
"notion:fetch",
"notion:fetch-all",
"fetch-one",
"fetch-all",
"notion:count-pages",
"notion:translate",
"notion:status-translation",
Expand Down Expand Up @@ -399,8 +399,8 @@ describe("API Documentation Endpoint", () => {

it("should define CreateJobRequest schema", () => {
const validJobTypes: JobType[] = [
"notion:fetch",
"notion:fetch-all",
"fetch-one",
"fetch-all",
"notion:count-pages",
"notion:translate",
"notion:status-translation",
Expand Down
6 changes: 3 additions & 3 deletions api-server/api-documentation-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe("API Documentation Validation", () => {
items: [
{
id: "job-123",
type: "notion:fetch" as const,
type: "fetch-one" as const,
status: "completed" as const,
createdAt: "2025-02-06T10:00:00.000Z",
startedAt: "2025-02-06T10:00:01.000Z",
Expand Down Expand Up @@ -215,7 +215,7 @@ describe("API Documentation Validation", () => {

const jobWithProgress = {
id: "job-123",
type: "notion:fetch-all" as const,
type: "fetch-all" as const,
status: "running" as const,
createdAt: "2025-02-06T12:00:00.000Z",
startedAt: "2025-02-06T12:00:01.000Z",
Expand Down Expand Up @@ -418,7 +418,7 @@ describe("API Documentation Validation", () => {
describe("Job Tracker Integration", () => {
it("should produce data matching job schema", () => {
const tracker = getJobTracker();
const jobId = tracker.createJob("notion:fetch");
const jobId = tracker.createJob("fetch-one");

const job = tracker.getJob(jobId);
expect(job).toBeDefined();
Expand Down
29 changes: 16 additions & 13 deletions api-server/api-routes.validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ describe("API Routes - Validation", () => {

describe("Job Types Validation", () => {
const validJobTypes: JobType[] = [
"notion:fetch",
"notion:fetch-all",
"fetch-one",
"fetch-all",
"notion:count-pages",
"notion:translate",
"notion:status-translation",
Expand Down Expand Up @@ -82,11 +82,14 @@ describe("API Routes - Validation", () => {

it("should have correct job type descriptions", () => {
const expectedDescriptions: Record<JobType, string> = {
"fetch-ready": "Fetch ready pages from Notion",
"fetch-all": "Fetch all pages from Notion",
"fetch-one": "Fetch a single page from Notion by page ID",
"fetch-ready":
'Fetch pages with status "Ready to publish" and transition to "Draft published"',
"fetch-all":
'Fetch all pages except status "Remove" and sync generated artifacts',
"notion:fetch": "Fetch pages from Notion",
"notion:fetch-all": "Fetch all pages from Notion",
"notion:count-pages": "Count pages from Notion",
"notion:count-pages": "Count pages in Notion database",
"notion:translate": "Translate content",
"notion:status-translation": "Update status for translation workflow",
"notion:status-draft": "Update status for draft publish workflow",
Expand Down Expand Up @@ -126,7 +129,7 @@ describe("API Routes - Validation", () => {

it("should return correct job list response shape", () => {
const tracker = getJobTracker();
const jobId = tracker.createJob("notion:fetch");
const jobId = tracker.createJob("fetch-one");

const jobs = tracker.getAllJobs();

Expand Down Expand Up @@ -159,7 +162,7 @@ describe("API Routes - Validation", () => {

it("should return correct job creation response shape", () => {
const tracker = getJobTracker();
const jobType: JobType = "notion:fetch-all";
const jobType: JobType = "fetch-all";
const jobId = tracker.createJob(jobType);

const expectedResponse = {
Expand Down Expand Up @@ -257,7 +260,7 @@ describe("API Routes - Validation", () => {
] as const;

const tracker = getJobTracker();
const jobId = tracker.createJob("notion:fetch");
const jobId = tracker.createJob("fetch-one");

// Test each status transition
tracker.updateJobStatus(jobId, "running");
Expand All @@ -272,7 +275,7 @@ describe("API Routes - Validation", () => {

it("should handle failed job status with error result", () => {
const tracker = getJobTracker();
const jobId = tracker.createJob("notion:fetch-all");
const jobId = tracker.createJob("fetch-all");

tracker.updateJobStatus(jobId, "running");
tracker.updateJobStatus(jobId, "failed", {
Expand All @@ -290,8 +293,8 @@ describe("API Routes - Validation", () => {
describe("Request Validation", () => {
it("should validate job type in request body", () => {
const validJobTypes: JobType[] = [
"notion:fetch",
"notion:fetch-all",
"fetch-one",
"fetch-all",
"notion:count-pages",
"notion:translate",
"notion:status-translation",
Expand All @@ -305,14 +308,14 @@ describe("API Routes - Validation", () => {
return validJobTypes.includes(type as JobType);
};

expect(isValidJobType("notion:fetch")).toBe(true);
expect(isValidJobType("fetch-one")).toBe(true);
expect(isValidJobType("invalid:type")).toBe(false);
expect(isValidJobType("")).toBe(false);
});

it("should accept optional options in request body", () => {
const requestBody = {
type: "notion:fetch-all" as JobType,
type: "fetch-all" as JobType,
options: {
maxPages: 10,
statusFilter: "In Progress",
Expand Down
2 changes: 1 addition & 1 deletion api-server/audit-logging-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("Audit Logging Integration", () => {
authorization: `Bearer ${TEST_API_KEY}`,
"x-forwarded-for": "192.168.1.100",
},
body: JSON.stringify({ type: "notion:fetch" }),
body: JSON.stringify({ type: "fetch-one" }),
});

// Authenticate request
Expand Down
8 changes: 4 additions & 4 deletions api-server/audit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("AuditLogger", () => {

it("should capture query parameters", () => {
const req = new Request(
"http://localhost:3001/jobs?status=running&type=notion:fetch",
"http://localhost:3001/jobs?status=running&type=fetch-one",
{
method: "GET",
}
Expand All @@ -147,7 +147,7 @@ describe("AuditLogger", () => {
};
const entry = audit.createEntry(req, authResult);

expect(entry.query).toBe("?status=running&type=notion:fetch");
expect(entry.query).toBe("?status=running&type=fetch-one");
});
});

Expand Down Expand Up @@ -616,7 +616,7 @@ describe("AuditLogger", () => {
);

const req = new Request(
"http://localhost:3001/jobs?status=running&type=notion:fetch",
"http://localhost:3001/jobs?status=running&type=fetch-one",
{ method: "GET" }
);

Expand All @@ -633,7 +633,7 @@ describe("AuditLogger", () => {
const logContents = readFileSync(logPath, "utf-8");
const logEntry = JSON.parse(logContents.trim());

expect(logEntry.query).toBe("?status=running&type=notion:fetch");
expect(logEntry.query).toBe("?status=running&type=fetch-one");
});

it("should append multiple entries for multiple requests", async () => {
Expand Down
5 changes: 2 additions & 3 deletions api-server/content-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export async function assertCleanWorkingTree(force: boolean): Promise<void> {
}

export async function prepareContentBranchForFetch(
mode: "fetch-ready" | "fetch-all"
mode: "fetch-one" | "fetch-ready" | "fetch-all"
): Promise<{
remoteRef: string;
}> {
Expand Down Expand Up @@ -937,10 +937,9 @@ export async function runContentTask(

export function isContentMutatingJob(jobType: string): boolean {
return (
jobType === "fetch-one" ||
jobType === "fetch-ready" ||
jobType === "fetch-all" ||
jobType === "notion:fetch" ||
jobType === "notion:fetch-all" ||
jobType === "notion:translate"
);
Comment on lines 941 to 944

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep legacy fetch jobs marked as content mutating

Removing notion:fetch and notion:fetch-all from isContentMutatingJob regresses existing API job types that are still valid in JOB_COMMANDS/validation. Those jobs will now bypass content-repo orchestration (no runContentTask commit/push workflow and weaker preflight checks), so clients using legacy fetch types can get successful runs without the expected managed content-branch sync behavior.

Useful? React with 👍 / 👎.

}
8 changes: 4 additions & 4 deletions api-server/docker-runtime-smoke-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ describe("Docker Runtime Smoke Tests", () => {

// Verify known job types are present
const typeIds = body.data.types.map((t: { id: string }) => t.id);
expect(typeIds).toContain("notion:fetch");
expect(typeIds).toContain("notion:fetch-all");
expect(typeIds).toContain("fetch-one");
expect(typeIds).toContain("fetch-all");
});
});

Expand All @@ -457,7 +457,7 @@ describe("Docker Runtime Smoke Tests", () => {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ type: "notion:fetch-all" }),
body: JSON.stringify({ type: "fetch-all" }),
});

// Should require authentication
Expand All @@ -484,7 +484,7 @@ describe("Docker Runtime Smoke Tests", () => {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "notion:fetch-all",
type: "fetch-all",
options: { dryRun: true },
}),
});
Expand Down
30 changes: 15 additions & 15 deletions api-server/endpoint-schema-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {
describe("Request body validation - options field", () => {
it("should reject invalid options type", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: "not-an-object",
});
expect(result.success).toBe(false);
Expand All @@ -215,7 +215,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

it("should reject unknown option keys", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: {
unknownOption: "value",
},
Expand All @@ -228,7 +228,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

it("should reject invalid maxPages type", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: {
maxPages: "not-a-number",
},
Expand All @@ -245,7 +245,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

it("should allow zero maxPages", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: {
maxPages: 0,
},
Expand All @@ -258,7 +258,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

it("should reject non-integer maxPages", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: {
maxPages: 10.5,
},
Expand All @@ -274,7 +274,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

it("should reject empty statusFilter", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: {
statusFilter: "",
},
Expand All @@ -293,7 +293,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

for (const option of booleanOptions) {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
options: {
[option]: "not-a-boolean",
},
Expand All @@ -311,18 +311,18 @@ describe("Endpoint Schema Validation - POST /jobs", () => {

it("should accept valid request with minimal fields", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch",
type: "fetch-one",
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.type).toBe("notion:fetch");
expect(result.data.type).toBe("fetch-one");
expect(result.data.options).toBeUndefined();
}
});

it("should accept valid request with all options", () => {
const result = safeValidate(createJobRequestSchema, {
type: "notion:fetch-all",
type: "fetch-all",
options: {
maxPages: 10,
statusFilter: "In Progress",
Expand All @@ -333,7 +333,7 @@ describe("Endpoint Schema Validation - POST /jobs", () => {
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.type).toBe("notion:fetch-all");
expect(result.data.type).toBe("fetch-all");
expect(result.data.options?.maxPages).toBe(10);
}
});
Expand Down Expand Up @@ -391,12 +391,12 @@ describe("Endpoint Schema Validation - GET /jobs", () => {
it("should accept both filters together", () => {
const result = safeValidate(jobsQuerySchema, {
status: "completed",
type: "notion:fetch",
type: "fetch-one",
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.status).toBe("completed");
expect(result.data.type).toBe("notion:fetch");
expect(result.data.type).toBe("fetch-one");
}
});

Expand Down Expand Up @@ -659,7 +659,7 @@ describe("Endpoint Schema Validation - Response Schemas", () => {
items: [
{
id: "job-123",
type: "notion:fetch",
type: "fetch-one",
status: "running",
createdAt: new Date().toISOString(),
startedAt: new Date().toISOString(),
Expand All @@ -681,7 +681,7 @@ describe("Endpoint Schema Validation - Response Schemas", () => {
it("should validate create job response schema", () => {
const createJobResponse = {
jobId: "job-123",
type: "notion:fetch",
type: "fetch-one",
status: "pending",
message: "Job created successfully",
_links: {
Expand Down
Loading
Loading