Skip to content

Latest commit

Β 

History

History
72 lines (48 loc) Β· 2.78 KB

File metadata and controls

72 lines (48 loc) Β· 2.78 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

ContentChef Node SDK β€” a Lerna monorepo with two packages:

  • packages/contentchef-node β€” TypeScript client for the ContentChef content API (online + preview channels)
  • packages/contentchef-media β€” Media URL generation utilities (wraps Cloudinary)

Common Commands

All commands run from within a package directory (e.g., packages/contentchef-node/):

npm test              # clean + jest (with coverage)
npm run build         # clean + dual build (ESM β†’ dist/esm, CJS β†’ dist/cjs)
npm run lint          # eslint
npx jest --testPathPattern=<pattern>  # run a single test file

Monorepo install from root (npm workspaces, Lerna 8):

npm install           # installs all packages
npm run lint          # lerna run lint
npm test              # lerna run test
npm run build         # lerna run build

Architecture

contentchef-node

Entry point src/index.ts exports a configure() function that accepts IContentChefConfiguration (spaceId, API key, optional host/timeout) and returns an IConfiguredSDK with two channel factories:

  • onlineChannel(apiKey, channel) β€” retrieves published content only
  • previewChannel(apiKey, channel) β€” retrieves published + staging content, supports target dates via ITargetDateResolver

Each channel exposes: content<T>(), search<T>(), localizedContent<T>(), localizedSearch<T>().

Key services:

  • ConfigurationManager (src/services/ConfigurationManager/) β€” validates SDK config, implements IConfigurable to pass config to Channel
  • Channel (src/services/Channel/) β€” builds API endpoints, executes fetch requests with X-Chef-Key header, serializes sorting/filtering

API endpoint patterns:

  • Online: /space/{spaceId}/online/{method}/{channel}
  • Preview: /space/{spaceId}/preview/{state}/{method}/{channel}

contentchef-media

Thin wrapper around cloudinary-build-url. Exports imageUrl(), videoUrl(), rawFileUrl() with default cloud name 'contentchef' and HTTPS enforced.

Build Output

Both packages produce dual targets:

  • dist/cjs/ β€” CommonJS (main entry)
  • dist/esm/ β€” ES modules (module entry)
  • dist/index.d.ts β€” TypeScript declarations

Testing

  • Jest with ts-jest, test files in __tests__/ dirs using .test.ts or .spec.ts suffix
  • HTTP mocking via nock (contentchef-node)
  • Coverage collected automatically

Linting

Uses ESLint (flat config at eslint.config.mjs) with typescript-eslint. Single quotes enforced, no-empty-object-type disabled, ban-ts-comment disabled in tests.

PR Labels for Changelog

  • breaking (πŸ’₯), enhancement (πŸš€), bug (πŸ›), documentation (πŸ“), internal (🏠)