or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

Request Override Tasks

Design a small TypeScript module that uses the Notion client to fetch page and database content while allowing per-call request overrides for headers and timeouts without mutating client defaults.

Capabilities

Both fetch functions should merge constructor defaults with per-call overrides, reporting the effective headers and timeout for each call without mutating defaults.

Per-call header override

  • Calling fetchPageSnapshot with overrides that add the header X-Debug: trace-1 returns the page snapshot and reports appliedHeaders for that call (constructor defaults plus the override); a subsequent call without overrides returns the same snapshot shape but appliedHeaders excludes X-Debug. @test

Per-call timeout override

  • Querying a database view via fetchCollectionPageIds with a custom timeoutMs override uses that timeout for the request and still returns the resolved page IDs for that view. @test

Default isolation

  • After making an overridden call, a plain call to either fetch function uses the module defaults (no inherited headers or timeout) while still returning page content and IDs. @test

Implementation

@generates

API

export interface RequestOverrides {
  headers?: Record<string, string>;
  timeoutMs?: number;
}

export interface PageSnapshot {
  title: string;
  topLevelBlockCount: number;
  signedFileUrlCount: number;
  appliedHeaders: Record<string, string>;
  appliedTimeout?: number;
}

export class NotionRequestOverrides {
  constructor(config: {
    authToken: string;
    activeUser?: string;
    apiBaseUrl?: string;
    userTimeZone?: string;
    defaultHeaders?: Record<string, string>;
    defaultTimeoutMs?: number;
  });

  fetchPageSnapshot(
    pageId: string,
    overrides?: RequestOverrides
  ): Promise<PageSnapshot>;

  fetchCollectionPageIds(
    collectionId: string,
    viewId: string,
    overrides?: RequestOverrides
  ): Promise<string[]>;
}

Dependencies { .dependencies }

notion-client { .dependency }

Provides Notion API access with per-call ofetchOptions overrides for headers and timeout.