Skip to content
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added

- **Seven recipes built on run on each**: turn a `.env` file into a Kubernetes Secret; convert Unix timestamps
in a JSON response to dates; decode every JWT in a log, HAR file or curl trace; remove tracking parameters
from a list of URLs; hash an email list with SHA-256 for Customer Match; extract the domain from each URL in
a list; parse the user agents of an access log into a CSV.

### Changed

- Recipe pages show what runs inside a run-on-each or branch step: every nested step with its link, the
settings it changes, its condition and what happens when it fails, how an each step splits its input and
how a branch merges its lanes, in the pre-rendered page too.
- **Decode CloudWatch Logs subscription data** decodes every record of a Kinesis or Firehose batch, not
only the first, and finds the payload in an event printed by Python or Node.js. A message ending in a
literal `\n` no longer stops it.
- **Excel column to SQL IN clause** escapes and quotes each value on its own, so the `mysql` flavor
(backslash escapes) and the `mssql` flavor (`N'…'` for non-ASCII values) work per value.
- **Bulk UTM link builder** removes old `utm_` parameters with *normalize query params*, so names with
digits, without `=` or percent-encoded are removed too, and the drop list takes more names (`fbclid`,
`gclid`). Tags inside a `#fragment` are no longer removed.

### Fixed

- **gzip decompress** reports short input that is not gzip (`{`, `[`, a cut-off `H4sIAAAA`) as not valid
gzip data instead of a failed integrity check.
- A recipe page with one numbered step says "1 step", on the page and on its share card.
- Leaving a recipe page stops working out its "What if you skip a step?" examples, instead of running them
on in the background while the next page waits for the engine.

## [1.7.0] - 2026-10-08

### Added
Expand Down
16 changes: 10 additions & 6 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,21 @@ npm run release -- plan # what a release from HEAD would ship, at which versio

### Recipes (`src/recipes/`) — pre-rendered pipeline pages
- A recipe is a hand-picked multi-step pipeline for one real task, published at `/recipes/<slug>/` (index: `/recipes/`).
Folder per recipe: `recipe.ts` (default export `Recipe`: steps built with `step()`/`branch()`/`each()`/`laneStep()` from
`define.ts`, each top-level step with a `why`; `each()` runs `laneStep()`s on every line or JSON value; 2+ `samples` with golden outputs, the first is the page's worked
example) and `guide.md` (frontmatter `title`/`description` for the page head, then prose `##` sections — no
Folder per recipe: `recipe.ts` (default export `Recipe`: top-level steps built with `step()`/`branch()`/`each()` from
`define.ts`, each with a `why`; nested steps with `laneStep()`/`laneBranch()`/`laneEach()`, which carry no `why` and
spell out regex condition flags as `sanitizeSteps` stores them (never raw literals); `each()` runs its steps on every
line or JSON value; 2+ `samples` with golden outputs, the first is the page's worked example) and `guide.md` (frontmatter `title`/`description` for the page head, then prose `##` sections — no
example blocks). `npm run gen` also writes `src/recipes/_generated/` (`index.ts` metadata, `loaders.ts` one chunk
per recipe with its guide via `?raw`, `static.ts` for Node); `generated.test.ts` fails when stale.
- Rules (`check.ts`, run by `recipes.test.ts` and `check:recipes`): real utilities/params, no `dom`/`main`/`eval`
steps (the build runs recipes in Node, the page in a worker), every sample reproduces its output on every run and
at any date, **every top-level step changes some sample's output when left out** (no padding), 2+ real steps or a
branch, title/description/primaryQuery unique across recipes and utility guides, `primaryQuery` not a utility
guide title's head term (no competing with `/util/<id>/`), ≥300 words of guide prose, no near-copied prose.
at any date, **every top-level step changes some sample's output when left out** (no padding), 2+ real utility steps
counting nested ones (one utility wrapped in `each` is still one), title/description/primaryQuery unique across recipes
and utility guides, `primaryQuery` neither inside a utility guide title nor containing its head term (the title before
" — ", minus "Online": "bulk slug generator" competes with `/util/slug/`), ≥300 words of guide prose, no near-copied prose.
- `trace.ts` turns a run into what the page shows (each step's output, what leaving each step out does).
`RecipeArticle` renders nested steps recursively (params, conditions, failure policy, split and merge modes):
the pre-rendered page is all a crawler sees, so a setting inside a lane must show there.
`scripts/seo/build.ts` traces every recipe with the static registry, **fails the build** if the first sample's
output drifted, renders `RecipeArticle` with `renderToStaticMarkup` and embeds the trace as
`<script type="application/json" id="recipe-trace">`. `RecipePage` reads that trace, so nothing runs on load; the
Expand Down
4 changes: 2 additions & 2 deletions scripts/seo/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { loadOgFonts, renderOgPng, runPool } from './og'
import { parseGuide, renderGuideHtml, renderMarkdownDocument, type Guide } from '../../src/app/pages/guide'
import { relatedUtilities } from '../../src/app/pages/related'
import { featuredRecipes, recipesUsing, relatedRecipes } from '../../src/app/pages/recipes/recipeHelpers'
import { featuredRecipes, recipesUsing, relatedRecipes, stepCountText } from '../../src/app/pages/recipes/recipeHelpers'
import { traceRecipe, TRACE_ELEMENT_ID, type PipelineRunner, type RecipeTrace } from '../../src/recipes/trace'
import type { Recipe, RecipeMeta } from '../../src/recipes/types'
import { metaOfRecipe } from '../gen-recipes'
Expand Down Expand Up @@ -591,7 +591,7 @@ export async function buildSeo(options: BuildSeoOptions): Promise<BuildSeoResult
...manifest.map(m => ({ file: `${m.id}.png`, card: { name: displayName(m.name), category: m.category, description: m.description } })),
...recipeMetas.map(r => ({
file: path.join('recipes', `${r.slug}.png`),
card: { name: r.name, category: `Recipe · ${r.stepCount} steps`, description: r.chain.join(' → ') },
card: { name: r.name, category: `Recipe · ${stepCountText(r.stepCount)}`, description: r.chain.join(' → ') },
})),
{
file: 'default.png',
Expand Down
87 changes: 84 additions & 3 deletions src/app/pages/recipes/RecipeArticle.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import { describe, expect, it } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import { render, screen } from '@testing-library/react'
import { MANIFEST } from '@/utilities/_generated/manifest'
import { each, laneStep, step } from '@/recipes/define'
import { each, laneBranch, laneEach, laneStep, step } from '@/recipes/define'
import type { Recipe } from '@/recipes/types'
import { RecipeArticle } from './RecipeArticle'
import { RecipeArticle, RecipeWidget } from './RecipeArticle'

const metas = new Map(MANIFEST.map(m => [m.id, m]))

Expand Down Expand Up @@ -32,10 +33,83 @@ describe('RecipeArticle', () => {
}
render(<RecipeArticle recipe={perValue} utility={id => metas.get(id)} guideHtml="" steps={[]} skip={[]} live={null} related={[]} />)
expect(screen.getAllByText('Run on each value').length).toBeGreaterThan(0)
expect(screen.getByText('on each value:')).toBeInTheDocument()
expect(screen.getByText('Each value of the JSON object goes through:')).toBeInTheDocument()
expect(screen.getAllByRole('link').some(a => a.getAttribute('href') === '/util/base64_decode/')).toBe(true)
})

it('shows every nested step with its label, utility link, changed params, condition and failure policy', () => {
const nested: Recipe = {
...recipe,
steps: [
step('find', 'extract_preset', { type: ['jwt'], unique: true }, 'Finds every token in the pasted log, one per line.'),
each('tokens', { mode: 'lines' }, [
laneStep('payload', 'jwt_decode', { part: 'payload' }, { onError: 'stop', label: 'read the payload' }),
laneEach('dates', { mode: 'json-values' }, [
laneStep('date', 'timestamp_convert', { to: 'iso', timezone: 'UTC' }, { condition: { kind: 'regex', pattern: '^1[4-9]\\d{8}$' } }),
]),
], 'Decodes every token on its own and turns its timestamps into dates.', { onError: 'empty', includeEmpty: true }),
],
}
const { container } = render(<RecipeArticle recipe={nested} utility={id => metas.get(id)} guideHtml="" steps={[]} skip={[]} live={null} related={[]} />)
const text = container.textContent ?? ''
expect(screen.getByText('Each line, empty ones included, goes through:')).toBeInTheDocument()
expect(screen.getByText('A line whose steps fail comes out empty.')).toBeInTheDocument()
expect(screen.getByText('If it fails, the steps after it do not run.')).toBeInTheDocument()
expect(text).toContain('read the payload (jwt decode)')
expect(screen.getByText('Each value of the JSON object goes through:')).toBeInTheDocument()
expect(screen.getByText(/Runs only when its input matches/).textContent)
.toBe('Runs only when its input matches ^1[4-9]\\d{8}$; otherwise the input passes through.')
// the nested steps' non-default params, with the labels the editor shows
const terms = screen.getAllByRole('term').map(t => t.textContent)
expect(terms).toContain(metas.get('jwt_decode')!.params.part.label)
expect(terms).toContain(metas.get('timestamp_convert')!.params.to.label)
for (const id of ['extract_preset', 'jwt_decode', 'timestamp_convert']) {
expect(screen.getAllByRole('link').some(a => a.getAttribute('href') === `/util/${id}/`)).toBe(true)
}
})

it("shows a branch's lanes, an empty pass-through lane and how the lanes are merged", () => {
const lanes: Recipe = {
...recipe,
steps: [each('count', { mode: 'lines' }, [
laneBranch('both', [[laneStep('n', 'text_stats', {}), laneStep('g', 'jsonpath', { path: '$.graphemes', mode: 'first', indent: 2 })], []],
{ mode: 'concat', separator: ' · ' }),
], 'Writes how many characters each line has in front of the line itself.')],
}
const { container } = render(<RecipeArticle recipe={lanes} utility={id => metas.get(id)} guideHtml="" steps={[]} skip={[]} live={null} related={[]} />)
expect(container.textContent).toContain('Every lane gets the same input, and their outputs are joined with · :')
expect(screen.getByText('Lane 1:')).toBeInTheDocument()
expect(screen.getByText('Lane 2: its input, unchanged')).toBeInTheDocument()
expect(screen.getByText('$.graphemes')).toBeInTheDocument()
})

it('renders nested steps in static markup, as the pre-render does', () => {
const tracking: Recipe = {
...recipe,
steps: [each('strip', { mode: 'lines' }, [
laneStep('drop', 'query_params_normalize', { drop: 'utm_*,fbclid', sort: false }, { condition: { kind: 'regex', pattern: '^https?://\\S+$', flags: 'i' } }),
laneStep('upper', 'case', { mode: 'upper' }),
], 'Cleans one link at a time and leaves every other line alone.')],
}
const html = renderToStaticMarkup(<RecipeArticle recipe={tracking} utility={id => metas.get(id)} guideHtml="" steps={[]} skip={[]} live={null} related={[]} />)
expect(html).toContain('utm_*,fbclid')
expect(html).toContain('^https?://\\S+$</code> (ignoring case); otherwise the input passes through.')
expect(html).toContain('href="/util/query_params_normalize/"')
})

it('names the top-level step a failing nested step is in, when a step is left out', () => {
const nested: Recipe = {
...recipe,
steps: [
step('unquote', 'replace', { pattern: '"', replacement: '', regex: false }, 'Drops the quotes so every value reads as plain text.'),
each('values', { mode: 'lines' }, [laneStep('b64', 'base64_decode')], 'Decodes every line of Base64 on its own.'),
],
}
render(<RecipeArticle recipe={nested} utility={id => metas.get(id)} guideHtml="" steps={[]} live={null} related={[]}
skip={[{ id: 'unquote', error: { stepId: 'b64', message: 'not Base64' }, unchanged: false }]} />)
expect(screen.getByText('The pipeline breaks: step 2 (Run on each line) fails with “not Base64”.')).toBeInTheDocument()
})

it('words a condition by what it does: runs on a match, or is skipped on a match', () => {
render(<RecipeArticle recipe={recipe} utility={id => metas.get(id)} guideHtml="" steps={[]} skip={[]} live={null} related={[]} />)
expect(screen.getByText(/Runs only when its input matches/).textContent)
Expand All @@ -61,4 +135,11 @@ describe('RecipeArticle', () => {
expect(screen.getByRole('heading', { name: 'What if you skip a step?' })).toBeTruthy()
expect(screen.getByText('Working it out…')).toBeTruthy()
})

it('counts the numbered steps in the widget, in the singular for one', () => {
const widget = (stepCount: number) => renderToStaticMarkup(
<RecipeWidget samples={recipe.samples} sampleId="a" input="" output="" stepCount={stepCount} openHref="/#/p/x" />)
expect(widget(1)).toContain('1 step, every one editable.')
expect(widget(4)).toContain('4 steps, every one editable.')
})
})
Loading
Loading