diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index dcf6f53..306f33d 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,12 +4,13 @@ ## Checklist -- [ ] **Metadata complete in the registration** (`plugin.RegisterProvider`: provider id, name, category, homepage; each source's id, kind, layer, what it watches, URLs, packages, page), and I read the words. There is no list to update. Not applicable: +- [ ] **Metadata complete in the registration** (`providers//provider.go`, its one `plugin.RegisterProvider`: provider id, name, category, homepage; each source's id, layer, what it watches, URLs, packages), and I read the words. There is no list to update. Not applicable: - [ ] Every commit is signed off (`git commit -s`, DCO) -- [ ] Golden test over a real saved copy of the source (`testdata/golden/-.json`) -- [ ] `testdata/README.md` lists each file: URL, date fetched, license, quote of the part the plugin reads +- [ ] Golden test over a real saved copy of the source (`providers//testdata/golden/-.json`) +- [ ] `providers//testdata/README.md` lists each file: URL, date fetched, license, quote of the part the plugin reads - [ ] One pinned drop test: a realistic input that produces no event -- [ ] `providers/-.md` written or updated from `providers/_template.md`, including **Why this source** +- [ ] The source's section of `providers//README.md` written or updated (a new provider's page from `docs/provider-template.md`), including **Why this source** +- [ ] Provider-specific code only in `providers//`; a kind (`kinds//`) imports no provider - [ ] Fetches only through `env.Get` / `core/kit/` - [ ] `make check` passes locally (`make plugins` prints the source as you expect) - [ ] Nothing private: no credentials, internal hosts, private links, customer names diff --git a/.github/workflows/CI_go.yml b/.github/workflows/CI_go.yml index 82162c1..0b05d26 100644 --- a/.github/workflows/CI_go.yml +++ b/.github/workflows/CI_go.yml @@ -1,7 +1,8 @@ # The plugins build, are formatted and vetted, and their tests pass with the race # detector. Two guards keep plugins self-contained: # - imports: only this module, the standard library and the approved dependencies; -# - network: net/http only in the fetch layer (core/fetch/, core/kit/, plugins/openapi/adapter/). +# - network: net/http only in the fetch layer (core/fetch/, core/kit/) and the +# openapi test kit (kinds/openapi/openapitest/, recorded responses over httptest). # The steps are Makefile targets, so `make check` runs exactly this locally. # Until the Go code lands there is no go.mod, and every step after the first is skipped # with a notice, so the check passes. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5cc4f74..92bca64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,8 +5,8 @@ # A maintainer can also run it by hand any time (Actions -> Release -> Run workflow -> # pick the bump), e.g. for an urgent fix or a minor release. It never runs on push or on a PR. # -# patch v0.4.1 -> v0.4.2 fixes, new providers on an existing format plugin -# minor v0.4.1 -> v0.5.0 new format plugins, new exported API, anything a user should read about +# patch v0.4.1 -> v0.4.2 fixes, new providers or sources on an existing kind +# minor v0.4.1 -> v0.5.0 new kinds, new or moved exported API, anything a user should read about # (no tag yet -> v0.1.0) # # v1.0.0 and later majors are not an option here: they are a deliberate decision a @@ -26,7 +26,7 @@ on: workflow_dispatch: inputs: bump: - description: "Which part of the version to bump (patch: fixes and providers; minor: new format plugins or API)" + description: "Which part of the version to bump (patch: fixes and providers; minor: new kinds or API)" type: choice options: - patch @@ -99,12 +99,12 @@ jobs: echo "::error::$next already exists." exit 1 fi - # A new format plugin (a new plugins// directory) deserves a minor, not a + # A new kind (a new kinds// directory) deserves a minor, not a # patch. A scheduled run can't decide that, so it skips and a maintainer releases by hand. if [ "$EVENT" = "schedule" ] && [ -n "$latest" ]; then - new_formats=$(comm -13 <(git ls-tree -d --name-only "$latest" plugins/ | sort) <(git ls-tree -d --name-only HEAD plugins/ | sort)) + new_formats=$(comm -13 <(git ls-tree -d --name-only "$latest" kinds/ | sort) <(git ls-tree -d --name-only HEAD kinds/ | sort)) if [ -n "$new_formats" ]; then - echo "::warning::New format plugin(s) since $latest: $new_formats. That's a minor release: run Release by hand with bump=minor." + echo "::warning::New kind(s) since $latest: $new_formats. That's a minor release: run Release by hand with bump=minor." echo "skip=true" >> "$GITHUB_OUTPUT" exit 0 fi diff --git a/AGENTS.md b/AGENTS.md index 57716c7..dd752a0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,9 +4,9 @@ Rules for AI coding agents (and humans) working in this repo. `CLAUDE.md` import ## Rule 1: every new or changed provider or source has complete metadata in its registration -**A source exists when its kind's package registers it with `plugin.RegisterProvider`, and its metadata lives only there: the provider's id, name, category and homepage, and each source's id, layer, what it watches, the URLs it reads, the packages it covers (`pypi:stripe`) and its page, `providers/.md`.** Adding, changing or removing a source is a change to that registration (and to its page) in the same PR. There is no list to update: nothing in this repo, the docs site or anywhere else keeps one by hand. +**A source exists when its provider's `providers//provider.go` registers it with `plugin.RegisterProvider` (once per provider, every source of it, whatever the kind), and its metadata lives only there: the provider's id, name, category and homepage, and each source's id, layer, what it watches, the URLs it reads and the packages it covers (`pypi:stripe`). Its page is the provider's, `providers//README.md`, one section per source.** Adding, changing or removing a source is a change to that registration (and to its section of the page) in the same PR. There is no list to update: nothing in this repo, the docs site or anywhere else keeps one by hand. -`go run ./cmd/list-plugins` prints the list from the registry (JSON), and the Release workflow attaches it to every release as `plugins.json`; the docs site and patch-it's hosted ingestion service read it from there. `RegisterProvider` refuses incomplete metadata and `go test` fails when a source's page is missing, but no check can tell whether the words are right: you are that check. Say in the PR that you read them. +`go run ./cmd/list-plugins` prints the list from the registry (JSON), and the Release workflow attaches it to every release as `plugins.json`; the docs site and patch-it's hosted ingestion service read it from there. `RegisterProvider` refuses incomplete metadata or a second registration of a provider, and `go test` fails when a provider's folder isn't imported by `providers/all`, or a source isn't named on its provider's page, but no check can tell whether the words are right: you are that check. Say in the PR that you read them. ## Rule 2: this repo is public @@ -23,12 +23,14 @@ Refer to the service that runs these plugins as "patch-it's hosted ingestion ser ## Rules for plugin code -- **Start a new source with `make new-plugin ARGS='--provider --name --source --kind '`** (`go run ./cmd/new-plugin`; [which kind](docs/which-kind.md)), then fill in every `TODO(new-plugin)`; `make todos` (part of `make check` and CI_go) fails while one is left. +- **How to read is a kind; what to read is a provider.** `kinds//` reads one kind of source, written once, and imports no provider. `providers//` holds one provider and nothing about another: `provider.go` (its registration, built from the kinds' exported types), `README.md` (its page), any code only it needs (`.go`: an OpenAPI adapter, a feed's reader), `testdata/` and its tests. A provider imports only `core/` and `kinds/`. No folder per source, no forwarders: when code moves, the old path goes in the same change. `go test ./providers/all` checks all of this. + +- **Start a new source with `make new-plugin ARGS='--provider --name --source --kind '`** (`go run ./cmd/new-plugin`; [which kind](docs/which-kind.md)): it writes into `providers//`, a new folder or one more source in the existing one. Then fill in every `TODO(new-plugin)`; `make todos` (part of `make check` and CI_go) fails while one is left. - **Fetch only through the environment** (`env.Get` or `core/kit/`). No `net/http` outside the fetch layer, no filesystem outside `testdata/`, no database. -- **Golden test + dated source quote**: a saved copy of the real source in `testdata/`, a row in `testdata/README.md` (URL, date fetched, license, quote), and `testdata/golden/-.json` with the exact events. +- **Golden test + dated source quote**: a saved copy of the real source in `providers//testdata/`, a row in its `testdata/README.md` (URL, date fetched, license, quote), and `testdata/golden/-.json` with the exact events. - **Precision over recall.** When unsure whether something is a change, don't emit an event. -- **One pinned drop test** per plugin: a realistic input that must produce no event. -- **`providers/-.md`** for every provider, copied from `providers/_template.md`, including **Why this source**: the link, the date it was checked, why it's the best source, the alternatives not used, and a short quote. +- **One pinned drop test** per source: a realistic input that must produce no event. +- **A section of `providers//README.md`** for every source (a new provider's page from `docs/provider-template.md`), including **Why this source**: the link, the date it was checked, why it's the best source, the alternatives not used, and a short quote. - **No source, no event**: every event carries the source URL and a quote. - Don't edit golden files to make a test pass without explaining in the PR why the new output is right. @@ -59,16 +61,20 @@ core/kit/ core/kit/kittest/ Cite, Wayback, Notices; the test kit (Mem, Pages, core/extract/ what readers of prose share: RSS/Atom entries, HTML as text, dates, code spans core/event/ the change event of patch-it's contract: types, fingerprint, validation core/diff/ core/normalize/ core/hint/ the OpenAPI diff engine and its helpers -plugins// one package per kind, with its providers: openapi (+ adapter/, one spec adapter - per provider), notices (+ retire/, feed/, eol/), migrationguide (+ sdkguide/, - members/), changelog (Markdown, RST, GitHub release notes or JSON), catalog, apisurface (+ pysurface/, dtsurface/); - plugins/all imports every one +kinds// how to read, one package per kind, written once, no provider in it: openapi (+ adapter/, + the interface a provider's spec adapter implements), notices (+ retire/, feed/, eol/), + migrationguide (+ sdkguide/, members/), changelog (Markdown, RST, GitHub release notes + or JSON), catalog, apisurface (+ pysurface/, dtsurface/); each with a test/ package + its providers' tests share +providers// what to read, one folder per provider: provider.go (its RegisterProvider: the provider + and every source), README.md (its page, a section per source), .go only for code + only it needs, testdata/ (+ README.md, golden/), its golden and drop tests +providers/all/ imports every provider; its tests check the folders, the metadata and the import graph cmd/list-plugins/ prints the list from the registry (make plugins); internal/pluginlist/ is its logic -cmd/new-plugin/ scaffolds a provider's source on a kind (make new-plugin ARGS=...; go run ./cmd/new-plugin --help) +cmd/new-plugin/ scaffolds a source into providers// (make new-plugin ARGS=...; go run ./cmd/new-plugin --help) contract/fixtures/ a copy of patch-it's change-event fixtures (CI_contract checks it) Makefile make check (what CI_go runs, plus the leak guard), make plugins -docs/ contributor docs, including writing-a-plugin.md -providers/-.md one page per provider +docs/ contributor docs, including writing-a-plugin.md and provider-template.md scripts/ leak_guard.py (hashed internal names), check_contract.py .github/ CODEOWNERS, PR template, release-notes categories, workflows (CI_go, CI_dco, CI_leak_guard, CI_contract, Release) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7ede16..4ca58af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,17 +2,18 @@ Thanks for helping patch-it watch more APIs. This file is the rulebook; [docs/writing-a-plugin.md](docs/writing-a-plugin.md) is the how-to. -**Start a new provider with the starter:** `make new-plugin ARGS='--provider --source --kind '` ([which kind?](docs/which-kind.md); in a terminal it asks for the rest) writes the definition, its registration, a test over placeholder sources, the testdata rows, the provider page, and the source's metadata in its `RegisterProvider` block; you fill in the `TODO(new-plugin)`s ([how](docs/writing-a-plugin.md#1-scaffold-it-with-new-plugin)). +**Start a new provider or source with the starter:** `make new-plugin ARGS='--provider --source --kind '` ([which kind?](docs/which-kind.md); in a terminal it asks for the rest) writes everything into the provider's folder, `providers//`: the source's definition, its registration with its metadata in `provider.go` (the provider's one `RegisterProvider` block), a test over placeholder sources, the testdata rows, and the source's section of the provider's page; you fill in the `TODO(new-plugin)`s ([how](docs/writing-a-plugin.md#1-scaffold-it-with-new-plugin)). ## The rules -1. **Give every provider and source complete metadata in its registration.** A source exists when its kind's package registers it with `plugin.RegisterProvider`: the provider's id, name, category and homepage, and the source's id, layer, what it watches, the URLs it reads and its page. That registration is the only list: `make plugins` prints it, each release carries it as `plugins.json`, and docs.patch-it.dev reads it from there. Nothing else to update. +1. **Give every provider and source complete metadata in its registration.** A source exists when its provider's `providers//provider.go` registers it with `plugin.RegisterProvider` (once per provider, every source in it, built from the kinds' exported types): the provider's id, name, category and homepage, and the source's id, layer, what it watches, the URLs it reads and the packages it covers; its page is the provider's `README.md`. That registration is the only list: `make plugins` prints it, each release carries it as `plugins.json`, and docs.patch-it.dev reads it from there. Nothing else to update. 2. **Fetch only through the environment.** Plugins get their sources from `env.Get` or the helpers in `core/kit/`, never from `net/http` directly, the filesystem or a database. That keeps tests offline and lets the hosted service cache, retry and rate-limit politely. -3. **Every plugin has a golden test** over a real saved copy of its source: `testdata/` in, `testdata/golden/-.json` out. `testdata/README.md` lists each file with its URL, the date you fetched it, its license, and a short quote of the part your plugin reads. Keep openly licensed files whole; trim vendor documentation pages to what the test needs. +3. **Every source has a golden test** over a real saved copy of it: `providers//testdata/` in, `providers//testdata/golden/-.json` out. The provider's `testdata/README.md` lists each file with its URL, the date you fetched it, its license, and a short quote of the part your plugin reads. Keep openly licensed files whole; trim vendor documentation pages to what the test needs. 4. **Precision over recall.** A missed change is a bug we can fix later. A wrong change becomes a wrong pull request in someone's repo. When in doubt, don't emit. -5. **One pinned drop test per plugin**: a realistic input your plugin must *not* turn into an event (an unrelated section, a renamed heading, a non-breaking addition). -6. **Document the provider** in `providers/-.md`, copied from [`providers/_template.md`](providers/_template.md): what it watches, **why you chose that source** (and the alternatives you didn't), how the provider announces changes, what the plugin reads and ignores, and known gaps. -7. **Nothing private.** This repo is public. No credentials, tokens, internal hostnames or links to private repos or systems, in code, tests, commit messages or PR descriptions. CI scans every PR for secrets and for known internal names. +5. **One pinned drop test per source**: a realistic input your plugin must *not* turn into an event (an unrelated section, a renamed heading, a non-breaking addition). +6. **Document the source** in its section of the provider's page, `providers//README.md` (a new provider's from [`docs/provider-template.md`](docs/provider-template.md)): what it watches, **why you chose that source** (and the alternatives you didn't), how the provider announces changes, what the plugin reads and ignores, and known gaps. +7. **Keep how apart from what.** `kinds//` says how to read a kind of source, written once, and imports no provider; `providers//` says what to read for one provider and imports only `core/` and `kinds/`, never another provider. Code specific to one provider (an OpenAPI adapter, a feed's reader) lives in its folder. `go test ./providers/all` checks the import graph. +8. **Nothing private.** This repo is public. No credentials, tokens, internal hostnames or links to private repos or systems, in code, tests, commit messages or PR descriptions. CI scans every PR for secrets and for known internal names. ## Sign your commits (DCO) @@ -36,7 +37,7 @@ That adds `Signed-off-by: Your Name `, matching the commit's au | Workflow | What it checks | |---|---| -| `CI_go` | `go mod tidy`, build, vet, gofmt, `go test -race` (including that every registered source has its metadata and page); plugins import only this module, the standard library and approved dependencies; `net/http` only in the fetch layer. Each step is a [Makefile](Makefile) target: `make check` runs them all locally | +| `CI_go` | `go mod tidy`, build, vet, gofmt, `go test -race` (including that every provider's folder is imported and registers it, every registered source has its metadata and is named on its provider's page, and the import graph: kinds import no provider, a provider only `core/` and `kinds/`); plugins import only this module, the standard library and approved dependencies; `net/http` only in the fetch layer. Each step is a [Makefile](Makefile) target: `make check` runs them all locally | | `CI_dco` | Every commit in the PR is signed off by its author | | `CI_leak_guard` | gitleaks over the PR's commits, and a check for known internal names (stored as hashes only). Also runs weekly over the whole repo | | `Claude Code Review` | Claude reviews the PR against the rules above, once (PRs from this repo's branches; forks: a maintainer comments `@claude review`). Advisory, not a required check | @@ -46,7 +47,7 @@ That adds `Signed-off-by: Your Name `, matching the commit's au Releases are tags on `main` (`v0.x.y`), made only by the **Release** workflow. Nothing is tagged on push, and agents never tag or release. -**Automatic, twice a week:** every Monday and Thursday at 14:00 UTC the workflow makes a **patch** release, but only if something was merged since the last tag; otherwise it does nothing. If the merges add a **new kind** (a new `plugins//` directory), the scheduled run skips with a warning instead: run it by hand with **minor**. So a merged plugin reaches patch-it's hosted ingestion service within a few days. +**Automatic, twice a week:** every Monday and Thursday at 14:00 UTC the workflow makes a **patch** release, but only if something was merged since the last tag; otherwise it does nothing. If the merges add a **new kind** (a new `kinds//` directory), the scheduled run skips with a warning instead: run it by hand with **minor**. So a merged plugin reaches patch-it's hosted ingestion service within a few days. **By hand, any time** (an urgent fix, or a **minor** release): diff --git a/Makefile b/Makefile index b95da4f..b493030 100644 --- a/Makefile +++ b/Makefile @@ -50,11 +50,12 @@ imports: echo "::error::imports outside the allowlist (Makefile, ALLOWED):"; echo "$$others"; exit 1; \ fi -# Plugins fetch through env.Get / kit, never on their own. +# Plugins fetch through env.Get / kit, never on their own. The one exception +# is a test kit: openapitest serves recorded API responses over httptest. nethttp: @bad=$$($(GO) list -f '{{.ImportPath}} {{join .Imports " "}}' ./... \ | grep -E '(^| )net/http( |$$)' | cut -d' ' -f1 \ - | grep -vE '^$(MODULE)/(core/fetch|core/kit|plugins/openapi/adapter)(/|$$)' || true); \ + | grep -vE '^$(MODULE)/(core/fetch|core/kit|kinds/openapi/openapitest)(/|$$)' || true); \ if [ -n "$$bad" ]; then \ echo "::error::these packages import net/http; fetch through env.Get or kit instead:"; echo "$$bad"; exit 1; \ fi @@ -65,7 +66,7 @@ test: # A provider started with new-plugin is done when nothing it wrote still says # TODO(new-plugin). -TODO_DIRS := plugins providers +TODO_DIRS := kinds providers todos: @left=$$(grep -rl 'TODO(new-plugin)' $(TODO_DIRS) || true); \ if [ -n "$$left" ]; then \ diff --git a/README.md b/README.md index 5df0e49..91d1fac 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ You need Go (the version in `go.mod`), `make` and Python 3. ```sh make new-plugin ARGS='--provider acme --name Acme --source api --kind notices --reader feed --url https://acme.example/changelog.xml' ``` -2. **Fill in every `TODO(new-plugin)`**: the reader, the provider and source metadata in its `plugin.RegisterProvider` block, a saved copy of the source in `testdata/`, and "Why this source" in `providers/acme-api.md`. Then write the golden file and read it like code: +2. **Fill in every `TODO(new-plugin)`** in `providers/acme/`: the reader, the provider and source metadata in `provider.go`, a saved copy of the source in `testdata/`, and "Why this source" in `README.md`. Then write the golden file and read it like code: ```sh - go test ./plugins/notices -run TestAcmeApi -update + go test ./providers/acme -run TestApi -update ``` 3. **Check it the way CI will, and open the PR** (`git commit -s`, one provider per PR): ```sh @@ -31,7 +31,7 @@ You need Go (the version in `go.mod`), `make` and Python 3. ## More - [Which kind fits my provider?](docs/which-kind.md) and [how to write a plugin](docs/writing-a-plugin.md): providers, sources, kinds, versions, the test kit, step by step. -- [How it works](docs/how-it-works.md): what a plugin does, the layout, the checks, releases. +- [How it works](docs/how-it-works.md): what a plugin does, the layout (`kinds/` how to read, `providers/` what to read), the checks, releases. - What's covered: `make plugins` prints every provider and source from the code; each [release](https://github.com/patch-it-dev/patch-it-plugins/releases) carries it as `plugins.json`, and [docs.patch-it.dev](https://docs.patch-it.dev/supported-apis/plugins/) shows it. - [CONTRIBUTING.md](CONTRIBUTING.md) (the rules), [AGENTS.md](AGENTS.md) (for AI coding agents), [Discussions](https://github.com/patch-it-dev/patch-it-plugins/discussions), [good first issues](https://github.com/patch-it-dev/patch-it-plugins/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). - What patch-it does with the events: [patch-it.dev](https://patch-it.dev) and [docs.patch-it.dev](https://docs.patch-it.dev). [Apache-2.0](LICENSE), copyright patch-it contributors. diff --git a/cmd/list-plugins/main.go b/cmd/list-plugins/main.go index 1f9c2b9..7e71ae1 100644 --- a/cmd/list-plugins/main.go +++ b/cmd/list-plugins/main.go @@ -14,7 +14,7 @@ import ( "os" "github.com/patch-it-dev/patch-it-plugins/internal/pluginlist" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/all" + _ "github.com/patch-it-dev/patch-it-plugins/providers/all" ) func main() { diff --git a/cmd/new-plugin/formats.go b/cmd/new-plugin/formats.go index b85fd8a..2a7df44 100644 --- a/cmd/new-plugin/formats.go +++ b/cmd/new-plugin/formats.go @@ -1,25 +1,26 @@ package main -// formatSpec is how a provider is added to one format plugin: where its -// definition goes, the line that registers it, the placeholder sources its -// test reads, and how the test runs it. +// formatSpec is how a source is added on one kind (and reader): its +// definition in the provider's package, the plugin its registration runs, +// the placeholder sources its test reads, and how the test runs it. type formatSpec struct { - kind string // the kind: the plugins/ package that registers and tests it - layer string // the source's default layer (plugin.Layers()) - defDir string // the package directory the definition goes in - def string // the definition file (template) - register string // the plugin.Register line added to plugins/'s init (template) - ref string // how the test and the Register line name the definition - pluginOf string // the plugin literal for the registered test (template) - fixtures map[string]string // placeholder sources under plugins//testdata: name (template) -> content (template) - source string // the fixture the golden test reads; the drop test reads a copy, -drop. - ingest string // the test's Ingest func and anything it needs (template) - imports []string // the test's imports besides testing and kittest - next string // a format-specific line for the next steps - drop string // the drop test, when "no event at all" can't be it (template) - dropFile string // the drop test's placeholder, when not a copy of the source's + kind string // the kind: the kinds/ package whose plugin runs it + layer string // the source's default layer (plugin.Layers()) + def string // the definition file, providers//.go (template) + plugin string // the plugin its registration runs, in provider.go (template) + regImports []string // what provider.go imports for plugin + pluginOf string // the plugin literal for the registered test (template) + fixtures map[string]string // placeholder sources under providers//testdata: name (template) -> content (template) + source string // the fixture the golden test reads; the drop test reads a copy, -drop. + ingest string // the test's Ingest func and anything it needs (template) + imports []string // the test's imports besides testing and kittest + next string // a format-specific line for the next steps + drop string // the drop test, when "no event at all" can't be it (template) + dropFile string // the drop test's placeholder, when not a copy of the source's } +const module = "github.com/patch-it-dev/patch-it-plugins/" + const todo = "TODO(new-plugin)" // defaultReaders are the reader --kind picks when --reader is left out. @@ -32,17 +33,18 @@ var defaultReaders = map[string]string{ var formats = map[string]formatSpec{ "notices/feed": { - kind: "notices", - layer: "api", - defDir: "plugins/notices/feed", - def: `package feed + kind: "notices", + layer: "api", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" // {{.Ident}} is {{.Provider}}'s feed of changes. // // ` + todo + `: say what the feed is and what you checked, with the date, as -// the feeds in readers.go do: RSS or Atom, how many entries it keeps, how -// {{.Provider}} marks a breaking change or a deprecation. -var {{.Ident}} = Feed{ +// providers/github/actions.go does: RSS or Atom, how many entries it keeps, +// how {{.Provider}} marks a breaking change or a deprecation. +var {{.Ident}} = feed.Feed{ API: "{{.ID}}", Vendor: "{{.Provider}}", URL: "{{.Source}}", @@ -56,13 +58,15 @@ var {{.Ident}} = Feed{ // lines in Excerpt. For an entry that is marked but that you can't read for // sure, return a Finding with only Entry and Dropped set. Return nothing for // an entry that isn't a breaking change or a deprecation. Precision over -// recall: readCloudflareAPI in readers.go is a worked example. -func read{{.Ident}}(e Entry) []Finding { +// recall: readCloudflareAPI in providers/cloudflare/api.go is a worked +// example. +func read{{.Ident}}(e feed.Entry) []feed.Finding { return nil } `, - register: `plugin.Register(Plugin{Page: feed.{{.Ident}}, Archiver: kit.Wayback{}})`, - pluginOf: `Plugin{Page: feed.{{.Ident}}}`, + plugin: `notices.Plugin{Page: {{.Ident}}, Archiver: kit.Wayback{}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/notices", "github.com/patch-it-dev/patch-it-plugins/core/kit"}, + pluginOf: `notices.Plugin{Page: {{.Ident}}}`, fixtures: map[string]string{"{{.File}}.rss.xml": ` placeholderhttps://example.com/placeholder @@ -74,40 +78,45 @@ func read{{.Ident}}(e Entry) []Finding { // page), cited through a test archive that serves the same copy. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() - saved := kittest.Pages{feed.{{.Ident}}.URL: file} + saved := kittest.Pages{ {{.Ident}}.URL: file} archive := &kittest.Archive{T: t, Pages: saved} - return kittest.Page(t, kittest.Env(t, saved), Plugin{Page: feed.{{.Ident}}, Archiver: archive}) + return kittest.Page(t, kittest.Env(t, saved), notices.Plugin{Page: {{.Ident}}, Archiver: archive}) } `, - imports: []string{"github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/plugins/notices/feed"}, + imports: []string{"github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/kinds/notices"}, }, "notices/deprecations": { - kind: "notices", - layer: "ai-models", - defDir: "plugins/notices/retire", - def: `package retire + kind: "notices", + layer: "ai-models", + def: `package {{.Package}} -import "strings" +import ( + "strings" + + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" +) // {{.Ident}} is {{.Provider}}'s model deprecations page. // // ` + todo + `: say what the page is and what you checked, with the date, as -// providers.go does: served as markdown, the table's columns (a "Shutdown -// date" or "Retirement date" column first, then the model and its -// replacement), how far back it goes. -var {{.Ident}} = Page{ +// providers/openai/models.go does: served as markdown, the table's columns +// (a "Shutdown date" or "Retirement date" column first, then the model and +// its replacement), how far back it goes. +var {{.Ident}} = retire.Page{ API: "{{.ID}}", Provider: "{{.ProviderID}}", Vendor: "{{.Provider}}", URL: "{{.Source}}", // ` + todo + `: keep the model names the provider's calls take as text - // models (not image or embedding ones), as openAIText in providers.go does. + // models (not image or embedding ones), as openAIText in + // providers/openai/models.go does. Keep: func(name string) bool { return strings.HasPrefix(name, "placeholder-text-") }, } `, - register: `plugin.Register(Plugin{Page: retire.{{.Ident}}, Archiver: kit.Wayback{}})`, - pluginOf: `Plugin{Page: retire.{{.Ident}}}`, + plugin: `notices.Plugin{Page: {{.Ident}}, Archiver: kit.Wayback{}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/notices", "github.com/patch-it-dev/patch-it-plugins/core/kit"}, + pluginOf: `notices.Plugin{Page: {{.Ident}}}`, fixtures: map[string]string{"{{.File}}-deprecations.md": `# Placeholder deprecations page ` + todo + `: a placeholder. Replace it with a real copy of {{.Source}} (as markdown) and list it in README.md. @@ -146,26 +155,27 @@ func Test{{.Ident}}DropsANonChange(t *testing.T) { // page), cited through a test archive that serves the same copy. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() - saved := kittest.Pages{retire.{{.Ident}}.URL: file} + saved := kittest.Pages{ {{.Ident}}.URL: file} archive := &kittest.Archive{T: t, Pages: saved} - return kittest.Page(t, kittest.Env(t, saved), Plugin{Page: retire.{{.Ident}}, Archiver: archive}) + return kittest.Page(t, kittest.Env(t, saved), notices.Plugin{Page: {{.Ident}}, Archiver: archive}) } `, - imports: []string{"encoding/json", "strings", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire"}, + imports: []string{"encoding/json", "strings", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/kinds/notices"}, }, "migrationguide/sdk": { - kind: "migrationguide", - layer: "sdk", - defDir: "plugins/migrationguide/sdkguide", - def: `package sdkguide + kind: "migrationguide", + layer: "sdk", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/sdkguide" // {{.Ident}} is {{.Provider}}'s SDK guide to each major release (MIGRATION.md // at the major's first tag), its releases listed from PyPI. // // ` + todo + `: the PyPI name, the repo and the calls the guide's table // names. Say what you checked, with the date. -var {{.Ident}} = Guide{ +var {{.Ident}} = sdkguide.Guide{ API: "{{.ID}}", Package: "{{.PyPI}}", Repo: "TODO-owner/TODO-repo", @@ -173,8 +183,9 @@ var {{.Ident}} = Guide{ Symbols: []string{"TODO.create"}, } `, - register: `plugin.Register(Plugin{Guide: sdkguide.{{.Ident}}})`, - pluginOf: `Plugin{Guide: sdkguide.{{.Ident}}}`, + plugin: `migrationguide.Plugin{Guide: {{.Ident}}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide"}, + pluginOf: `migrationguide.Plugin{Guide: {{.Ident}}}`, fixtures: map[string]string{"{{.File}}-MIGRATION.md": `# Migrating to v1 ` + todo + `: a placeholder. Replace it with a real copy of the guide at the release tag and list it in README.md. @@ -219,20 +230,21 @@ const {{.Lower}}Previous = "0.0.0" // ` + todo + `: the major the saved guide is for. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() - g := sdkguide.{{.Ident}}.At(1) + g := {{.Ident}}.At(1) env := kittest.Env(t, kittest.Pages{g.URL(): file}) - return kittest.Versions(t, env, Plugin{Guide: g}, + return kittest.Versions(t, env, migrationguide.Plugin{Guide: g}, plugin.Version{ID: {{.Lower}}Previous, Ref: "v" + {{.Lower}}Previous}, plugin.Version{ID: g.Version(), Ref: "v" + g.Version()}) } `, - imports: []string{"encoding/json", "strings", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin", "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/sdkguide"}, + imports: []string{"encoding/json", "strings", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin", "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide"}, }, "migrationguide/members": { - kind: "migrationguide", - layer: "package", - defDir: "plugins/migrationguide/members", - def: `package members + kind: "migrationguide", + layer: "package", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" // {{.Ident}} is {{.Provider}}'s migration guide to each major, with its table // of removed members, read at the major's first tag. @@ -241,7 +253,7 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { // guide's path at a major's tag ({major} for its number, {prev} for the one // before) and the heading the table is under. Say what you checked, with the // date. -var {{.Ident}} = Guide{ +var {{.Ident}} = members.Guide{ API: "{{.ID}}", Package: "{{.PyPI}}", Module: "{{.Module}}", @@ -250,8 +262,9 @@ var {{.Ident}} = Guide{ Section: "Removed members", } `, - register: `plugin.Register(Plugin{Guide: members.{{.Ident}}})`, - pluginOf: `Plugin{Guide: members.{{.Ident}}}`, + plugin: `migrationguide.Plugin{Guide: {{.Ident}}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide"}, + pluginOf: `migrationguide.Plugin{Guide: {{.Ident}}}`, fixtures: map[string]string{"{{.File}}-migration-guide.rst": `.. ` + todo + `: a placeholder. Replace it with a real copy of the guide at the release tag and list it in README.md. Removed members @@ -290,7 +303,7 @@ placeholder_elsewhere Not in the main table. func Test{{.Ident}}DropsANonChange(t *testing.T) { for _, e := range {{.Lower}}Ingest(t, {{.Lower}}Drop) { if slices.Contains(e.Subject.Symbols, "placeholder_elsewhere") { - t.Errorf("event for placeholder_elsewhere, which isn't under %q", members.{{.Ident}}.Section) + t.Errorf("event for placeholder_elsewhere, which isn't under %q", {{.Ident}}.Section) } } } @@ -309,33 +322,35 @@ const {{.Lower}}Release = "1.0.0" // {{.Lower}}Release over a saved copy of the guide. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() - g := members.{{.Ident}} + g := {{.Ident}} env := kittest.Env(t, kittest.Pages{g.RawURL("v"+{{.Lower}}Release, 1): file}) - return kittest.Versions(t, env, Plugin{Guide: g}, plugin.Version{ID: {{.Lower}}Previous}, plugin.Version{ID: {{.Lower}}Release}) + return kittest.Versions(t, env, migrationguide.Plugin{Guide: g}, plugin.Version{ID: {{.Lower}}Previous}, plugin.Version{ID: {{.Lower}}Release}) } `, - imports: []string{"slices", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin", "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members"}, + imports: []string{"slices", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin", "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide"}, }, "changelog/markdown": { - kind: "changelog", - layer: "package", - defDir: "plugins/changelog", - def: `package changelog + kind: "changelog", + layer: "package", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" // {{.Ident}} is {{.Provider}}'s changelog, read release by release (its // releases listed from the ecosystem's registry, each at TagPrefix+version). // // ` + todo + `: the ecosystem, the import name, the repo, the tag prefix and -// the changelog's path. Say what you checked, with the date, as changelog.go -// does for Textual and urllib3. -var {{.Ident}} = File{ +// the changelog's path. Say what you checked, with the date, as +// providers/textual/provider.go does. +var {{.Ident}} = changelog.File{ API: "{{.ID}}", Package: "{{.PyPI}}", Ecosystem: "pypi", Module: "{{.Module}}", Repo: "TODO-owner/TODO-repo", TagPrefix: "v", Path: "CHANGELOG.md", } `, - register: `plugin.Register(Plugin{File: {{.Ident}}})`, - pluginOf: `Plugin{File: {{.Ident}}}`, + plugin: `changelog.Plugin{File: {{.Ident}}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/changelog"}, + pluginOf: `changelog.Plugin{File: {{.Ident}}}`, fixtures: map[string]string{"{{.File}}-CHANGELOG.md": `# Changelog @@ -364,7 +379,7 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() f := {{.Ident}}Golden env := kittest.Env(t, kittest.Pages{f.URL(): file}) - p := Plugin{File: f} + p := changelog.Plugin{File: f} to, err := p.ReadAt(context.Background(), env, plugin.Version{ID: f.Release, Ref: f.Tag}) if err != nil { t.Fatal(err) @@ -373,26 +388,28 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { return kittest.Extracted(t, env, p, from, to) } `, - imports: []string{"context", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin"}, + imports: []string{"context", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin", "github.com/patch-it-dev/patch-it-plugins/kinds/changelog"}, }, "changelog/json": { - kind: "changelog", - layer: "api", - defDir: "plugins/changelog", - def: `package changelog + kind: "changelog", + layer: "api", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" // {{.Ident}} is {{.Provider}}'s machine-readable API changelog. // // ` + todo + `: the repo and the file's path, and what you checked, with the -// date, as json.go does for MongoDB Atlas. -var {{.Ident}} = Log{ +// date, as providers/mongodb/provider.go does for the Atlas changelog. +var {{.Ident}} = changelog.Log{ API: "{{.ID}}", Vendor: "{{.Provider}}", Name: "TODO: the API's name, for sentences", Repo: "TODO-owner/TODO-repo", Path: "changelog/changelog.json", } `, - register: `plugin.Register(Plugin{Log: {{.Ident}}})`, - pluginOf: `Plugin{Log: {{.Ident}}}`, + plugin: `changelog.Plugin{Log: {{.Ident}}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/changelog"}, + pluginOf: `changelog.Plugin{Log: {{.Ident}}}`, fixtures: map[string]string{ "{{.File}}-changelog.json": `[{"date": "2026-11-14", "paths": [{"path": "/placeholder", "httpMethod": "GET", "versions": [{"version": "2026-01-01", "changes": [{"change": "placeholder: not a life-cycle change", "changeCode": "response-property-added", "backwardCompatible": true}]}]}]}]` + "\n", }, @@ -411,7 +428,7 @@ var ( func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() env := kittest.Env(t, kittest.Pages{ {{.Ident}}.URL({{.Lower}}Commit.Ref): file}) - p := Plugin{Log: {{.Ident}}} + p := changelog.Plugin{Log: {{.Ident}}} to, err := p.ReadAt(context.Background(), env, {{.Lower}}Commit) if err != nil { t.Fatal(err) @@ -419,31 +436,36 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { return kittest.Extracted(t, env, p, plugin.Snapshot{Version: {{.Lower}}Before}, to) } `, - imports: []string{"context", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin"}, + imports: []string{"context", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin", "github.com/patch-it-dev/patch-it-plugins/kinds/changelog"}, }, "catalog": { - kind: "catalog", - layer: "runtime", - defDir: "plugins/catalog", - def: `package catalog + kind: "catalog", + layer: "runtime", + def: `package {{.Package}} -import "regexp" +import ( + "regexp" + + "github.com/patch-it-dev/patch-it-plugins/kinds/catalog" +) // {{.Ident}} is {{.Provider}}'s command catalog: one JSON file per command in a -// directory of its repo, read at each release tag, as Redis's is (redis.go). +// directory of its repo, read at each release tag, as Redis's is +// (providers/redis/provider.go). // // ` + todo + `: the ecosystem and package for the events' subject, the repo, // the directory and the release tags' shape. Say what you checked, with the -// date, as redis.go does for Redis. -var {{.Ident}} = Commands{ +// date, as providers/redis/provider.go does. +var {{.Ident}} = catalog.Commands{ API: "{{.ID}}", Ecosystem: "{{.ProviderID}}", Package: "{{.ProviderID}}", Repo: "TODO-owner/TODO-repo", Dir: "TODO/commands", Release: regexp.MustCompile(` + "`" + `^v?(\d+\.\d+\.\d+)$` + "`" + `), } `, - register: `plugin.Register({{.Ident}})`, - pluginOf: `{{.Ident}}`, + plugin: `{{.Ident}}`, + regImports: []string{}, + pluginOf: `{{.Ident}}`, fixtures: map[string]string{ "{{.File}}-old.json": "[{\"name\": \"placeholder.json\", \"type\": \"file\"}, {\"name\": \"kept.json\", \"type\": \"file\"}]\n", "{{.File}}-new.json": "[{\"name\": \"kept.json\", \"type\": \"file\"}]\n", @@ -463,8 +485,8 @@ const ( func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() env := kittest.Env(t, kittest.Pages{ - {{.Ident}}.listingURL({{.Lower}}OldRef): "testdata/{{.File}}-old.json", - {{.Ident}}.listingURL({{.Lower}}NewRef): file, + {{.Ident}}.ListingURL({{.Lower}}OldRef): "testdata/{{.File}}-old.json", + {{.Ident}}.ListingURL({{.Lower}}NewRef): file, {{.Ident}}.FileURL({{.Lower}}OldRef, "placeholder.json"): "testdata/{{.File}}-placeholder.json", }) return kittest.Versions(t, env, {{.Ident}}, @@ -475,50 +497,53 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { }, "openapi": { - kind: "openapi", - layer: "api", - defDir: "plugins/openapi/adapter", - def: `package adapter + kind: "openapi", + layer: "api", + def: `package {{.Package}} import ( "context" "fmt" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // {{.Ident}} adapts {{.Provider}}'s OpenAPI spec for the openapi plugin. // // ` + todo + `: LatestTag finds the newest release (a tag, or the commit // that last changed the spec) and Fetch downloads the spec at it with -// fetch.Get, as supabase.go and vercel.go do. Say where the spec is -// published and what you checked, with the date. +// fetch.Get, as providers/supabase/management_api.go and +// providers/vercel/api.go do. Say where the spec is published and what you +// checked, with the date. type {{.Ident}} struct{} -var _ Adapter = {{.Ident}}{} +var _ adapter.Adapter = {{.Ident}}{} func ({{.Ident}}) API() string { return "{{.ID}}" } // LatestTag is the newest release of the spec. func ({{.Ident}}) LatestTag(ctx context.Context) (string, error) { - return "", fmt.Errorf("{{.ID}}: LatestTag isn't written yet (plugins/openapi/adapter/{{.File}}.go)") + return "", fmt.Errorf("{{.ID}}: LatestTag isn't written yet (providers/{{.ProviderID}}/{{.File}}.go)") } // Fetch downloads the spec at tag. -func ({{.Ident}}) Fetch(ctx context.Context, tag string) (Spec, error) { - return Spec{}, fmt.Errorf("{{.ID}}: Fetch isn't written yet (plugins/openapi/adapter/{{.File}}.go)") +func ({{.Ident}}) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { + return adapter.Spec{}, fmt.Errorf("{{.ID}}: Fetch isn't written yet (providers/{{.ProviderID}}/{{.File}}.go)") } // Versions are every release of the spec, oldest first, each with the Ref // Fetch takes: what lets every pair of releases be diffed, not only the // newest. ` + todo + `: list them with core/versions (GitHubReleases, -// GitHubCommits, GitHubTags), as versions.go does for the other adapters. +// GitHubCommits, GitHubTags) or adapter.Releases and adapter.Commits, as the +// other providers' adapters do. func ({{.Ident}}) Versions(ctx context.Context) ([]plugin.Version, error) { - return nil, fmt.Errorf("{{.ID}}: Versions isn't written yet (plugins/openapi/adapter/{{.File}}.go)") + return nil, fmt.Errorf("{{.ID}}: Versions isn't written yet (providers/{{.ProviderID}}/{{.File}}.go)") } `, - register: `plugin.Register(Plugin{Adapter: adapter.{{.Ident}}{}})`, - pluginOf: `Plugin{Adapter: adapter.{{.Ident}}{}}`, + plugin: `openapi.Plugin{Adapter: {{.Ident}}{}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/openapi"}, + pluginOf: `openapi.Plugin{Adapter: {{.Ident}}{}}`, fixtures: map[string]string{ "{{.File}}-old.json": `{"openapi": "3.0.3", "info": {"title": "placeholder", "version": "1"}, "paths": {}}` + "\n", "{{.File}}-new.json": `{"openapi": "3.0.3", "info": {"title": "placeholder", "version": "2"}, "paths": {}}` + "\n", @@ -547,18 +572,19 @@ func (a {{.Lower}}Adapter) Fetch(_ context.Context, tag string) (adapter.Spec, e // {{.Lower}}Ingest extracts the change from the saved old spec to file. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() - p := Plugin{Adapter: {{.Lower}}Adapter{"old": "testdata/{{.File}}-old.json", "new": file}} + p := openapi.Plugin{Adapter: {{.Lower}}Adapter{"old": "testdata/{{.File}}-old.json", "new": file}} return kittest.Versions(t, kittest.Env(t, nil), p, plugin.Version{ID: "old", Ref: "old"}, plugin.Version{ID: "new", Ref: "new"}) } `, - imports: []string{"context", "fmt", "os", "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin"}, - next: "Write LatestTag, Fetch and Versions in plugins/openapi/adapter/{{.File}}.go (fetch.Get only); add Diff/Keep to the Register line if the spec needs them (see vercel.go).", + imports: []string{"context", "fmt", "os", "github.com/patch-it-dev/patch-it-plugins/kinds/openapi", "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/core/plugin"}, + next: "Write LatestTag, Fetch and Versions in providers/{{.ProviderID}}/{{.File}}.go (fetch.Get only); add Diff/Keep to its registration if the spec needs them (see providers/vercel/api.go).", }, "apisurface/pypi": { - kind: "apisurface", - layer: "sdk", - defDir: "plugins/apisurface", - def: `package apisurface + kind: "apisurface", + layer: "sdk", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" // {{.Ident}} is {{.Provider}}'s package on PyPI, its public API read from each // release's wheel. @@ -567,12 +593,13 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { // imports (from --package, or guessed). Say // what you checked, with the date: that the wheel holds the package's .py // (or .pyi) files. -var {{.Ident}} = Package{ID: "{{.ID}}", Name: "{{.PyPI}}", Ecosystem: "pypi", Module: "{{.Module}}"} +var {{.Ident}} = apisurface.Package{ID: "{{.ID}}", Name: "{{.PyPI}}", Ecosystem: "pypi", Module: "{{.Module}}"} `, - register: `plugin.Register(Plugin{Package: {{.Ident}}})`, - pluginOf: `Plugin{Package: {{.Ident}}}`, + plugin: `apisurface.Plugin{Package: {{.Ident}}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/apisurface"}, + pluginOf: `apisurface.Plugin{Package: {{.Ident}}}`, fixtures: map[string]string{ - "{{.File}}-old.py": "# ` + todo + `: a placeholder for the older release's module. Save the real release's wheel instead (see apisurface_test.go).\ndef placeholder(a, b=1):\n pass\n", + "{{.File}}-old.py": "# ` + todo + `: a placeholder for the older release's module. Save the real release's wheel instead (see providers/openai/python_surface_test.go).\ndef placeholder(a, b=1):\n pass\n", "{{.File}}-new.py": "# ` + todo + `: a placeholder for the newer release's module: it drops b, one event.\ndef placeholder(a):\n pass\n", }, // The drop test's newer release: the older one again, nothing gone. @@ -582,7 +609,7 @@ var {{.Ident}} = Package{ID: "{{.ID}}", Name: "{{.PyPI}}", Ecosystem: "pypi", Mo // testdata/{{.File}}-old.py as {{.Module}}/__init__.py, and 1.1.0, one // holding file. The wheels are built here so the placeholders are text. // ` + todo + `: save the two real wheels (trimmed if they're large, as -// apisurface_test.go's are) and serve them instead. +// providers/openai/testdata/'s are) and serve them instead. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() wheel := func(src string) []byte { @@ -613,7 +640,7 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Errorf("fetched %s, which the test didn't save", url) return nil, fmt.Errorf("no saved copy of %s", url) } - ctx, p := context.Background(), Plugin{Package: {{.Ident}}} + ctx, p := context.Background(), apisurface.Plugin{Package: {{.Ident}}} vs, err := p.ListVersions(ctx, env) if err != nil || len(vs) != 2 { t.Fatalf("versions %v: %v", vs, err) @@ -621,14 +648,15 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { return kittest.Versions(t, env, p, vs[0], vs[1]) } `, - imports: []string{"archive/zip", "bytes", "context", "fmt", "github.com/patch-it-dev/patch-it-plugins/core/event"}, + imports: []string{"archive/zip", "bytes", "context", "fmt", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface"}, next: "Save two real wheels of the package and serve them in {{.Lower}}Ingest; the kind reads their .py files, never runs them.", }, "apisurface/npm": { - kind: "apisurface", - layer: "sdk", - defDir: "plugins/apisurface", - def: `package apisurface + kind: "apisurface", + layer: "sdk", + def: `package {{.Package}} + +import "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" // {{.Ident}} is {{.Provider}}'s package on npm, its public API read from each // release's TypeScript declarations. @@ -636,12 +664,13 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { // ` + todo + `: check the name on npm, and that its tarball has .d.ts // files (package.json's "types" or "exports"). Say what you checked, with // the date. -var {{.Ident}} = npmPackage("{{.ID}}", "{{.NPM}}") +var {{.Ident}} = apisurface.NPMPackage("{{.ID}}", "{{.NPM}}") `, - register: `plugin.Register(Plugin{Package: {{.Ident}}})`, - pluginOf: `Plugin{Package: {{.Ident}}}`, + plugin: `apisurface.Plugin{Package: {{.Ident}}}`, + regImports: []string{"github.com/patch-it-dev/patch-it-plugins/kinds/apisurface"}, + pluginOf: `apisurface.Plugin{Package: {{.Ident}}}`, fixtures: map[string]string{ - "{{.File}}-old.d.ts": "// ` + todo + `: a placeholder for the older release's declarations. Save the real release's tarball instead (see npm_test.go).\nexport declare function placeholder(a: string, b?: number): void;\n", + "{{.File}}-old.d.ts": "// ` + todo + `: a placeholder for the older release's declarations. Save the real release's tarball instead (see kinds/apisurface/apisurfacetest).\nexport declare function placeholder(a: string, b?: number): void;\n", "{{.File}}-new.d.ts": "// ` + todo + `: a placeholder for the newer release's declarations: b is no longer optional, one event.\nexport declare function placeholder(a: string, b: number): void;\n", }, // The drop test's newer release: the older one again, a name added. @@ -651,7 +680,7 @@ var {{.Ident}} = npmPackage("{{.ID}}", "{{.NPM}}") // testdata/{{.File}}-old.d.ts as index.d.ts, and 1.1.0, one holding file. // The tarballs are built here so the placeholders are text. // ` + todo + `: save the two real tarballs (trimmed if they're large, as -// npm_test.go's are) and serve them instead. +// the providers' npm/ copies are) and serve them instead. func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Helper() tarball := func(src string) []byte { @@ -689,7 +718,7 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { t.Errorf("fetched %s, which the test didn't save", url) return nil, fmt.Errorf("no saved copy of %s", url) } - ctx, p := context.Background(), Plugin{Package: {{.Ident}}} + ctx, p := context.Background(), apisurface.Plugin{Package: {{.Ident}}} vs, err := p.ListVersions(ctx, env) if err != nil || len(vs) != 2 { t.Fatalf("versions %v: %v", vs, err) @@ -697,13 +726,13 @@ func {{.Lower}}Ingest(t *testing.T, file string) []event.Event { return kittest.Versions(t, env, p, vs[0], vs[1]) } `, - imports: []string{"archive/tar", "bytes", "compress/gzip", "context", "fmt", "strings", "github.com/patch-it-dev/patch-it-plugins/core/event"}, + imports: []string{"archive/tar", "bytes", "compress/gzip", "context", "fmt", "strings", "github.com/patch-it-dev/patch-it-plugins/core/event", "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface"}, next: "Save two real tarballs of the package and serve them in {{.Lower}}Ingest; the kind reads their .d.ts files, never runs them.", }, } // testFile is the generated test, the same for every format. -const testFile = `package {{.Kind}} +const testFile = `package {{.Package}} import ( {{range .Imports}} "{{.}}" @@ -724,12 +753,12 @@ func Test{{.Ident}}RegistersItself(t *testing.T) { // The golden test: the saved source in, every event out. // ` + todo + `: once the source is real, run // -// go test ./plugins/{{.Kind}} -run Test{{.Ident}}Golden -update +// go test ./providers/{{.ProviderID}} -run Test{{.Ident}}Golden -update // -// and read testdata/golden/{{.Name}}.json like code: every event in it is a +// and read testdata/golden/{{.Golden}}.json like code: every event in it is a // pull request someone may get. func Test{{.Ident}}Golden(t *testing.T) { - kittest.Golden(t, "testdata/golden/{{.Name}}.json", {{.Lower}}Ingest(t, {{.Lower}}Source)) + kittest.Golden(t, "testdata/golden/{{.Golden}}.json", {{.Lower}}Ingest(t, {{.Lower}}Source)) } {{if .Drop}}{{.Drop}}{{else}}// The pinned drop test: a realistic input that must not become an event. diff --git a/cmd/new-plugin/main.go b/cmd/new-plugin/main.go index 1f7fba2..c338a05 100644 --- a/cmd/new-plugin/main.go +++ b/cmd/new-plugin/main.go @@ -11,18 +11,17 @@ // and --kind (the provider's name, category and homepage come from the // registry). Run it once per source. // -// It writes the source's definition in the kind's package (or the reader -// package the kind uses: plugins/openapi/adapter/, plugins/notices/retire/, -// plugins/notices/feed/, plugins/migrationguide/sdkguide/, -// plugins/migrationguide/members/), with the version wiring the kind needs -// from it (an OpenAPI adapter's Versions; every other kind lists, reads and -// extracts versions itself), adds the plugin.RegisterProvider block (the -// provider and the source with their metadata) to the kind's init, a test -// (registered, golden, drop) over placeholder sources with an empty golden -// file, a row in that testdata/README.md, providers/.md from -// providers/_template.md, and the kind's import in plugins/all when it isn't -// there. `go test ./...` passes right after; every place to fill in says -// TODO(new-plugin). +// Everything goes in the provider's folder, providers//: the +// source's definition, .go, using the kind's exported types (an +// OpenAPI adapter with its Versions; a feed or a page with its reader; a +// changelog, a guide or a package as a value), its registration in +// provider.go (a new provider's provider.go, or one more source in the +// existing one's RegisterProvider), a test (registered, golden, drop) over +// placeholder sources with an empty golden file, rows in testdata/README.md, +// a section in the provider's README.md (a new provider's from +// docs/provider-template.md), and, for a new provider, its import in +// providers/all. `go test ./...` passes right after; every place to fill in +// says TODO(new-plugin). // // It changes nothing when the provider/source id is taken, or a file it // would write exists. @@ -43,13 +42,14 @@ import ( "path/filepath" "regexp" "slices" + "strconv" "strings" "text/template" "time" "unicode" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/all" + _ "github.com/patch-it-dev/patch-it-plugins/providers/all" ) // Options are the command's flags. @@ -64,13 +64,12 @@ type Options struct { // The source. SourceID string // unique within the provider: "api", "python-sdk" - Kind string // the kind that reads it: plugins/ + Kind string // the kind that reads it: kinds/ Reader string // for a kind with several readers: "feed" for notices; "" is the kind's default Layer string // the source's layer (plugin.Layers()); "" is the template's default URLs []string // the provider's pages or files it reads; none is a placeholder Packages []string // the packages it covers, "pypi:acme" Watches string // what the source watches, in a few words - Page string // the provider page, providers/.md; "" is -. An existing page is shared, not rewritten Today time.Time // Go runs the go command afterwards: the golden file from the placeholders @@ -78,7 +77,7 @@ type Options struct { Go bool tmpl string // the template: a kind, or kind/reader - name string // the files' base name: -, or the provider's id when they're the same + name string // the golden file's name: -, or the provider's id when they're the same url string // the first URL } @@ -103,7 +102,6 @@ func main() { flag.Var(&urls, "url", "a page or file the source reads, https://... (repeatable; default: a placeholder to fill in)") flag.Var(&packages, "package", "a package the source covers, ecosystem:name, e.g. pypi:acme or npm:@acme/sdk (repeatable)") flag.StringVar(&o.Watches, "watches", "", "what it watches, in a few words (default: a placeholder)") - flag.StringVar(&o.Page, "page", "", "the provider page, providers/.md (default: -); a second source of a provider may share the existing page") flag.Parse() o.URLs, o.Packages = urls, packages if term() { @@ -195,10 +193,12 @@ var ( // data is what the templates fill in. type data struct { - ID, Name, Ident, Lower, ProviderID, Provider, Source, File, Format, Kind, Module, PyPI, NPM string - Slug string // the provider, lowercase: a model subject's provider - SourceFile, DropFile, PluginOf, Ingest, Drop string - Imports []string + ID, Ident, Lower, ProviderID, Provider, Source, File, Format, Kind, Module, PyPI, NPM string + Package string // the provider's Go package: its id without hyphens + Golden string // the golden file's name, without .json + Slug string // the provider, lowercase: a model subject's provider + SourceFile, DropFile, PluginOf, Ingest, Drop string + Imports []string } // Run scaffolds the source, or changes nothing and says why. @@ -250,21 +250,15 @@ func Run(o Options, out io.Writer) error { return fmt.Errorf("--watches: no |, quotes, backslashes or backticks") } - sharedPage := false - if o.Page == "" { - o.Page = o.name - } else if !validID.MatchString(o.Page) { - return fmt.Errorf("--page %q: want the name of a page in providers/, without .md", o.Page) - } else if _, err := os.Stat(filepath.Join(o.Root, "providers", o.Page+".md")); err == nil { - sharedPage = true - } - // Taken? Check everything before writing anything. if _, ok := plugin.LookupSource(id); ok { return fmt.Errorf("source %s is already registered: pick another --source", id) } + dir := filepath.Join("providers", o.ProviderID) + _, statErr := os.Stat(filepath.Join(o.Root, dir, "provider.go")) + newProvider := statErr != nil - d := data{ID: id, Name: o.name, ProviderID: o.ProviderID, Provider: o.Provider, Source: o.url, Format: o.tmpl, Kind: f.kind, PyPI: o.ProviderID} + d := data{ID: id, ProviderID: o.ProviderID, Provider: o.Provider, Source: o.url, Format: o.tmpl, Kind: f.kind, PyPI: o.ProviderID, Golden: o.name} for _, p := range o.Packages { if name, ok := strings.CutPrefix(p, "pypi:"); ok { d.PyPI = name @@ -279,19 +273,19 @@ func Run(o Options, out io.Writer) error { } } d.Module = strings.ReplaceAll(strings.ToLower(d.PyPI), "-", "_") - d.Ident = ident(o.name) + d.Package = strings.ReplaceAll(o.ProviderID, "-", "") + d.Ident = ident(o.SourceID) d.Lower = string(unicode.ToLower(rune(d.Ident[0]))) + d.Ident[1:] - d.File = fileBase(o.name) + d.File = fileBase(o.SourceID) d.Slug = strings.Trim(regexp.MustCompile(`[^a-z0-9]+`).ReplaceAllString(strings.ToLower(o.Provider), "-"), "-") d.SourceFile = fill(f.source, d) d.DropFile = dropName(d.SourceFile) d.PluginOf = fill(f.pluginOf, d) d.Ingest = fill(f.ingest, d) d.Drop = fill(f.drop, d) - d.Imports = append(slices.Clone(f.imports), "testing", "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest") + d.Imports = append(slices.Clone(f.imports), "testing", module+"core/kit/kittest") slices.Sort(d.Imports) - pkgDir := "plugins/" + f.kind writes := map[string][]byte{} add := func(path string, b []byte) { writes[path] = b } @@ -299,61 +293,84 @@ func Run(o Options, out io.Writer) error { if err != nil { return fmt.Errorf("the %s template: %w", o.tmpl, err) } - add(filepath.Join(f.defDir, d.File+".go"), def) + add(filepath.Join(dir, d.File+".go"), def) test, err := gofmt(fill(testFile, d)) if err != nil { return fmt.Errorf("the test template: %w", err) } - add(filepath.Join(pkgDir, d.File+"_test.go"), test) + add(filepath.Join(dir, d.File+"_test.go"), test) for name, content := range f.fixtures { - add(filepath.Join(pkgDir, "testdata", fill(name, d)), []byte(fill(content, d))) + add(filepath.Join(dir, "testdata", fill(name, d)), []byte(fill(content, d))) } drop := f.dropFile if drop == "" { drop = f.fixtures[f.source] } - add(filepath.Join(pkgDir, "testdata", d.DropFile), []byte(fill(drop, d))) + add(filepath.Join(dir, "testdata", d.DropFile), []byte(fill(drop, d))) // What the placeholders give; rewritten with -update below, and again // once the source is real. - add(filepath.Join(pkgDir, "testdata", "golden", o.name+".json"), []byte("[]\n")) - - if !sharedPage { - page, err := providerPage(o) - if err != nil { - return err - } - add(filepath.Join("providers", o.Page+".md"), page) - } + add(filepath.Join(dir, "testdata", "golden", o.name+".json"), []byte("[]\n")) for path := range writes { if _, err := os.Stat(filepath.Join(o.Root, path)); err == nil { return fmt.Errorf("%s already exists: pick another --source, or remove what's left of an earlier run", path) } } - for _, dir := range []string{f.defDir, pkgDir} { + if !newProvider { if err := identsFree(filepath.Join(o.Root, dir), d.Ident, d.Lower, "read"+d.Ident, "Test"+d.Ident+"Golden"); err != nil { return err } } - // The edits to existing files. - mainFile, registered, err := register(o.Root, pkgDir, providerBlock(o, d, fill(f.register, d))) - if err != nil { - return err - } - edits := map[string][]byte{mainFile: registered} - if all, ok, err := importInAll(o.Root, f.kind); err != nil { - return err - } else if ok { - edits[filepath.Join("plugins", "all", "all.go")] = all - } - readmePath := filepath.Join(pkgDir, "testdata", "README.md") - readme, err := os.ReadFile(filepath.Join(o.Root, readmePath)) - if err != nil { - return err - } - if edits[readmePath], err = readmeRows(readme, []string{d.SourceFile, d.DropFile}, o.url); err != nil { - return fmt.Errorf("%s: %w", readmePath, err) + // The provider's registration, page and testdata README: new, or edited. + source := sourceLiteral(o, fill(f.plugin, d)) + readmePath := filepath.Join(dir, "testdata", "README.md") + edits := map[string][]byte{} + if newProvider { + reg, err := gofmt(providerFile(o, d, strings.TrimPrefix(source, "plugin.Source"), f.regImports)) + if err != nil { + return fmt.Errorf("the provider.go template: %w", err) + } + add(filepath.Join(dir, "provider.go"), reg) + page, err := providerPage(o) + if err != nil { + return err + } + add(filepath.Join(dir, "README.md"), page) + rows, err := readmeRows([]byte(fill(testdataREADME, d)), []string{d.SourceFile, d.DropFile}, o.url) + if err != nil { + return err + } + add(readmePath, rows) + all, err := importInAll(o.Root, o.ProviderID) + if err != nil { + return err + } + edits[filepath.Join("providers", "all", "all.go")] = all + } else { + regPath := filepath.Join(dir, "provider.go") + reg, err := addSource(filepath.Join(o.Root, regPath), source, f.regImports) + if err != nil { + return err + } + edits[regPath] = reg + pagePath := filepath.Join(dir, "README.md") + page, err := os.ReadFile(filepath.Join(o.Root, pagePath)) + if err != nil { + return err + } + section, err := pageSection(o) + if err != nil { + return err + } + edits[pagePath] = append(append(bytes.TrimRight(page, "\n"), "\n\n"...), section...) + readme, err := os.ReadFile(filepath.Join(o.Root, readmePath)) + if err != nil { + readme = []byte(fill(testdataREADME, d)) + } + if edits[readmePath], err = readmeRows(readme, []string{d.SourceFile, d.DropFile}, o.url); err != nil { + return fmt.Errorf("%s: %w", readmePath, err) + } } // Write. @@ -381,7 +398,7 @@ func Run(o Options, out io.Writer) error { } if o.Go { for _, args := range [][]string{ - {"test", "./" + pkgDir, "-run", "^Test" + d.Ident + "Golden$", "-update"}, + {"test", "./" + filepath.ToSlash(dir), "-run", "^Test" + d.Ident + "Golden$", "-update"}, } { cmd := exec.Command("go", args...) cmd.Dir = o.Root @@ -389,32 +406,38 @@ func Run(o Options, out io.Writer) error { return fmt.Errorf("the files are written, but `go %s` failed: %w\n%s", strings.Join(args, " "), err, b) } } - fmt.Fprintf(out, " %s (from the placeholders)\n", filepath.Join(pkgDir, "testdata", "golden", o.name+".json")) + fmt.Fprintf(out, " %s (from the placeholders)\n", filepath.Join(dir, "testdata", "golden", o.name+".json")) } fmt.Fprint(out, fill(nextSteps, struct { data - Extra, Page string - Shared bool - }{d, fill(f.next, d), o.Page, sharedPage})) + Extra string + }{d, fill(f.next, d)})) return nil } const nextSteps = ` -Next steps (every place to fill in says TODO(new-plugin): grep -rn 'TODO(new-plugin)' .): +Next steps (every place to fill in says TODO(new-plugin): grep -rn 'TODO(new-plugin)' providers/{{.ProviderID}}): 1. Save a real copy of the source over the placeholder: - curl -fsSL -o plugins/{{.Kind}}/testdata/{{.SourceFile}} '' - and a realistic input that must not become an event as plugins/{{.Kind}}/testdata/{{.DropFile}}. - Fill in their rows in plugins/{{.Kind}}/testdata/README.md (URL, date fetched, license, quote). - 2. Fill in the definition (the TODOs in the file next to the Register line for {{.Ident}}).{{if .Extra}} + curl -fsSL -o providers/{{.ProviderID}}/testdata/{{.SourceFile}} '' + and a realistic input that must not become an event as providers/{{.ProviderID}}/testdata/{{.DropFile}}. + Fill in their rows in providers/{{.ProviderID}}/testdata/README.md (URL, date fetched, license, quote). + 2. Fill in the definition, providers/{{.ProviderID}}/{{.File}}.go.{{if .Extra}} {{.Extra}}{{end}} 3. Write the golden file, then read it like code: - go test ./plugins/{{.Kind}} -run Test{{.Ident}} -update - 4. {{if .Shared}}Add {{.ID}} to providers/{{.Page}}.md (shared with the provider's other plugins){{else}}Fill in providers/{{.Page}}.md{{end}}, above all "Why this source", and the source's - metadata in its RegisterProvider block (what it watches, its URLs; a new provider's category and - homepage). go run ./cmd/list-plugins prints the list with it; there is no list to edit. + go test ./providers/{{.ProviderID}} -run Test{{.Ident}} -update + 4. Fill in {{.ID}}'s section of providers/{{.ProviderID}}/README.md, above all "Why this source", and + the source's metadata in providers/{{.ProviderID}}/provider.go (what it watches, its URLs; a new + provider's category and homepage). go run ./cmd/list-plugins prints the list with it; there is no + list to edit. 5. make check, then open the PR (git commit -s). ` +// testdataREADME is a new provider's testdata/README.md, before its rows. +const testdataREADME = `# {{.Provider}}: saved copies and goldens + +Real copies of what {{.Provider}} publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under ` + "`golden/`" + ` are every event the tests must store; ` + "`go test ./providers/{{.ProviderID}} -update`" + ` rewrites them after an intended change, and the PR says why the new output is right. +` + func fill(tmpl string, d any) string { var b strings.Builder if err := template.Must(template.New("").Parse(tmpl)).Execute(&b, d); err != nil { @@ -495,21 +518,9 @@ func declNames(decl ast.Decl) []string { return nil } -// providerBlock turns a template's "plugin.Register()" line into -// the provider's registration with its metadata: a provider already -// registered (a second source of Algolia) keeps its name, category and -// homepage; a new one gets what the flags say, or placeholders that say -// TODO(new-plugin). -func providerBlock(o Options, d data, line string) string { - expr := strings.TrimSuffix(strings.TrimPrefix(line, "plugin.Register("), ")") - category := "plugin.CategoryDevTools, // TODO(new-plugin): the provider's category, one of plugin.Categories()\n\t\t" - if o.Category != "" { - category = fmt.Sprintf("plugin.Category(%q),", o.Category) - } - homepage := `"https://example.com/TODO-` + o.ProviderID + `-homepage", // TODO(new-plugin): the provider's own site` + "\n\t\t" - if o.Homepage != "" { - homepage = fmt.Sprintf("%q,", o.Homepage) - } +// sourceLiteral is the source's entry in its provider's Sources, with its +// metadata and the plugin that runs it. +func sourceLiteral(o Options, pluginExpr string) string { var urls, pkgs []string for _, u := range o.URLs { urls = append(urls, fmt.Sprintf("%q", u)) @@ -519,59 +530,134 @@ func providerBlock(o Options, d data, line string) string { } packages := "" if len(pkgs) > 0 { - packages = fmt.Sprintf("\n\t\t\tPackages: []string{%s},", strings.Join(pkgs, ", ")) + packages = fmt.Sprintf("\n\tPackages: []string{%s},", strings.Join(pkgs, ", ")) + } + return fmt.Sprintf(`plugin.Source{ + ID: %q, Layer: %q, + Watches: %q, + URLs: []string{%s},%s + Plugin: %s, +}`, o.SourceID, o.Layer, o.Watches, strings.Join(urls, ", "), packages, pluginExpr) +} + +// providerFile is a new provider's provider.go: its registration, with what +// the flags say about it, or placeholders that say TODO(new-plugin). +func providerFile(o Options, d data, source string, imports []string) string { + category := "plugin.CategoryDevTools, // TODO(new-plugin): the provider's category, one of plugin.Categories()\n\t\t" + if o.Category != "" { + category = fmt.Sprintf("plugin.Category(%q),", o.Category) } - return fmt.Sprintf(`plugin.RegisterProvider(plugin.Provider{ + homepage := `"https://example.com/TODO-` + o.ProviderID + `-homepage", // TODO(new-plugin): the provider's own site` + "\n\t\t" + if o.Homepage != "" { + homepage = fmt.Sprintf("%q,", o.Homepage) + } + imps := append([]string{module + "core/plugin"}, imports...) + slices.Sort(imps) + var b strings.Builder + fmt.Fprintf(&b, "// Package %s is what patch-it reads for %s: every source, registered\n// below with its metadata, each read by its kind (kinds/). README.md\n// says why each source and what it reads.\npackage %s\n\nimport (\n", d.Package, o.Provider, d.Package) + for _, imp := range slices.Compact(imps) { + fmt.Fprintf(&b, "\t%q\n", imp) + } + fmt.Fprintf(&b, `) + +func init() { + plugin.RegisterProvider(plugin.Provider{ ID: %q, Name: %q, Category: %s Homepage: %s - Sources: []plugin.Source{{ - ID: %q, Layer: %q, Page: %q, - Watches: %q, - URLs: []string{%s},%s - Plugin: %s, - }}, - })`, o.ProviderID, o.Provider, category, homepage, o.SourceID, o.Layer, "providers/"+o.Page+".md", o.Watches, strings.Join(urls, ", "), packages, expr) + Sources: []plugin.Source{ + %s, + }, + }) +} +`, o.ProviderID, o.Provider, category, homepage, source) + return b.String() } -// register adds line at the end of the init func that registers pkgDir's -// plugins, next to the others. -func register(root, pkgDir, line string) (string, []byte, error) { - files, err := filepath.Glob(filepath.Join(root, pkgDir, "*.go")) +// addSource adds source to the Sources of the RegisterProvider call in an +// existing provider.go, and the imports its plugin needs. +func addSource(path, source string, imports []string) ([]byte, error) { + src, err := os.ReadFile(path) if err != nil { - return "", nil, err + return nil, err + } + fset := token.NewFileSet() + file, err := parser.ParseFile(fset, path, src, parser.SkipObjectResolution) + if err != nil { + return nil, err } - for _, path := range files { - if strings.HasSuffix(path, "_test.go") { - continue + // The Sources of the provider's one plugin.RegisterProvider call. + var sources ast.Expr + ast.Inspect(file, func(n ast.Node) bool { + call, ok := n.(*ast.CallExpr) + if !ok || sources != nil { + return sources == nil } - src, err := os.ReadFile(path) - if err != nil { - return "", nil, err + sel, ok := call.Fun.(*ast.SelectorExpr) + if !ok { + return true // append(...), make(...): not the registration } - fset := token.NewFileSet() - file, err := parser.ParseFile(fset, path, src, parser.SkipObjectResolution) - if err != nil { - return "", nil, err + if pkg, isIdent := sel.X.(*ast.Ident); !isIdent || pkg.Name != "plugin" || sel.Sel.Name != "RegisterProvider" || len(call.Args) != 1 { + return true } - for _, decl := range file.Decls { - fn, ok := decl.(*ast.FuncDecl) - if !ok || fn.Name.Name != "init" || fn.Recv != nil || !bytes.Contains(src[fn.Pos()-1:fn.End()-1], []byte("plugin.Register")) { - continue - } - at := fset.Position(fn.Body.Rbrace).Offset - var b bytes.Buffer - b.Write(src[:at]) - b.WriteString("\t" + line + "\n") - b.Write(src[at:]) - out, err := format.Source(b.Bytes()) - if err != nil { - return "", nil, fmt.Errorf("adding the Register line to %s: %w", path, err) + lit, ok := call.Args[0].(*ast.CompositeLit) + if !ok { + return true + } + for _, el := range lit.Elts { + if kv, ok := el.(*ast.KeyValueExpr); ok { + if k, ok := kv.Key.(*ast.Ident); ok && k.Name == "Sources" { + sources = kv.Value + } } - rel, _ := filepath.Rel(root, path) - return rel, out, nil + } + return false + }) + var at int + switch v := sources.(type) { + case *ast.CompositeLit: // []plugin.Source{...} + at = fset.Position(v.Rbrace).Offset + source = strings.TrimPrefix(source, "plugin.Source") + case *ast.CallExpr: // append(specs(), ...) + at = fset.Position(v.Rparen).Offset + default: + return nil, fmt.Errorf("%s: found no Sources in a plugin.RegisterProvider(plugin.Provider{...}) call", path) + } + var b bytes.Buffer + b.Write(bytes.TrimRight(src[:at], " \t\n")) + if !bytes.HasSuffix(bytes.TrimRight(src[:at], " \t\n"), []byte(",")) && !bytes.HasSuffix(bytes.TrimRight(src[:at], " \t\n"), []byte("{")) { + b.WriteString(",") + } + b.WriteString("\n" + source + ",\n") + b.Write(src[at:]) + out := b.Bytes() + for _, imp := range imports { + if out, err = addImport(out, imp); err != nil { + return nil, err } } - return "", nil, fmt.Errorf("found no init in %s that calls plugin.RegisterProvider", pkgDir) + if out, err = format.Source(out); err != nil { + return nil, fmt.Errorf("adding the source to %s: %w", path, err) + } + return out, nil +} + +// addImport adds path to src's imports when it isn't there. +func addImport(src []byte, path string) ([]byte, error) { + file, err := parser.ParseFile(token.NewFileSet(), "", src, parser.ImportsOnly) + if err != nil { + return nil, err + } + for _, imp := range file.Imports { + if p, _ := strconv.Unquote(imp.Path.Value); p == path { + return src, nil + } + } + q := strconv.Quote(path) + if bytes.Contains(src, []byte("import (\n")) { + return bytes.Replace(src, []byte("import (\n"), []byte("import (\n\t"+q+"\n"), 1), nil + } + end := int(file.Name.End()) - 1 + return slices.Concat(src[:end], []byte("\n\nimport "+q+"\n"), src[end:]), nil } // readmeRows adds a row per saved file to the first table of a testdata @@ -625,18 +711,38 @@ func readmeRows(readme []byte, files []string, source string) ([]byte, error) { return []byte(strings.Join(lines, "\n")), nil } -// providerPage is providers/_template.md for this provider. +// providerPage is a new provider's README.md: docs/provider-template.md +// for this provider and source. func providerPage(o Options) ([]byte, error) { - tmpl, err := os.ReadFile(filepath.Join(o.Root, "providers", "_template.md")) + tmpl, err := os.ReadFile(filepath.Join(o.Root, "docs", "provider-template.md")) + if err != nil { + return nil, err + } + return []byte(fillPage(o, string(tmpl))), nil +} + +// pageSection is the template's section for one source, added to the +// README.md of a provider that has one. +func pageSection(o Options) ([]byte, error) { + tmpl, err := os.ReadFile(filepath.Join(o.Root, "docs", "provider-template.md")) if err != nil { return nil, err } s := string(tmpl) + i := strings.Index(s, "\n## ") + if i < 0 { + return nil, fmt.Errorf("docs/provider-template.md has no source section (## ...)") + } + return []byte(fillPage(o, s[i+1:])), nil +} + +func fillPage(o Options, s string) string { + s = regexp.MustCompile(`(?s)\n\n`).ReplaceAllString(s, "TODO(new-plugin): fill every part of "+o.ProviderID+"/"+o.SourceID+"'s section, then delete this line. Scaffolded by `go run ./cmd/new-plugin`.\n\n") s = strings.ReplaceAll(s, "", o.Provider) + s = strings.ReplaceAll(s, "", "TODO(new-plugin): what it is") s = strings.ReplaceAll(s, "`/`", "`"+o.ProviderID+"/"+o.SourceID+"`") + s = strings.ReplaceAll(s, "`` (`kinds/`)", "`"+o.Kind+"` (`kinds/"+o.Kind+"`)") s = strings.ReplaceAll(s, "``", "<"+o.url+">") s = strings.ReplaceAll(s, "``", o.Today.Format("2006-01-02")+" (TODO(new-plugin): the date you checked it)") - s = strings.Replace(s, "Copy this file to `providers/-.md` and fill every section. Delete these instructions.", - "TODO(new-plugin): fill every section, then delete this line. Scaffolded by `go run ./cmd/new-plugin`.", 1) - return []byte(s), nil + return s } diff --git a/cmd/new-plugin/main_test.go b/cmd/new-plugin/main_test.go index 72f3ad7..87ac254 100644 --- a/cmd/new-plugin/main_test.go +++ b/cmd/new-plugin/main_test.go @@ -26,8 +26,9 @@ func optionsFor(root, tmpl string) Options { } // A source of every kind and reader, scaffolded into a copy of the repo: -// the copy builds, vets and passes its tests, and list-plugins lists them -// all. Then the same command again changes nothing. +// the first makes the provider's folder, every other is one more source in +// it. The copy builds, vets and passes its tests, and list-plugins lists +// them all. Then the same command again changes nothing. func TestScaffoldEveryKind(t *testing.T) { if testing.Short() { t.Skip("runs the go command over a copy of the repo") @@ -47,7 +48,7 @@ func TestScaffoldEveryKind(t *testing.T) { t.Errorf("%s: no next steps in\n%s", f, out.String()) } } - for _, args := range [][]string{{"build", "./..."}, {"vet", "./..."}, {"test", "-count=1", "./plugins/...", "./internal/..."}} { + for _, args := range [][]string{{"build", "./..."}, {"vet", "./..."}, {"test", "-count=1", "./providers/...", "./internal/..."}} { cmd := exec.Command(goCmd, args...) cmd.Dir = root if b, err := cmd.CombinedOutput(); err != nil { @@ -77,23 +78,66 @@ func TestScaffoldEveryKind(t *testing.T) { } } -// A second source of a provider shares its page and its provider: no new -// page, and the registration names the existing ones. -func TestScaffoldSharesTheProviderPage(t *testing.T) { +// A source of a provider that has a folder goes in it: one more source in +// its provider.go's one registration, a section in its README.md, rows in +// its testdata README, and no new import in providers/all. +func TestScaffoldAddsASourceToItsProvider(t *testing.T) { root := copyRepo(t) - o := Options{Root: root, ProviderID: "algolia", SourceID: "analytics", Kind: "openapi", Page: "algolia", Today: today} + allBefore, _ := os.ReadFile(filepath.Join(root, "providers", "all", "all.go")) + o := Options{Root: root, ProviderID: "algolia", SourceID: "analytics", Kind: "openapi", Today: today} if err := Run(o, io.Discard); err != nil { t.Fatal(err) } - if _, err := os.Stat(filepath.Join(root, "providers", "algolia-analytics.md")); err == nil { - t.Error("wrote providers/algolia-analytics.md; want the shared providers/algolia.md") - } - reg, _ := os.ReadFile(filepath.Join(root, "plugins", "openapi", "openapi.go")) - for _, want := range []string{`ID: "algolia", Name: "Algolia"`, `ID: "analytics"`, `Page: "providers/algolia.md"`, `plugin.Category("search")`} { + reg, _ := os.ReadFile(filepath.Join(root, "providers", "algolia", "provider.go")) + for _, want := range []string{`ID: "algolia", Name: "Algolia"`, `ID: "analytics"`, `openapi.Plugin{Adapter: Analytics{}}`} { if !bytes.Contains(reg, []byte(want)) { - t.Errorf("the registration has no %s", want) + t.Errorf("provider.go has no %s", want) } } + if n := bytes.Count(reg, []byte("plugin.RegisterProvider(")); n != 1 { + t.Errorf("provider.go registers the provider %d times, want once", n) + } + page, _ := os.ReadFile(filepath.Join(root, "providers", "algolia", "README.md")) + if !bytes.Contains(page, []byte("`algolia/analytics`")) || !bytes.Contains(page, []byte("`algolia/search-api`")) { + t.Error("README.md doesn't keep its sections and add one for algolia/analytics") + } + rows, _ := os.ReadFile(filepath.Join(root, "providers", "algolia", "testdata", "README.md")) + if !bytes.Contains(rows, []byte("`analytics-new.json`")) { + t.Error("testdata/README.md has no row for the new source's saved copy") + } + if _, err := os.Stat(filepath.Join(root, "providers", "algolia", "analytics.go")); err != nil { + t.Error(err) + } + if allAfter, _ := os.ReadFile(filepath.Join(root, "providers", "all", "all.go")); !bytes.Equal(allBefore, allAfter) { + t.Error("providers/all changed for a provider it imports already") + } +} + +// A provider.go with other calls above its registration (a package-level +// var, a helper) still gets the source inside its RegisterProvider call. +func TestScaffoldFindsTheRegistrationAmongOtherCalls(t *testing.T) { + root := copyRepo(t) + path := filepath.Join(root, "providers", "textual", "provider.go") + src, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + src = bytes.Replace(src, []byte("\nfunc init() {"), []byte("\nvar _ = len(\"x\")\n\nfunc helper() []int { return append([]int{}, 1) }\n\nfunc init() {"), 1) + if !bytes.Contains(src, []byte(`var _ = len("x")`)) { + t.Fatal("setup didn't apply: provider.go has no \"func init() {\" to put the calls above") + } + if err := os.WriteFile(path, src, 0o644); err != nil { + t.Fatal(err) + } + o := Options{Root: root, ProviderID: "textual", SourceID: "docs", Kind: "notices", Reader: "feed", Today: today} + if err := Run(o, io.Discard); err != nil { + t.Fatal(err) + } + reg, _ := os.ReadFile(path) + at := bytes.Index(reg, []byte("plugin.RegisterProvider(")) + if at < 0 || !bytes.Contains(reg[at:], []byte(`ID: "docs"`)) || bytes.Count(reg, []byte(`ID: "docs"`)) != 1 { + t.Errorf("the source isn't inside the registration:\n%s", reg) + } } func TestRefusesBadInput(t *testing.T) { diff --git a/cmd/new-plugin/resolve.go b/cmd/new-plugin/resolve.go index 99612db..6874ea7 100644 --- a/cmd/new-plugin/resolve.go +++ b/cmd/new-plugin/resolve.go @@ -132,20 +132,13 @@ func cmp(a, b string) string { return b } -// importInAll adds plugins/ to plugins/all's imports when it isn't -// there (a new kind), so a program importing all runs it. ok is false when -// it's already there. -func importInAll(root, kind string) ([]byte, bool, error) { - path := filepath.Join(root, "plugins", "all", "all.go") - src, err := os.ReadFile(path) +// importInAll adds providers/ to providers/all's imports, so a +// program importing all runs its sources. +func importInAll(root, provider string) ([]byte, error) { + src, err := os.ReadFile(filepath.Join(root, "providers", "all", "all.go")) if err != nil { - return nil, false, err + return nil, err } - imp := `"github.com/patch-it-dev/patch-it-plugins/plugins/` + kind + `"` - if bytes.Contains(src, []byte(imp)) { - return nil, false, nil - } - out := bytes.Replace(src, []byte("import (\n"), []byte("import (\n\t_ "+imp+"\n"), 1) - b, err := format.Source(out) - return b, err == nil, err + out := bytes.Replace(src, []byte("import (\n"), []byte("import (\n\t_ \""+module+"providers/"+provider+"\"\n"), 1) + return format.Source(out) } diff --git a/core/kit/kittest/kittest.go b/core/kit/kittest/kittest.go index ceccfc9..fbf3984 100644 --- a/core/kit/kittest/kittest.go +++ b/core/kit/kittest/kittest.go @@ -11,7 +11,7 @@ // got := kittest.Versions(t, env, p, plugin.Version{ID: "1.26.15", Ref: "1.26.15"}, plugin.Version{ID: "2.0.0", Ref: "2.0.0"}) // kittest.Golden(t, "testdata/golden/urllib3-2.0.0.json", got) // -// `go test ./plugins/ -update` rewrites a plugin's golden files; +// `go test ./providers/ -update` rewrites a provider's golden files; // review the diff like code. package kittest diff --git a/core/kit/notices.go b/core/kit/notices.go index a2c3a2b..b7f5aee 100644 --- a/core/kit/notices.go +++ b/core/kit/notices.go @@ -1,7 +1,7 @@ package kit // Notices is what a reader of a live page of dated notices (a deprecations -// table, an end-of-life table, a feed: plugins/notices) found on one read +// table, an end-of-life table, a feed: kinds/notices) found on one read // of it. The kind compares what the live page and its snapshot give with // reflect.DeepEqual (Cite), so a Notices holds plain values, never a func. type Notices interface { diff --git a/core/plugin/plugin_test.go b/core/plugin/plugin_test.go index d7681bd..e389e94 100644 --- a/core/plugin/plugin_test.go +++ b/core/plugin/plugin_test.go @@ -63,7 +63,7 @@ func TestNamesAreSorted(t *testing.T) { func register(t *testing.T, provider string) { t.Helper() RegisterProvider(Provider{ID: provider, Name: provider, Category: CategoryDevTools, Homepage: "https://example.test", - Sources: []Source{{ID: "api", Layer: LayerAPI, Watches: "w", URLs: []string{"https://example.test/spec"}, Page: "providers/test.md", Plugin: testPlugin{name: provider + "/api"}}}}) + Sources: []Source{{ID: "api", Layer: LayerAPI, Watches: "w", URLs: []string{"https://example.test/spec"}, Plugin: testPlugin{name: provider + "/api"}}}}) t.Cleanup(func() { mu.Lock() defer mu.Unlock() diff --git a/core/plugin/provider.go b/core/plugin/provider.go index 2a1fa30..adc7dbe 100644 --- a/core/plugin/provider.go +++ b/core/plugin/provider.go @@ -14,14 +14,15 @@ import ( // A provider is whose API, SDK or package it is (Stripe, OpenAI, Kubernetes), // in one category. It has one or more sources: each one place patch-it reads // (a spec repo, a deprecations page, a changelog), read by one kind (the -// plugins/ package whose plugin runs it), at one layer of a customer's -// stack. A source's id is "/": "stripe/api", +// kinds/ package whose plugin runs it: how to read), at one layer of a +// customer's stack. A source's id is "/": "stripe/api", // "algolia/search-api", "openai/models". // -// Every source is registered with its metadata, in code, by the kind's -// package (RegisterProvider). That registration is the only list of what -// patch-it watches: `go run ./cmd/list-plugins` prints it, the Release -// workflow attaches it to each release as plugins.json, and patch-it's hosted +// Every provider is registered once, with its metadata and every source, in +// code, by its own package (providers//provider.go, what to read: +// RegisterProvider). That registration is the only list of what patch-it +// watches: `go run ./cmd/list-plugins` prints it, the Release workflow +// attaches it to each release as plugins.json, and patch-it's hosted // ingestion service serves it. There is no list to keep by hand. // Category is what a provider is, for grouping: one per provider. @@ -77,10 +78,9 @@ func Layers() []Layer { return []Layer{LayerAPI, LayerSDK, LayerPackage, LayerRuntime, LayerCI, LayerAIModels, LayerInfra} } -// Provider is one provider and the sources a kind's package registers for it. -// A provider with sources in several kinds (Anthropic: a deprecations page and -// an SDK migration guide) is registered by each, with the same ID, Name, -// Category and Homepage; the registry merges them. +// Provider is one provider and every source of it, whatever their kinds +// (Anthropic: a deprecations page, an SDK migration guide, two packages' +// public API), registered once by providers//. type Provider struct { ID string // lowercase slug: "algolia" Name string // as the provider writes it: "Algolia" @@ -94,7 +94,7 @@ type Source struct { // ID is the source's part of its id, unique within the provider: // "search-api" in "algolia/search-api". ID string - // Kind is the kind that reads it: the plugins/ package Plugin is + // Kind is the kind that reads it: the kinds/ package Plugin is // defined in. RegisterProvider fills it in; a value set by hand must // match. Kind string @@ -105,8 +105,10 @@ type Source struct { // URLs are the provider's own pages or files it reads, absolute; the // first is the one a person should look at. URLs []string - // Page is the source's page in this repo: "providers/algolia.md" (why - // this source, what it reads and ignores, its known gaps). + // Page is the provider's page in this repo, where every source of it is + // described (why this source, what it reads and ignores, its known + // gaps): "providers/algolia/README.md". RegisterProvider fills it in; a + // value set by hand must match. Page string // Packages are the published packages whose changes this source // covers, as ":" ("pypi:stripe", "npm:@vercel/sdk"): @@ -136,30 +138,28 @@ var ( ) // RegisterProvider registers p's sources, each under its id, with its Plugin -// (Lookup). Incomplete metadata is a programming error, as a duplicate is. +// (Lookup). A provider is registered once, with every source. Incomplete +// metadata is a programming error, as a second registration is. func RegisterProvider(p Provider) { if err := p.check(); err != nil { panic("plugin: " + err.Error()) } for i := range p.Sources { p.Sources[i].Kind = KindOf(p.Sources[i].Plugin) + p.Sources[i].Page = PageOf(p.ID) } mu.Lock() defer mu.Unlock() - if have, ok := providers[p.ID]; ok { - if have.Name != p.Name || have.Category != p.Category || have.Homepage != p.Homepage { - panic(fmt.Sprintf("plugin: provider %q registered twice with different metadata", p.ID)) - } + if _, ok := providers[p.ID]; ok { + panic(fmt.Sprintf("plugin: provider %q is already registered: a provider registers every source at once, in providers/%s/provider.go", p.ID, p.ID)) } for _, s := range p.Sources { if _, dup := sources[p.ID+"/"+s.ID]; dup { panic(fmt.Sprintf("plugin: source %q is already registered", p.ID+"/"+s.ID)) } } - have := providers[p.ID] - merged := Provider{ID: p.ID, Name: p.Name, Category: p.Category, Homepage: p.Homepage, Sources: append(have.Sources, p.Sources...)} - providers[p.ID] = merged - bare := merged + providers[p.ID] = p + bare := p bare.Sources = nil for _, s := range p.Sources { id := p.ID + "/" + s.ID @@ -168,6 +168,9 @@ func RegisterProvider(p Provider) { } } +// PageOf is a provider's page in this repo: "providers//README.md". +func PageOf(provider string) string { return "providers/" + provider + "/README.md" } + // check is the metadata every provider and source must have. func (p Provider) check() error { switch { @@ -202,10 +205,10 @@ func (p Provider) check() error { return fmt.Errorf("source %q: Watches is empty", id) case len(s.URLs) == 0: return fmt.Errorf("source %q has no URLs", id) - case !strings.HasPrefix(s.Page, "providers/") || !strings.HasSuffix(s.Page, ".md"): - return fmt.Errorf("source %q: Page %q isn't providers/.md", id, s.Page) + case s.Page != "" && s.Page != PageOf(p.ID): + return fmt.Errorf("source %q: Page %q, but a provider's page is %s", id, s.Page, PageOf(p.ID)) case s.Kind != "" && s.Kind != KindOf(s.Plugin): - return fmt.Errorf("source %q: Kind %q, but its plugin is in plugins/%s", id, s.Kind, KindOf(s.Plugin)) + return fmt.Errorf("source %q: Kind %q, but its plugin is in kinds/%s", id, s.Kind, KindOf(s.Plugin)) } for _, u := range s.URLs { if !absolute(u) { @@ -243,7 +246,7 @@ func absolute(u string) bool { } // KindOf is the kind a plugin is: the name of the package its type is -// defined in (plugins/openapi -> "openapi"). +// defined in (kinds/openapi -> "openapi"). func KindOf(p Plugin) string { t := reflect.TypeOf(p) for t.Kind() == reflect.Pointer { diff --git a/core/plugin/provider_test.go b/core/plugin/provider_test.go index b6c5059..856e7a1 100644 --- a/core/plugin/provider_test.go +++ b/core/plugin/provider_test.go @@ -28,18 +28,19 @@ func (neither) Extract(context.Context, Env, Snapshot, Snapshot) (Result, error) // src is a source of the provider whose id is provider, named by its id. func src(id, provider string) Source { - return Source{ID: id, Layer: LayerAPI, Watches: "w", URLs: []string{"https://example.com/spec"}, Page: "providers/acme.md", Plugin: fake{provider + "/" + id}} + return Source{ID: id, Layer: LayerAPI, Watches: "w", URLs: []string{"https://example.com/spec"}, Plugin: fake{provider + "/" + id}} } -func acme(sources ...Source) Provider { - return Provider{ID: "acme-test", Name: "Acme", Category: CategoryPayments, Homepage: "https://example.com", Sources: sources} +func acme(sources ...Source) Provider { return acmeAs("acme-test", sources...) } + +func acmeAs(id string, sources ...Source) Provider { + return Provider{ID: id, Name: "Acme", Category: CategoryPayments, Homepage: "https://example.com", Sources: sources} } func TestRegisterProviderRegistersEachSourceByItsID(t *testing.T) { - RegisterProvider(acme(src("api", "acme-test"))) - RegisterProvider(acme(src("sdk", "acme-test"))) // a second kind adds a source + RegisterProvider(acme(src("api", "acme-test"), src("sdk", "acme-test"))) s, ok := LookupSource("acme-test/api") - if !ok || s.FullID() != "acme-test/api" || s.Source.Kind != "plugin" { + if !ok || s.FullID() != "acme-test/api" || s.Source.Kind != "plugin" || s.Source.Page != "providers/acme-test/README.md" { t.Errorf("LookupSource = %+v, %v", s, ok) } if p, ok := Lookup("acme-test/api"); !ok || p.Name() != "acme-test/api" { @@ -96,6 +97,11 @@ func TestRegisterProviderRefusesIncompleteMetadata(t *testing.T) { s.Plugin = neither{"x9/api"} return s }()}}, + "wrong page": {ID: "x10", Name: "X", Category: CategoryAI, Homepage: "https://x.example", Sources: []Source{func() Source { + s := src("api", "x10") + s.Page = "providers/x10.md" // not providers/x10/README.md + return s + }()}}, "wrong kind": {ID: "x6", Name: "X", Category: CategoryAI, Homepage: "https://x.example", Sources: []Source{func() Source { s := src("api", "x6") s.Kind = "openapi" @@ -108,25 +114,25 @@ func TestRegisterProviderRefusesIncompleteMetadata(t *testing.T) { } } -func TestRegisterProviderRefusesConflictingProvider(t *testing.T) { - RegisterProvider(acme(src("one", "acme-test"))) +// A provider registers every source at once: a second registration, even of +// other sources, is a programming error. +func TestRegisterProviderRefusesASecondRegistration(t *testing.T) { + RegisterProvider(acmeAs("acme-twice", src("one", "acme-twice"))) defer func() { if recover() == nil { - t.Error("a provider registered again with another name didn't panic") + t.Error("a provider registered twice didn't panic") } }() - p := acme(src("two", "acme-test")) - p.Name = "Acme Corp" - RegisterProvider(p) + RegisterProvider(acmeAs("acme-twice", src("two", "acme-twice"))) } // A package names its sources. func TestForPackage(t *testing.T) { - s := src("pkg", "acme-test") + s := src("pkg", "acme-pkg") s.Packages = []string{"pypi:acme-test", "npm:@acme/test"} - RegisterProvider(acme(s)) + RegisterProvider(acmeAs("acme-pkg", s)) got := ForPackage("npm:@acme/test") - if len(got) != 1 || got[0].FullID() != "acme-test/pkg" { + if len(got) != 1 || got[0].FullID() != "acme-pkg/pkg" { t.Errorf("ForPackage = %+v", got) } if got := ForPackage("pypi:nobody"); len(got) != 0 { diff --git a/docs/how-it-works.md b/docs/how-it-works.md index feb9144..b88ce50 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -1,6 +1,8 @@ # How it works -A **provider** (Stripe, OpenAI, GitHub…) has one category and one or more **sources**: each one place it announces changes (an OpenAPI spec repo, a changelog, a deprecations page, a feed), read by one **kind** of plugin (`plugins//`), at one **layer** of a customer's stack. A source's id is `provider/source` (`stripe/api`, `openai/models`): what its events carry in `api`. Every provider and source is registered in code with its metadata (`plugin.RegisterProvider`): that registration is the only list. +A **provider** (Stripe, OpenAI, GitHub…) has one category and one or more **sources**: each one place it announces changes (an OpenAPI spec repo, a changelog, a deprecations page, a feed), read by one **kind** of plugin, at one **layer** of a customer's stack. A source's id is `provider/source` (`stripe/api`, `openai/models`): what its events carry in `api`. + +The code is split the same way. **How to read** a kind of source is written once, in `kinds//`. **What to read** for a provider is in its own folder, `providers//`: one `provider.go` registers the provider and every source of it, whatever their kinds, with its metadata (`plugin.RegisterProvider`), built from the kinds' exported types; code only that provider needs (an OpenAPI adapter, a feed's reader) sits beside it, with its saved pages, golden files, tests and one page, `README.md`. That registration is the only list. ## What a plugin does @@ -9,7 +11,7 @@ A **provider** (Stripe, OpenAI, GitHub…) has one category and one or more **so 2. **Compare.** It compares two versions of the source: two OpenAPI specs, two versions of a deprecations page, a release's changelog section against the release before. `Extract` does it for any pair: two versions, or a living page's last read and today's. 3. **Emit events.** Each change becomes one event in [patch-it's change-event format](https://github.com/patch-it-dev/patch-it/tree/main/docs/contract): what changed, how bad it is (breaking, deprecation, behavior change, non-breaking), the date it takes effect, and the source URL with a quote. **No source, no event.** When unsure, a plugin emits nothing: a wrong event would become a wrong pull request. -Most providers are an entry for an existing kind, not new code. patch-it's hosted ingestion service runs every source on a schedule and serves the events to the patch-it GitHub Action and CLI. +Most sources are an entry in their provider's `provider.go` on an existing kind, not new code. patch-it's hosted ingestion service runs every source on a schedule and serves the events to the patch-it GitHub Action and CLI. ## What's covered @@ -21,15 +23,15 @@ There's no list in this repo: `make plugins` prints every provider and source fr |---|---| | [`core/plugin/`](../core/plugin/) | The `Plugin` interface (`Extract`) in its two shapes, `Versioned` (`ListVersions`, `ReadAt`) and `Living` (`Read`); `ErrNothingToRead`; the registry of providers and sources (`RegisterProvider`, `Lookup`, `LookupSource`, `Providers`), `Env`, `Result` | | [`core/versions/`](../core/versions/) | Every version of a source: GitHub releases, tags and commits, PyPI, npm | -| [`plugins/`](../plugins/) | One package per kind, with its providers (openapi, changelog, notices, migrationguide, catalog, apisurface); `plugins/all` imports every one | -| [`cmd/new-plugin/`](../cmd/new-plugin/), [`cmd/list-plugins/`](../cmd/list-plugins/) | The starter for a new provider; the list of providers and sources, printed from the registry | +| [`kinds/`](../kinds/) | How to read: one package per kind (openapi, changelog, notices, migrationguide, catalog, apisurface), each with its readers and a test helper package; no kind imports a provider | +| [`providers/`](../providers/) | What to read: one folder per provider, `providers//` with `provider.go` (its registration), `README.md` (its page: why each source, what it reads), any code only it needs, `testdata/` and its tests; [`providers/all`](../providers/all/) imports every one, and its tests check the folders and the import graph | +| [`cmd/new-plugin/`](../cmd/new-plugin/), [`cmd/list-plugins/`](../cmd/list-plugins/) | The starter for a new provider or source (into `providers//`); the list of providers and sources, printed from the registry | | [`core/kit/`](../core/kit/), [`core/kit/kittest/`](../core/kit/kittest/), [`core/github/`](../core/github/), [`core/extract/`](../core/extract/) | What plugins share (Wayback citing, the newest release or commit on GitHub, RSS/Atom and HTML text helpers) and the test kit (in-memory store, saved pages, golden files) | | [`core/event/`](../core/event/) | The change event of [patch-it's contract](https://github.com/patch-it-dev/patch-it/tree/main/docs/contract): its types, fingerprint and validation | -| [`core/diff/`](../core/diff/), [`core/normalize/`](../core/normalize/), [`core/hint/`](../core/hint/), [`plugins/openapi/adapter/`](../plugins/openapi/adapter/) | The OpenAPI diff engine: compare two specs, turn the changes into events, attach changelog hints; one adapter per spec provider | -| [`plugins/notices/retire/`](../plugins/notices/retire/), [`plugins/notices/feed/`](../plugins/notices/feed/), [`plugins/notices/eol/`](../plugins/notices/eol/), [`plugins/migrationguide/sdkguide/`](../plugins/migrationguide/sdkguide/), [`plugins/migrationguide/members/`](../plugins/migrationguide/members/), [`core/fetch/`](../core/fetch/) | The notices readers (deprecations pages, feeds, end-of-life tables) and the migration-guide readers (removed parameters, removed members); the HTTP fetch and cache | +| [`core/diff/`](../core/diff/), [`core/normalize/`](../core/normalize/), [`core/hint/`](../core/hint/), [`kinds/openapi/adapter/`](../kinds/openapi/adapter/) | The OpenAPI diff engine: compare two specs, turn the changes into events, attach changelog hints; the interface each provider's spec adapter implements, and what adapters share | +| [`kinds/notices/retire/`](../kinds/notices/retire/), [`kinds/notices/feed/`](../kinds/notices/feed/), [`kinds/notices/eol/`](../kinds/notices/eol/), [`kinds/migrationguide/sdkguide/`](../kinds/migrationguide/sdkguide/), [`kinds/migrationguide/members/`](../kinds/migrationguide/members/), [`core/fetch/`](../core/fetch/) | The notices readers (deprecations pages, feeds, end-of-life tables) and the migration-guide readers (removed parameters, removed members); the HTTP fetch and cache | | [`contract/fixtures/`](../contract/) | A copy of patch-it's change-event fixtures | -| [`providers/`](../providers/) | One page per provider: why that source, what the plugin reads | -| [`docs/`](./) | [How to write a plugin](writing-a-plugin.md), the [README template](README-template.md) patch-it's public repos share | +| [`docs/`](./) | [How to write a plugin](writing-a-plugin.md), the [provider page template](provider-template.md), the [README template](README-template.md) patch-it's public repos share | ## Run the checks @@ -37,9 +39,9 @@ There's no list in this repo: `make plugins` prints every provider and source fr make check # what CI runs: tidy, build, gofmt, vet, import and net/http guards, go test -race, no TODO(new-plugin) left, leak guard ``` -The tests are offline: every plugin's test reads a saved copy of its source from `testdata/` and compares the events with a golden file. After an intended change to a plugin's output, `go test ./plugins/ -update` rewrites its golden files; review that diff like code. +The tests are offline: every source's test reads a saved copy of it from its provider's `testdata/` and compares the events with a golden file. After an intended change to a source's output, `go test ./providers/ -update` rewrites its golden files; review that diff like code. -`GITHUB_TOKEN` (optional, no scopes) only raises GitHub's rate limit when the `openapi` adapters look up release tags; the tests never use it. Nothing else is read from the environment. +`GITHUB_TOKEN` (optional, no scopes) only raises GitHub's rate limit when the OpenAPI adapters look up release tags; the tests never use it. Nothing else is read from the environment. ## Releases diff --git a/docs/plugins.schema.json b/docs/plugins.schema.json index 7b1ab8d..16eba69 100644 --- a/docs/plugins.schema.json +++ b/docs/plugins.schema.json @@ -41,7 +41,7 @@ "layer": { "type": "string", "enum": ["api", "sdk", "package", "runtime", "ci", "ai-models", "infra"] }, "watches": { "type": "string", "minLength": 1 }, "urls": { "type": "array", "items": { "type": "string", "pattern": "^https://" } }, - "page": { "type": "string", "pattern": "^https://github\\.com/patch-it-dev/patch-it-plugins/blob/[^/]+/providers/[a-z0-9][a-z0-9.-]*\\.md$" } + "page": { "type": "string", "pattern": "^https://github\\.com/patch-it-dev/patch-it-plugins/blob/[^/]+/providers/[a-z0-9][a-z0-9-]*/README\\.md$" } } } } diff --git a/docs/provider-template.md b/docs/provider-template.md new file mode 100644 index 0000000..4f2cc97 --- /dev/null +++ b/docs/provider-template.md @@ -0,0 +1,36 @@ +# + +Every source patch-it reads for , one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + + + +## (`/`) + +### What it watches + +One or two sentences: which API, SDK, package or runtime, and which kinds of change (removed fields, model shutdowns, major releases…). + +Kind: `` (`kinds/`), and the reader or adapter it uses. + +### Why this source + +The link (or links) the source reads, and **why this one**: + +- **Source:** ``, checked on ``. +- **Why this one:** why it's the most reliable place this provider announces breaking changes (an official spec beats a changelog; a changelog beats a blog post; a blog post beats a forum). +- **Alternatives considered:** other places the provider publishes changes, and why the source doesn't read them (incomplete, not machine-readable, published late, marketing only…). +- **Quote:** one short line copied from the source that shows the kind of change the source turns into an event. + +### How the provider announces changes + +How often it changes, how it versions its API, and how much notice it gives before something breaks. + +### What the plugin reads and ignores + +What becomes an event, and what is deliberately dropped (and why). Precision over recall: when unsure, drop. + +### Known gaps + +Changes this provider makes that the source can't see yet. diff --git a/docs/which-kind.md b/docs/which-kind.md index 1421a49..403c68e 100644 --- a/docs/which-kind.md +++ b/docs/which-kind.md @@ -15,11 +15,11 @@ Every kind is one of two shapes ([writing-a-plugin.md, step 4](writing-a-plugin. | Is there a **structured catalog** in the provider's repo: one JSON file per command, or one file of upcoming removals? | `catalog` | Each release (or commit) of the catalog, compared with the one before: names that disappeared entirely, or removals newly announced | The command definitions a server is built from, at each release tag | | Is it a **published package** with no changelog worth reading? | `apisurface` | Each release's files from the registry (PyPI wheels, npm TypeScript declarations), compared: removed or renamed classes, functions, methods, and parameters removed or newly required | An SDK generated from a spec, released often, whose changelog says "chore: update types" | -Still no "yes"? Open a [discussion](https://github.com/patch-it-dev/patch-it-plugins/discussions) with the source's link: a new kind is a new package under `plugins/`, and the questions above get one more row. +Still no "yes"? Open a [discussion](https://github.com/patch-it-dev/patch-it-plugins/discussions) with the source's link: a new kind is a new package under `kinds/` (how to read, written once; each provider's sources in `providers//` say what to read), and the questions above get one more row. ## Two sources, not one kind -- **An API and its SDKs are separate sources.** The API's changes come from its spec or its notices; an SDK's from its migration guide, its changelog, or its published files. Register each on its kind, under the same provider. +- **An API and its SDKs are separate sources.** The API's changes come from its spec or its notices; an SDK's from its migration guide, its changelog, or its published files. Register each, on its kind, in the provider's one `providers//provider.go`. - **There is no kind per vendor or per tool.** Kubernetes API removals are a `migrationguide` or `notices` source; a Kubernetes client is a package source (`changelog` or `apisurface`); a Terraform provider is a `changelog` source. - **Prefer the most machine-readable source** (a spec beats a changelog, a changelog beats a feed, a feed beats a blog post): [writing-a-plugin.md, step 2](writing-a-plugin.md#2-pick-the-source). diff --git a/docs/writing-a-plugin.md b/docs/writing-a-plugin.md index 4b47102..475cdec 100644 --- a/docs/writing-a-plugin.md +++ b/docs/writing-a-plugin.md @@ -1,8 +1,8 @@ # Writing a plugin -A **provider** (Stripe, OpenAI, Kubernetes…) has a **category** and one or more **sources**. A source is one place the provider announces changes; it is read by one **kind** of plugin (the `plugins/` package: `openapi`, `changelog`, `notices`, `migrationguide`, `catalog`, `apisurface`), covers one **layer** (`api`, `sdk`, `package`, `runtime`, `ci`, `ai-models`, `infra`), and has **versions**. Its id is `provider/source` (`stripe/api`, `algolia/search-api`). This guide walks through adding a source, from picking it to the PR. The rules are in [CONTRIBUTING.md](../CONTRIBUTING.md); this is the how-to. How the pieces fit: [how-it-works.md](how-it-works.md). +A **provider** (Stripe, OpenAI, Kubernetes…) has a **category** and one or more **sources**. A source is one place the provider announces changes; it is read by one **kind** of plugin (the `kinds/` package: `openapi`, `changelog`, `notices`, `migrationguide`, `catalog`, `apisurface`), covers one **layer** (`api`, `sdk`, `package`, `runtime`, `ci`, `ai-models`, `infra`), and has **versions**. Its id is `provider/source` (`stripe/api`, `algolia/search-api`). A kind says **how to read** and is written once; a provider's folder, `providers//`, says **what to read**: its `provider.go` registers the provider and every source of it, and holds nothing about any other provider. This guide walks through adding a source, from picking it to the PR. The rules are in [CONTRIBUTING.md](../CONTRIBUTING.md); this is the how-to. How the pieces fit: [how-it-works.md](how-it-works.md). -**Most new sources don't need new code.** They are a new entry for an existing kind: a new `changelog.File`, a new `retire.Page`, a new `feed.Feed` reader, a new OpenAPI adapter, a new `apisurface.Package`. Write a new kind only when none of them reads your source. There is no "Kubernetes kind" or "Terraform kind": Kubernetes API removals are a migration-guide or notices source, a client SDK is a package source, a Terraform provider is a changelog source. +**Most new sources don't need new code in a kind.** They are a new value of an existing kind's type in the provider's folder: a `changelog.File`, a `retire.Page`, a `feed.Feed` with its reader, an OpenAPI adapter, an `apisurface.Package`. Write a new kind only when none of them reads your source. There is no "Kubernetes kind" or "Terraform kind": Kubernetes API removals are a migration-guide or notices source, a client SDK is a package source, a Terraform provider is a changelog source. ## 1. Scaffold it with `new-plugin` @@ -14,19 +14,18 @@ make new-plugin ARGS='--provider acme --name Acme --category devtools --homepage # the same: go run ./cmd/new-plugin --provider acme ... # --kind: openapi, changelog, notices, migrationguide, catalog, apisurface # --reader, for a kind with several: changelog markdown|json, notices deprecations|feed, migrationguide sdk|members -# optional: --layer api|sdk|package|runtime|ci|ai-models|infra (default: the kind's), --watches "...", -# --page acme (share an existing providers/ page; default -) +# optional: --layer api|sdk|package|runtime|ci|ai-models|infra (default: the kind's), --watches "..." ``` Run in a terminal without the flags, it asks for them: the provider's id, then (for a new provider) its name, category and homepage, then the source's id, kind, reader, layer, URLs, packages and what it watches. A second source of a registered provider needs only `--provider`, `--source` and `--kind`: the name, category and homepage come from the registry. One run adds one source; run it again for the next. -It writes, and lists: +It writes, and lists, everything in the provider's folder, `providers//`: -- the source's definition in the package its kind reads it from (`plugins/openapi/adapter/`, `plugins/notices/retire/`, `plugins/notices/feed/`, `plugins/migrationguide/sdkguide/`, `plugins/migrationguide/members/` or `plugins//`), with the version wiring the kind needs from it: an OpenAPI adapter's `LatestTag`, `Fetch` and `Versions` to write; every other kind lists, reads and extracts versions itself; -- its `plugin.RegisterProvider` block (the provider and the source with every metadata field, packages included) in the kind's `init`, and the kind's import in `plugins/all` if it's a new kind; -- `plugins//__test.go`: the registration test, a golden test and a pinned drop test, over placeholder sources in `testdata/`, with the golden file written from them; -- a row per saved file in that `testdata/README.md` (URL, date, license, quote to fill in); -- `providers/-.md` from the template (or nothing, with `--page`, when the provider already has one); +- `.go`: the source's definition, built from the kind's exported types, with the version wiring the kind needs from it: an OpenAPI adapter's `LatestTag`, `Fetch` and `Versions` to write; a feed's reader; every other kind lists, reads and extracts versions itself; +- its registration in `provider.go`: for a new provider, a new `provider.go` with the provider's `plugin.RegisterProvider` call (every metadata field, packages included) and its import in `providers/all`; for a provider with a folder, one more source in its `Sources`; +- `_test.go`: the registration test, a golden test and a pinned drop test, over placeholder sources in `testdata/`, with the golden file written from them; +- a row per saved file in `testdata/README.md` (URL, date, license, quote to fill in); +- the source's section in `README.md`, the provider's page (a new provider's from [`provider-template.md`](provider-template.md)); `go test ./...` passes right after; every place to fill in says `TODO(new-plugin)` (`grep -rn 'TODO(new-plugin)' .`), and `make check` (its `todos` step, also in CI_go) fails until none is left. It refuses a `provider/source` id that's taken, or a file it would write that exists, and then changes nothing. @@ -39,7 +38,7 @@ Use the provider's own, most machine-readable source. In order of preference: 3. **An official RSS / Atom feed** of changes. Built to be machine-read. 4. **An official documentation page** (a deprecations page), ideally served as markdown. A live page changes, so events cite a Wayback Machine snapshot of it. -Never scrape what the provider's `robots.txt` or terms disallow, and never read a forum or a third-party blog. Write down what you chose and why in the provider page (step 8). +Never scrape what the provider's `robots.txt` or terms disallow, and never read a forum or a third-party blog. Write down what you chose and why on the provider's page (step 8). ### Measure the source over its history before trusting it @@ -53,7 +52,7 @@ A source that looks right on today's copy can be wrong as a history of changes. - a release branch cut before an older branch's last minor didn't have it yet; - it described only an API client: a helper or a "custom request" method, marked `x-helper` or similar. - So the default rule for a spec is the `deprecationsOnly` filter (`plugins/openapi/vercel.go`): operation deprecations, plus removals of operations marked deprecated first. Keep an unmarked removal only if the history shows they're real. + So the default rule for a spec is the `openapi.DeprecationsOnly` filter (`kinds/openapi/openapi.go`, as `providers/vercel/api.go` uses it): operation deprecations, plus removals of operations marked deprecated first. Keep an unmarked removal only if the history shows they're real. - **Withdrawals:** a deprecation the provider takes back (`endpoint-reactivated`), a removed version that reappears. Replay the history in order, and let a withdrawal cancel what it withdraws. - **Property-level changes,** request and response. Response properties of a generated spec often churn by the hundred per release. Count before deciding; leaving them out is a fine first version. @@ -63,7 +62,7 @@ Then check what's left against the provider's own words: - **Cross-check a removal with the release notes** ("Remove unfreeze REST endpoint" for the endpoint that left the spec). - **Probing the live API from outside rarely settles it.** Many APIs answer 401 or 403 to every path without credentials, real or made up. -Write the numbers on the provider page, as `providers/vercel.md` does for its spec's history, so a reviewer can check the rule against them. +Write the numbers on the provider's page, as `providers/vercel/README.md` does for its spec's history, so a reviewer can check the rule against them. ### Cite a version, and pick one a repo pins @@ -80,14 +79,14 @@ Write the numbers on the provider page, as `providers/vercel.md` does for its sp [Which kind fits my provider?](which-kind.md) asks the questions; the table says what each kind reads. -| Kind | Reads | Add a source by | +| Kind | Reads | Add a source, in `providers//`, by | |---|---|---| -| `plugins/openapi` | An OpenAPI spec per release, diffed with `core/diff/` and turned into events by `core/normalize/` | An `adapter.Adapter` in `plugins/openapi/adapter/` (latest tag, fetch a tag's spec; `Versions` to list every release) and a `plugin.RegisterProvider` block | -| `plugins/notices` | A live page of dated notices: a model provider's deprecations page (a table of date, model, replacement: Markdown, Markdoc or HTML), a vendor's RSS or Atom feed, a vendor's table of whole API version ranges and their support status | A `retire.Page` in `plugins/notices/retire/providers.go`, a `feed.Feed` with a reader for that vendor's entries in `plugins/notices/feed/`, or an `eol.Page` in `plugins/notices/eol/` (`new-plugin` doesn't scaffold this reader yet) | -| `plugins/migrationguide` | A guide that lists what a release removed, at the release's tag: an SDK's migration guide per new major (removed request parameters), or a package's table of removed members (an RST simple table or a Markdown pipe table) | A `sdkguide.Guide` in `plugins/migrationguide/sdkguide/`, or a `members.Guide` in `plugins/migrationguide/members/` | -| `plugins/changelog` | A changelog: a `CHANGELOG.md` / `CHANGES.rst` / `HISTORY.rst`, each release's section at its tag (releases from PyPI or npm, or for any other ecosystem the repo's `TagPrefix` + X.Y.Z tags), or each GitHub release's notes (`Notes`), or a vendor's machine-readable API changelog in JSON (per day, endpoint and API version, oasdiff change codes), commit by commit | A `changelog.File` with its `Ecosystem` and `TagPrefix`, or a `changelog.Log` | -| `plugins/catalog` | A provider's own structured list of what it offers: a command catalog kept as one JSON file per command in its repo, read at each release tag and compared for commands that disappeared entirely | A `catalog.Commands` (repo, directory, release tag pattern); a catalog of another shape is a new reader type in the package | -| `plugins/apisurface` | A published package's public API, compared between two releases: the classes, functions, methods and parameters in each release's files (the wheel or sdist from PyPI, the TypeScript declarations in an npm tarball) | An `apisurface.Package` (registry name, ecosystem, top-level module; `npmPackage` for npm) and its `plugin.RegisterProvider` block | +| `kinds/openapi` | An OpenAPI spec per release, diffed with `core/diff/` and turned into events by `core/normalize/` | An `adapter.Adapter` (latest tag, fetch a tag's spec; `Versions` to list every release, with `adapter.Releases`, `adapter.Commits` or `core/versions`) in `.go`, and an `openapi.Plugin` source in `provider.go` (`Diff` and `Keep` when the spec needs them) | +| `kinds/notices` | A live page of dated notices: a model provider's deprecations page (a table of date, model, replacement: Markdown, Markdoc or HTML), a vendor's RSS or Atom feed, a vendor's table of whole API version ranges and their support status | A `retire.Page` (what models to keep), a `feed.Feed` with a reader for that vendor's entries, or an `eol.Page` (`new-plugin` doesn't scaffold this reader yet), run by a `notices.Plugin` | +| `kinds/migrationguide` | A guide that lists what a release removed, at the release's tag: an SDK's migration guide per new major (removed request parameters), or a package's table of removed members (an RST simple table or a Markdown pipe table) | A `sdkguide.Guide` or a `members.Guide`, run by a `migrationguide.Plugin` | +| `kinds/changelog` | A changelog: a `CHANGELOG.md` / `CHANGES.rst` / `HISTORY.rst`, each release's section at its tag (releases from PyPI or npm, or for any other ecosystem the repo's `TagPrefix` + X.Y.Z tags), or each GitHub release's notes (`Notes`), or a vendor's machine-readable API changelog in JSON (per day, endpoint and API version, oasdiff change codes), commit by commit | A `changelog.File` with its `Ecosystem` and `TagPrefix` (`changelog.SDK` builds an SDK's source from it), or a `changelog.Log` | +| `kinds/catalog` | A provider's own structured list of what it offers: a command catalog kept as one JSON file per command in its repo, read at each release tag and compared for commands that disappeared entirely; a file of upcoming removals, commit by commit | A `catalog.Commands` (repo, directory, release tag pattern) or a `catalog.UpcomingChanges`; a catalog of another shape is a new reader type in the kind | +| `kinds/apisurface` | A published package's public API, compared between two releases: the classes, functions, methods and parameters in each release's files (the wheel or sdist from PyPI, the TypeScript declarations in an npm tarball) | An `apisurface.Package` (registry name, ecosystem, top-level module; `apisurface.NPMPackage` for npm), its source built with `apisurface.PyPI` or `apisurface.NPM` | ## 4. The interface @@ -136,7 +135,7 @@ When a release or a page has no part the reader can use (a changelog with no sec A source that has versions (a spec's releases, a package's releases, a guide per major, the commits that changed a file) is read version by version, so a customer several versions behind gets every step: the runner lists the versions, reads each consecutive pair with `ReadAt` and extracts it once (a released version never changes). -- **List** with [`core/versions`](../core/versions/versions.go): `GitHubReleases`, `GitHubTags`, `GitHubCommits` (the commits that changed a file), `PyPIReleases` (`PyPIReleasesWithYanked` when a change can be documented at a release later yanked), `NPMReleases`, `GitHubPages` (any other GitHub list, page by page). An OpenAPI adapter lists its own versions (`adapter.Lister`): every adapter does. Never pin a tag in code: a version you need for a golden test is a pinned *case* in the test (`changelog.Urllib3.At("2.0.0")`, in a `_test.go` file), not the registered source; `plugins/all`'s `TestNoPinnedReleaseInPluginCode` fails on a release number or commit SHA in any plugin's non-test code. +- **List** with [`core/versions`](../core/versions/versions.go): `GitHubReleases`, `GitHubTags`, `GitHubCommits` (the commits that changed a file), `PyPIReleases` (`PyPIReleasesWithYanked` when a change can be documented at a release later yanked), `NPMReleases`, `GitHubPages` (any other GitHub list, page by page). An OpenAPI adapter lists its own versions (`adapter.Lister`): every adapter does. Never pin a tag in code: a version you need for a golden test is a pinned *case* in the test (`Urllib3.At("2.0.0")` in `providers/urllib3/`, in a `_test.go` file), not the registered source; `providers/all`'s `TestNoPinnedReleaseInPluginCode` fails on a release number or commit SHA in any kind's or provider's non-test code. - **Pins** (`Version.MapsTo`): when a release pins a version of another source (an SDK release and the API version it calls), set it while listing, from the release itself (its notes, the version constant in its code). It is how a feed query on the SDK's versions also returns the API's changes. Leave it zero when the release doesn't say: never fill it from a table kept by hand. - **Read at** a version's `Ref` (a tag, a commit SHA) and return the exact URL read as the snapshot's `SourceURL`: it's the events' citation. - **Extract** sets `previous_version` to `from`'s version: every `api_operation` and `package_release` event must name it (the contract's rule 13). `from` is zero only for the first version read, which has nothing to compare: patch-it's hosted ingestion service reads that version as its first snapshot and extracts nothing from it, so a version pair always starts at a real `from` (an `api_operation` or `package_release` event extracted from zero would be rejected). @@ -150,38 +149,41 @@ A living page (a deprecations page, a feed: a `notices` source) only shows its l ### The `apisurface` kind: reading a package's API without running it -`plugins/apisurface` downloads a release's wheel (or sdist) through `env.Get`, opens it in memory (`archive/zip`, `archive/tar`: nothing is written to disk) and hands the `.py` and `.pyi` files to `plugins/apisurface/pysurface`, which reads them as text: logical lines, indentation, and the headers of `def`, `class`, `__all__` and `from … import`. Nothing in the package is imported, compiled or run. That's the safest way to read code someone else publishes, and it needs no dependency: a Python interpreter (the `ast` module) would mean running a second runtime next to the plugins, and the pure-Go Python parsers available follow old grammars and pull in a large module for what is a few hundred lines here. The cost is that only signatures are read, never what a body does, and anything the reader can't be sure of is left out (see `providers/openai-python-surface.md`). Archive and file sizes are capped (`MaxFileBytes`, `MaxSourceBytes`), so a crafted release can't exhaust the runner. +`kinds/apisurface` downloads a release's wheel (or sdist) through `env.Get`, opens it in memory (`archive/zip`, `archive/tar`: nothing is written to disk) and hands the `.py` and `.pyi` files to `kinds/apisurface/pysurface`, which reads them as text: logical lines, indentation, and the headers of `def`, `class`, `__all__` and `from … import`. Nothing in the package is imported, compiled or run. That's the safest way to read code someone else publishes, and it needs no dependency: a Python interpreter (the `ast` module) would mean running a second runtime next to the plugins, and the pure-Go Python parsers available follow old grammars and pull in a large module for what is a few hundred lines here. The cost is that only signatures are read, never what a body does, and anything the reader can't be sure of is left out (see `providers/openai/README.md`, the Python SDK's section). Archive and file sizes are capped (`MaxFileBytes`, `MaxSourceBytes`), so a crafted release can't exhaust the runner. -An npm release is read the same way: its tarball (the version document's `dist.tarball`) is opened in memory and only `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files are kept, for `plugins/apisurface/dtsurface`. Declaration files hold declarations only, never statements, so a tokenizer and a parser of declarations, which skips each type expression by its brackets, read every name, member and parameter a caller can see, in about a thousand lines of standard-library Go. The alternatives would each be worse here: the TypeScript compiler is JavaScript, so it would mean running Node and code from npm next to the plugins; the Go ports of TypeScript's parser are internal to their projects or need cgo (tree-sitter); and a full type checker is far more than a public-API diff needs. No package code runs, no install script runs, no dependency is added (the `make imports` allowlist is unchanged). What it doesn't do, on purpose: resolve types (a property's type isn't followed), or read interface members (see `providers/openai-node-surface.md`). +An npm release is read the same way: its tarball (the version document's `dist.tarball`) is opened in memory and only `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files are kept, for `kinds/apisurface/dtsurface`. Declaration files hold declarations only, never statements, so a tokenizer and a parser of declarations, which skips each type expression by its brackets, read every name, member and parameter a caller can see, in about a thousand lines of standard-library Go. The alternatives would each be worse here: the TypeScript compiler is JavaScript, so it would mean running Node and code from npm next to the plugins; the Go ports of TypeScript's parser are internal to their projects or need cgo (tree-sitter); and a full type checker is far more than a public-API diff needs. No package code runs, no install script runs, no dependency is added (the `make imports` allowlist is unchanged). What it doesn't do, on purpose: resolve types (a property's type isn't followed), or read interface members (see `providers/openai/README.md`, the Node SDK's section). An event cites the newer release's file, and its excerpt quotes the definition's path and line in both releases. npm packages (`.d.ts` files) are next. ### Register the provider and its source -In the kind's package `init`, with the metadata ([AGENTS.md](../AGENTS.md) rule 1): +In the provider's `providers//provider.go`, one `init` registers the provider and every source of it, whatever their kinds, with the metadata ([AGENTS.md](../AGENTS.md) rule 1): ```go func init() { plugin.RegisterProvider(plugin.Provider{ ID: "urllib3", Name: "urllib3", Category: plugin.CategoryPackages, Homepage: "https://urllib3.readthedocs.io", - Sources: []plugin.Source{{ - ID: "urllib3", Layer: plugin.LayerPackage, Page: "providers/urllib3.md", - Watches: "Names removed or deprecated in each release, …", - URLs: []string{"https://github.com/urllib3/urllib3/blob/main/CHANGES.rst"}, - Packages: []string{"pypi:urllib3"}, - Plugin: Plugin{File: Urllib3}, - }}, + Sources: []plugin.Source{ + { + ID: "urllib3", Layer: plugin.LayerPackage, + Watches: "Names removed or deprecated in each release, …", + URLs: []string{"https://github.com/urllib3/urllib3/blob/main/CHANGES.rst"}, + Packages: []string{"pypi:urllib3"}, + Plugin: changelog.Plugin{File: Urllib3}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerPackage, "https://github.com/urllib3/urllib3"), + }, }) } ``` -`RegisterProvider` panics on missing metadata, a duplicate id, or a provider registered twice with a different name, category or homepage (a provider with sources in two kinds repeats the same ones). `plugin.Lookup` and `plugin.LookupSource` find a source by its id, `provider/source`. The plugin's `Name` is that id: what every event carries in `api`, and what the fingerprint hashes. +`RegisterProvider` fills in each source's kind (the `kinds/` package its plugin's type is defined in) and its page (`providers//README.md`), and panics on missing metadata, a duplicate id, or a provider registered a second time. `plugin.Lookup` and `plugin.LookupSource` find a source by its id, `provider/source`. The plugin's `Name` is that id: what every event carries in `api`, and what the fingerprint hashes. `Packages` are the published packages the source covers, `:` (`pypi:stripe`, `npm:@vercel/sdk`): the package itself for a package or SDK source, the provider's official SDKs for an API source. `plugin.ForPackage` finds a package's sources, so a customer's lockfile maps to sources with no table kept anywhere else. List only names you checked; none is fine. ### Fetching: `env.Get` and `core/kit/` -- Fetch **only** with `env.Get`. It caches by `ETag` / `Last-Modified`, retries, and in tests serves saved files. `CI_go` fails a package outside `core/fetch/`, `core/kit/` and `plugins/openapi/adapter/` that imports `net/http`. +- Fetch **only** with `env.Get`. It caches by `ETag` / `Last-Modified`, retries, and in tests serves saved files. `CI_go` fails a package outside `core/fetch/` and `core/kit/` that imports `net/http`. - `kit.Cite(ctx, archiver, url, read, want)`: for a **living page**'s `Read`. Takes a Wayback Machine snapshot, reads it with your own reader and checks it says exactly what the live page said. Make the events from the snapshot and cite its URL. No snapshot, no events. - `plugin.SHA256(body)`: the hash a living page's `CompareHash` holds. - `github.LatestRelease`, `github.LatestCommit`, `github.Commit`, `github.Head` ([`core/github`](../core/github/github.go)): the newest release or commit on GitHub, one place; don't decode GitHub's responses yourself. @@ -192,7 +194,7 @@ The event format is [patch-it's change-event contract](https://github.com/patch- ## 5. Save the source -Save a real copy of what the plugin reads under your package's `testdata/` (or the reader package's, like `plugins/notices/retire/testdata/`). Add a row to that directory's `README.md`: file, URL, date fetched, license, and a short quote of the part the plugin reads. +Save a real copy of what the source reads under the provider's `testdata/`, `providers//testdata/`. Add a row to its `README.md`: file, URL, date fetched, license, and a short quote of the part the plugin reads. - **Openly licensed files** (MIT, BSD, Apache, CC BY): keep them whole. - **Vendor documentation pages**: trim to what the plugin reads (the tables, the sections), copy every kept line unchanged, mark it "excerpt for testing; © the vendor", and say what you left out. @@ -207,12 +209,12 @@ The test kit, `core/kit/kittest`, runs the plugin with no network, no database a ```go func TestGolden(t *testing.T) { env := kittest.Env(t, kittest.Pages{ - Redis.listingURL("8.8-m03"): "testdata/redis-contents-src-commands-8.8-m03.json", - Redis.listingURL("8.8-rc1"): "testdata/redis-contents-src-commands-8.8-rc1.json", - Redis.FileURL("8.8-m03", "gcra.json"): "testdata/redis-8.8-m03-gcra.json", - Redis.FileURL("8.8-m03", "gcrasetvalue.json"): "testdata/redis-8.8-m03-gcrasetvalue.json", + Commands.ListingURL("8.8-m03"): "testdata/redis-contents-src-commands-8.8-m03.json", + Commands.ListingURL("8.8-rc1"): "testdata/redis-contents-src-commands-8.8-rc1.json", + Commands.FileURL("8.8-m03", "gcra.json"): "testdata/redis-8.8-m03-gcra.json", + Commands.FileURL("8.8-m03", "gcrasetvalue.json"): "testdata/redis-8.8-m03-gcrasetvalue.json", }) - got := kittest.Versions(t, env, Redis, + got := kittest.Versions(t, env, Commands, plugin.Version{ID: "8.8-m03", Ref: "8.8-m03"}, plugin.Version{ID: "8.8-rc1", Ref: "8.8-rc1"}) kittest.Golden(t, "testdata/golden/redis-commands.json", got) } @@ -222,21 +224,22 @@ func TestGolden(t *testing.T) { - A versioned source: `kittest.Versions(t, env, plugin, from, to)` reads both versions with `ReadAt` and extracts the pair, as the hosted service does. When the older side needn't be read (a changelog's or a migration guide's `Extract` reads only the newer release's own section), build the snapshots yourself and call `kittest.Extracted(t, env, plugin, from, to)`, naming the real release before as `from`. - A living page: `kittest.Page(t, env, plugin)` is its first read, cited through `&kittest.Archive{T: t, Pages: saved}`; a second read of the same page must return the kept snapshot and store nothing. - Each stores into an in-memory store (`kittest.Mem`) and extracts **twice**: a rejected event, an error, or a second extract that stores anything new fails the test. `kittest.Pair` and `kittest.ReadPage` are the same steps returning errors, for tests that expect one. -- `kittest.Golden` compares the stored events with the JSON file. Create or rewrite it with `go test ./plugins/ -update`, then read the diff like code: every event in it is a pull request someone may get. +- `kittest.Golden` compares the stored events with the JSON file. Create or rewrite it with `go test ./providers/ -update`, then read the diff like code: every event in it is a pull request someone may get. ## 7. Pin a drop test and the registration - **One drop test**: a realistic input the plugin must *not* turn into an event (an unrelated section, a behavior change written as prose, a product name in a sentence). Precision over recall: a missed change is a bug we fix later; a wrong change is a wrong pull request in someone's repo. Make it prove something: also run the same input with the filter off, and assert the noise it drops is there. -- **`registered_test.go`**: `kittest.Registered(t, Plugin{…})` checks the package registered that plugin under that name. -- **A new kind (a new package under plugins/)**: add its blank import to [`plugins/all/all.go`](../plugins/all/all.go). `TestEveryPluginIsImported` fails until you do; the hosted service runs exactly what `plugins/all` imports. +- **The registration**: `kittest.Registered(t, openapi.Plugin{…})` checks the source is registered under that name with that plugin. +- **A new provider (a new folder under providers/)**: its blank import goes in [`providers/all/all.go`](../providers/all/all.go) (`new-plugin` adds it). `TestEveryProviderIsImported` fails until it's there; the hosted service runs exactly what `providers/all` imports. `TestTheImportGraph` fails when a kind imports a provider, or a provider imports anything of this module but `core/` and `kinds/`. +- **A new kind (a new package under kinds/)**: it says how to read and knows no provider; the providers that use it import it. ## 8. Write the provider page -Copy [`providers/_template.md`](../providers/_template.md) to `providers/.md` and fill in every section: what it watches; **why this source** (the link, the date you checked it, why it's the best place this provider announces breaking changes, the alternatives you didn't use and why, one short quote); how the provider announces changes; what the plugin reads and ignores; known gaps. +Each source has a section on its provider's page, `providers//README.md` (a new provider's from [`provider-template.md`](provider-template.md); `new-plugin` writes the section). Fill in every part: what it watches; **why this source** (the link, the date you checked it, why it's the best place this provider announces breaking changes, the alternatives you didn't use and why, one short quote); how the provider announces changes; what the plugin reads and ignores; known gaps. ## 9. Fill in the metadata in the registration -**Not optional** ([AGENTS.md](../AGENTS.md) rule 1). The `plugin.RegisterProvider` block the starter wrote is the only place the source is listed: the provider's id, name, category (`plugin.Categories()`) and homepage, and the source's id (`/`), layer (`plugin.Layers()`), what it watches, the URLs it reads and its page. A second source of a provider repeats the provider's id, name, category and homepage exactly. `make plugins` prints the list with it; each release attaches that list as `plugins.json`, which docs.patch-it.dev and patch-it's hosted ingestion service read. There's nothing else to update. +**Not optional** ([AGENTS.md](../AGENTS.md) rule 1). The `plugin.RegisterProvider` block the starter wrote is the only place the source is listed: the provider's id, name, category (`plugin.Categories()`) and homepage, and the source's id (`/`), layer (`plugin.Layers()`), what it watches, the URLs it reads and the packages it covers. A provider is registered once, in its `provider.go`: a second source is one more entry in its `Sources`. `make plugins` prints the list with it; each release attaches that list as `plugins.json`, which docs.patch-it.dev and patch-it's hosted ingestion service read. There's nothing else to update. ## 10. Check and open the PR diff --git a/internal/pluginlist/pluginlist_test.go b/internal/pluginlist/pluginlist_test.go index ff9c129..9f65238 100644 --- a/internal/pluginlist/pluginlist_test.go +++ b/internal/pluginlist/pluginlist_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/all" + _ "github.com/patch-it-dev/patch-it-plugins/providers/all" ) const root = "../.." diff --git a/plugins/apisurface/apisurface.go b/kinds/apisurface/apisurface.go similarity index 99% rename from plugins/apisurface/apisurface.go rename to kinds/apisurface/apisurface.go index d916c15..3a9daf3 100644 --- a/plugins/apisurface/apisurface.go +++ b/kinds/apisurface/apisurface.go @@ -36,7 +36,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" - "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface/pysurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/pysurface" ) // Package is one published package. diff --git a/plugins/apisurface/apisurface_test.go b/kinds/apisurface/apisurface_test.go similarity index 83% rename from plugins/apisurface/apisurface_test.go rename to kinds/apisurface/apisurface_test.go index 44f2627..27bf081 100644 --- a/plugins/apisurface/apisurface_test.go +++ b/kinds/apisurface/apisurface_test.go @@ -3,83 +3,13 @@ package apisurface import ( "archive/zip" "bytes" - "context" "strings" "testing" - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/core/versions" - "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface/pysurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/pysurface" ) -const ( - wheel111 = "https://files.pythonhosted.org/packages/f7/86/ea99e3f966a639a3256e2f79d78cd63d45d5eb651a5457ccbdcfd9eed24a/openai-1.1.1-py3-none-any.whl" - wheel112 = "https://files.pythonhosted.org/packages/dd/82/b92f73453ea318c0d46f31aeb56e9d94a42606c010fb72a513f4a3cd4bac/openai-1.1.2-py3-none-any.whl" -) - -// The saved releases (testdata/README.md): PyPI's answers and the two -// wheels, trimmed to the openai.types.beta package. -var saved = kittest.Pages{ - "https://pypi.org/pypi/openai/json": "testdata/pypi-openai-excerpt.json", - "https://pypi.org/pypi/openai/1.1.1/json": "testdata/pypi-openai-1.1.1.json", - "https://pypi.org/pypi/openai/1.1.2/json": "testdata/pypi-openai-1.1.2.json", - wheel111: "testdata/openai-1.1.1-py3-none-any.trimmed.whl", - wheel112: "testdata/openai-1.1.2-py3-none-any.trimmed.whl", -} - -// pair lists the releases, reads 1.1.1 and 1.1.2 and extracts the pair, as -// patch-it's hosted ingestion service does, into the test kit's store. -func pair(t *testing.T) []event.Event { - t.Helper() - ctx, env := context.Background(), kittest.Env(t, saved) - p := Plugin{Package: OpenAIPython} - vs, err := p.ListVersions(ctx, env) - if err != nil { - t.Fatal(err) - } - var ids []string - for _, v := range vs { - ids = append(ids, v.ID) - } - if got := strings.Join(ids, " "); got != "1.1.0 1.1.1 1.1.2" { - t.Fatalf("versions %s", got) - } - last := versions.Pairs(vs)[1] - return kittest.Versions(t, env, p, last[0], last[1]) -} - -// openai 1.1.2 renamed the misspelled AsssitantDeleted to AssistantDeleted, -// module and all: the old name is gone from both places code could import -// it. (Not read as a rename: the class has no parameters to tell it's the -// same class.) -func TestGolden(t *testing.T) { - got := pair(t) - kittest.Golden(t, "testdata/golden/openai-python-surface.json", got) - for _, e := range got { - if e.PreviousVersion != "1.1.1" || e.Version != "1.1.2" || e.SourceURL != wheel112 || !strings.Contains(e.SourceExcerpt, "openai/types/beta/asssitant_deleted.py line ") { - t.Errorf("%v: %s<-%s, excerpt %q", e.Subject.Symbols, e.Version, e.PreviousVersion, e.SourceExcerpt) - } - } -} - -// The pinned drop test: 1.1.2 adds AssistantDeleted and its module. A name -// that appears is no breaking change: no event names it. -func TestAnAddedNameIsNoEvent(t *testing.T) { - for _, e := range pair(t) { - for _, s := range e.Subject.Symbols { - if strings.Contains(s, "AssistantDeleted") || strings.Contains(s, "assistant_deleted") { - t.Errorf("event for %s, which 1.1.2 added", s) - } - } - } -} - -func TestRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Package: OpenAIPython}) -} - func sym(kind string, params ...pysurface.Param) pysurface.Symbol { if params == nil { params = []pysurface.Param{} diff --git a/kinds/apisurface/apisurfacetest/apisurfacetest.go b/kinds/apisurface/apisurfacetest/apisurfacetest.go new file mode 100644 index 0000000..fb18efe --- /dev/null +++ b/kinds/apisurface/apisurfacetest/apisurfacetest.go @@ -0,0 +1,207 @@ +// Package apisurfacetest is what the tests of providers' apisurface sources +// share: a package's saved releases (testdata/pypi// or +// testdata/npm//, testdata/README.md) served where the registry +// has them, and a source's golden pair, drop pair and registration in one +// call. +package apisurfacetest + +import ( + "context" + "encoding/json" + "os" + "path/filepath" + "slices" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" +) + +// Case is one source's saved releases: a golden pair, the events it must +// store, and a drop pair, a real release that must store none. Both pairs +// are consecutive releases on the registry. +type Case struct { + Package apisurface.Package + Golden [2]string + Want []string // each event as " " + Drop [2]string +} + +// PyPI checks a PyPI source: its golden pair stores exactly the events +// listed, each citing the newer wheel and quoting both releases, against +// testdata/golden/-.json; its drop pair stores none; and +// it is registered. +func PyPI(t *testing.T, c Case) { + t.Helper() + kittest.Registered(t, apisurface.Plugin{Package: c.Package}) + t.Run("golden", func(t *testing.T) { + got := pypiPair(t, c, c.Golden) + var lines []string + for _, e := range got { + lines = append(lines, string(e.Subject.Change)+" "+strings.Join(e.Subject.Symbols, ",")+" "+e.Subject.Parameter) + if e.Version != c.Golden[1] || e.PreviousVersion != c.Golden[0] || !strings.Contains(e.SourceURL, "files.pythonhosted.org") || !strings.Contains(e.SourceExcerpt, c.Package.Name+" "+c.Golden[0]+" (") { + t.Errorf("%s: %s<-%s cites %s, excerpt %q", e.Subject.Symbols, e.Version, e.PreviousVersion, e.SourceURL, e.SourceExcerpt) + } + } + slices.Sort(lines) + if !slices.Equal(lines, c.Want) { + t.Errorf("got\n%s\nwant\n%s", strings.Join(lines, "\n"), strings.Join(c.Want, "\n")) + } + kittest.Golden(t, goldenFile(c), got) + }) + t.Run("drop", func(t *testing.T) { + for _, e := range pypiPair(t, c, c.Drop) { + t.Errorf("%s %v %s", e.Subject.Change, e.Subject.Symbols, e.Subject.Parameter) + } + }) +} + +// NPM checks an npm source as PyPI does a PyPI one, the events citing the +// registry. +func NPM(t *testing.T, c Case) { + t.Helper() + kittest.Registered(t, apisurface.Plugin{Package: c.Package}) + t.Run("golden", func(t *testing.T) { + got := npmPair(t, c, c.Golden) + if len(got) == 0 { + t.Fatal("no events") + } + var lines []string + for _, e := range got { + lines = append(lines, string(e.Subject.Change)+" "+strings.Join(e.Subject.Symbols, ",")+" "+e.Subject.Parameter) + if e.Version != c.Golden[1] || e.PreviousVersion != c.Golden[0] || !strings.HasPrefix(e.SourceURL, "https://registry.npmjs.org/") || !strings.Contains(e.SourceExcerpt, c.Package.Name+" "+c.Golden[0]+" (") || e.Subject.Ecosystem != "npm" { + t.Errorf("%s: %s<-%s cites %s, excerpt %q", e.Subject.Symbols, e.Version, e.PreviousVersion, e.SourceURL, e.SourceExcerpt) + } + } + slices.Sort(lines) + if !slices.Equal(lines, c.Want) { + t.Errorf("got\n%s\nwant\n%s", strings.Join(lines, "\n"), strings.Join(c.Want, "\n")) + } + kittest.Golden(t, goldenFile(c), got) + }) + t.Run("drop", func(t *testing.T) { + for _, e := range npmPair(t, c, c.Drop) { + t.Errorf("%s %v %s", e.Subject.Change, e.Subject.Symbols, e.Subject.Parameter) + } + }) +} + +// goldenFile is testdata/golden/-.json. +func goldenFile(c Case) string { + provider, source, _ := strings.Cut(c.Package.ID, "/") + return "testdata/golden/" + provider + "-" + source + ".json" +} + +// pypiPages serves a case's saved files: PyPI's answers, and each picked +// wheel, trimmed, under its real URL. +func pypiPages(t *testing.T, name string) kittest.Pages { + t.Helper() + dir := filepath.Join("testdata", "pypi", name) + pages := kittest.Pages{"https://pypi.org/pypi/" + name + "/json": filepath.Join(dir, "pypi-"+name+"-excerpt.json")} + files, err := filepath.Glob(filepath.Join(dir, "pypi-"+name+"-*.json")) + if err != nil { + t.Fatal(err) + } + for _, f := range files { + v := strings.TrimSuffix(strings.TrimPrefix(filepath.Base(f), "pypi-"+name+"-"), ".json") + if v == "excerpt" { + continue + } + pages["https://pypi.org/pypi/"+name+"/"+v+"/json"] = f + var doc struct { + URLs []struct { + URL string `json:"url"` + Filename string `json:"filename"` + } `json:"urls"` + } + if err := json.Unmarshal(kittest.Read(t, f), &doc); err != nil { + t.Fatal(err) + } + for _, u := range doc.URLs { + trimmed := filepath.Join(dir, strings.TrimSuffix(u.Filename, ".whl")+".trimmed.whl") + if _, err := os.Stat(trimmed); err == nil { + pages[u.URL] = trimmed + } + } + } + return pages +} + +// pypiPair stores one pair of a case's releases, listed as PyPI lists them. +func pypiPair(t *testing.T, c Case, pair [2]string) []event.Event { + t.Helper() + ctx, env := context.Background(), kittest.Env(t, pypiPages(t, c.Package.Name)) + p := apisurface.Plugin{Package: c.Package} + vs, err := p.ListVersions(ctx, env) + if err != nil { + t.Fatal(err) + } + byID := map[string]plugin.Version{} + for _, v := range vs { + byID[v.ID] = v + } + from, ok1 := byID[pair[0]] + to, ok2 := byID[pair[1]] + if !ok1 || !ok2 { + t.Fatalf("%s: %v not both listed in %v", c.Package.Name, pair, vs) + } + return kittest.Versions(t, env, p, from, to) +} + +// npmDir is a package's directory under testdata/npm. +func npmDir(name string) string { + return filepath.Join("testdata", "npm", strings.ReplaceAll(strings.TrimPrefix(name, "@"), "/", "-")) +} + +// npmPages serves a case's saved files under the registry's URLs: the +// package document, each version's, and each trimmed tarball. +func npmPages(t *testing.T, name string) kittest.Pages { + t.Helper() + dir, safe := npmDir(name), strings.ReplaceAll(strings.TrimPrefix(name, "@"), "/", "-") + reg := "https://registry.npmjs.org/" + strings.ReplaceAll(name, "/", "%2F") + pages := kittest.Pages{reg: filepath.Join(dir, "npm-"+safe+"-excerpt.json")} + files, err := filepath.Glob(filepath.Join(dir, "npm-"+safe+"-*.json")) + if err != nil { + t.Fatal(err) + } + for _, f := range files { + v := strings.TrimSuffix(strings.TrimPrefix(filepath.Base(f), "npm-"+safe+"-"), ".json") + if v == "excerpt" { + continue + } + pages[reg+"/"+v] = f + var doc struct { + Dist struct { + Tarball string `json:"tarball"` + } `json:"dist"` + } + if err := json.Unmarshal(kittest.Read(t, f), &doc); err != nil { + t.Fatal(err) + } + pages[doc.Dist.Tarball] = filepath.Join(dir, strings.TrimSuffix(filepath.Base(doc.Dist.Tarball), ".tgz")+".trimmed.tgz") + } + return pages +} + +func npmPair(t *testing.T, c Case, pair [2]string) []event.Event { + t.Helper() + ctx, env := context.Background(), kittest.Env(t, npmPages(t, c.Package.Name)) + p := apisurface.Plugin{Package: c.Package} + vs, err := p.ListVersions(ctx, env) + if err != nil { + t.Fatal(err) + } + byID := map[string]plugin.Version{} + for _, v := range vs { + byID[v.ID] = v + } + from, ok1 := byID[pair[0]] + to, ok2 := byID[pair[1]] + if !ok1 || !ok2 { + t.Fatalf("%s: %v not both listed in %v", c.Package.Name, pair, vs) + } + return kittest.Versions(t, env, p, from, to) +} diff --git a/plugins/apisurface/artifact.go b/kinds/apisurface/artifact.go similarity index 98% rename from plugins/apisurface/artifact.go rename to kinds/apisurface/artifact.go index 010edc3..53599e1 100644 --- a/plugins/apisurface/artifact.go +++ b/kinds/apisurface/artifact.go @@ -16,7 +16,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" - "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface/pysurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/pysurface" ) // The limits on what is read out of an archive: a release is data, and a diff --git a/plugins/apisurface/dtsurface/dtsurface_test.go b/kinds/apisurface/dtsurface/dtsurface_test.go similarity index 99% rename from plugins/apisurface/dtsurface/dtsurface_test.go rename to kinds/apisurface/dtsurface/dtsurface_test.go index 94aca92..c126a07 100644 --- a/plugins/apisurface/dtsurface/dtsurface_test.go +++ b/kinds/apisurface/dtsurface/dtsurface_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface/pysurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/pysurface" ) const pkgJSON = `{"name": "acme", "types": "./index.d.ts", diff --git a/plugins/apisurface/dtsurface/lex.go b/kinds/apisurface/dtsurface/lex.go similarity index 100% rename from plugins/apisurface/dtsurface/lex.go rename to kinds/apisurface/dtsurface/lex.go diff --git a/plugins/apisurface/dtsurface/parse.go b/kinds/apisurface/dtsurface/parse.go similarity index 100% rename from plugins/apisurface/dtsurface/parse.go rename to kinds/apisurface/dtsurface/parse.go diff --git a/plugins/apisurface/dtsurface/surface.go b/kinds/apisurface/dtsurface/surface.go similarity index 99% rename from plugins/apisurface/dtsurface/surface.go rename to kinds/apisurface/dtsurface/surface.go index d8c962b..590ac3f 100644 --- a/plugins/apisurface/dtsurface/surface.go +++ b/kinds/apisurface/dtsurface/surface.go @@ -8,7 +8,7 @@ import ( "sort" "strings" - "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface/pysurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/pysurface" ) // File is one file of the package, its path from the package's root diff --git a/plugins/apisurface/npm.go b/kinds/apisurface/npm.go similarity index 98% rename from plugins/apisurface/npm.go rename to kinds/apisurface/npm.go index b2ff86a..730dfa7 100644 --- a/plugins/apisurface/npm.go +++ b/kinds/apisurface/npm.go @@ -16,7 +16,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" - "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface/dtsurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/dtsurface" ) // readNPM downloads an npm release's tarball (from its version document on diff --git a/plugins/apisurface/pysurface/lines.go b/kinds/apisurface/pysurface/lines.go similarity index 100% rename from plugins/apisurface/pysurface/lines.go rename to kinds/apisurface/pysurface/lines.go diff --git a/plugins/apisurface/pysurface/pysurface.go b/kinds/apisurface/pysurface/pysurface.go similarity index 100% rename from plugins/apisurface/pysurface/pysurface.go rename to kinds/apisurface/pysurface/pysurface.go diff --git a/plugins/apisurface/pysurface/pysurface_test.go b/kinds/apisurface/pysurface/pysurface_test.go similarity index 100% rename from plugins/apisurface/pysurface/pysurface_test.go rename to kinds/apisurface/pysurface/pysurface_test.go diff --git a/kinds/apisurface/sources.go b/kinds/apisurface/sources.go new file mode 100644 index 0000000..5ce73ab --- /dev/null +++ b/kinds/apisurface/sources.go @@ -0,0 +1,44 @@ +package apisurface + +import ( + "strings" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" +) + +// PyPI is the source a PyPI package's public API is, its metadata read off +// pkg: repo is the package's source repository. A package's Module is the +// top-level directory its wheel installs (checked by hand on the package's +// newest wheel). +func PyPI(pkg Package, layer plugin.Layer, repo string) plugin.Source { + _, id, _ := strings.Cut(pkg.ID, "/") + return plugin.Source{ + ID: id, Layer: layer, + Watches: "Classes, functions, methods and parameters removed or renamed in the public API of the " + pkg.Name + " Python package, release by release, read from each release's wheel", + URLs: []string{"https://pypi.org/project/" + pkg.Name + "/", repo}, + Packages: []string{"pypi:" + pkg.Name}, + Plugin: Plugin{Package: pkg}, + } +} + +// NPMPackage is the npm package name, read from its TypeScript declarations, +// for the source id. An npm package's Module is its own name: symbols are +// named from the import path code writes +// ("@anthropic-ai/sdk/resources/messages.Messages.create"). +func NPMPackage(id, name string) Package { + return Package{ID: id, Name: name, Ecosystem: "npm", Module: name} +} + +// NPM is the source an npm package's public API is, its metadata read off +// pkg: repo is the package's source repository, also any other packages +// ("npm:redis") whose API is pkg's. +func NPM(pkg Package, repo string, also ...string) plugin.Source { + _, id, _ := strings.Cut(pkg.ID, "/") + return plugin.Source{ + ID: id, Layer: plugin.LayerSDK, + Watches: "Exported classes, functions, methods, properties, types and parameters removed, or parameters no longer optional, in the public API of the " + pkg.Name + " npm package, release by release, read from each release's TypeScript declarations", + URLs: []string{"https://www.npmjs.com/package/" + pkg.Name, repo}, + Packages: append([]string{"npm:" + pkg.Name}, also...), + Plugin: Plugin{Package: pkg}, + } +} diff --git a/plugins/catalog/catalog.go b/kinds/catalog/catalog.go similarity index 54% rename from plugins/catalog/catalog.go rename to kinds/catalog/catalog.go index aaf2470..ca91ee8 100644 --- a/plugins/catalog/catalog.go +++ b/kinds/catalog/catalog.go @@ -4,8 +4,8 @@ // name (and, for a list of upcoming changes, its date and what to use // instead). Each reader is a plugin of its own in this package, read // version by version (plugin.Versioned): Redis's commands at each release -// tag (redis.go), GitHub's GraphQL upcoming changes at each commit -// (graphql.go). +// tag (Commands, commands.go), GitHub's GraphQL upcoming changes at each commit +// (UpcomingChanges, upcoming.go). // // Precision over recall: a name that moves (a genuine rename) reads as one // removal and one addition, same as any other. A reader never guesses a @@ -16,31 +16,8 @@ import ( "fmt" "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" ) -func init() { - plugin.RegisterProvider(plugin.Provider{ - ID: "redis", Name: "Redis", Category: plugin.CategoryDatabases, Homepage: "https://redis.io", - Sources: []plugin.Source{{ - ID: "commands", Layer: plugin.LayerRuntime, Page: "providers/redis.md", - Watches: "Commands removed entirely between two Redis releases, from the command definitions in the server's own source (src/commands/) at each release tag", - URLs: []string{"https://github.com/redis/redis/tree/unstable/src/commands", "https://github.com/redis/redis/releases"}, - Plugin: Redis, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "github", Name: "GitHub", Category: plugin.CategoryDevTools, Homepage: "https://github.com", - Sources: []plugin.Source{{ - ID: "graphql", Layer: plugin.LayerAPI, Page: "providers/github-graphql.md", - Watches: "GraphQL API fields, arguments, input fields and enum values GitHub announces it will remove, with the date, from the file its breaking-changes page is built from", - URLs: []string{"https://docs.github.com/en/graphql/overview/breaking-changes", "https://github.com/github/docs/blob/main/src/graphql/data/fpt/upcoming-changes.json"}, - Packages: []string{"npm:@octokit/graphql"}, - Plugin: GitHubGraphQL, - }}, - }) -} - // finish fingerprints and validates the events a reader made, keeping the // valid ones and the reasons the others failed. details, when given, are // the fingerprints' detail, one per event: what separates two changes at diff --git a/plugins/catalog/redis.go b/kinds/catalog/commands.go similarity index 92% rename from plugins/catalog/redis.go rename to kinds/catalog/commands.go index e78253c..f027d94 100644 --- a/plugins/catalog/redis.go +++ b/kinds/catalog/commands.go @@ -41,19 +41,10 @@ type Commands struct { Release *regexp.Regexp } -// Redis is redis/redis's src/commands/ (checked 2026-11-20: 460 files at -// 8.10.0, every final release a GitHub release tagged X.Y.Z). The directory -// exists from 7.0.0; an older release has nothing to read. -var Redis = Commands{ - API: "redis/commands", Ecosystem: "redis", Package: "redis", - Repo: "redis/redis", Dir: "src/commands", - Release: regexp.MustCompile(`^(\d+\.\d+\.\d+)$`), -} - func (c Commands) Name() string { return c.API } -// listingURL is GitHub's listing of the directory at a ref. -func (c Commands) listingURL(ref string) string { +// ListingURL is GitHub's listing of the directory at a ref. +func (c Commands) ListingURL(ref string) string { return fmt.Sprintf("%s/repos/%s/contents/%s?ref=%s", github.API, c.Repo, c.Dir, url.QueryEscape(ref)) } @@ -83,7 +74,7 @@ func (c Commands) ListVersions(ctx context.Context, env plugin.Env) ([]plugin.Ve // names. A release without the directory (before 7.0.0) has nothing to // read. func (c Commands) ReadAt(ctx context.Context, env plugin.Env, v plugin.Version) (plugin.Snapshot, error) { - u := c.listingURL(v.Ref) + u := c.ListingURL(v.Ref) body, err := env.Get(ctx, u) var se *fetch.StatusError if errors.As(err, &se) && se.StatusCode == 404 { diff --git a/kinds/catalog/commands_test.go b/kinds/catalog/commands_test.go new file mode 100644 index 0000000..e9a0ab5 --- /dev/null +++ b/kinds/catalog/commands_test.go @@ -0,0 +1,14 @@ +package catalog + +import "testing" + +// A subcommand is named with its container, as code sends it. +func TestASubcommandIsNamedWithItsContainer(t *testing.T) { + name, _, err := command([]byte(`{"KILL": {"summary": "x", "container": "CLIENT"}}`)) + if err != nil || name != "CLIENT KILL" { + t.Errorf("%q, %v", name, err) + } + if _, _, err := command([]byte(`{"A": {}, "B": {}}`)); err == nil { + t.Error("two commands in one file must be an error, not a guess") + } +} diff --git a/plugins/catalog/graphql.go b/kinds/catalog/upcoming.go similarity index 95% rename from plugins/catalog/graphql.go rename to kinds/catalog/upcoming.go index 511f94b..4413f51 100644 --- a/plugins/catalog/graphql.go +++ b/kinds/catalog/upcoming.go @@ -44,15 +44,6 @@ type UpcomingChanges struct { Endpoint string } -// GitHubGraphQL is GitHub's GraphQL API's upcoming changes (checked -// 2026-11-21: 1,291 entries, every one "criticality": "breaking", 29 -// commits since 2023-05-01). -var GitHubGraphQL = UpcomingChanges{ - API: "github/graphql", Vendor: "GitHub", - Repo: "github/docs", Path: "src/graphql/data/fpt/upcoming-changes.json", - Endpoint: "POST /graphql", -} - func (u UpcomingChanges) Name() string { return u.API } // FileURL is the file at a commit: its own provenance. diff --git a/kinds/catalog/upcoming_test.go b/kinds/catalog/upcoming_test.go new file mode 100644 index 0000000..f8e099f --- /dev/null +++ b/kinds/catalog/upcoming_test.go @@ -0,0 +1,30 @@ +package catalog + +import ( + "fmt" + "strings" + "testing" +) + +// An input object's field and a root field's argument are request +// parameters of POST /graphql; any other location is a property of its type. +func TestUpcomingChangesLocations(t *testing.T) { + for loc, want := range map[string]string{ + "AddPullRequestReviewInput.comments": "request_parameter POST /graphql AddPullRequestReviewInput.comments", + "Query.sponsorables.dependencyEcosystem": "request_parameter POST /graphql Query.sponsorables.dependencyEcosystem", + "RepositoryPermission.TRIAGE_PLUS": "schema_property RepositoryPermission TRIAGE_PLUS", + "Issue.stateReason.enableDuplicate": "schema_property Issue stateReason.enableDuplicate", + } { + s, ok := graphql.subject(loc) + got := strings.Join(strings.Fields(fmt.Sprintf("%s %s %s %s", s.Kind, s.Operation, s.Schema, s.Property)), " ") + if !ok || got != want { + t.Errorf("%s: %q, want %q", loc, got, want) + } + } + if _, ok := graphql.subject("NoDot"); ok { + t.Error("a location without a field isn't read") + } +} + +// graphql is an UpcomingChanges like GitHub's GraphQL API's. +var graphql = UpcomingChanges{API: "github/graphql", Vendor: "GitHub", Repo: "github/docs", Path: "src/graphql/data/fpt/upcoming-changes.json", Endpoint: "POST /graphql"} diff --git a/plugins/changelog/changelog.go b/kinds/changelog/changelog.go similarity index 84% rename from plugins/changelog/changelog.go rename to kinds/changelog/changelog.go index 4fc4714..63121a8 100644 --- a/plugins/changelog/changelog.go +++ b/kinds/changelog/changelog.go @@ -38,38 +38,6 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/versions" ) -func init() { - plugin.RegisterProvider(plugin.Provider{ - ID: "textual", Name: "Textual", Category: plugin.CategoryPackages, Homepage: "https://textual.textualize.io", - Sources: []plugin.Source{{ - ID: "textual", Layer: plugin.LayerPackage, Page: "providers/textual.md", - Watches: "Names removed, renamed or deprecated in each release, from the release's section of CHANGELOG.md at its tag", - URLs: []string{"https://github.com/Textualize/textual/blob/main/CHANGELOG.md", "https://pypi.org/project/textual/"}, - Packages: []string{"pypi:textual"}, - Plugin: Plugin{File: Textual}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "urllib3", Name: "urllib3", Category: plugin.CategoryPackages, Homepage: "https://urllib3.readthedocs.io", - Sources: []plugin.Source{{ - ID: "urllib3", Layer: plugin.LayerPackage, Page: "providers/urllib3.md", - Watches: "Names removed or deprecated in each release, from the release's section of CHANGES.rst at its tag", - URLs: []string{"https://github.com/urllib3/urllib3/blob/main/CHANGES.rst", "https://pypi.org/project/urllib3/"}, - Packages: []string{"pypi:urllib3"}, - Plugin: Plugin{File: Urllib3}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "mongodb", Name: "MongoDB", Category: plugin.CategoryDatabases, Homepage: "https://www.mongodb.com", - Sources: []plugin.Source{{ - ID: "atlas-admin-api", Layer: plugin.LayerAPI, Page: "providers/mongodb-atlas.md", - Watches: "Atlas Administration API versions deprecated and removed at their sunset date, per endpoint, from MongoDB's own API changelog", - URLs: []string{"https://github.com/mongodb/openapi/blob/main/changelog/changelog.json"}, - Plugin: Plugin{Log: MongoDBAtlas}, - }}, - }) -} - // File is one package's changelog. Unpinned (Tag and Release empty), it is // read release by release: every version on the package registry (PyPI, npm) // or, for an ecosystem patch-it doesn't list (Go, Maven, NuGet, RubyGems, @@ -97,22 +65,6 @@ func (f File) At(release string) File { return f } -// Textual is Textual's Keep a Changelog CHANGELOG.md (checked 2026-11-14 at -// v0.86.0: "## [0.86.0] - 2024-11-16", "### Removed", and "Breaking change:" -// bullets under "### Changed"), tagged v. -var Textual = File{ - API: "textual/textual", Package: "textual", Ecosystem: "pypi", Module: "textual", - Repo: "Textualize/textual", TagPrefix: "v", Path: "CHANGELOG.md", -} - -// Urllib3 is urllib3's CHANGES.rst (checked 2026-11-14 at 2.0.0: "2.0.0 -// (2023-04-26)" over "=====", "Removed" and "Deprecated" over "-----"), -// tagged . -var Urllib3 = File{ - API: "urllib3/urllib3", Package: "urllib3", Ecosystem: "pypi", Module: "urllib3", - Repo: "urllib3/urllib3", Path: "CHANGES.rst", -} - // URL is what ReadAt fetches: the changelog as it was at the (pinned) tag, // or the tag's release on GitHub's API. func (f File) URL() string { diff --git a/kinds/changelog/changelog_test.go b/kinds/changelog/changelog_test.go new file mode 100644 index 0000000..bfab36d --- /dev/null +++ b/kinds/changelog/changelog_test.go @@ -0,0 +1,66 @@ +package changelog + +import ( + "errors" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" +) + +// A Go module's events name the module as code imports it at that major. +func TestAGoModuleIsNamedByItsMajor(t *testing.T) { + f := File{Package: "github.com/acme/acme-go", Ecosystem: "go"} + for release, want := range map[string]string{"73.0.0": "github.com/acme/acme-go/v73", "1.4.0": "github.com/acme/acme-go", "0.31.0": "github.com/acme/acme-go"} { + if got := f.At(release).installed(); got != want { + t.Errorf("%s: %s, want %s", release, got, want) + } + } +} + +// A release's notes on GitHub are read whole: any heading level starts a +// section, a code fence is skipped, and notes for another tag or none at +// all are never read as "no breaking changes". +func TestReleaseNotesAreReadWhole(t *testing.T) { + f := File{Package: "acme", Repo: "acme/acme", TagPrefix: "v", Notes: true}.At("2.0.0") + body := "## BREAKING CHANGES\\n\\n* `acme.old()` has been removed\\n\\n```\\n- `acme.example()` has been removed\\n```\\n\\n### Features\\n\\n* add `acme.new()`\\n" + _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "name": "v2.0.0", "body": "` + body + `"}`)) + if err != nil { + t.Fatal(err) + } + if len(fs) != 1 || fs[0].Dropped != "" || strings.Join(fs[0].Change.Symbols, ",") != "acme.old" { + t.Errorf("findings %+v", fs) + } + if f.Cite() != "https://github.com/acme/acme/releases/tag/v2.0.0" || f.URL() != "https://api.github.com/repos/acme/acme/releases/tags/v2.0.0" { + t.Errorf("cite %s, url %s", f.Cite(), f.URL()) + } + if _, _, err := f.Read([]byte(`{"tag_name": "v1.9.0", "body": "x"}`)); err == nil { + t.Error("another release's notes: want an error") + } + if _, _, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": ""}`)); !errors.Is(err, plugin.ErrNothingToRead) { + t.Errorf("no notes: %v, want plugin.ErrNothingToRead", err) + } +} + +// A rename whose new name the same release renames again or removes points +// to where the chain ends: never to a name the release took away. +func TestRenamesAreFollowedToTheirEnd(t *testing.T) { + f := File{Package: "acme", Repo: "acme/acme", TagPrefix: "v", Notes: true}.At("2.0.0") + body := "## BREAKING CHANGES\\n\\n" + + "* `acme.a()` has been renamed to `acme.b()`\\n* `acme.b()` has been renamed to `acme.c()`\\n" + + "* `acme.x()` has been renamed to `acme.y()`\\n* `acme.y()` has been removed\\n" + + "* `acme.p()` has been renamed to `acme.q()`\\n* `acme.q()` has been renamed to `acme.p()`\\n" + + "## Deprecations\\n\\n* Deprecated `acme.d` in favor of `acme.y`\\n" + _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": "` + body + `"}`)) + if err != nil { + t.Fatal(err) + } + var got []string + for _, f := range fs { + got = append(got, strings.Join(f.Change.Symbols, ",")+">"+f.Change.Replacement) + } + want := "acme.a>acme.c acme.b>acme.c acme.x> acme.y> acme.p> acme.q> acme.d>acme.y" + if strings.Join(got, " ") != want { + t.Errorf("got %s\nwant %s", strings.Join(got, " "), want) + } +} diff --git a/kinds/changelog/changelogtest/changelogtest.go b/kinds/changelog/changelogtest/changelogtest.go new file mode 100644 index 0000000..40621e4 --- /dev/null +++ b/kinds/changelog/changelogtest/changelogtest.go @@ -0,0 +1,71 @@ +// Package changelogtest is what the tests of providers' changelog sources +// share: a release replayed as patch-it's hosted ingestion service extracts +// it, and an SDK's golden, drop test and registration in one call. +package changelogtest + +import ( + "context" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" +) + +// Release is the pair previous -> f's pinned release, as patch-it's hosted +// ingestion service extracts it. A changelog's Extract reads only the newer +// release's own section, so previous is named, not read. +func Release(t *testing.T, f changelog.File, saved, previous string) []event.Event { + t.Helper() + env := kittest.Env(t, kittest.Pages{f.URL(): saved}) + p := changelog.Plugin{File: f} + to, err := p.ReadAt(context.Background(), env, plugin.Version{ID: f.Release, Ref: f.Tag}) + if err != nil { + t.Fatal(err) + } + from := plugin.Snapshot{Version: plugin.Version{ID: previous, Ref: f.TagPrefix + previous}} + return kittest.Extracted(t, env, p, from, to) +} + +// SDKCase is one SDK's changelog, saved at a release's tag +// (testdata/README.md), and the release its golden pins: the pair from the +// release before (on the registry, or among the repo's tags) to it. drop is +// another release in the same saved file (for Notes, in dropped, its own +// saved release) whose notes name nothing removed: it must read as no event. +type SDKCase struct { + File changelog.File + Release, Prev string + Saved, Dropped string + Drop string +} + +// CheckSDKs runs each case's golden, its drop test and its registration. +func CheckSDKs(t *testing.T, cases []SDKCase) { + t.Helper() + for _, c := range cases { + t.Run(c.File.API, func(t *testing.T) { + kittest.Registered(t, changelog.Plugin{File: c.File}) + got := Release(t, c.File.At(c.Release), "testdata/"+c.Saved, c.Prev) + if len(got) == 0 { + t.Fatal("no events: the golden must pin a release with some") + } + kittest.Golden(t, "testdata/golden/"+strings.ReplaceAll(c.File.API, "/", "-")+".json", got) + + saved := c.Saved + if c.Dropped != "" { + saved = c.Dropped + } + _, fs, err := c.File.At(c.Drop).Read(kittest.Read(t, "testdata/"+saved)) + if err != nil { + t.Fatal(err) + } + for _, f := range fs { + if f.Dropped == "" { + t.Errorf("drop test %s: an event from %q", c.Drop, f.Bullet.Text) + } + } + }) + } +} diff --git a/plugins/changelog/classify.go b/kinds/changelog/classify.go similarity index 100% rename from plugins/changelog/classify.go rename to kinds/changelog/classify.go diff --git a/plugins/changelog/json.go b/kinds/changelog/json.go similarity index 93% rename from plugins/changelog/json.go rename to kinds/changelog/json.go index 9c1d6b2..5893b56 100644 --- a/plugins/changelog/json.go +++ b/kinds/changelog/json.go @@ -38,18 +38,6 @@ type Log struct { Path string // the file's path in the repo } -// MongoDBAtlas is the Atlas Administration API's changelog, -// changelog/changelog.json in mongodb/openapi (checked 2026-11-19: 188 days -// from 2023-02-01 to 2026-11-18, released by MongoDB's CI, "Release API -// Changelog", a few times a month; the docs page -// https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog/ -// is built from it). Atlas versions each resource by date (`2023-01-01`), -// chosen per request in the Accept header. -var MongoDBAtlas = Log{ - API: "mongodb/atlas-admin-api", Vendor: "MongoDB", Name: "Atlas Administration API", - Repo: "mongodb/openapi", Path: "changelog/changelog.json", -} - // URL is the file at one commit: its own provenance. func (l Log) URL(sha string) string { return fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/%s", l.Repo, sha, l.Path) diff --git a/plugins/changelog/parse.go b/kinds/changelog/parse.go similarity index 100% rename from plugins/changelog/parse.go rename to kinds/changelog/parse.go diff --git a/plugins/changelog/parse_test.go b/kinds/changelog/parse_test.go similarity index 100% rename from plugins/changelog/parse_test.go rename to kinds/changelog/parse_test.go diff --git a/plugins/changelog/pins.go b/kinds/changelog/pins.go similarity index 96% rename from plugins/changelog/pins.go rename to kinds/changelog/pins.go index 157b620..24e7de5 100644 --- a/plugins/changelog/pins.go +++ b/kinds/changelog/pins.go @@ -32,9 +32,9 @@ var statedPin = []*regexp.Regexp{ // one: "2026-11-18.endive", "2022-08-01". const apiVersion = `\d{4}-\d{2}-\d{2}(?:\.[a-z]+)?` -// pins are the versions each release of a Markdown changelog states it +// Pins are the versions each release of a Markdown changelog states it // pins, by release as its heading names it. -func pins(file []byte) map[string]string { +func Pins(file []byte) map[string]string { out, conflict := map[string]string{}, map[string]bool{} release, fenced := "", false for _, l := range strings.Split(strings.ReplaceAll(string(file), "\r\n", "\n"), "\n") { @@ -98,7 +98,7 @@ func (f File) pinned(ctx context.Context, env plugin.Env, vs []plugin.Version) [ log.Printf("%s: what its releases pin isn't read this time: %v", f.API, err) return vs } - stated := pins(page) + stated := Pins(page) for i := range vs { if v, ok := stated[vs[i].ID]; ok { vs[i].MapsTo = plugin.Pin{API: f.Pins, Version: v} diff --git a/kinds/changelog/pins_test.go b/kinds/changelog/pins_test.go new file mode 100644 index 0000000..98eaab3 --- /dev/null +++ b/kinds/changelog/pins_test.go @@ -0,0 +1,23 @@ +package changelog + +import ( + "maps" + "testing" +) + +// Two different versions in one release's section are none; a statement in +// a code block, or before the first release, is nobody's. +func TestAnUnsurePinIsNone(t *testing.T) { + got := Pins([]byte("# Changelog\nThis release changes the pinned API version to `2020-01-01`.\n" + + "## 2.0.0 - 2026-01-02\nThis release changes the pinned API version to `2026-01-01.a`.\nThis release changes the pinned API version to `2026-01-02.b`.\n" + + "## 1.1.0 - 2026-01-01\n```\nThis release changes the pinned API version to `2025-12-01.a`.\n```\n" + + "## 1.0.0 - 2025-12-01\n* This release changes the pinned API version to `2025-11-01.a`.\n")) + if want := map[string]string{"1.0.0": "2025-11-01.a"}; !maps.Equal(got, want) { + t.Errorf("got %v, want %v", got, want) + } + // A "# comment" in a code example doesn't end the release's section. + got = Pins([]byte("## 3.0.0 - 2026-02-01\n```sh\n# upgrade\n```\nThis release changes the pinned API version to `2026-02-01.c`.\n")) + if want := map[string]string{"3.0.0": "2026-02-01.c"}; !maps.Equal(got, want) { + t.Errorf("after a code block: got %v, want %v", got, want) + } +} diff --git a/plugins/changelog/sdks.go b/kinds/changelog/sdks.go similarity index 69% rename from plugins/changelog/sdks.go rename to kinds/changelog/sdks.go index a92a94d..2ab4449 100644 --- a/plugins/changelog/sdks.go +++ b/kinds/changelog/sdks.go @@ -2,14 +2,15 @@ package changelog import "github.com/patch-it-dev/patch-it-plugins/core/plugin" -// The providers' official SDKs (stripe.go, sentry.go, cloudflare.go, ...), -// each read from its own changelog at every release (or, with Notes, from its +// A provider's official SDKs (providers//provider.go) are each +// read from its own changelog at every release (or, with Notes, from its // release notes on GitHub). Every one was checked by hand: the file's path, // the tag each release is cut at, and a release whose section this reader // turns into events (each provider's test pins it). -// sdk is the source an SDK's changelog is, its metadata read off f. -func sdk(page, id string, f File, packages ...string) plugin.Source { +// SDK is the source an SDK's changelog is, its metadata read off f: id is +// the source's part of its id ("python" in "stripe/python"). +func SDK(id string, f File, packages ...string) plugin.Source { watches := "Names removed, renamed or deprecated in each release of " + f.Package + ", from the release's section of " + f.Path + " at its tag" first := "https://github.com/" + f.Repo + "/blob/HEAD/" + f.Path if f.Notes { @@ -17,7 +18,7 @@ func sdk(page, id string, f File, packages ...string) plugin.Source { first = "https://github.com/" + f.Repo + "/releases" } return plugin.Source{ - ID: id, Layer: layerOf(f), Page: page, Watches: watches, + ID: id, Layer: layerOf(f), Watches: watches, URLs: []string{first}, Packages: packages, Plugin: Plugin{File: f}, } } diff --git a/kinds/changelog/testdata/README.md b/kinds/changelog/testdata/README.md new file mode 100644 index 0000000..b1e09fd --- /dev/null +++ b/kinds/changelog/testdata/README.md @@ -0,0 +1,7 @@ +# Version lists + +What the kind's own tests read; each provider's saved changelogs are in its folder, `providers//testdata/`. + +| File | URL | Saved | License | Use | +|---|---|---|---|---| +| `versions/stripe-go-tags.json`, `versions/octokit-rest-releases.json` | https://api.github.com/repos/stripe/stripe-go/tags, https://api.github.com/repos/octokit/rest.js/releases (shape only) | written for the test, 2026-11-20 | not saved copies: a few real tag names and releases in the shape of GitHub's API (a pre-release, a draft and a tag of another series among them) | for the version-listing test only (tags for an ecosystem with no registry lister, releases for release notes); no golden reads them | diff --git a/plugins/changelog/testdata/versions/octokit-rest-releases.json b/kinds/changelog/testdata/versions/octokit-rest-releases.json similarity index 100% rename from plugins/changelog/testdata/versions/octokit-rest-releases.json rename to kinds/changelog/testdata/versions/octokit-rest-releases.json diff --git a/plugins/changelog/testdata/versions/stripe-go-tags.json b/kinds/changelog/testdata/versions/stripe-go-tags.json similarity index 100% rename from plugins/changelog/testdata/versions/stripe-go-tags.json rename to kinds/changelog/testdata/versions/stripe-go-tags.json diff --git a/kinds/changelog/versions_test.go b/kinds/changelog/versions_test.go new file mode 100644 index 0000000..214e429 --- /dev/null +++ b/kinds/changelog/versions_test.go @@ -0,0 +1,38 @@ +package changelog + +import ( + "context" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" +) + +// An ecosystem patch-it lists no registry for (Go here) lists the repo's +// TagPrefix + X.Y.Z tags; a source read from release notes lists the repo's +// published releases. Pre-releases, drafts and other tags are left out. +func TestReleasesFromTagsAndFromGitHubReleases(t *testing.T) { + env := kittest.Env(t, kittest.Pages{ + "https://api.github.com/repos/stripe/stripe-go/tags?per_page=100&page=1": "testdata/versions/stripe-go-tags.json", + "https://api.github.com/repos/octokit/rest.js/releases?per_page=100&page=1": "testdata/versions/octokit-rest-releases.json", + }) + for _, c := range []struct { + file File + want string + }{ + {File{API: "stripe/go", Ecosystem: "go", Repo: "stripe/stripe-go", TagPrefix: "v", Path: "CHANGELOG.md"}, "72.121.0@v72.121.0 72.122.0@v72.122.0 73.0.0@v73.0.0"}, + {File{API: "github/octokit-rest", Ecosystem: "npm", Repo: "octokit/rest.js", TagPrefix: "v", Notes: true}, "17.11.2@v17.11.2 18.0.0@v18.0.0"}, + } { + vs, err := Plugin{File: c.file}.ListVersions(context.Background(), env) + if err != nil { + t.Fatal(err) + } + var ids []string + for _, v := range vs { + ids = append(ids, v.ID+"@"+v.Ref) + } + if got := strings.Join(ids, " "); got != c.want { + t.Errorf("%s: %s, want %s", c.file.API, got, c.want) + } + } +} diff --git a/plugins/migrationguide/members/export_test.go b/kinds/migrationguide/members/export_test.go similarity index 65% rename from plugins/migrationguide/members/export_test.go rename to kinds/migrationguide/members/export_test.go index b5dbb04..e08c058 100644 --- a/plugins/migrationguide/members/export_test.go +++ b/kinds/migrationguide/members/export_test.go @@ -7,6 +7,4 @@ var ( SoleName = soleName ) -func (g Guide) TagOf(release string) string { return g.tagOf(release) } -func (g Guide) CommitsURL(major int) string { return g.commitsURL(major) } func (g Guide) AbsoluteLinks(s string) string { return g.absoluteLinks(s) } diff --git a/plugins/migrationguide/members/markdown.go b/kinds/migrationguide/members/markdown.go similarity index 100% rename from plugins/migrationguide/members/markdown.go rename to kinds/migrationguide/members/markdown.go diff --git a/kinds/migrationguide/members/markdown_test.go b/kinds/migrationguide/members/markdown_test.go new file mode 100644 index 0000000..041002a --- /dev/null +++ b/kinds/migrationguide/members/markdown_test.go @@ -0,0 +1,176 @@ +package members_test + +import ( + "errors" + "os" + "path/filepath" + "slices" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + . "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" // the reader under test + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/migrationguidetest" +) + +// A replacement cell that is a Markdown link around one code span is read as +// that name; a link inside prose, or around more than a code span, isn't. +func TestSoleNameReadsALinkedName(t *testing.T) { + for cell, want := range map[string]string{ + "`new_fn`": "new_fn", + "[`new_fn`](/docs/new-fn)": "new_fn", + " [`acme.new_fn()`](https://x.test/a) ": "new_fn", + "[`new_fn`](/docs/new-fn#anchor)": "new_fn", + "Use [`new_fn`](/docs/new-fn)": "", + "[`new_fn`](/docs/new-fn) instead": "", + "[the `new_fn` API](/docs/new-fn)": "", + "[`new_fn`]": "", + "[`x=1`](/docs/x)": "", + "[`a`](/a) and [`b`](/b)": "", + } { + if got := SoleName(cell, "acme"); got != want { + t.Errorf("SoleName(%q) = %q, want %q", cell, got, want) + } + } +} + +// Without DropIns every one-replacement row is a rename, as NumPy's are; with +// it, only the listed ones. Paths applies to the replacement as to the name. +func TestDropInsLimitsRenames(t *testing.T) { + page := strings.Join([]string{ + "## Removed", + "| Removed | Use instead |", + "| --- | --- |", + "| `old_a` | [`new_a`](/a) |", + "| `old_b` | `new_b` |", + }, "\n") + g := Guide{API: "acme/sdk", Package: "acme", Module: "acme", Repo: "acme/acme", Path: "MIGRATION.md", + Section: "Removed", Format: FormatMarkdown, Header: "Removed", + Paths: map[string]string{"old_a": "mod.old_a", "new_a": "mod.new_a"}} + run := func(g Guide) map[string]string { + out := map[string]string{} + for _, e := range migrationguidetest.Release(t, migrationguidetest.GuideEnv(t, g, writeTemp(t, page), "2.0.0"), g, "1.9.0", "2.0.0") { + out[e.Subject.Symbols[0]] = string(e.Subject.Change) + " " + e.Subject.Replacement + } + return out + } + if got := run(g); got["mod.old_a"] != "renamed_symbol mod.new_a" || got["old_b"] != "renamed_symbol new_b" { + t.Errorf("no DropIns: %v", got) + } + g.DropIns = []string{"mod.old_a"} + if got := run(g); got["mod.old_a"] != "renamed_symbol mod.new_a" || got["old_b"] != "removed_symbol " { + t.Errorf("DropIns mod.old_a: %v", got) + } +} + +func writeTemp(t *testing.T, page string) string { + t.Helper() + f := filepath.Join(t.TempDir(), "guide.md") + if err := os.WriteFile(f, []byte(page), 0o644); err != nil { + t.Fatal(err) + } + return f +} + +// The hint is shown in a pull request or an issue, where a site-relative link +// breaks: LinkBase makes the guide's links absolute, and leaves the rest. +func TestAbsoluteLinks(t *testing.T) { + g := Guide{LinkBase: "https://docs.newrelic.com/"} + in := "Replacement API: [`notice_error()`](/docs/x/notice_error), see [here](https://example.test/y)" + want := "Replacement API: [`notice_error()`](https://docs.newrelic.com/docs/x/notice_error), see [here](https://example.test/y)" + if got := g.AbsoluteLinks(in); got != want { + t.Errorf("got %q, want %q", got, want) + } + if got := (Guide{}).AbsoluteLinks(in); got != in { + t.Errorf("no LinkBase changed the hint: %q", got) + } +} + +func TestPipeCells(t *testing.T) { + for row, want := range map[string][]string{ + "| Removed | Use instead |": {"Removed", "Use instead"}, + "| --- | --- |": {"---", "---"}, + "| `a`, `b` | Nothing |": {"`a`, `b`", "Nothing"}, + "| `x | y` | a \\| b |": {"`x | y`", "a | b"}, + "|`a`|`b`|": {"`a`", "`b`"}, + "| `request.batch_post`, `EVENTS_ENDPOINT` |": {"`request.batch_post`, `EVENTS_ENDPOINT`"}, + "| one | two | three |": {"one", "two", "three"}, + } { + if got := PipeCells(row); !slices.Equal(got, want) { + t.Errorf("PipeCells(%q) = %q, want %q", row, got, want) + } + } +} + +func TestMarkdownTable(t *testing.T) { + g := Guide{Package: "acme", Module: "acme", Section: "Removed", Format: FormatMarkdown, Header: "Removed", EnvVars: []string{"ACME_MODE"}} + page := strings.Join([]string{ + "# Guide", + "## Removed", + "```python", + "# not a heading", + "```", + "Text before the table.", + "", + "| Removed | Use instead |", + "| :--- | ---: |", + "| `acme.old_fn()` | `acme.new_fn` |", + "| `A`, `B`, and `ACME_MODE` | Nothing |", + "| `C` | `D` and `E` |", + "| `F` | Use `G` instead |", + "| `same` | `same` |", + "| `x=1` | `y` |", + "| The `dep` dependency | Nothing |", + "| `short` |", + "", + "| Removed | Use instead |", + "| --- | --- |", + "| `not_read` | `the second table` |", + }, "\n") + rs, err := Parse([]byte(page), g) + if err != nil { + t.Fatal(err) + } + type row struct{ member, replacement, dropped string } + var got []row + for _, r := range rs { + d := "" + if r.Dropped != "" { + d = "dropped" + } + got = append(got, row{r.Member, r.Replacement, d}) + } + want := []row{ + {"old_fn", "new_fn", ""}, + {"A", "", ""}, + {"B", "", ""}, + {"ACME_MODE", "", "dropped"}, + {"C", "", ""}, + {"F", "", ""}, + {"same", "", ""}, + {"`x=1`", "", "dropped"}, + {"The `dep` dependency", "", "dropped"}, + {"| `short` |", "", "dropped"}, + } + if !slices.Equal(got, want) { + t.Errorf("got\n%v\nwant\n%v", got, want) + } + if rs[0].Guideline != "Use instead: `acme.new_fn`" || + rs[0].Excerpt != "Removed\n| Removed | Use instead |\n| :--- | ---: |\n| `acme.old_fn()` | `acme.new_fn` |" { + t.Errorf("%+v", rs[0]) + } + + for name, c := range map[string]struct { + page string + nothing bool // plugin.ErrNothingToRead: no part to read, not a guide that changed shape + }{ + "no section": {"## Other\n| Removed | Use instead |\n| --- | --- |\n| `a` | b |", true}, + "no table": {"## Removed\ntext\n## Next\n| Removed | Use instead |\n| --- | --- |\n| `a` | b |", true}, + "another table": {"## Removed\n| Method | Endpoint |\n| --- | --- |\n| `a` | b |", false}, + } { + _, err := Parse([]byte(c.page), g) + if err == nil || errors.Is(err, plugin.ErrNothingToRead) != c.nothing { + t.Errorf("%s: err %v, want an error that is plugin.ErrNothingToRead: %v", name, err, c.nothing) + } + } +} diff --git a/plugins/migrationguide/members/members.go b/kinds/migrationguide/members/members.go similarity index 93% rename from plugins/migrationguide/members/members.go rename to kinds/migrationguide/members/members.go index 7e029af..9122981 100644 --- a/plugins/migrationguide/members/members.go +++ b/kinds/migrationguide/members/members.go @@ -1,7 +1,7 @@ // Package members is the migration-guide kind's reader for a package release // that removed members of its top-level module, read from the release's own // migration guide at its tag: change event v2's `package_release` subject. -// The kind (plugins/migrationguide) reads the guide and calls Read; this +// The kind (kinds/migrationguide) reads the guide and calls Read; this // package knows where the guide is and how its table reads. A guide is read // at the first release of each major (X.0.0), listed from PyPI: nothing in // the code names a release. NumPy first: its 2.0 guide lists about 60 @@ -121,8 +121,8 @@ const ( FormatMarkdown Format = "markdown" ) -// tagOf is the git tag of a release of the package. -func (g Guide) tagOf(release string) string { +// TagOf is the git tag of a release of the package. +func (g Guide) TagOf(release string) string { if g.TagPrefix != "" { return g.TagPrefix + release } @@ -143,26 +143,13 @@ func (g Guide) header() string { return "removed member" } -// NumPy is NumPy's migration guide to a major, "Main namespace" table -// (doc/source/numpy_2_0_migration_guide.rst at v2.0.0, checked 2026-11-04; -// no other major has one yet, checked 2026-11-20). -var NumPy = Guide{ - API: "numpy/numpy", - Package: "numpy", - Module: "np", - Repo: "numpy/numpy", - Path: "doc/source/numpy_{major}_0_migration_guide.rst", - Section: "Main namespace", - Effect: "code using it raises AttributeError", -} - // PathAt is the guide's path for a major. func (g Guide) PathAt(major int) string { return strings.NewReplacer("{major}", strconv.Itoa(major), "{prev}", strconv.Itoa(major-1)).Replace(g.Path) } -// commitsURL lists the newest commit that changed a major's guide. -func (g Guide) commitsURL(major int) string { +// CommitsURL lists the newest commit that changed a major's guide. +func (g Guide) CommitsURL(major int) string { return fmt.Sprintf("%s/repos/%s/commits?path=%s&per_page=1", github.API, g.Repo, url.QueryEscape(g.PathAt(major))) } @@ -273,7 +260,7 @@ func (g Guide) Releases(ctx context.Context, env plugin.Env) ([]plugin.Version, return nil, err } for i := range vs { - vs[i].Ref = g.tagOf(vs[i].ID) + vs[i].Ref = g.TagOf(vs[i].ID) } return vs, nil } @@ -288,9 +275,9 @@ func (g Guide) GuideURL(ctx context.Context, env plugin.Env, v plugin.Version) ( } major := versions.Major(v.ID) if !g.Untagged { - return g.RawURL(g.tagOf(v.ID), major), nil + return g.RawURL(g.TagOf(v.ID), major), nil } - sha, err := github.LatestCommit(ctx, env.Get, g.commitsURL(major)) + sha, err := github.LatestCommit(ctx, env.Get, g.CommitsURL(major)) if err != nil { return "", fmt.Errorf("the commit %s's guide for %s is read at: %w", g.Package, v.ID, err) } diff --git a/plugins/migrationguide/migrationguide.go b/kinds/migrationguide/migrationguide.go similarity index 59% rename from plugins/migrationguide/migrationguide.go rename to kinds/migrationguide/migrationguide.go index fa95a49..1c75bd5 100644 --- a/plugins/migrationguide/migrationguide.go +++ b/kinds/migrationguide/migrationguide.go @@ -20,53 +20,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/sdkguide" ) -func init() { - plugin.RegisterProvider(plugin.Provider{ - ID: "anthropic", Name: "Anthropic", Category: plugin.CategoryAI, Homepage: "https://www.anthropic.com", - Sources: []plugin.Source{{ - ID: "python-sdk", Layer: plugin.LayerSDK, Page: "providers/anthropic.md", - Watches: "Request parameters each new major of the Python SDK removes from `messages.create()` and friends, from MIGRATION.md at the major's tag", - URLs: []string{"https://github.com/anthropics/anthropic-sdk-python/blob/main/MIGRATION.md", "https://pypi.org/project/anthropic/"}, - Packages: []string{"pypi:anthropic"}, - Plugin: Plugin{Guide: sdkguide.Anthropic}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "numpy", Name: "NumPy", Category: plugin.CategoryPackages, Homepage: "https://numpy.org", - Sources: []plugin.Source{{ - ID: "numpy", Layer: plugin.LayerPackage, Page: "providers/numpy.md", - Watches: "Members a new major removes or renames in the main namespace, from that major's migration guide at its first tag", - URLs: []string{"https://numpy.org/devdocs/numpy_2_0_migration_guide.html", "https://pypi.org/project/numpy/"}, - Packages: []string{"pypi:numpy"}, - Plugin: Plugin{Guide: members.NumPy}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "posthog", Name: "PostHog", Category: plugin.CategoryAnalytics, Homepage: "https://posthog.com", - Sources: []plugin.Source{{ - ID: "python-sdk", Layer: plugin.LayerSDK, Page: "providers/posthog.md", - Watches: "Members a new major of the posthog Python SDK removes, from its migration guide in docs/ at the major's first tag", - URLs: []string{"https://github.com/PostHog/posthog-python/tree/main/docs", "https://pypi.org/project/posthog/"}, - Packages: []string{"pypi:posthog"}, - Plugin: Plugin{Guide: members.PostHog}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "newrelic", Name: "New Relic", Category: plugin.CategoryMonitoring, Homepage: "https://newrelic.com", - Sources: []plugin.Source{{ - ID: "python-agent", Layer: plugin.LayerSDK, Page: "providers/newrelic.md", - Watches: "Members a new major of the New Relic Python agent removes, from the major's release notes (Removed features)", - URLs: []string{"https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes/", "https://pypi.org/project/newrelic/"}, - Packages: []string{"pypi:newrelic"}, - Plugin: Plugin{Guide: members.NewRelic}, - }}, - }) -} - // Guide is one source's migration guide: which releases there are, where the // guide is at each, and how its table reads. sdkguide.Guide and // members.Guide are the two readers. diff --git a/kinds/migrationguide/migrationguidetest/migrationguidetest.go b/kinds/migrationguide/migrationguidetest/migrationguidetest.go new file mode 100644 index 0000000..820abd2 --- /dev/null +++ b/kinds/migrationguide/migrationguidetest/migrationguidetest.go @@ -0,0 +1,40 @@ +// Package migrationguidetest is what the tests of migration-guide sources +// share: a guide saved as a file, served where the source reads it, and the +// pair to the major it describes, extracted as patch-it's hosted ingestion +// service does. +package migrationguidetest + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" +) + +// Release is the pair previous -> rel, the first release of a major, read +// through env, as patch-it's hosted ingestion service extracts it. previous +// isn't a major's first release: it has no guide, and nothing is fetched for +// it. +func Release(t *testing.T, env plugin.Env, g migrationguide.Guide, previous, rel string) []event.Event { + t.Helper() + return kittest.Versions(t, env, migrationguide.Plugin{Guide: g}, plugin.Version{ID: previous}, plugin.Version{ID: rel}) +} + +// GuideEnv serves file as g's guide for rel, at rel's tag. +func GuideEnv(t *testing.T, g members.Guide, file, rel string) plugin.Env { + t.Helper() + return kittest.Env(t, kittest.Pages{g.RawURL(g.TagOf(rel), versions.Major(rel)): file}) +} + +// UntaggedEnv serves file as an Untagged guide's for rel, at commit, and +// commits (a saved file) as GitHub's answer naming commit the newest that +// changed the guide. +func UntaggedEnv(t *testing.T, g members.Guide, file, rel, commits, commit string) plugin.Env { + t.Helper() + major := versions.Major(rel) + return kittest.Env(t, kittest.Pages{g.CommitsURL(major): commits, g.RawURL(commit, major): file}) +} diff --git a/plugins/migrationguide/sdkguide/sdkguide.go b/kinds/migrationguide/sdkguide/sdkguide.go similarity index 94% rename from plugins/migrationguide/sdkguide/sdkguide.go rename to kinds/migrationguide/sdkguide/sdkguide.go index cc02580..0cf91a2 100644 --- a/plugins/migrationguide/sdkguide/sdkguide.go +++ b/kinds/migrationguide/sdkguide/sdkguide.go @@ -37,16 +37,6 @@ type Guide struct { Symbols []string } -// Anthropic is anthropic-sdk-python's MIGRATION.md, unpinned: read at the -// first release of each major (Major 0; At pins it). -var Anthropic = Guide{ - API: "anthropic/python-sdk", - Package: "anthropic", - Repo: "anthropics/anthropic-sdk-python", - Methods: "`messages.create()`", - Symbols: []string{"messages.create", "messages.stream", "messages.parse"}, -} - // At is g pinned to one major. func (g Guide) At(major int) Guide { g.Major = major diff --git a/plugins/migrationguide/sdkguide/versions.go b/kinds/migrationguide/sdkguide/versions.go similarity index 95% rename from plugins/migrationguide/sdkguide/versions.go rename to kinds/migrationguide/sdkguide/versions.go index 7a7f5fe..20a6b73 100644 --- a/plugins/migrationguide/sdkguide/versions.go +++ b/kinds/migrationguide/sdkguide/versions.go @@ -9,7 +9,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/versions" ) -// What the migration-guide kind (plugins/migrationguide) asks of a guide. +// What the migration-guide kind (kinds/migrationguide) asks of a guide. // Slug is the source id the events carry: "anthropic/python-sdk". func (g Guide) Slug() string { return g.API } diff --git a/plugins/notices/eol/eol.go b/kinds/notices/eol/eol.go similarity index 91% rename from plugins/notices/eol/eol.go rename to kinds/notices/eol/eol.go index 4c9d852..9f86218 100644 --- a/plugins/notices/eol/eol.go +++ b/kinds/notices/eol/eol.go @@ -1,5 +1,5 @@ // Package eol is the notices kind's reader for a vendor's own API -// end-of-life page (plugins/notices reads it, snapshots and cites it): a +// end-of-life page (kinds/notices reads it, snapshots and cites it): a // table of whole version ranges, each with a support status. One event per // version number a row says is already retired (breaking) or scheduled to be // (deprecation); a row that only says "Supported." names nothing to report. @@ -52,19 +52,6 @@ type Page struct { Operation func(version string) string } -// Salesforce is the REST API's end-of-life policy page (checked 2026-11-20): -// a table of version ranges, each "Supported.", already retired ("As of -// Summer '25, these versions are retired and unavailable."), or scheduled -// ("Deprecated and unsupported from Summer '27. Retired from Summer '28."). -// Salesforce gives no exact date, only the named release ("Summer '27"); the -// policy text above the table says the notice is at least a year ahead of -// retirement. -var Salesforce = Page{ - API: "salesforce/rest-api", Vendor: "Salesforce", - URL: "https://developer.salesforce.com/docs/platform/api-rest/guide/api-rest-eol.html", - Operation: func(v string) string { return "GET /services/data/v" + v + "/" }, -} - // Row is one version range and what its status cell says, cleaned of HTML. type Row struct { From, To int // inclusive, both ends; From == To for a single version @@ -172,7 +159,7 @@ func Findings(page []byte) ([]Finding, error) { return out, nil } -// What the notices kind (plugins/notices) asks of an end-of-life page. +// What the notices kind (kinds/notices) asks of an end-of-life page. // Read is what one read of a page found, dropped rows included. type Read []Finding diff --git a/plugins/notices/feed/extract.go b/kinds/notices/feed/extract.go similarity index 100% rename from plugins/notices/feed/extract.go rename to kinds/notices/feed/extract.go diff --git a/plugins/notices/feed/feed.go b/kinds/notices/feed/feed.go similarity index 95% rename from plugins/notices/feed/feed.go rename to kinds/notices/feed/feed.go index 7ef01ba..9f140c3 100644 --- a/plugins/notices/feed/feed.go +++ b/kinds/notices/feed/feed.go @@ -1,5 +1,5 @@ // Package feed is the notices kind's reader for a vendor's RSS or Atom -// changelog feed (plugins/notices reads it, snapshots and cites it): one event per breaking or deprecation entry (or per name such an +// changelog feed (kinds/notices reads it, snapshots and cites it): one event per breaking or deprecation entry (or per name such an // entry lists), quoting the line that says so. Rung 3 of the source ladder. // // A feed is prose, so each feed comes with a Reader that knows what its @@ -67,7 +67,7 @@ func (f Feed) Findings(b []byte) ([]Finding, error) { return out, nil } -// What the notices kind (plugins/notices) asks of a feed. +// What the notices kind (kinds/notices) asks of a feed. // Findings are what one read of a feed found, dropped entries included. type Findings []Finding diff --git a/kinds/notices/feed/feed_test.go b/kinds/notices/feed/feed_test.go new file mode 100644 index 0000000..4193067 --- /dev/null +++ b/kinds/notices/feed/feed_test.go @@ -0,0 +1,33 @@ +package feed + +import ( + "testing" +) + +func TestParseRefusesWhatIsntAFeed(t *testing.T) { + for name, b := range map[string]string{ + "html": "moved", + "no items": `x`, + "no entry": `x`, + } { + if _, err := Parse([]byte(b)); err == nil { + t.Errorf("%s: want an error, never zero events read as a quiet week", name) + } + } +} + +// RSS without content:encoded falls back to description; Atom takes the +// alternate link and the category terms. +func TestParseReadsBothFormats(t *testing.T) { + r, err := Parse([]byte(`A & Bhttps://x.test/a + Retired<p>text</p>`)) + if err != nil || r[0].Title != "A & B" || r[0].HTML != "

text

" || r[0].Categories[0] != "Retired" || r[0].ID != "https://x.test/a" { + t.Errorf("rss: %+v %v", r, err) + } + a, err := Parse([]byte(`iT + + <b>s</b>`)) + if err != nil || a[0].Link != "https://x.test/e" || a[0].HTML != "s" || a[0].Categories[0] != "Deprecated" { + t.Errorf("atom: %+v %v", a, err) + } +} diff --git a/kinds/notices/feed/helpers.go b/kinds/notices/feed/helpers.go new file mode 100644 index 0000000..c269a79 --- /dev/null +++ b/kinds/notices/feed/helpers.go @@ -0,0 +1,59 @@ +package feed + +import ( + "regexp" + "strings" + + "github.com/patch-it-dev/patch-it-plugins/core/event" +) + +var ( + willStop = regexp.MustCompile(`(?i)\bwill be (retired|removed|shut down|discontinued)\b`) + willSoften = regexp.MustCompile(`(?i)\b(will be deprecated|is deprecated|are deprecated|before)\b`) + + // ListItem is an HTML list item; its text is the first group. + ListItem = regexp.MustCompile(`(?is)
  • (.*?)
  • `) +) + +// Marked reports whether one of an entry's labels is one of words, in any +// case. +func Marked(labels []string, words ...string) bool { + for _, l := range labels { + for _, w := range words { + if strings.EqualFold(l, w) { + return true + } + } + } + return false +} + +// Dated is the first line holding a date and saying what happens on it: +// breaking when the thing stops on the date, deprecation when the vendor only +// asks to move by it. "" when no line says either. +func Dated(lines []string) (line, date string, ct event.ChangeType) { + for _, l := range lines { + // The date after the words, not the first on the line: "deprecated + // as of February 23, 2026 and will be shut down on August 23, 2026". + if m := willStop.FindStringIndex(l); m != nil { + if d := Date(l[m[1]:]); d != "" { + return l, d, event.ChangeTypeBreaking + } + } + if m := willSoften.FindStringIndex(l); m != nil { + if d := Date(l[m[1]:]); d != "" { + return l, d, event.ChangeTypeDeprecation + } + } + } + return "", "", "" +} + +// Excerpt is lines as one quote, capped at the contract's 2000 characters. +func Excerpt(lines ...string) string { + s := strings.Join(lines, "\n") + if r := []rune(s); len(r) > 2000 { + s = string(r[:1999]) + "…" + } + return s +} diff --git a/plugins/notices/notices.go b/kinds/notices/notices.go similarity index 65% rename from plugins/notices/notices.go rename to kinds/notices/notices.go index 16d48ce..2ab52db 100644 --- a/plugins/notices/notices.go +++ b/kinds/notices/notices.go @@ -34,83 +34,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/kit" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/eol" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/feed" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" ) -func init() { - plugin.RegisterProvider(plugin.Provider{ - ID: "openai", Name: "OpenAI", Category: plugin.CategoryAI, Homepage: "https://openai.com", - Sources: []plugin.Source{{ - ID: "models", Layer: plugin.LayerAIModels, Page: "providers/openai-models.md", - Watches: "Model deprecations and shutdown dates (Chat Completions and Responses text models)", - URLs: []string{"https://developers.openai.com/api/docs/deprecations"}, - Packages: []string{"pypi:openai", "npm:openai"}, - Plugin: Plugin{Page: retire.OpenAI, Archiver: kit.Wayback{}}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "anthropic", Name: "Anthropic", Category: plugin.CategoryAI, Homepage: "https://www.anthropic.com", - Sources: []plugin.Source{{ - ID: "models", Layer: plugin.LayerAIModels, Page: "providers/anthropic-models.md", - Watches: "Model deprecations and retirement dates (Messages API models)", - URLs: []string{"https://platform.claude.com/docs/en/about-claude/model-deprecations"}, - Packages: []string{"pypi:anthropic", "npm:@anthropic-ai/sdk"}, - Plugin: Plugin{Page: retire.Anthropic, Archiver: kit.Wayback{}}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "github", Name: "GitHub", Category: plugin.CategoryDevTools, Homepage: "https://github.com", - Sources: []plugin.Source{{ - ID: "actions", Layer: plugin.LayerCI, Page: "providers/github-actions.md", - Watches: "GitHub Actions retirements, such as runner images and the `runs-on` labels they remove", - URLs: []string{"https://github.blog/changelog/label/actions/feed/"}, - Plugin: Plugin{Page: feed.GitHubActions, Archiver: kit.Wayback{}}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "google", Name: "Google", Category: plugin.CategoryAI, Homepage: "https://cloud.google.com", - Sources: []plugin.Source{{ - ID: "vertex-ai-models", Layer: plugin.LayerAIModels, Page: "providers/vertex-ai-models.md", - Watches: "Generative AI model deprecations on Vertex AI", - URLs: []string{"https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml"}, - Plugin: Plugin{Page: feed.VertexAIModels, Archiver: kit.Wayback{}}, - }, { - ID: "gemini-models", Layer: plugin.LayerAIModels, Page: "providers/google-gemini-models.md", - Watches: "Gemini API model shutdown dates (the earliest Google gives) and their replacements, from Google's own deprecations table", - URLs: []string{"https://ai.google.dev/gemini-api/docs/deprecations", "https://aistudio.google.com/docs/deprecations"}, - Packages: []string{"pypi:google-genai", "npm:@google/genai"}, - Plugin: Plugin{Page: retire.Gemini, Archiver: kit.Wayback{}}, - }, { - ID: "vertex-model-retirements", Layer: plugin.LayerAIModels, Page: "providers/google-vertex-model-retirements.md", - Watches: "Vertex AI (Gemini Enterprise Agent Platform) model retirement dates and replacements, from Google Cloud's model versions tables", - URLs: []string{"https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions"}, - Packages: []string{"pypi:google-genai", "pypi:google-cloud-aiplatform", "npm:@google/genai"}, - Plugin: Plugin{Page: retire.Vertex, Archiver: kit.Wayback{}}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "cloudflare", Name: "Cloudflare", Category: plugin.CategoryInfrastructure, Homepage: "https://www.cloudflare.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/cloudflare.md", - Watches: "REST API operations Cloudflare deprecates, breaking on their end-of-life date when it gives one", - URLs: []string{"https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml"}, - Packages: []string{"pypi:cloudflare", "npm:cloudflare"}, - Plugin: Plugin{Page: feed.CloudflareAPI, Archiver: kit.Wayback{}}, - }}, - }) - plugin.RegisterProvider(plugin.Provider{ - ID: "salesforce", Name: "Salesforce", Category: plugin.CategoryCRM, Homepage: "https://www.salesforce.com", - Sources: []plugin.Source{{ - ID: "rest-api", Layer: plugin.LayerAPI, Page: "providers/salesforce.md", - Watches: "REST API version ranges deprecated and retired, from Salesforce's own API end-of-life policy page", - URLs: []string{"https://developer.salesforce.com/docs/platform/api-rest/guide/api-rest-eol.html"}, - Plugin: Plugin{Page: eol.Salesforce, Archiver: kit.Wayback{}}, - }}, - }) -} - // Page is one live page of notices and how it reads: retire.Page, // feed.Feed and eol.Page. type Page interface { diff --git a/kinds/notices/noticestest/noticestest.go b/kinds/notices/noticestest/noticestest.go new file mode 100644 index 0000000..53253a5 --- /dev/null +++ b/kinds/notices/noticestest/noticestest.go @@ -0,0 +1,27 @@ +// Package noticestest is what the tests of providers' notices sources +// share: a saved page through the whole plugin, against its golden file. +package noticestest + +import ( + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" +) + +// Golden reads the page saved as file through the whole plugin and compares +// every event with testdata/golden/.json. The archive +// serves the same copy as the snapshot, so the events cite it; kittest's +// second read of the unchanged page asks for no second snapshot and stores +// nothing new. +func Golden(t *testing.T, page notices.Page, file string) { + t.Helper() + saved := kittest.Pages{page.PageURL(): file} + archive := &kittest.Archive{T: t, Pages: saved} + got := kittest.Page(t, kittest.Env(t, saved), notices.Plugin{Page: page, Archiver: archive}) + if archive.Calls != 1 { + t.Errorf("%d snapshots, want 1: the second read's page is unchanged", archive.Calls) + } + kittest.Golden(t, "testdata/golden/"+strings.ReplaceAll(page.Slug(), "/", "-")+".json", got) +} diff --git a/plugins/notices/retire/formats.go b/kinds/notices/retire/formats.go similarity index 100% rename from plugins/notices/retire/formats.go rename to kinds/notices/retire/formats.go diff --git a/plugins/notices/retire/notices.go b/kinds/notices/retire/notices.go similarity index 94% rename from plugins/notices/retire/notices.go rename to kinds/notices/retire/notices.go index 9b941b8..774b9b9 100644 --- a/plugins/notices/retire/notices.go +++ b/kinds/notices/retire/notices.go @@ -7,7 +7,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit" ) -// What the notices kind (plugins/notices) asks of a deprecations page. +// What the notices kind (kinds/notices) asks of a deprecations page. // Retirements are what one read of a page found. type Retirements []Retirement diff --git a/plugins/notices/retire/retire.go b/kinds/notices/retire/retire.go similarity index 100% rename from plugins/notices/retire/retire.go rename to kinds/notices/retire/retire.go diff --git a/kinds/notices/retire/retire_test.go b/kinds/notices/retire/retire_test.go new file mode 100644 index 0000000..74a927e --- /dev/null +++ b/kinds/notices/retire/retire_test.go @@ -0,0 +1,88 @@ +package retire + +import ( + "errors" + "strings" + "testing" + "time" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" +) + +func TestTableEdgeCases(t *testing.T) { + page := strings.Join([]string{ + "### 2026-05-01: newer announcement", + "| Shutdown date | Model | Recommended replacement |", + "| --- | --- | --- |", + "| Jun 1, 2026 | `gpt-4-x` \\| `gpt-4-x-alias` | `gpt-5.6-sol` |", + "| To be announced | `gpt-4-later` | `gpt-5.6-sol` |", + "", + "### 2026-01-01: older announcement", + "| Shutdown date | Model | Recommended replacement |", + "| --- | --- | --- |", + "| 2026-03-01 | `gpt-4-x` | `gpt-4o` |", + "| 2026-03-01 | `gpt-4-later` | `gpt-4o` |", + "", + "| Shutdown date | System | Recommended replacement |", + "| --- | --- | --- |", + "| 2024-01-04 | `/v1/fine-tunes` | `/v1/fine_tuning/jobs` |", + }, "\n") + rs, err := Parse([]byte(page), gptOnly) + if err != nil { + t.Fatal(err) + } + got := map[string]Retirement{} + for _, r := range rs { + got[r.Model] = r + } + if len(got) != 2 || got["gpt-4-x"].Date != "2026-06-01" || got["gpt-4-x-alias"].Date != "2026-06-01" { + t.Errorf("the newest announcement wins, aliases split on the escaped pipe, no date means no event: %+v", got) + } + if _, ok := got["gpt-4-later"]; ok { + t.Error("a newer \"To be announced\" withdraws an older row's date: no stale event") + } + if _, err := Parse([]byte("# Deprecations\n\nnothing here\n"), gptOnly); !errors.Is(err, plugin.ErrNothingToRead) { + t.Errorf("a page with no retirement tables must be plugin.ErrNothingToRead, not zero events: %v", err) + } +} + +func TestEventsOnePerModel(t *testing.T) { + rs := []Retirement{{Model: "gpt-4", Date: "2026-10-23", Replacement: "`gpt-5.6-sol`", Excerpt: "### h\n| Shutdown date | … |\n| October 23, 2026 | `gpt-4` | `gpt-5.6-sol` |"}} + src := "https://web.archive.org/web/20261013115538/https://developers.openai.com/api/docs/deprecations.md" + events, errs := Events(acme, rs, src, time.Date(2026, 10, 13, 0, 0, 0, 0, time.UTC)) + if len(errs) != 0 || len(events) != 1 { + t.Fatalf("events %d, errs %v", len(events), errs) + } + e := events[0] + want := event.Subject{Type: event.SubjectModel, Provider: "openai", Name: "gpt-4", Replacement: "gpt-5.6-sol"} + if e.Subject.Type != want.Type || e.Subject.Provider != want.Provider || e.Subject.Name != want.Name || e.Subject.Replacement != want.Replacement { + t.Errorf("subject: %+v", e.Subject) + } + if e.API != "openai/models" || e.Version != "2026-10-23" || e.PreviousVersion != "" || !e.Breaking || + e.SourceURL != src || e.SourceExcerpt != rs[0].Excerpt || e.Confidence != 1.0 { + t.Errorf("event: %+v", e) + } + if e.Fingerprint != event.Fingerprint("openai/models", "2026-10-23", event.ChangeTypeBreaking, e.Subject, "") { + t.Error("the fingerprint is the contract's formula over the model subject") + } + // The replacement is set only when the provider names exactly one model. + for cell, want := range map[string]string{"`gpt-5.6-sol`": "gpt-5.6-sol", "`a` or `b`": "", "`gpt-5.6-sol` (`reasoning.mode: pro`)": "", "none": ""} { + if got := replacement(cell); got != want { + t.Errorf("replacement(%q) = %q, want %q", cell, got, want) + } + } + if !strings.Contains(e.Description, `"gpt-4"`) || !strings.Contains(e.MigrationHint, "gpt-5.6-sol") { + t.Errorf("%q / %q", e.Description, e.MigrationHint) + } + moved, _ := Events(acme, []Retirement{{Model: "gpt-4", Date: "2026-11-23", Replacement: "`gpt-5.6-sol`", Excerpt: "x"}}, src, time.Now()) + if moved[0].Fingerprint == e.Fingerprint { + t.Error("a moved shutdown date is a new event") + } +} + +// acme is a page like OpenAI's, for the tests of the reader itself: the +// providers' own pages are tested with their providers. +var acme = Page{API: "openai/models", Provider: "openai", Vendor: "OpenAI", URL: "https://developers.openai.com/api/docs/deprecations.md", Keep: gptOnly} + +func gptOnly(name string) bool { return strings.HasPrefix(name, "gpt-") } diff --git a/plugins/openapi/adapter/adapter.go b/kinds/openapi/adapter/adapter.go similarity index 79% rename from plugins/openapi/adapter/adapter.go rename to kinds/openapi/adapter/adapter.go index cdea119..1908dbc 100644 --- a/plugins/openapi/adapter/adapter.go +++ b/kinds/openapi/adapter/adapter.go @@ -1,7 +1,10 @@ -// Package adapter defines the per-API source adapter interface and holds -// each API's adapter, starting with Stripe. An adapter only knows where its -// API's spec lives and how to fetch it — fetching mechanics live in -// fetch/, and diffing/normalizing/storing are shared, not adapter code. +// Package adapter defines the interface a provider's OpenAPI source +// implements (its adapter, in providers//; Stripe's is the +// reference) and the helpers adapters share: listing a repo's releases or a +// spec's commits, converting YAML, and moving a server's base path into the +// paths. An adapter only knows where its API's spec lives and how to fetch +// it: fetching mechanics live in core/fetch, and diffing, normalizing and +// storing are the openapi kind's, not adapter code. package adapter import ( diff --git a/kinds/openapi/adapter/helpers.go b/kinds/openapi/adapter/helpers.go new file mode 100644 index 0000000..288cdfd --- /dev/null +++ b/kinds/openapi/adapter/helpers.go @@ -0,0 +1,173 @@ +package adapter + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "strings" + + "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "gopkg.in/yaml.v3" +) + +// ServerBasePath puts the server URL's path back at the front of every path, +// so an operation is named by the path a caller sends ("GET /api/0/…"), and +// a spec that moves the server's path into its paths (or out of them) reads +// as the same operations, not as every operation removed and added again. +// Used by every adapter whose API has a path in its server URL. +// +// Sentry did move it: +// Until sentry-api-schema 2.0.1 the server was "https://{region}.sentry.io" +// and the paths started "/api/0/"; from 2.1.0 (2026-11-13) the server is +// "https://{region}.sentry.io/api/0" and the paths don't. The URLs a caller +// sends are the same, but compared as published, every operation (289 of +// them) reads as removed and added again. With the server's path moved into +// the paths, every spec names an operation by the path a caller sends, +// "GET /api/0/organizations/", as Sentry's API reference does. +// +// A spec whose server has no path is returned byte for byte. The values are +// otherwise unchanged (numbers kept as written); the path moved is recorded +// for SourcePointer. +func ServerBasePath(body []byte) ([]byte, error) { + dec := json.NewDecoder(bytes.NewReader(body)) + dec.UseNumber() + var doc map[string]any + if err := dec.Decode(&doc); err != nil { + return nil, fmt.Errorf("parsing the spec: %w", err) + } + base := "" + for i, s := range AsSlice(doc["servers"]) { + u, _ := AsMap(s)["url"].(string) + p := serverPath(u) + if i > 0 && p != base { + return nil, fmt.Errorf("servers with different paths (%q, %q)", base, p) + } + base = p + } + if base == "" { + return body, nil + } + paths := AsMap(doc["paths"]) + moved := make(map[string]any, len(paths)) + for p, item := range paths { + if !strings.HasPrefix(p, "/") { + return nil, fmt.Errorf("path %q doesn't start with /", p) + } + moved[base+p] = item + } + doc["paths"] = moved + doc[basePathKey] = base + return json.Marshal(doc) +} + +// serverPath is the path of a server URL ("/api/0" for +// "https://{region}.sentry.io/api/0", "/api/v1" for Convex's +// "{deployment-url}/api/v1", whose whole origin is a variable), without a +// trailing slash; "" for none. Read by hand: url.Parse refuses a variable in +// the host. +func serverPath(u string) string { + _, rest, ok := strings.Cut(u, "://") + if !ok { + if !strings.HasPrefix(u, "{") || !strings.Contains(u, "}") { + return "" + } + _, rest, _ = strings.Cut(u, "}") + return strings.TrimRight(rest, "/") + } + i := strings.Index(rest, "/") + if i < 0 { + return "" + } + return strings.TrimRight(rest[i:], "/") +} + +// BasePathPointer turns a pointer into a path ServerBasePath prefixed with +// the server's path back into one into the path as published. Every other +// pointer, and every pointer into a spec ServerBasePath didn't change, is +// already right. +func BasePathPointer(content []byte) func(string) string { + var doc struct { + Base string `json:"x-patch-it-base-path"` + } + _ = json.Unmarshal(content, &doc) // unreadable content: pointers stay as they are + if doc.Base == "" { + return func(ptr string) string { return ptr } + } + prefix := "/paths/" + PointerToken(doc.Base) + return func(ptr string) string { + rest, ok := strings.CutPrefix(ptr, prefix) + // Every path starts with /, so what follows is "~1..."; anything + // else is a pointer into a path that wasn't moved. + if !ok || !strings.HasPrefix(rest, "~1") { + return ptr + } + return "/paths/" + rest + } +} + +// AsSlice is v as an array, or nil. +func AsSlice(v any) []any { + s, _ := v.([]any) + return s +} + +// YAMLToJSON converts a YAML spec to JSON: diff.Parse reads JSON only, and +// normalize quotes the node it cites re-serialized, never the original bytes, +// so nothing quoted changes. +func YAMLToJSON(body []byte) ([]byte, error) { + var doc any + if err := yaml.Unmarshal(body, &doc); err != nil { + return nil, fmt.Errorf("parsing yaml: %w", err) + } + return json.Marshal(doc) +} + +// PointerToken encodes one JSON Pointer token (RFC 6901), as diff does. +func PointerToken(s string) string { + return strings.NewReplacer("~", "~0", "/", "~1").Replace(s) +} + +// AsMap is v as an object, or nil, which reads and ranges as empty. +func AsMap(v any) map[string]any { + m, _ := v.(map[string]any) + return m +} + +// Releases are a GitHub repo's releases, oldest first, the tags keep returns +// true for (nil keeps every one). +func Releases(ctx context.Context, repo string, keep func(string) bool) ([]plugin.Version, error) { + return versions.GitHubReleases(ctx, github.Get, repo, keep) +} + +// Commits are the days a file changed, each read at the day's last commit +// (Daily). +func Commits(ctx context.Context, repo, path string) ([]plugin.Version, error) { + vs, err := versions.GitHubCommits(ctx, github.Get, repo, path) + if err != nil { + return nil, err + } + return Daily(vs), nil +} + +// Daily keeps one version per day of vs (oldest first, IDs dates, as +// versions.GitHubCommits lists them): the day's last commit, so a spec +// committed several times a day has one version per day, each ID once. +func Daily(vs []plugin.Version) []plugin.Version { + var out []plugin.Version + for _, v := range vs { + if n := len(out); n > 0 && out[n-1].ID == v.ID { + out[n-1] = v + continue + } + out = append(out, v) + } + return out +} + +// basePathKey is the root key ServerBasePath records the server path it moved +// into the paths under. The differ reads only paths and components, so the +// key is never diffed. +const basePathKey = "x-patch-it-base-path" diff --git a/kinds/openapi/adapter/helpers_test.go b/kinds/openapi/adapter/helpers_test.go new file mode 100644 index 0000000..88103b2 --- /dev/null +++ b/kinds/openapi/adapter/helpers_test.go @@ -0,0 +1,48 @@ +package adapter + +import ( + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" +) + +// Daily keeps each day's last commit, in order. +func TestDailyKeepsEachDaysLastCommit(t *testing.T) { + in := []plugin.Version{{ID: "2026-10-27", Ref: "a"}, {ID: "2026-10-28", Ref: "b"}, {ID: "2026-10-28", Ref: "c"}, {ID: "2026-10-30", Ref: "d"}} + var got []string + for _, v := range Daily(in) { + got = append(got, v.ID+" "+v.Ref) + } + if want := "2026-10-27 a,2026-10-28 c,2026-10-30 d"; strings.Join(got, ",") != want { + t.Errorf("got %v, want %s", got, want) + } +} + +func TestServerBasePathRefusesWhatItCantMove(t *testing.T) { + if _, err := ServerBasePath([]byte(`{"servers":[{"url":"https://x/api"}],"paths":{"/a":{},"a":{}}}`)); err == nil { + t.Error("a path without a leading /: want an error") + } + if _, err := ServerBasePath([]byte(`{"servers":[{"url":"https://x/api/0"},{"url":"https://y"}],"paths":{}}`)); err == nil { + t.Error("servers with different paths: want an error") + } +} + +// A server whose whole origin is a variable (Convex's "{deployment-url}/api/v1") +// still has a path to move. +func TestServerPath(t *testing.T) { + for in, want := range map[string]string{ + "{deployment-url}/api/v1": "/api/v1", + "{deployment-url}/api/v1/": "/api/v1", + "{deployment-url}": "", + "https://{region}.sentry.io/api/0": "/api/0", + "https://{region}.sentry.io/api/0/": "/api/0", + "https://{region}.sentry.io": "", + "https://sentry.io/": "", + "/api/0": "", + } { + if got := serverPath(in); got != want { + t.Errorf("serverPath(%q) = %q, want %q", in, got, want) + } + } +} diff --git a/kinds/openapi/openapi.go b/kinds/openapi/openapi.go new file mode 100644 index 0000000..72aeb8b --- /dev/null +++ b/kinds/openapi/openapi.go @@ -0,0 +1,187 @@ +// Package openapi is the kind for an API that publishes an OpenAPI spec per +// release (a tag, a release, or the commits that changed the spec): every +// release is listed, each consecutive pair diffed (ListVersions, ReadAt, +// Extract), the changes normalized into events, and migration hints +// attached from the API's changelog when it has one. +package openapi + +import ( + "context" + "fmt" + "log" + + "github.com/patch-it-dev/patch-it-plugins/core/diff" + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/hint" + "github.com/patch-it-dev/patch-it-plugins/core/normalize" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" +) + +// RequestSide keeps the changes to what callers send. GitLab's response +// schemas are generated from entity docs it is still backfilling: between +// v18.11.0-ee and v19.0.0-ee, 280 response properties went from the generator's +// default "string" to their real type and 74 schemas were folded into others, +// while the API returned the same JSON. That reads as ~360 breaking changes +// nobody would hit, so response-side changes are dropped, not guessed at. +func RequestSide(c diff.Change) bool { return c.Side == event.SideRequest } + +// Plugin runs one API's spec adapter. +type Plugin struct { + Adapter adapter.Adapter + // Hints fills migration_hint from the API's own changelog. Optional: nil, + // or a changelog that can't be reached, leaves the normalizer's hints. + Hints hint.Source + // Keep, when set, drops the changes it returns false for, before they + // become events: for a spec whose structure changes more often than its + // API does. Nil keeps every change. + Keep func(diff.Change) bool + // Diff adapts the differ to the spec's conventions. The zero value is + // right for Stripe's. + Diff diff.Options + // RemovalsNeedANewVersion drops operation removals between two specs of + // the same version: for an API whose spec is fixed up on a release + // branch after the release, where a removal there is a correction to the + // spec, not a release removing an API (Elasticsearch removes APIs in a + // new minor or major, never in a patch). + RemovalsNeedANewVersion bool +} + +func (p Plugin) Name() string { return p.Adapter.API() } + +// ListVersions is every release of the spec, oldest first, when the adapter +// can list them (adapter.Lister); otherwise only the newest (LatestTag). +func (p Plugin) ListVersions(ctx context.Context, _ plugin.Env) ([]plugin.Version, error) { + if l, ok := p.Adapter.(adapter.Lister); ok { + return l.Versions(ctx) + } + tag, err := p.Adapter.LatestTag(ctx) + if err != nil { + return nil, fmt.Errorf("finding latest tag: %w", err) + } + return []plugin.Version{{ID: tag, Ref: tag}}, nil +} + +// ReadAt fetches the spec at v.Ref. The snapshot's version ID is the version +// the spec itself declares (what events carry), which may differ from the tag; +// for an adapter that lists the specs' own versions (SpecVersioned) it must +// be v's. +func (p Plugin) ReadAt(ctx context.Context, _ plugin.Env, v plugin.Version) (plugin.Snapshot, error) { + s, err := p.Adapter.Fetch(ctx, v.Ref) + if err != nil { + return plugin.Snapshot{}, fmt.Errorf("fetching %s %s: %w", p.Adapter.API(), v.Ref, err) + } + if _, ok := p.Adapter.(adapter.SpecVersioned); ok && s.Version != v.ID { + return plugin.Snapshot{}, fmt.Errorf("%s %s: the spec at %s declares %s: not published there yet", p.Adapter.API(), v.ID, v.Ref, s.Version) + } + v.ID = s.Version + return plugin.Snapshot{Version: v, Content: s.Content, SourceURL: s.SourceURL}, nil +} + +// Extract diffs two snapshots of the spec into events, with to's version and +// from's as previous_version. A zero from is an empty spec before the first. +func (p Plugin) Extract(ctx context.Context, env plugin.Env, from, to plugin.Snapshot) (plugin.Result, error) { + var oldParsed *diff.Spec + if !from.IsZero() { + var err error + if oldParsed, err = diff.Parse(from.Content); err != nil { + return plugin.Result{}, fmt.Errorf("parsing the %s spec at %s: %w", p.Adapter.API(), from.Version.ID, err) + } + } + newParsed, err := diff.Parse(to.Content) + if err != nil { + return plugin.Result{}, fmt.Errorf("parsing the %s spec at %s: %w", p.Adapter.API(), to.Version.ID, err) + } + events, errs := p.events(oldParsed, newParsed, from.Content, to.Content, normalize.Source{ + API: p.Adapter.API(), + Version: to.Version.ID, + PreviousVersion: from.Version.ID, + NewSpecURL: to.SourceURL, + OldSpecURL: from.SourceURL, + DetectedAt: env.Now().UTC(), + }) + p.attachHints(ctx, to.Version.ID, events) + return plugin.Result{Events: events, Rejected: errs}, nil +} + +var _ plugin.Versioned = Plugin{} + +// events diffs two parsed specs into events, applying Keep, and pointing each +// event's source_pointer into the published file when the adapter reshaped it. +func (p Plugin) events(oldParsed, newParsed *diff.Spec, oldContent, newContent []byte, src normalize.Source) ([]event.Event, []error) { + changes := diff.ChangesWith(oldParsed, newParsed, p.Diff) + if p.Keep != nil { + kept := changes[:0:0] + for _, c := range changes { + if p.Keep(c) { + kept = append(kept, c) + } + } + if dropped := len(changes) - len(kept); dropped > 0 { + log.Printf("%s %s: %d of %d changes dropped by the source's filter", src.API, src.Version, dropped, len(changes)) + } + changes = kept + } + if p.RemovalsNeedANewVersion && src.Version == src.PreviousVersion { + kept := changes[:0:0] + for _, c := range changes { + if c.Kind != diff.OperationRemoved { + kept = append(kept, c) + } + } + if dropped := len(changes) - len(kept); dropped > 0 { + log.Printf("%s %s: %d removals dropped: same version as the last spec", src.API, src.Version, dropped) + } + changes = kept + } + events, errs := normalize.Events(changes, src) + rp, ok := p.Adapter.(adapter.Reshaper) + if !ok || len(events) == 0 { + return events, errs + } + oldPtr, newPtr := rp.SourcePointer(oldContent), rp.SourcePointer(newContent) + for i := range events { + e := &events[i] + // normalize cites the old spec only for evidence that lives there. + if e.SourceURL == src.OldSpecURL && e.SourceURL != src.NewSpecURL { + e.SourcePointer = oldPtr(e.SourcePointer) + } else { + e.SourcePointer = newPtr(e.SourcePointer) + } + } + return events, errs +} + +// attachHints looks the events up in the API's changelog for their version. +// Never fails the run: a hint is help for the fix, not provenance for the event. +func (p Plugin) attachHints(ctx context.Context, version string, events []event.Event) { + if p.Hints == nil || len(events) == 0 { + return + } + api := p.Adapter.API() + ix, err := p.Hints.Index(ctx, version) + if err != nil { + log.Printf("%s %s: migration hints unavailable: %v", api, version, err) + return + } + n := ix.Attach(events) + log.Printf("%s %s: migration hints on %d of %d events, from %d changelog entries", api, version, n, len(events), len(ix.Entries)) +} + +// DeprecationsOnly keeps operation deprecations, and removals of operations +// the old spec had marked deprecated (by opts' reading of "marked"): +// everything else is dropped. For a spec whose removals and property changes +// were mostly not changes to the API (vercel, supabase). +func DeprecationsOnly(opts diff.Options) func(diff.Change) bool { + return func(c diff.Change) bool { + switch c.Kind { + case diff.OperationDeprecated: + return true + case diff.OperationRemoved: + op, _ := c.Node.(map[string]any) + return opts.OperationDeprecated(op) + default: + return false + } + } +} diff --git a/plugins/openapi/openapi_test.go b/kinds/openapi/openapi_test.go similarity index 98% rename from plugins/openapi/openapi_test.go rename to kinds/openapi/openapi_test.go index 041d553..c8bd9d1 100644 --- a/plugins/openapi/openapi_test.go +++ b/kinds/openapi/openapi_test.go @@ -10,7 +10,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/hint" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // fakeHints stands in for a changelog: an index built from the entries given, diff --git a/kinds/openapi/openapitest/openapitest.go b/kinds/openapi/openapitest/openapitest.go new file mode 100644 index 0000000..6a27c10 --- /dev/null +++ b/kinds/openapi/openapitest/openapitest.go @@ -0,0 +1,129 @@ +// Package openapitest is what the tests of providers' OpenAPI sources share: +// a fixed clock, recorded version listings, and the node a pointer names in +// a saved spec. +package openapitest + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "strconv" + "strings" + "testing" + "time" + + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "gopkg.in/yaml.v3" +) + +// Recorded serves saved API responses (testdata/versions/, recorded +// 2026-11-20 and trimmed: testdata/README.md) by request path and query; +// any other request fails the test. +func Recorded(t *testing.T, files map[string]string) *httptest.Server { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + key := r.URL.Path + if r.URL.RawQuery != "" { + key += "?" + r.URL.RawQuery + } + file, ok := files[key] + if !ok { + t.Errorf("unexpected request %s", key) + http.NotFound(w, r) + return + } + b, err := os.ReadFile("testdata/versions/" + file) + if err != nil { + t.Error(err) + } + w.Write(b) + })) + t.Cleanup(srv.Close) + return srv +} + +// IDs lists versions as "id@ref", space-separated. +func IDs(vs []plugin.Version) string { + var out []string + for _, v := range vs { + out = append(out, v.ID+"@"+v.Ref) + } + return strings.Join(out, " ") +} + +// Env is a plugin.Env on kittest's fixed clock. +func Env(*kittest.Mem) plugin.Env { + return plugin.Env{Now: func() time.Time { return kittest.Clock }} +} + +// JSONNode resolves an RFC 6901 pointer in a JSON file and serializes the node +// the way normalize serializes excerpts. +func JSONNode(t *testing.T, file, pointer string) string { + t.Helper() + var node any + if err := json.Unmarshal(kittest.Read(t, file), &node); err != nil { + t.Fatal(err) + } + for _, tok := range strings.Split(strings.TrimPrefix(pointer, "/"), "/") { + tok = strings.NewReplacer("~1", "/", "~0", "~").Replace(tok) + switch n := node.(type) { + case map[string]any: + node = n[tok] + case []any: + i, err := strconv.Atoi(tok) + if err != nil || i >= len(n) { + return "" + } + node = n[i] + default: + return "" + } + } + b, err := json.Marshal(node) + if err != nil { + t.Fatal(err) + } + return string(b) +} + +// Truncated reports whether excerpt is node cut to the contract's limit. +func Truncated(excerpt, node string) bool { + prefix, ok := strings.CutSuffix(excerpt, "…") + return ok && strings.HasPrefix(node, prefix) +} + +// YAMLNodeJSON resolves an RFC 6901 pointer in a YAML file and serializes the +// node the way normalize serializes excerpts. +func YAMLNodeJSON(t *testing.T, file, pointer string) string { + t.Helper() + data, err := os.ReadFile(file) + if err != nil { + t.Fatal(err) + } + var node any + if err := yaml.Unmarshal(data, &node); err != nil { + t.Fatal(err) + } + for _, tok := range strings.Split(strings.TrimPrefix(pointer, "/"), "/") { + tok = strings.NewReplacer("~1", "/", "~0", "~").Replace(tok) + switch n := node.(type) { + case map[string]any: + node = n[tok] + case []any: + i, err := strconv.Atoi(tok) + if err != nil || i >= len(n) { + return "" + } + node = n[i] + default: + return "" + } + } + b, err := json.Marshal(node) + if err != nil { + t.Fatal(err) + } + return string(b) +} diff --git a/plugins/openapi/versions_test.go b/kinds/openapi/versions_test.go similarity index 70% rename from plugins/openapi/versions_test.go rename to kinds/openapi/versions_test.go index 374ef03..0975522 100644 --- a/plugins/openapi/versions_test.go +++ b/kinds/openapi/versions_test.go @@ -3,15 +3,13 @@ package openapi import ( "context" "fmt" - "net/http" - "net/http/httptest" "strings" "testing" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // listingAdapter is fakeAdapter that can also list its versions. @@ -82,42 +80,6 @@ func TestListVersionsFallsBackToTheNewest(t *testing.T) { } } -// The real adapters list GitHub releases (Stripe: the API versions their -// notes name) or the commits that changed their spec, through core/versions. -func TestAdaptersListReleasesAndCommits(t *testing.T) { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch { - case r.URL.Path == "/repos/stripe/openapi/releases": - fmt.Fprint(w, `[{"tag_name":"v2","published_at":"2026-02-01T00:00:00Z","body":"| openapi/spec3.sdk.{json,yaml} | 2026-02-01.b |"},`+ - `{"tag_name":"v1","published_at":"2026-01-01T00:00:00Z","body":"| openapi/spec3.sdk.{json,yaml} | 2026-01-01.a |"}]`) - case r.URL.Path == "/repos/supabase/supabase/commits" && r.URL.Query().Get("path") == "apps/docs/spec/api_v1_openapi.json": - fmt.Fprint(w, `[{"sha":"b","commit":{"committer":{"date":"2026-02-01T00:00:00Z"}}},{"sha":"a","commit":{"committer":{"date":"2026-01-01T00:00:00Z"}}}]`) - default: - http.NotFound(w, r) - } - })) - defer srv.Close() - old := versions.GitHubAPI - versions.GitHubAPI = srv.URL - defer func() { versions.GitHubAPI = old }() - for _, c := range []struct { - a adapter.Adapter - want string - }{{adapter.Stripe{}, "v1 v2"}, {adapter.Supabase{}, "a b"}} { - vs, err := Plugin{Adapter: c.a}.ListVersions(context.Background(), plugin.Env{}) - if err != nil { - t.Fatalf("%s: %v", c.a.API(), err) - } - var refs []string - for _, v := range vs { - refs = append(refs, v.Ref) - } - if strings.Join(refs, " ") != c.want { - t.Errorf("%s: refs %v, want %s", c.a.API(), refs, c.want) - } - } -} - // specVersioned lists the specs' own versions (as Stripe does). type specVersioned struct{ fakeAdapter } diff --git a/plugins/all/all.go b/plugins/all/all.go deleted file mode 100644 index 051a892..0000000 --- a/plugins/all/all.go +++ /dev/null @@ -1,13 +0,0 @@ -// Package all imports every plugin, so each registers itself: a program that -// runs plugins imports this one package. A new plugin package is added here -// (TestEveryPluginIsImported fails until it is). -package all - -import ( - _ "github.com/patch-it-dev/patch-it-plugins/plugins/apisurface" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/catalog" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/changelog" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/notices" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/openapi" -) diff --git a/plugins/all/all_test.go b/plugins/all/all_test.go deleted file mode 100644 index 27cbde5..0000000 --- a/plugins/all/all_test.go +++ /dev/null @@ -1,186 +0,0 @@ -package all - -import ( - "go/ast" - "go/parser" - "go/token" - "io/fs" - "os" - "path/filepath" - "slices" - "strconv" - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -// Every package next to this one that registers a plugin is imported here, so -// a program importing all runs it. -func TestEveryPluginIsImported(t *testing.T) { - f, err := parser.ParseFile(token.NewFileSet(), "all.go", nil, parser.ImportsOnly) - if err != nil { - t.Fatal(err) - } - var imported []string - for _, imp := range f.Imports { - path, _ := strconv.Unquote(imp.Path.Value) - imported = append(imported, filepath.Base(path)) - } - dirs, err := os.ReadDir("..") - if err != nil { - t.Fatal(err) - } - found := 0 - for _, d := range dirs { - if !d.IsDir() || !registers(t, filepath.Join("..", d.Name())) { - continue - } - found++ - if !slices.Contains(imported, d.Name()) { - t.Errorf("plugin package %s registers a plugin but all.go doesn't import it", d.Name()) - } - } - if found == 0 { - t.Fatal("found no plugin package next to this one") - } -} - -// registers reports whether a package's non-test code calls -// plugin.RegisterProvider (or plugin.Register). -func registers(t *testing.T, dir string) bool { - t.Helper() - files, err := filepath.Glob(filepath.Join(dir, "*.go")) - if err != nil { - t.Fatal(err) - } - for _, f := range files { - if strings.HasSuffix(f, "_test.go") { - continue - } - b, err := os.ReadFile(f) - if err != nil { - t.Fatal(err) - } - if strings.Contains(string(b), "plugin.Register(") || strings.Contains(string(b), "plugin.RegisterProvider(") { - return true - } - } - return false -} - -// Importing all registers plugins, under unique names, sorted. -func TestImportingAllRegistersThePlugins(t *testing.T) { - names := plugin.Names() - if len(names) == 0 { - t.Fatal("no plugin registered") - } - if !slices.IsSorted(names) || len(slices.Compact(slices.Clone(names))) != len(names) { - t.Errorf("names %v: want sorted and unique", names) - } -} - -// Every registered source has complete metadata (RegisterProvider checks the -// fields), is found by its id, and its page exists. -func TestEverySourceHasMetadata(t *testing.T) { - for _, s := range plugin.Sources() { - if _, err := os.Stat(filepath.Join("..", "..", s.Source.Page)); err != nil { - t.Errorf("%s: its page %s doesn't exist (copy providers/_template.md)", s.FullID(), s.Source.Page) - } - if p, ok := plugin.Lookup(s.FullID()); !ok || p.Name() != s.FullID() { - t.Errorf("Lookup(%q) didn't find it", s.FullID()) - } - } - if len(plugin.Names()) != len(plugin.Sources()) { - t.Errorf("%d plugins, %d sources", len(plugin.Names()), len(plugin.Sources())) - } -} - -// Every registered source's kind is an answer of docs/which-kind.md, so the -// guide sends every source somewhere. -func TestWhichKindNamesEveryKind(t *testing.T) { - guide, err := os.ReadFile("../../docs/which-kind.md") - if err != nil { - t.Fatal(err) - } - for _, s := range plugin.Sources() { - if !strings.Contains(string(guide), "| `"+s.Source.Kind+"` |") { - t.Errorf("%s's kind, %s, isn't an answer in docs/which-kind.md", s.FullID(), s.Source.Kind) - } - } -} - -// Every package under plugins/ is a kind that registers its sources, or a -// reader package inside one (plugins///); and none only -// forwards to another package (type aliases and re-exported values, no code -// of its own). -func TestEveryPackageIsAKindOrPartOfOne(t *testing.T) { - dirs, err := os.ReadDir("..") - if err != nil { - t.Fatal(err) - } - for _, d := range dirs { - if d.IsDir() && d.Name() != "all" && !registers(t, filepath.Join("..", d.Name())) { - t.Errorf("plugins/%s registers no source: a kind registers its sources, a reader lives inside its kind", d.Name()) - } - } - err = filepath.WalkDir("..", func(p string, d fs.DirEntry, err error) error { - if err != nil || !d.IsDir() || d.Name() == "testdata" { - if d != nil && d.IsDir() && d.Name() == "testdata" { - return filepath.SkipDir - } - return err - } - if forwardsOnly(t, p) { - t.Errorf("%s only forwards to another package: import that package instead", p) - } - return nil - }) - if err != nil { - t.Fatal(err) - } -} - -// forwardsOnly reports whether a package's non-test code is nothing but type -// aliases and values copied from other packages. -func forwardsOnly(t *testing.T, dir string) bool { - t.Helper() - files, err := filepath.Glob(filepath.Join(dir, "*.go")) - if err != nil { - t.Fatal(err) - } - decls := 0 - for _, f := range files { - if strings.HasSuffix(f, "_test.go") { - continue - } - file, err := parser.ParseFile(token.NewFileSet(), f, nil, 0) - if err != nil { - t.Fatal(err) - } - for _, decl := range file.Decls { - g, ok := decl.(*ast.GenDecl) - if !ok { - return false // a func: code of its own - } - for _, spec := range g.Specs { - switch s := spec.(type) { - case *ast.ImportSpec: - continue - case *ast.TypeSpec: - if !s.Assign.IsValid() { - return false - } - case *ast.ValueSpec: - for _, v := range s.Values { - if _, sel := v.(*ast.SelectorExpr); !sel { - return false - } - } - } - decls++ - } - } - } - return decls > 0 -} diff --git a/plugins/apisurface/npm_packages.go b/plugins/apisurface/npm_packages.go deleted file mode 100644 index 3235471..0000000 --- a/plugins/apisurface/npm_packages.go +++ /dev/null @@ -1,54 +0,0 @@ -package apisurface - -import ( - "strings" - - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -// The npm packages whose public API this kind reads from their TypeScript -// declarations, one source each, registered with their provider. An npm -// package's Module is its own name: symbols are named from the import path -// code writes ("@anthropic-ai/sdk/resources/messages.Messages.create"). -var ( - OpenAINode = npmPackage("openai/node-surface", "openai") - AnthropicTS = npmPackage("anthropic/typescript-surface", "@anthropic-ai/sdk") - StripeNode = npmPackage("stripe/node-surface", "stripe") - GoogleGenAIJS = npmPackage("google/genai-js-surface", "@google/genai") - SentryNode = npmPackage("sentry/node-surface", "@sentry/node") - MongoDBNode = npmPackage("mongodb/node-surface", "mongodb") - RedisNode = npmPackage("redis/node-redis-surface", "@redis/client") - SupabaseJS = npmPackage("supabase/js-surface", "@supabase/supabase-js") - NeonServerless = npmPackage("neon/serverless-surface", "@neondatabase/serverless") - ConvexJS = npmPackage("convex/js-surface", "convex") -) - -func npmPackage(id, name string) Package { - return Package{ID: id, Name: name, Ecosystem: "npm", Module: name} -} - -func init() { - npm := func(p plugin.Provider, pkg Package, repo string, also ...string) { - _, src, _ := strings.Cut(pkg.ID, "/") - p.Sources = []plugin.Source{{ - ID: src, Layer: plugin.LayerSDK, Page: "providers/" + p.ID + "-" + src + ".md", - Watches: "Exported classes, functions, methods, properties, types and parameters removed, or parameters no longer optional, in the public API of the " + pkg.Name + " npm package, release by release, read from each release's TypeScript declarations", - URLs: []string{"https://www.npmjs.com/package/" + pkg.Name, repo}, - Packages: append([]string{"npm:" + pkg.Name}, also...), - Plugin: Plugin{Package: pkg}, - }} - plugin.RegisterProvider(p) - } - npm(plugin.Provider{ID: "openai", Name: "OpenAI", Category: plugin.CategoryAI, Homepage: "https://openai.com"}, OpenAINode, "https://github.com/openai/openai-node") - npm(plugin.Provider{ID: "anthropic", Name: "Anthropic", Category: plugin.CategoryAI, Homepage: "https://www.anthropic.com"}, AnthropicTS, "https://github.com/anthropics/anthropic-sdk-typescript") - npm(plugin.Provider{ID: "stripe", Name: "Stripe", Category: plugin.CategoryPayments, Homepage: "https://stripe.com"}, StripeNode, "https://github.com/stripe/stripe-node") - npm(plugin.Provider{ID: "google", Name: "Google", Category: plugin.CategoryAI, Homepage: "https://cloud.google.com"}, GoogleGenAIJS, "https://github.com/googleapis/js-genai") - npm(plugin.Provider{ID: "sentry", Name: "Sentry", Category: plugin.CategoryMonitoring, Homepage: "https://sentry.io"}, SentryNode, "https://github.com/getsentry/sentry-javascript") - npm(plugin.Provider{ID: "mongodb", Name: "MongoDB", Category: plugin.CategoryDatabases, Homepage: "https://www.mongodb.com"}, MongoDBNode, "https://github.com/mongodb/node-mongodb-native") - // redis on npm re-exports @redis/client and its siblings wholesale; the - // client's declarations are where its API is. - npm(plugin.Provider{ID: "redis", Name: "Redis", Category: plugin.CategoryDatabases, Homepage: "https://redis.io"}, RedisNode, "https://github.com/redis/node-redis", "npm:redis") - npm(plugin.Provider{ID: "supabase", Name: "Supabase", Category: plugin.CategoryDatabases, Homepage: "https://supabase.com"}, SupabaseJS, "https://github.com/supabase/supabase-js") - npm(plugin.Provider{ID: "neon", Name: "Neon", Category: plugin.CategoryDatabases, Homepage: "https://neon.com"}, NeonServerless, "https://github.com/neondatabase/serverless") - npm(plugin.Provider{ID: "convex", Name: "Convex", Category: plugin.CategoryDatabases, Homepage: "https://www.convex.dev"}, ConvexJS, "https://github.com/convex/convex-js") -} diff --git a/plugins/apisurface/npm_test.go b/plugins/apisurface/npm_test.go deleted file mode 100644 index b6c667d..0000000 --- a/plugins/apisurface/npm_test.go +++ /dev/null @@ -1,182 +0,0 @@ -package apisurface - -import ( - "context" - "encoding/json" - "path/filepath" - "slices" - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -// npmCases are the npm sources' saved releases (testdata/npm//, -// testdata/README.md): a golden pair with the events it must store, and a -// drop pair that must store none. Both are consecutive releases on npm. -var npmCases = []pypiCase{ - // openai 7.60.0 dropped the agents' AgentSessionBudgetReachedEvent - // type (the session spending limits pulled from the API). - {OpenAINode, [2]string{"7.59.0", "7.60.0"}, []string{ - "removed_symbol openai/resources/beta.AgentSessionBudgetReachedEvent,openai/resources/beta/agents.AgentSessionBudgetReachedEvent,openai/resources/beta/agents/agents.AgentSessionBudgetReachedEvent ", - }, [2]string{"7.60.0", "7.61.0"}}, - // @anthropic-ai/sdk 1.7.0 dropped the beta billing-frozen error. - {AnthropicTS, [2]string{"1.6.0", "1.7.0"}, []string{ - "removed_symbol @anthropic-ai/sdk/resources/beta.BetaBillingFrozenErrorDetails,@anthropic-ai/sdk/resources/beta/organization.BetaBillingFrozenErrorDetails,@anthropic-ai/sdk/resources/beta/organization/organization.BetaBillingFrozenErrorDetails ", - "removed_symbol Anthropic.Beta.BetaBillingFrozenError,Anthropic.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/client.Anthropic.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/client.Anthropic.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/beta.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/beta.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization/organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization/organization.Organization.BetaBillingFrozenError ", - }, [2]string{"1.7.0", "1.8.0"}}, - // stripe 23.0.0 removed constructEventWithoutVerification and the - // ErrorType namespace. - {StripeNode, [2]string{"22.6.2", "23.0.0"}, []string{ - "removed_symbol Stripe.ErrorType ", - "removed_symbol Stripe.constructEventWithoutVerification ", - }, [2]string{"23.0.0", "23.0.1"}}, - // @sentry/node 10.0.0 stopped exporting systemErrorIntegration. 11.13.0 - // made the logger namespace a const object: its functions are still - // there, as members the reader doesn't follow. - {SentryNode, [2]string{"9.47.2", "10.0.0"}, []string{ - "removed_symbol systemErrorIntegration ", - }, [2]string{"11.12.0", "11.13.0"}}, - // @neondatabase/serverless 1.0.0 dropped ClientBase.neonConfig and the - // native export; Pool.connect, gone from Pool, is pg's base class's. - {NeonServerless, [2]string{"0.10.4", "1.0.0"}, []string{ - "removed_symbol native ", - }, [2]string{"1.0.0", "1.0.1"}}, - // @redis/client 5.0.0 removed commandOptions and RedisFlushModes. - {RedisNode, [2]string{"1.6.1", "5.0.0"}, []string{ - "removed_symbol RedisFlushModes ", - "removed_symbol commandOptions ", - }, [2]string{"6.3.0", "6.3.1"}}, - // @supabase/supabase-js 2.0.0 removed the v1 subscription methods. - {SupabaseJS, [2]string{"1.35.7", "2.0.0"}, []string{ - "removed_symbol SupabaseClient.getSubscriptions ", - "removed_symbol SupabaseClient.removeAllSubscriptions ", - "removed_symbol SupabaseClient.removeSubscription ", - }, [2]string{"2.118.0", "2.119.0"}}, - // @google/genai 1.0.0 removed LiveMusicSetClientContentParameters. - {GoogleGenAIJS, [2]string{"0.15.0", "1.0.0"}, []string{ - "removed_symbol @google/genai/node.LiveMusicSetClientContentParameters ", - "removed_symbol @google/genai/web.LiveMusicSetClientContentParameters ", - "removed_symbol LiveMusicSetClientContentParameters ", - }, [2]string{"1.0.0", "1.1.0"}}, - // mongodb 7.0.0 removed CancellationToken, Transaction and more. - {MongoDBNode, [2]string{"6.22.0", "7.0.0"}, []string{ - "removed_symbol AsyncDisposable ", - "removed_symbol CancellationToken ", - "removed_symbol ChangeStream.streamOptions ", - "removed_symbol ClientMetadata ", - "removed_symbol ClientMetadataOptions ", - "removed_symbol ClientSession.transaction ", - "removed_symbol CloseOptions ", - "removed_symbol CursorStreamOptions ", - "removed_symbol ReadPreference.minWireVersion ", - "removed_symbol ResumeOptions ", - "removed_symbol ServerCapabilities ", - "removed_symbol Transaction ", - }, [2]string{"7.0.0", "7.1.0"}}, - // convex 1.35.1 removed the react entry's QueryOptions and - // UseQueryResult types. - {ConvexJS, [2]string{"1.35.0", "1.35.1"}, []string{ - "removed_symbol convex/browser.QueryOptions ", - }, [2]string{"1.42.2", "1.42.3"}}, -} - -// npmDir is a package's directory under testdata/npm. -func npmDir(name string) string { - return filepath.Join("testdata", "npm", strings.ReplaceAll(strings.TrimPrefix(name, "@"), "/", "-")) -} - -// npmPages serves a case's saved files under the registry's URLs: the -// package document, each version's, and each trimmed tarball. -func npmPages(t *testing.T, name string) kittest.Pages { - t.Helper() - dir, safe := npmDir(name), strings.ReplaceAll(strings.TrimPrefix(name, "@"), "/", "-") - reg := "https://registry.npmjs.org/" + strings.ReplaceAll(name, "/", "%2F") - pages := kittest.Pages{reg: filepath.Join(dir, "npm-"+safe+"-excerpt.json")} - files, err := filepath.Glob(filepath.Join(dir, "npm-"+safe+"-*.json")) - if err != nil { - t.Fatal(err) - } - for _, f := range files { - v := strings.TrimSuffix(strings.TrimPrefix(filepath.Base(f), "npm-"+safe+"-"), ".json") - if v == "excerpt" { - continue - } - pages[reg+"/"+v] = f - var doc struct { - Dist struct { - Tarball string `json:"tarball"` - } `json:"dist"` - } - if err := json.Unmarshal(kittest.Read(t, f), &doc); err != nil { - t.Fatal(err) - } - pages[doc.Dist.Tarball] = filepath.Join(dir, strings.TrimSuffix(filepath.Base(doc.Dist.Tarball), ".tgz")+".trimmed.tgz") - } - return pages -} - -func npmPair(t *testing.T, c pypiCase, pair [2]string) []event.Event { - t.Helper() - ctx, env := context.Background(), kittest.Env(t, npmPages(t, c.pkg.Name)) - p := Plugin{Package: c.pkg} - vs, err := p.ListVersions(ctx, env) - if err != nil { - t.Fatal(err) - } - byID := map[string]plugin.Version{} - for _, v := range vs { - byID[v.ID] = v - } - from, ok1 := byID[pair[0]] - to, ok2 := byID[pair[1]] - if !ok1 || !ok2 { - t.Fatalf("%s: %v not both listed in %v", c.pkg.Name, pair, vs) - } - return kittest.Versions(t, env, p, from, to) -} - -// The golden test of every npm source. -func TestNPMGolden(t *testing.T) { - for _, c := range npmCases { - t.Run(c.pkg.ID, func(t *testing.T) { - got := npmPair(t, c, c.golden) - if len(got) == 0 { - t.Fatal("no events") - } - var lines []string - for _, e := range got { - lines = append(lines, string(e.Subject.Change)+" "+strings.Join(e.Subject.Symbols, ",")+" "+e.Subject.Parameter) - if e.Version != c.golden[1] || e.PreviousVersion != c.golden[0] || !strings.HasPrefix(e.SourceURL, "https://registry.npmjs.org/") || !strings.Contains(e.SourceExcerpt, c.pkg.Name+" "+c.golden[0]+" (") || e.Subject.Ecosystem != "npm" { - t.Errorf("%s: %s<-%s cites %s, excerpt %q", e.Subject.Symbols, e.Version, e.PreviousVersion, e.SourceURL, e.SourceExcerpt) - } - } - slices.Sort(lines) - if !slices.Equal(lines, c.want) { - t.Errorf("got\n%s\nwant\n%s", strings.Join(lines, "\n"), strings.Join(c.want, "\n")) - } - provider, source, _ := strings.Cut(c.pkg.ID, "/") - kittest.Golden(t, "testdata/golden/"+provider+"-"+source+".json", got) - }) - } -} - -// The pinned drop test of every npm source: a real release that changes -// nothing a caller relies on stores no event. -func TestNPMDrop(t *testing.T) { - for _, c := range npmCases { - t.Run(c.pkg.ID, func(t *testing.T) { - for _, e := range npmPair(t, c, c.drop) { - t.Errorf("%s %v %s", e.Subject.Change, e.Subject.Symbols, e.Subject.Parameter) - } - }) - } -} - -func TestNPMRegistersItself(t *testing.T) { - for _, c := range npmCases { - kittest.Registered(t, Plugin{Package: c.pkg}) - } -} diff --git a/plugins/apisurface/pypi.go b/plugins/apisurface/pypi.go deleted file mode 100644 index e889a2a..0000000 --- a/plugins/apisurface/pypi.go +++ /dev/null @@ -1,58 +0,0 @@ -package apisurface - -import ( - "strings" - - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -// The PyPI packages whose public API this kind reads, one source each, -// registered with their provider. A package's Module is the top-level -// directory its wheel installs (checked by hand on each package's newest -// wheel, 2026-11-21). -var ( - OpenAIPython = Package{ID: "openai/python-surface", Name: "openai", Ecosystem: "pypi", Module: "openai"} - AnthropicPython = Package{ID: "anthropic/python-surface", Name: "anthropic", Ecosystem: "pypi", Module: "anthropic"} - StripePython = Package{ID: "stripe/python-surface", Name: "stripe", Ecosystem: "pypi", Module: "stripe"} - GoogleGenAI = Package{ID: "google/genai-python-surface", Name: "google-genai", Ecosystem: "pypi", Module: "google"} - SentryPython = Package{ID: "sentry/python-surface", Name: "sentry-sdk", Ecosystem: "pypi", Module: "sentry_sdk"} - PyMongo = Package{ID: "mongodb/pymongo-surface", Name: "pymongo", Ecosystem: "pypi", Module: "pymongo"} - RedisPy = Package{ID: "redis/redis-py-surface", Name: "redis", Ecosystem: "pypi", Module: "redis"} - NumPy = Package{ID: "numpy/python-surface", Name: "numpy", Ecosystem: "pypi", Module: "numpy"} - SupabasePython = Package{ID: "supabase/python-surface", Name: "supabase", Ecosystem: "pypi", Module: "supabase"} - AlgoliaPython = Package{ID: "algolia/python-surface", Name: "algoliasearch", Ecosystem: "pypi", Module: "algoliasearch"} - ElasticPython = Package{ID: "elastic/python-surface", Name: "elasticsearch", Ecosystem: "pypi", Module: "elasticsearch"} - DDTrace = Package{ID: "datadog/ddtrace-python-surface", Name: "ddtrace", Ecosystem: "pypi", Module: "ddtrace"} - CloudflarePython = Package{ID: "cloudflare/python-surface", Name: "cloudflare", Ecosystem: "pypi", Module: "cloudflare"} - Textual = Package{ID: "textual/python-surface", Name: "textual", Ecosystem: "pypi", Module: "textual"} - URLLib3 = Package{ID: "urllib3/python-surface", Name: "urllib3", Ecosystem: "pypi", Module: "urllib3"} -) - -func init() { - pypi := func(p plugin.Provider, pkg Package, layer plugin.Layer, repo string) { - _, src, _ := strings.Cut(pkg.ID, "/") - p.Sources = []plugin.Source{{ - ID: src, Layer: layer, Page: "providers/" + p.ID + "-" + src + ".md", - Watches: "Classes, functions, methods and parameters removed or renamed in the public API of the " + pkg.Name + " Python package, release by release, read from each release's wheel", - URLs: []string{"https://pypi.org/project/" + pkg.Name + "/", repo}, - Packages: []string{"pypi:" + pkg.Name}, - Plugin: Plugin{Package: pkg}, - }} - plugin.RegisterProvider(p) - } - pypi(plugin.Provider{ID: "openai", Name: "OpenAI", Category: plugin.CategoryAI, Homepage: "https://openai.com"}, OpenAIPython, plugin.LayerSDK, "https://github.com/openai/openai-python") - pypi(plugin.Provider{ID: "anthropic", Name: "Anthropic", Category: plugin.CategoryAI, Homepage: "https://www.anthropic.com"}, AnthropicPython, plugin.LayerSDK, "https://github.com/anthropics/anthropic-sdk-python") - pypi(plugin.Provider{ID: "stripe", Name: "Stripe", Category: plugin.CategoryPayments, Homepage: "https://stripe.com"}, StripePython, plugin.LayerSDK, "https://github.com/stripe/stripe-python") - pypi(plugin.Provider{ID: "google", Name: "Google", Category: plugin.CategoryAI, Homepage: "https://cloud.google.com"}, GoogleGenAI, plugin.LayerSDK, "https://github.com/googleapis/python-genai") - pypi(plugin.Provider{ID: "sentry", Name: "Sentry", Category: plugin.CategoryMonitoring, Homepage: "https://sentry.io"}, SentryPython, plugin.LayerSDK, "https://github.com/getsentry/sentry-python") - pypi(plugin.Provider{ID: "mongodb", Name: "MongoDB", Category: plugin.CategoryDatabases, Homepage: "https://www.mongodb.com"}, PyMongo, plugin.LayerSDK, "https://github.com/mongodb/mongo-python-driver") - pypi(plugin.Provider{ID: "redis", Name: "Redis", Category: plugin.CategoryDatabases, Homepage: "https://redis.io"}, RedisPy, plugin.LayerSDK, "https://github.com/redis/redis-py") - pypi(plugin.Provider{ID: "numpy", Name: "NumPy", Category: plugin.CategoryPackages, Homepage: "https://numpy.org"}, NumPy, plugin.LayerPackage, "https://github.com/numpy/numpy") - pypi(plugin.Provider{ID: "supabase", Name: "Supabase", Category: plugin.CategoryDatabases, Homepage: "https://supabase.com"}, SupabasePython, plugin.LayerSDK, "https://github.com/supabase/supabase-py") - pypi(plugin.Provider{ID: "algolia", Name: "Algolia", Category: plugin.CategorySearch, Homepage: "https://www.algolia.com"}, AlgoliaPython, plugin.LayerSDK, "https://github.com/algolia/algoliasearch-client-python") - pypi(plugin.Provider{ID: "elastic", Name: "Elastic", Category: plugin.CategorySearch, Homepage: "https://www.elastic.co"}, ElasticPython, plugin.LayerSDK, "https://github.com/elastic/elasticsearch-py") - pypi(plugin.Provider{ID: "datadog", Name: "Datadog", Category: plugin.CategoryMonitoring, Homepage: "https://www.datadoghq.com"}, DDTrace, plugin.LayerSDK, "https://github.com/DataDog/dd-trace-py") - pypi(plugin.Provider{ID: "cloudflare", Name: "Cloudflare", Category: plugin.CategoryInfrastructure, Homepage: "https://www.cloudflare.com"}, CloudflarePython, plugin.LayerSDK, "https://github.com/cloudflare/cloudflare-python") - pypi(plugin.Provider{ID: "textual", Name: "Textual", Category: plugin.CategoryPackages, Homepage: "https://textual.textualize.io"}, Textual, plugin.LayerPackage, "https://github.com/Textualize/textual") - pypi(plugin.Provider{ID: "urllib3", Name: "urllib3", Category: plugin.CategoryPackages, Homepage: "https://urllib3.readthedocs.io"}, URLLib3, plugin.LayerPackage, "https://github.com/urllib3/urllib3") -} diff --git a/plugins/apisurface/pypi_test.go b/plugins/apisurface/pypi_test.go deleted file mode 100644 index ec10dea..0000000 --- a/plugins/apisurface/pypi_test.go +++ /dev/null @@ -1,201 +0,0 @@ -package apisurface - -import ( - "context" - "encoding/json" - "os" - "path/filepath" - "slices" - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -// pypiCase is one PyPI source's saved releases (testdata/pypi//, -// testdata/README.md): a golden pair, the events it must store, and a drop -// pair, a real release that must store none. Both pairs are consecutive -// releases on PyPI. -type pypiCase struct { - pkg Package - golden [2]string - want []string // each event as " " - drop [2]string -} - -var pypiCases = []pypiCase{ - // anthropic 2.7.0 dropped the beta billing-frozen error types, module - // and all. 2.5.0 made DeadlineExceededError an alias of - // GatewayTimeoutError: still importable, no event. - {AnthropicPython, [2]string{"2.6.0", "2.7.0"}, []string{ - "removed_symbol types.beta.BetaBillingFrozenError,types.beta.beta_billing_frozen_error.BetaBillingFrozenError ", - "removed_symbol types.beta.BetaBillingFrozenErrorDetails,types.beta.beta_billing_frozen_error_details.BetaBillingFrozenErrorDetails ", - }, [2]string{"2.4.0", "2.5.0"}}, - // stripe 16.0.0 removed StripeObject.request. 15.5.0 only added. - {StripePython, [2]string{"15.6.2", "16.0.0"}, []string{"removed_symbol StripeObject.request "}, [2]string{"15.4.0", "15.5.0"}}, - // google-genai 1.0.0 removed TuningJobOrOperation. 3.4.0 re-exports - // interactions' names from a private module: still importable. - {GoogleGenAI, [2]string{"0.8.0", "1.0.0"}, []string{ - "removed_symbol genai.types.TuningJobOrOperation ", - "removed_symbol genai.types.TuningJobOrOperationDict ", - }, [2]string{"3.3.0", "3.4.0"}}, - // sentry-sdk 2.74.0 removed utils.to_timestamp. 2.68.0 renamed a - // property setter's parameter: callers never pass it. - {SentryPython, [2]string{"2.73.0", "2.74.0"}, []string{"removed_symbol utils.to_timestamp "}, [2]string{"2.67.1", "2.68.0"}}, - // pymongo 4.16.0's command cursors no longer take explicit_session. - {PyMongo, [2]string{"4.15.5", "4.16.0"}, []string{ - "removed_parameter asynchronous.command_cursor.AsyncCommandCursor explicit_session", - "removed_parameter asynchronous.command_cursor.AsyncRawBatchCommandCursor explicit_session", - "removed_parameter command_cursor.CommandCursor,synchronous.command_cursor.CommandCursor explicit_session", - "removed_parameter command_cursor.RawBatchCommandCursor,synchronous.command_cursor.RawBatchCommandCursor explicit_session", - }, [2]string{"4.15.4", "4.15.5"}}, - // redis 8.1.0 removed OSSMaintNotificationsHandler.get_handler_for_connection. - {RedisPy, [2]string{"8.0.1", "8.1.0"}, []string{"removed_symbol maint_notifications.OSSMaintNotificationsHandler.get_handler_for_connection "}, [2]string{"7.4.1", "8.0.0"}}, - // numpy 2.5.0 removed row_stack, deprecated since 2.0 (read from the - // .pyi stubs). - {NumPy, [2]string{"2.4.6", "2.5.0"}, []string{"removed_symbol row_stack "}, [2]string{"2.5.0", "2.5.1"}}, - // supabase 1.0.0's SupabaseAuthClient lost four parameters. 2.34.0 made - // supabase.client a star re-export of the package: still importable. - {SupabasePython, [2]string{"0.7.1", "1.0.0"}, []string{ - "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient api", - "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient cookie_options", - "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient local_storage", - "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient replace_default_headers", - "removed_parameter lib.client_options.ClientOptions.replace local_storage", - }, [2]string{"2.33.0", "2.34.0"}}, - // algoliasearch 4.44.3 dropped recommend's FacetFilters (4.44.4 brought - // it back: an addition, no event). - {AlgoliaPython, [2]string{"4.44.1", "4.44.3"}, []string{ - "removed_symbol recommend.models.FacetFilters,recommend.models.facet_filters.FacetFilters ", - }, [2]string{"4.44.3", "4.44.4"}}, - // elasticsearch 9.1.3 made the rethrottle methods' requests_per_second - // required. - {ElasticPython, [2]string{"9.1.2", "9.1.3"}, []string{ - "changed_default Elasticsearch.delete_by_query_rethrottle,client.Elasticsearch.delete_by_query_rethrottle requests_per_second", - "changed_default Elasticsearch.reindex_rethrottle,client.Elasticsearch.reindex_rethrottle requests_per_second", - "changed_default Elasticsearch.update_by_query_rethrottle,client.Elasticsearch.update_by_query_rethrottle requests_per_second", - }, [2]string{"9.1.1", "9.1.2"}}, - // ddtrace 4.13.0 moved AI Guard to ddtrace.aiguard: the old module - // forwards its names (__getattr__), so only the two integration helpers - // it dropped are gone. - {DDTrace, [2]string{"4.12.3", "4.13.0"}, []string{ - "removed_symbol appsec.ai_guard.integrations.resolve_strands_hook_provider ", - "removed_symbol appsec.ai_guard.integrations.resolve_strands_plugin ", - }, [2]string{"4.16.0", "4.16.1"}}, - // cloudflare 5.4.0 dropped the web crawler's crawl options from AI - // Search instances, and moved the IAM OAuth scopes resource out of its - // own package (the old package still binds the response wrappers: no - // event for those). - {CloudflarePython, [2]string{"5.3.0", "5.4.0"}, []string{ - "removed_symbol resources.iam.oauth_scopes.oauth_scopes.AsyncOAuthScopesResource ", - "removed_symbol resources.iam.oauth_scopes.oauth_scopes.OAuthScopesResource ", - "removed_symbol types.aisearch.instance_create_params.SourceParamsWebCrawlerCrawlOptions ", - }, [2]string{"4.3.0", "4.3.1"}}, - // textual 8.2.6's walk_selectable_widgets no longer takes bounded. - {Textual, [2]string{"8.2.5", "8.2.6"}, []string{"removed_parameter walk.walk_selectable_widgets bounded"}, [2]string{"8.2.6", "8.2.7"}}, - // urllib3 2.6.0 removed BaseHTTPResponse.getheader and getheaders, - // deprecated since 2.0. - {URLLib3, [2]string{"2.5.0", "2.6.0"}, []string{ - "removed_symbol BaseHTTPResponse.getheader,response.BaseHTTPResponse.getheader ", - "removed_symbol BaseHTTPResponse.getheaders,response.BaseHTTPResponse.getheaders ", - }, [2]string{"2.2.1", "2.2.2"}}, -} - -// pypiPages serves a case's saved files: PyPI's answers, and each picked -// wheel, trimmed, under its real URL. -func pypiPages(t *testing.T, name string) kittest.Pages { - t.Helper() - dir := filepath.Join("testdata", "pypi", name) - pages := kittest.Pages{"https://pypi.org/pypi/" + name + "/json": filepath.Join(dir, "pypi-"+name+"-excerpt.json")} - files, err := filepath.Glob(filepath.Join(dir, "pypi-"+name+"-*.json")) - if err != nil { - t.Fatal(err) - } - for _, f := range files { - v := strings.TrimSuffix(strings.TrimPrefix(filepath.Base(f), "pypi-"+name+"-"), ".json") - if v == "excerpt" { - continue - } - pages["https://pypi.org/pypi/"+name+"/"+v+"/json"] = f - var doc struct { - URLs []struct { - URL string `json:"url"` - Filename string `json:"filename"` - } `json:"urls"` - } - if err := json.Unmarshal(kittest.Read(t, f), &doc); err != nil { - t.Fatal(err) - } - for _, u := range doc.URLs { - trimmed := filepath.Join(dir, strings.TrimSuffix(u.Filename, ".whl")+".trimmed.whl") - if _, err := os.Stat(trimmed); err == nil { - pages[u.URL] = trimmed - } - } - } - return pages -} - -// pypiPair stores one pair of a case's releases, listed as PyPI lists them. -func pypiPair(t *testing.T, c pypiCase, pair [2]string) []event.Event { - t.Helper() - ctx, env := context.Background(), kittest.Env(t, pypiPages(t, c.pkg.Name)) - p := Plugin{Package: c.pkg} - vs, err := p.ListVersions(ctx, env) - if err != nil { - t.Fatal(err) - } - byID := map[string]plugin.Version{} - for _, v := range vs { - byID[v.ID] = v - } - from, ok1 := byID[pair[0]] - to, ok2 := byID[pair[1]] - if !ok1 || !ok2 { - t.Fatalf("%s: %v not both listed in %v", c.pkg.Name, pair, vs) - } - return kittest.Versions(t, env, p, from, to) -} - -// The golden test of every PyPI source: its golden pair stores exactly -// the events listed, each citing the newer wheel and quoting both releases. -func TestPyPIGolden(t *testing.T) { - for _, c := range pypiCases { - t.Run(c.pkg.ID, func(t *testing.T) { - got := pypiPair(t, c, c.golden) - var lines []string - for _, e := range got { - lines = append(lines, string(e.Subject.Change)+" "+strings.Join(e.Subject.Symbols, ",")+" "+e.Subject.Parameter) - if e.Version != c.golden[1] || e.PreviousVersion != c.golden[0] || !strings.Contains(e.SourceURL, "files.pythonhosted.org") || !strings.Contains(e.SourceExcerpt, c.pkg.Name+" "+c.golden[0]+" (") { - t.Errorf("%s: %s<-%s cites %s, excerpt %q", e.Subject.Symbols, e.Version, e.PreviousVersion, e.SourceURL, e.SourceExcerpt) - } - } - slices.Sort(lines) - if !slices.Equal(lines, c.want) { - t.Errorf("got\n%s\nwant\n%s", strings.Join(lines, "\n"), strings.Join(c.want, "\n")) - } - provider, source, _ := strings.Cut(c.pkg.ID, "/") - kittest.Golden(t, "testdata/golden/"+provider+"-"+source+".json", got) - }) - } -} - -// The pinned drop test of every PyPI source: a real release that changes -// the package's files but nothing a caller relies on stores no event. -func TestPyPIDrop(t *testing.T) { - for _, c := range pypiCases { - t.Run(c.pkg.ID, func(t *testing.T) { - for _, e := range pypiPair(t, c, c.drop) { - t.Errorf("%s %v %s", e.Subject.Change, e.Subject.Symbols, e.Subject.Parameter) - } - }) - } -} - -func TestPyPIRegistersItself(t *testing.T) { - for _, c := range pypiCases { - kittest.Registered(t, Plugin{Package: c.pkg}) - } -} diff --git a/plugins/apisurface/testdata/README.md b/plugins/apisurface/testdata/README.md deleted file mode 100644 index ae6d3aa..0000000 --- a/plugins/apisurface/testdata/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Saved releases - -Each golden file, `golden/-.json`, is what the kind stores from a source's golden pair (`go test ./plugins/apisurface -update`): `openai-python-surface.json` from openai 1.1.1 → 1.1.2 (`apisurface_test.go`), the others from the pairs in `pypi_test.go` and `npm_test.go`, read from `pypi//` and `npm//`. - -| File | URL | Saved | License | Quote | -|---|---|---|---|---| -| `openai-1.1.1-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/f7/86/ea99e3f966a639a3256e2f79d78cd63d45d5eb651a5457ccbdcfd9eed24a/openai-1.1.1-py3-none-any.whl | 2026-11-20 | Apache-2.0 (openai-python; the wheel's `licenses/LICENSE` is kept in it). Trimmed: only `openai/__init__.py`, `openai/types/__init__.py`, every file under `openai/types/beta/`, and the dist-info `METADATA`, `WHEEL` and `LICENSE`, each copied byte for byte (46 of the wheel's files); the plugin reads the same symbols under `openai.types.beta` from it as from the whole wheel. | `class AsssitantDeleted(BaseModel):` (`openai/types/beta/asssitant_deleted.py`, line 10) | -| `openai-1.1.2-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/dd/82/b92f73453ea318c0d46f31aeb56e9d94a42606c010fb72a513f4a3cd4bac/openai-1.1.2-py3-none-any.whl | 2026-11-20 | The same, trimmed the same way. | `from .assistant_deleted import AssistantDeleted as AssistantDeleted` (`openai/types/beta/__init__.py`) | -| `pypi-openai-excerpt.json` | https://pypi.org/pypi/openai/json | 2026-11-20 | PyPI metadata. Trimmed: `releases` to 1.0.0rc1 (a pre-release, left out) and 1.1.0 to 1.1.2, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked` | | -| `pypi-openai-1.1.1.json`, `pypi-openai-1.1.2.json` | https://pypi.org/pypi/openai/1.1.1/json, …/1.1.2/json | 2026-11-20 | PyPI metadata. Trimmed: `info.name`, `info.version`, and `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/algoliasearch/`: `algoliasearch-4.44.1-py3-none-any.trimmed.whl`, `algoliasearch-4.44.3-py3-none-any.trimmed.whl`, `algoliasearch-4.44.4-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/a8/a7/74795993b739e721583653812155f0719159b79268b6eb4452594dc103fa/algoliasearch-4.44.1-py3-none-any.whl; https://files.pythonhosted.org/packages/32/05/84c46d0844055735c1192ba1a0364d871251dbf03e26a465eedf148e63f1/algoliasearch-4.44.3-py3-none-any.whl; https://files.pythonhosted.org/packages/39/53/d20cdf0238aa64a31aaea58e359aa761fe76515a7ff9872c345b5b06eaab/algoliasearch-4.44.4-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `algoliasearch/__init__.py`, `algoliasearch/recommend/__init__.py`, `algoliasearch/recommend/models/__init__.py`, `algoliasearch/recommend/models/facet_filters.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/algoliasearch/`: `pypi-algoliasearch-excerpt.json` and `pypi-algoliasearch-4.44.1.json`, `pypi-algoliasearch-4.44.3.json`, `pypi-algoliasearch-4.44.4.json` | https://pypi.org/pypi/algoliasearch/json, https://pypi.org/pypi/algoliasearch/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/anthropic/`: `anthropic-2.4.0-py3-none-any.trimmed.whl`, `anthropic-2.5.0-py3-none-any.trimmed.whl`, `anthropic-2.6.0-py3-none-any.trimmed.whl`, `anthropic-2.7.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/8b/5d/e399d9028411ce404d7ddbe6b8060d878b2549ed8cd671a7bb496ae20ffc/anthropic-2.4.0-py3-none-any.whl; https://files.pythonhosted.org/packages/f4/10/c4e6f015111c702c2d5a386ad57745b83c79c08eae68e541dbb16b5e3965/anthropic-2.5.0-py3-none-any.whl; https://files.pythonhosted.org/packages/38/0b/705a05ab68558914e725cf1143d7e409fa3bb596c35bca1eceab42402abe/anthropic-2.6.0-py3-none-any.whl; https://files.pythonhosted.org/packages/8a/da/ed144ab553eb2bc7b5febbfb37858f28b33ec332c37f0fdf260012ae3fe2/anthropic-2.7.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `anthropic/__init__.py`, `anthropic/_exceptions.py`, `anthropic/types/__init__.py`, `anthropic/types/beta/__init__.py`, `anthropic/types/beta/beta_billing_frozen_error.py`, `anthropic/types/beta/beta_billing_frozen_error_details.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/anthropic/`: `pypi-anthropic-excerpt.json` and `pypi-anthropic-2.4.0.json`, `pypi-anthropic-2.5.0.json`, `pypi-anthropic-2.6.0.json`, `pypi-anthropic-2.7.0.json` | https://pypi.org/pypi/anthropic/json, https://pypi.org/pypi/anthropic/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/cloudflare/`: `cloudflare-4.3.0-py3-none-any.trimmed.whl`, `cloudflare-4.3.1-py3-none-any.trimmed.whl`, `cloudflare-5.3.0-py3-none-any.trimmed.whl`, `cloudflare-5.4.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/83/7f/0f9370a1d2a2e425056134ccfc6b5b8f12ed43be600223bd1612f9f56c32/cloudflare-4.3.0-py3-none-any.whl; https://files.pythonhosted.org/packages/3a/8f/c6c543565efd3144da4304efa5917aac06b6416a8663a6defe0e9b2b7569/cloudflare-4.3.1-py3-none-any.whl; https://files.pythonhosted.org/packages/c5/6f/b7624d3a8f0637b04e883f289f530c88e1c4f683c70d8ebe291e4b430ec1/cloudflare-5.3.0-py3-none-any.whl; https://files.pythonhosted.org/packages/c2/bf/20002f7398cb5dc2f289cccd19777aa8869d40d5b01961ccbe8e25e094a6/cloudflare-5.4.0-py3-none-any.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `cloudflare/resources/iam/__init__.py`, `cloudflare/resources/iam/oauth_scopes.py`, `cloudflare/resources/iam/oauth_scopes/__init__.py`, `cloudflare/resources/iam/oauth_scopes/oauth_scopes.py`, `cloudflare/types/aisearch/__init__.py`, `cloudflare/types/aisearch/instance_create_params.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/cloudflare/`: `pypi-cloudflare-excerpt.json` and `pypi-cloudflare-4.3.0.json`, `pypi-cloudflare-4.3.1.json`, `pypi-cloudflare-5.3.0.json`, `pypi-cloudflare-5.4.0.json` | https://pypi.org/pypi/cloudflare/json, https://pypi.org/pypi/cloudflare/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/ddtrace/`: `ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.trimmed.whl`, `ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl`, `ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl`, `ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.trimmed.whl` | https://files.pythonhosted.org/packages/d7/18/90b574aa3c046bd9f4862b0353d8f8a42aeba504c601c3235bd8d91f057f/ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.whl; https://files.pythonhosted.org/packages/52/97/9d4ec43fa15991f195e62795e1d46fb158cab3df29c370d272889b8f8640/ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.whl; https://files.pythonhosted.org/packages/6d/af/859a2d709008db2c95842aaab04f0d242a9b338cf8279f655b0f5946c9df/ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.whl; https://files.pythonhosted.org/packages/ac/0a/ccaa73a0d201d570b3b4a3e9ef8ff1617056d552dbd3d4f81292ee7af717/ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.whl | 2026-11-21 | Apache-2.0 or BSD-3-Clause (the wheel's own license files are kept in it). Trimmed: only `ddtrace/appsec/ai_guard/__init__.py`, `ddtrace/appsec/ai_guard/_api_client.py`, `ddtrace/appsec/ai_guard/integrations/__init__.py`, `ddtrace/appsec/ai_guard/integrations/litellm.py`, `ddtrace/appsec/ai_guard/integrations/strands.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/ddtrace/`: `pypi-ddtrace-excerpt.json` and `pypi-ddtrace-4.12.3.json`, `pypi-ddtrace-4.13.0.json`, `pypi-ddtrace-4.16.0.json`, `pypi-ddtrace-4.16.1.json` | https://pypi.org/pypi/ddtrace/json, https://pypi.org/pypi/ddtrace/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/elasticsearch/`: `elasticsearch-9.1.1-py3-none-any.trimmed.whl`, `elasticsearch-9.1.2-py3-none-any.trimmed.whl`, `elasticsearch-9.1.3-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/cf/4c/c0c95d3d881732a5d1b28e12c9be4dea5953ade71810f94565bd5bd2101a/elasticsearch-9.1.1-py3-none-any.whl; https://files.pythonhosted.org/packages/89/95/ee3bcf867cdbaba15a0118d6ca0b9b4477892ff3b92e7d6135cc42b262af/elasticsearch-9.1.2-py3-none-any.whl; https://files.pythonhosted.org/packages/bf/10/cab92a57625aeb2d787e3f5e3a698948bc5b34c151422afacff1f0f1c691/elasticsearch-9.1.3-py3-none-any.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `elasticsearch/__init__.py`, `elasticsearch/_sync/client/__init__.py`, `elasticsearch/client.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/elasticsearch/`: `pypi-elasticsearch-excerpt.json` and `pypi-elasticsearch-9.1.1.json`, `pypi-elasticsearch-9.1.2.json`, `pypi-elasticsearch-9.1.3.json` | https://pypi.org/pypi/elasticsearch/json, https://pypi.org/pypi/elasticsearch/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/google-genai/`: `google_genai-0.8.0-py3-none-any.trimmed.whl`, `google_genai-1.0.0-py3-none-any.trimmed.whl`, `google_genai-3.3.0-py3-none-any.trimmed.whl`, `google_genai-3.4.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/74/6d/c5b1757ffe28fdfb38df3fda79c614ec840ebac0b72a3fcbe2ed969e254d/google_genai-0.8.0-py3-none-any.whl; https://files.pythonhosted.org/packages/24/9d/63dbd2b6c630f44cbbf09c4e04b4c9012da01f6e585d34ae53d07931bb67/google_genai-1.0.0-py3-none-any.whl; https://files.pythonhosted.org/packages/ae/e4/619de4d0f985cfafc7a420339796279716aba5c6cac362ab4f97b856279f/google_genai-3.3.0-py3-none-any.whl; https://files.pythonhosted.org/packages/2b/7a/daed011805af7b3ef07c18d4ea8e9534891c7dfeeac438b0d22361f65e0a/google_genai-3.4.0-py3-none-any.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `google/genai/__init__.py`, `google/genai/interactions.py`, `google/genai/types.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/google-genai/`: `pypi-google-genai-excerpt.json` and `pypi-google-genai-0.8.0.json`, `pypi-google-genai-1.0.0.json`, `pypi-google-genai-3.3.0.json`, `pypi-google-genai-3.4.0.json` | https://pypi.org/pypi/google-genai/json, https://pypi.org/pypi/google-genai/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/numpy/`: `numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.trimmed.whl`, `numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.trimmed.whl`, `numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.trimmed.whl` | https://files.pythonhosted.org/packages/b3/49/ec46835a70be8fa6446c495126ac84fdb28cb2558e1620ffb87a10c8b64c/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.whl; https://files.pythonhosted.org/packages/fa/0a/11486d02add7b1384dff7374d124b1cfbb0ee864dcc9f6a2c0380638cf84/numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.whl; https://files.pythonhosted.org/packages/62/7b/14687aa674250e5e546f616f486b0d56d3631cd5b2415739141ce40bdcea/numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.whl | 2026-11-21 | BSD-3-Clause (and the licenses its wheel lists) (the wheel's own license files are kept in it). Trimmed: only `numpy/__init__.py`, `numpy/__init__.pyi`, `numpy/lib/_shape_base_impl.py`, `numpy/lib/_shape_base_impl.pyi` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/numpy/`: `pypi-numpy-excerpt.json` and `pypi-numpy-2.4.6.json`, `pypi-numpy-2.5.0.json`, `pypi-numpy-2.5.1.json` | https://pypi.org/pypi/numpy/json, https://pypi.org/pypi/numpy/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/pymongo/`: `pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.trimmed.whl`, `pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.trimmed.whl`, `pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.trimmed.whl` | https://files.pythonhosted.org/packages/5c/9e/5d6bd240a8d32e088078b37dcfa1579028c51d91168c0e992827ec1e87e6/pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.whl; https://files.pythonhosted.org/packages/33/e4/d80061be4e53125597dd2916171c87986043b190e50c1834fff455e71d42/pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.whl; https://files.pythonhosted.org/packages/4d/93/c36c0998dd91ad8b5031d2e77a903d5cd705b5ba05ca92bcc8731a2c3a8d/pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `pymongo/__init__.py`, `pymongo/asynchronous/__init__.py`, `pymongo/asynchronous/command_cursor.py`, `pymongo/command_cursor.py`, `pymongo/synchronous/__init__.py`, `pymongo/synchronous/command_cursor.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/pymongo/`: `pypi-pymongo-excerpt.json` and `pypi-pymongo-4.15.4.json`, `pypi-pymongo-4.15.5.json`, `pypi-pymongo-4.16.0.json` | https://pypi.org/pypi/pymongo/json, https://pypi.org/pypi/pymongo/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/redis/`: `redis-7.4.1-py3-none-any.trimmed.whl`, `redis-8.0.0-py3-none-any.trimmed.whl`, `redis-8.0.1-py3-none-any.trimmed.whl`, `redis-8.1.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/4a/2e/2677f3f93dae0497e7e33b6637302e7f3744efc553f34231183e32584885/redis-7.4.1-py3-none-any.whl; https://files.pythonhosted.org/packages/27/e3/b519734372d305bd547534a9f32e4ce9f98552af753dce72cf3483a0ff0b/redis-8.0.0-py3-none-any.whl; https://files.pythonhosted.org/packages/fd/0a/c2345ebf1ebe70840ce3f6c6ee612f8fa749cfbd1b03069c53bf0c62aaad/redis-8.0.1-py3-none-any.whl; https://files.pythonhosted.org/packages/66/9d/c5731f6e3608663d4d3656fd8d3aecee8b509c3082818f5a13eae925baea/redis-8.1.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `redis/__init__.py`, `redis/maint_notifications.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/redis/`: `pypi-redis-excerpt.json` and `pypi-redis-7.4.1.json`, `pypi-redis-8.0.0.json`, `pypi-redis-8.0.1.json`, `pypi-redis-8.1.0.json` | https://pypi.org/pypi/redis/json, https://pypi.org/pypi/redis/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/sentry-sdk/`: `sentry_sdk-2.67.1-py3-none-any.trimmed.whl`, `sentry_sdk-2.68.0-py3-none-any.trimmed.whl`, `sentry_sdk-2.73.0-py3-none-any.trimmed.whl`, `sentry_sdk-2.74.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/34/e2/70692eba662037cddf93391cbbf98297159f3038612e9b9a8129e16feb7a/sentry_sdk-2.67.1-py3-none-any.whl; https://files.pythonhosted.org/packages/7d/9b/e2421d08956d0bc4691d995393d835e563886bff499d8fb10fdefae85a8d/sentry_sdk-2.68.0-py3-none-any.whl; https://files.pythonhosted.org/packages/b2/88/cabf98d017d7b940720e514e5f8ee02e3e6f7495caf93c30735a38387ec4/sentry_sdk-2.73.0-py3-none-any.whl; https://files.pythonhosted.org/packages/55/b1/736d4b4b308694b0071844a533522ac06669ad61751687b94edfbf863f17/sentry_sdk-2.74.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `sentry_sdk/__init__.py`, `sentry_sdk/traces.py`, `sentry_sdk/utils.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/sentry-sdk/`: `pypi-sentry-sdk-excerpt.json` and `pypi-sentry-sdk-2.67.1.json`, `pypi-sentry-sdk-2.68.0.json`, `pypi-sentry-sdk-2.73.0.json`, `pypi-sentry-sdk-2.74.0.json` | https://pypi.org/pypi/sentry-sdk/json, https://pypi.org/pypi/sentry-sdk/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/stripe/`: `stripe-15.4.0-py3-none-any.trimmed.whl`, `stripe-15.5.0-py3-none-any.trimmed.whl`, `stripe-15.6.2-py3-none-any.trimmed.whl`, `stripe-16.0.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/00/e1/3047b4e244cc78bb598b0d5fcab6632b8bf8a4d526f2e840c4f4de02c989/stripe-15.4.0-py3-none-any.whl; https://files.pythonhosted.org/packages/d5/20/4c8377c570697ebe105ad5e073538e498d58e4985ca6e2944bdc917a5034/stripe-15.5.0-py3-none-any.whl; https://files.pythonhosted.org/packages/25/e9/251eb26d9ceae6c44adb3a54cb81ec717dc469452c09756b53a117726277/stripe-15.6.2-py3-none-any.whl; https://files.pythonhosted.org/packages/b5/de/5141ae3990862cc3d61a1cdd4acff72bcb587afb7b4d31c52eaddbb6bc8f/stripe-16.0.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `stripe/__init__.py`, `stripe/_stripe_object.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/stripe/`: `pypi-stripe-excerpt.json` and `pypi-stripe-15.4.0.json`, `pypi-stripe-15.5.0.json`, `pypi-stripe-15.6.2.json`, `pypi-stripe-16.0.0.json` | https://pypi.org/pypi/stripe/json, https://pypi.org/pypi/stripe/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/supabase/`: `supabase-0.7.1-py3-none-any.trimmed.whl`, `supabase-1.0.0-py3-none-any.trimmed.whl`, `supabase-2.33.0-py3-none-any.trimmed.whl`, `supabase-2.34.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/ea/1f/3aa8dd96fc0aab80693ff6c341b9178bd3eaacb81006703f3adf07719544/supabase-0.7.1-py3-none-any.whl; https://files.pythonhosted.org/packages/8d/7b/42e5e27e4c9f4f5e24c0d3294b7448948b97963c69d634c664b7beaaae4b/supabase-1.0.0-py3-none-any.whl; https://files.pythonhosted.org/packages/8d/48/1a8f57fdaf882f1dcd7836352e33829c1d455c6cfc387d2b0fb1e99ffdb6/supabase-2.33.0-py3-none-any.whl; https://files.pythonhosted.org/packages/18/20/48dc58aa9d3a0245694ef52433305edd4536f80ad3d30572d4658d160839/supabase-2.34.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `supabase/__init__.py`, `supabase/__version__.py`, `supabase/_async/__init__.py`, `supabase/_async/auth_client.py`, `supabase/_async/client.py`, `supabase/_sync/__init__.py`, `supabase/_sync/auth_client.py`, `supabase/_sync/client.py`, `supabase/client.py`, `supabase/lib/__init__.py`, `supabase/lib/auth_client.py`, `supabase/lib/client_options.py`, `supabase/lib/realtime_client.py`, `supabase/lib/storage_client.py`, `supabase/py.typed`, `supabase/types.py`, `supabase/version.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/supabase/`: `pypi-supabase-excerpt.json` and `pypi-supabase-0.7.1.json`, `pypi-supabase-1.0.0.json`, `pypi-supabase-2.33.0.json`, `pypi-supabase-2.34.0.json` | https://pypi.org/pypi/supabase/json, https://pypi.org/pypi/supabase/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/textual/`: `textual-8.2.5-py3-none-any.trimmed.whl`, `textual-8.2.6-py3-none-any.trimmed.whl`, `textual-8.2.7-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/cd/01/c4555f9c8a692ff83d84930150540f743ce94c89234f9e9a15ff4baba3a8/textual-8.2.5-py3-none-any.whl; https://files.pythonhosted.org/packages/b8/b4/c2b876f445e52522824cb900f2c7db3a7c24f89d20449ef278b4195d0ecb/textual-8.2.6-py3-none-any.whl; https://files.pythonhosted.org/packages/a8/f5/c1e18bc0707300a0e90204343abbf7d7acd6fb7ebe03a6d4893b99a234b8/textual-8.2.7-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `textual/walk.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/textual/`: `pypi-textual-excerpt.json` and `pypi-textual-8.2.5.json`, `pypi-textual-8.2.6.json`, `pypi-textual-8.2.7.json` | https://pypi.org/pypi/textual/json, https://pypi.org/pypi/textual/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `pypi/urllib3/`: `urllib3-2.2.1-py3-none-any.trimmed.whl`, `urllib3-2.2.2-py3-none-any.trimmed.whl`, `urllib3-2.5.0-py3-none-any.trimmed.whl`, `urllib3-2.6.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl; https://files.pythonhosted.org/packages/ca/1c/89ffc63a9605b583d5df2be791a27bc1a42b7c32bab68d3c8f2f73a98cd4/urllib3-2.2.2-py3-none-any.whl; https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl; https://files.pythonhosted.org/packages/56/1a/9ffe814d317c5224166b23e7c47f606d6e473712a2fad0f704ea9b99f246/urllib3-2.6.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `urllib3/__init__.py`, `urllib3/response.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's page under `providers/` | -| `pypi/urllib3/`: `pypi-urllib3-excerpt.json` and `pypi-urllib3-2.2.1.json`, `pypi-urllib3-2.2.2.json`, `pypi-urllib3-2.5.0.json`, `pypi-urllib3-2.6.0.json` | https://pypi.org/pypi/urllib3/json, https://pypi.org/pypi/urllib3/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | -| `npm/anthropic-ai-sdk/`: `sdk-1.6.0.trimmed.tgz`, `sdk-1.7.0.trimmed.tgz`, `sdk-1.8.0.trimmed.tgz` | https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.6.0.tgz; https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.7.0.tgz; https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.8.0.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `client.d.mts`, `index.d.mts`, `resources/beta.d.mts`, `resources/beta/beta.d.mts`, `resources/beta/index.d.mts`, `resources/beta/organization.d.mts`, `resources/beta/organization/index.d.mts`, `resources/beta/organization/organization.d.mts`, `resources/index.d.mts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/anthropic-ai-sdk/`: `npm-anthropic-ai-sdk-excerpt.json` and `npm-anthropic-ai-sdk-1.6.0.json`, `npm-anthropic-ai-sdk-1.7.0.json`, `npm-anthropic-ai-sdk-1.8.0.json` | https://registry.npmjs.org/@anthropic-ai%2Fsdk, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/convex/`: `convex-1.35.0.trimmed.tgz`, `convex-1.35.1.trimmed.tgz`, `convex-1.42.2.trimmed.tgz`, `convex-1.42.3.trimmed.tgz` | https://registry.npmjs.org/convex/-/convex-1.35.0.tgz; https://registry.npmjs.org/convex/-/convex-1.35.1.tgz; https://registry.npmjs.org/convex/-/convex-1.42.2.tgz; https://registry.npmjs.org/convex/-/convex-1.42.3.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/esm-types/browser/index.d.ts`, `dist/esm-types/browser/query_options.d.ts`, `dist/esm-types/react/client.d.ts`, `dist/esm-types/react/index.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/convex/`: `npm-convex-excerpt.json` and `npm-convex-1.35.0.json`, `npm-convex-1.35.1.json`, `npm-convex-1.42.2.json`, `npm-convex-1.42.3.json` | https://registry.npmjs.org/convex, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/google-genai/`: `genai-0.15.0.trimmed.tgz`, `genai-1.0.0.trimmed.tgz`, `genai-1.1.0.trimmed.tgz` | https://registry.npmjs.org/@google/genai/-/genai-0.15.0.tgz; https://registry.npmjs.org/@google/genai/-/genai-1.0.0.tgz; https://registry.npmjs.org/@google/genai/-/genai-1.1.0.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/genai.d.ts`, `dist/node/node.d.ts`, `dist/web/web.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/google-genai/`: `npm-google-genai-excerpt.json` and `npm-google-genai-0.15.0.json`, `npm-google-genai-1.0.0.json`, `npm-google-genai-1.1.0.json` | https://registry.npmjs.org/@google%2Fgenai, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/mongodb/`: `mongodb-6.22.0.trimmed.tgz`, `mongodb-7.0.0.trimmed.tgz`, `mongodb-7.1.0.trimmed.tgz` | https://registry.npmjs.org/mongodb/-/mongodb-6.22.0.tgz; https://registry.npmjs.org/mongodb/-/mongodb-7.0.0.tgz; https://registry.npmjs.org/mongodb/-/mongodb-7.1.0.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `mongodb.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/mongodb/`: `npm-mongodb-excerpt.json` and `npm-mongodb-6.22.0.json`, `npm-mongodb-7.0.0.json`, `npm-mongodb-7.1.0.json` | https://registry.npmjs.org/mongodb, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/neondatabase-serverless/`: `serverless-0.10.4.trimmed.tgz`, `serverless-1.0.0.trimmed.tgz`, `serverless-1.0.1.trimmed.tgz` | https://registry.npmjs.org/@neondatabase/serverless/-/serverless-0.10.4.tgz; https://registry.npmjs.org/@neondatabase/serverless/-/serverless-1.0.0.tgz; https://registry.npmjs.org/@neondatabase/serverless/-/serverless-1.0.1.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `index.d.mts`, `index.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/neondatabase-serverless/`: `npm-neondatabase-serverless-excerpt.json` and `npm-neondatabase-serverless-0.10.4.json`, `npm-neondatabase-serverless-1.0.0.json`, `npm-neondatabase-serverless-1.0.1.json` | https://registry.npmjs.org/@neondatabase%2Fserverless, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/openai/`: `openai-7.59.0.trimmed.tgz`, `openai-7.60.0.trimmed.tgz`, `openai-7.61.0.trimmed.tgz` | https://registry.npmjs.org/openai/-/openai-7.59.0.tgz; https://registry.npmjs.org/openai/-/openai-7.60.0.tgz; https://registry.npmjs.org/openai/-/openai-7.61.0.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `resources/beta.d.mts`, `resources/beta/agents.d.mts`, `resources/beta/agents/agents.d.mts`, `resources/beta/agents/index.d.mts`, `resources/beta/index.d.mts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/openai/`: `npm-openai-excerpt.json` and `npm-openai-7.59.0.json`, `npm-openai-7.60.0.json`, `npm-openai-7.61.0.json` | https://registry.npmjs.org/openai, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/redis-client/`: `client-1.6.1.trimmed.tgz`, `client-5.0.0.trimmed.tgz`, `client-6.3.0.trimmed.tgz`, `client-6.3.1.trimmed.tgz` | https://registry.npmjs.org/@redis/client/-/client-1.6.1.tgz; https://registry.npmjs.org/@redis/client/-/client-5.0.0.tgz; https://registry.npmjs.org/@redis/client/-/client-6.3.0.tgz; https://registry.npmjs.org/@redis/client/-/client-6.3.1.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/index.d.ts`, `dist/lib/client/index.d.ts`, `dist/lib/command-options.d.ts`, `dist/lib/commands/FLUSHALL.d.ts`, `dist/lib/errors.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/redis-client/`: `npm-redis-client-excerpt.json` and `npm-redis-client-1.6.1.json`, `npm-redis-client-5.0.0.json`, `npm-redis-client-6.3.0.json`, `npm-redis-client-6.3.1.json` | https://registry.npmjs.org/@redis%2Fclient, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/sentry-node/`: `node-10.0.0.trimmed.tgz`, `node-11.12.0.trimmed.tgz`, `node-11.13.0.trimmed.tgz`, `node-9.47.2.trimmed.tgz` | https://registry.npmjs.org/@sentry/node/-/node-10.0.0.tgz; https://registry.npmjs.org/@sentry/node/-/node-11.12.0.tgz; https://registry.npmjs.org/@sentry/node/-/node-11.13.0.tgz; https://registry.npmjs.org/@sentry/node/-/node-9.47.2.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `build/types/index.d.ts`, `build/types/logs/exports.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/sentry-node/`: `npm-sentry-node-excerpt.json` and `npm-sentry-node-10.0.0.json`, `npm-sentry-node-11.12.0.json`, `npm-sentry-node-11.13.0.json`, `npm-sentry-node-9.47.2.json` | https://registry.npmjs.org/@sentry%2Fnode, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/stripe/`: `stripe-22.6.2.trimmed.tgz`, `stripe-23.0.0.trimmed.tgz`, `stripe-23.0.1.trimmed.tgz` | https://registry.npmjs.org/stripe/-/stripe-22.6.2.tgz; https://registry.npmjs.org/stripe/-/stripe-23.0.0.tgz; https://registry.npmjs.org/stripe/-/stripe-23.0.1.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `esm/stripe.esm.node.d.ts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/stripe/`: `npm-stripe-excerpt.json` and `npm-stripe-22.6.2.json`, `npm-stripe-23.0.0.json`, `npm-stripe-23.0.1.json` | https://registry.npmjs.org/stripe, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | -| `npm/supabase-supabase-js/`: `supabase-js-1.35.7.trimmed.tgz`, `supabase-js-2.0.0.trimmed.tgz`, `supabase-js-2.118.0.trimmed.tgz`, `supabase-js-2.119.0.trimmed.tgz` | https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-1.35.7.tgz; https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.0.0.tgz; https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.118.0.tgz; https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.119.0.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/cors.d.cts`, `dist/cors.d.mts`, `dist/index.d.cts`, `dist/index.d.mts`, `dist/main/SupabaseClient.d.ts`, `dist/main/index.d.ts`, `dist/main/lib/SupabaseAuthClient.d.ts`, `dist/main/lib/SupabaseQueryBuilder.d.ts`, `dist/main/lib/SupabaseRealtimeClient.d.ts`, `dist/main/lib/constants.d.ts`, `dist/main/lib/fetch.d.ts`, `dist/main/lib/helpers.d.ts`, `dist/main/lib/types.d.ts`, `dist/main/lib/version.d.ts`, `dist/module/SupabaseClient.d.ts`, `dist/module/index.d.ts`, `dist/module/lib/SupabaseAuthClient.d.ts`, `dist/module/lib/SupabaseQueryBuilder.d.ts`, `dist/module/lib/SupabaseRealtimeClient.d.ts`, `dist/module/lib/constants.d.ts`, `dist/module/lib/fetch.d.ts`, `dist/module/lib/helpers.d.ts`, `dist/module/lib/types.d.ts`, `dist/module/lib/version.d.ts`, `dist/tracing.d.cts`, `dist/tracing.d.mts`, each copied byte for byte | see the source's page under `providers/` | -| `npm/supabase-supabase-js/`: `npm-supabase-supabase-js-excerpt.json` and `npm-supabase-supabase-js-1.35.7.json`, `npm-supabase-supabase-js-2.0.0.json`, `npm-supabase-supabase-js-2.118.0.json`, `npm-supabase-supabase-js-2.119.0.json` | https://registry.npmjs.org/@supabase%2Fsupabase-js, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/catalog/registered_test.go b/plugins/catalog/registered_test.go deleted file mode 100644 index 1f8630c..0000000 --- a/plugins/catalog/registered_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package catalog - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" -) - -func TestRegistersItself(t *testing.T) { - kittest.Registered(t, Redis) - kittest.Registered(t, GitHubGraphQL) -} diff --git a/plugins/catalog/testdata/README.md b/plugins/catalog/testdata/README.md deleted file mode 100644 index f71b7c9..0000000 --- a/plugins/catalog/testdata/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Saved catalog snapshots - -The golden files, `golden/redis-commands.json` and `golden/github-graphql.json`, are what the catalog kind stores from the files below (`go test ./plugins/catalog -update`). - -| File | URL | Fetched | License | Quote | -|---|---|---|---|---| -| `redis-contents-src-commands-8.8-m03.json` | https://api.github.com/repos/redis/redis/contents/src/commands?ref=8.8-m03 | 2026-11-20 | BSD-3-Clause / RSALv2 / SSPLv1 / AGPLv3 (redis/redis); the listing cut to the two fields read, `name` and `type`, every entry kept | `{"name": "gcra.json", "type": "file"}` | -| `redis-contents-src-commands-8.8-rc1.json` | https://api.github.com/repos/redis/redis/contents/src/commands?ref=8.8-rc1 | 2026-11-20 | as above | no `gcra.json`, no `gcrasetvalue.json` | -| `redis-contents-src-commands-8.8.0.json`, `redis-contents-src-commands-8.10.0.json` | https://api.github.com/repos/redis/redis/contents/src/commands?ref=8.8.0 and `?ref=8.10.0` | 2026-11-20 | as above | the drop test: 17 files added, none removed | -| `redis-8.8-m03-gcra.json` | https://raw.githubusercontent.com/redis/redis/8.8-m03/src/commands/gcra.json | 2026-11-20 | as above, kept whole, byte for byte | `"GCRA": {"summary": "Rate limit via GCRA (Generic Cell Rate Algorithm).", … "since": "8.8.0"` | -| `redis-8.8-m03-gcrasetvalue.json` | https://raw.githubusercontent.com/redis/redis/8.8-m03/src/commands/gcrasetvalue.json | 2026-11-20 | as above, kept whole, byte for byte | `"GCRASETVALUE": {"summary": "An internal command for recording a GCRA TAT value during AOF rewrite and replication."` | -| `redis-releases-excerpt.json` | https://api.github.com/repos/redis/redis/releases (shape only) | written for the test, 2026-11-20 | not a saved copy: five entries in the shape of GitHub's releases API (`tag_name`, `draft`, `prerelease`, `published_at`, `html_url`), dates approximate, a pre-release and a patch to an older line published later among them | for the version-listing test only | -| `github-graphql-upcoming-changes-.json` (seven) | https://github.com/github/docs/blob//src/graphql/data/fpt/upcoming-changes.json at fc26275f, 54c26c43, 2706f417 (2026-01-05 to 08) and fc7cedfe, 3a14e541, a934f06d, c5738e58 (2026-02-13 to 06-23) | 2026-11-21 | CC BY 4.0 (github/docs content). Excerpts for testing: each keeps the first entry under every date of the first file of its group, and every entry the group's commits add; every kept entry unchanged, in the file's order. The plugin finds the same additions between them as between the full files (2, 1, 1; and 17 re-added, past-dated) | `"location": "CheckAnnotation.databaseId", "description": "

    databaseId will be removed. Use fullDatabaseId instead.

    "` | -| `github-commits-upcoming-changes-excerpt.json` | https://api.github.com/repos/github/docs/commits?path=src/graphql/data/fpt/upcoming-changes.json (shape only) | written for the test, 2026-11-21 | not a saved copy: three of the real commits (SHA, date, URL), newest first as GitHub lists them | for the version-listing test only | diff --git a/plugins/changelog/changelog_test.go b/plugins/changelog/changelog_test.go deleted file mode 100644 index a89238d..0000000 --- a/plugins/changelog/changelog_test.go +++ /dev/null @@ -1,155 +0,0 @@ -package changelog - -import ( - "context" - "errors" - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -// Two real changelogs at their release tags (testdata/README.md) in, every -// event out: each the pair from the release before (on PyPI) to the pinned one. -func TestGolden(t *testing.T) { - for _, c := range []struct { - file File - saved string - previous string - }{ - {Textual0860, "testdata/textual-v0.86.0-CHANGELOG.md", "0.85.2"}, - {Urllib3200, "testdata/urllib3-2.0.0-CHANGES.rst", "1.26.15"}, - } { - t.Run(c.file.Package, func(t *testing.T) { - got := release(t, c.file, c.saved, c.previous) - kittest.Golden(t, "testdata/golden/"+c.file.Package+"-"+c.file.Release+".json", got) - }) - } -} - -// release is the pair previous -> f's pinned release, as patch-it's hosted -// ingestion service extracts it. A changelog's Extract reads only the newer -// release's own section, so previous is named, not read. -func release(t *testing.T, f File, saved, previous string) []event.Event { - t.Helper() - env := kittest.Env(t, kittest.Pages{f.URL(): saved}) - p := Plugin{File: f} - to, err := p.ReadAt(context.Background(), env, plugin.Version{ID: f.Release, Ref: f.Tag}) - if err != nil { - t.Fatal(err) - } - from := plugin.Snapshot{Version: plugin.Version{ID: previous, Ref: f.TagPrefix + previous}} - return kittest.Extracted(t, env, p, from, to) -} - -// Every bullet of each release that is breaking or a deprecation but isn't -// plain enough is dropped, not guessed: pinned here with why. -func TestUnsureBulletsAreDropped(t *testing.T) { - for _, c := range []struct { - file File - saved string - dropped []string // the start of each dropped bullet, in order - }{ - {Textual0860, "testdata/textual-v0.86.0-CHANGELOG.md", []string{ - "Breaking change: To improve consistency", // a look change, no names - }}, - {Urllib3200, "testdata/urllib3-2.0.0-CHANGES.rst", []string{ - "Removed support for Python 2.7", - "Removed fallback on certificate", - "Removed support for Python with an", - "Removed support for OpenSSL versions", - "Removed the list of default ciphers", - "Removed ``urllib3.contrib.appengine.AppEngineManager`` and support", // names and an environment - "Removed deprecated ``Retry`` options", // parameters - "Removed default value of ``None``", // a default, of a parameter - "Removed the ``urllib3.request`` module", // the release adds urllib3.request back - "Removed support for SSLv3.0", - "Removed ``DEFAULT_CIPHERS``, ``HAS_SNI``", // a private module - "Deprecated ``ssl_version`` option", // a parameter of what? - "Deprecated the ``strict`` parameter", - "Deprecated ``RequestField.header_formatter`` parameter", - }}, - } { - _, fs, err := c.file.Read(kittest.Read(t, c.saved)) - if err != nil { - t.Fatal(err) - } - var drops []Finding - for _, f := range fs { - if f.Dropped != "" { - drops = append(drops, f) - } - } - if len(drops) != len(c.dropped) { - for _, d := range drops { - t.Logf("dropped %q: %s", d.Bullet.Text, d.Dropped) - } - t.Errorf("%s: dropped %d, want %d", c.file.Package, len(drops), len(c.dropped)) - continue - } - for i, want := range c.dropped { - if !strings.HasPrefix(drops[i].Bullet.Text, want) { - t.Errorf("%s: drop %d is %q, want %q…", c.file.Package, i, drops[i].Bullet.Text, want) - } - } - } -} - -// A Go module's events name the module as code imports it at that major. -func TestAGoModuleIsNamedByItsMajor(t *testing.T) { - f := File{Package: "github.com/acme/acme-go", Ecosystem: "go"} - for release, want := range map[string]string{"73.0.0": "github.com/acme/acme-go/v73", "1.4.0": "github.com/acme/acme-go", "0.31.0": "github.com/acme/acme-go"} { - if got := f.At(release).installed(); got != want { - t.Errorf("%s: %s, want %s", release, got, want) - } - } -} - -// A release's notes on GitHub are read whole: any heading level starts a -// section, a code fence is skipped, and notes for another tag or none at -// all are never read as "no breaking changes". -func TestReleaseNotesAreReadWhole(t *testing.T) { - f := File{Package: "acme", Repo: "acme/acme", TagPrefix: "v", Notes: true}.At("2.0.0") - body := "## BREAKING CHANGES\\n\\n* `acme.old()` has been removed\\n\\n```\\n- `acme.example()` has been removed\\n```\\n\\n### Features\\n\\n* add `acme.new()`\\n" - _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "name": "v2.0.0", "body": "` + body + `"}`)) - if err != nil { - t.Fatal(err) - } - if len(fs) != 1 || fs[0].Dropped != "" || strings.Join(fs[0].Change.Symbols, ",") != "acme.old" { - t.Errorf("findings %+v", fs) - } - if f.Cite() != "https://github.com/acme/acme/releases/tag/v2.0.0" || f.URL() != "https://api.github.com/repos/acme/acme/releases/tags/v2.0.0" { - t.Errorf("cite %s, url %s", f.Cite(), f.URL()) - } - if _, _, err := f.Read([]byte(`{"tag_name": "v1.9.0", "body": "x"}`)); err == nil { - t.Error("another release's notes: want an error") - } - if _, _, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": ""}`)); !errors.Is(err, plugin.ErrNothingToRead) { - t.Errorf("no notes: %v, want plugin.ErrNothingToRead", err) - } -} - -// A rename whose new name the same release renames again or removes points -// to where the chain ends: never to a name the release took away. -func TestRenamesAreFollowedToTheirEnd(t *testing.T) { - f := File{Package: "acme", Repo: "acme/acme", TagPrefix: "v", Notes: true}.At("2.0.0") - body := "## BREAKING CHANGES\\n\\n" + - "* `acme.a()` has been renamed to `acme.b()`\\n* `acme.b()` has been renamed to `acme.c()`\\n" + - "* `acme.x()` has been renamed to `acme.y()`\\n* `acme.y()` has been removed\\n" + - "* `acme.p()` has been renamed to `acme.q()`\\n* `acme.q()` has been renamed to `acme.p()`\\n" + - "## Deprecations\\n\\n* Deprecated `acme.d` in favor of `acme.y`\\n" - _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": "` + body + `"}`)) - if err != nil { - t.Fatal(err) - } - var got []string - for _, f := range fs { - got = append(got, strings.Join(f.Change.Symbols, ",")+">"+f.Change.Replacement) - } - want := "acme.a>acme.c acme.b>acme.c acme.x> acme.y> acme.p> acme.q> acme.d>acme.y" - if strings.Join(got, " ") != want { - t.Errorf("got %s\nwant %s", strings.Join(got, " "), want) - } -} diff --git a/plugins/changelog/cloudflare.go b/plugins/changelog/cloudflare.go deleted file mode 100644 index 8961db4..0000000 --- a/plugins/changelog/cloudflare.go +++ /dev/null @@ -1,30 +0,0 @@ -package changelog - -import "github.com/patch-it-dev/patch-it-plugins/core/plugin" - -func init() { - const page = "providers/cloudflare-sdks.md" - plugin.RegisterProvider(plugin.Provider{ - ID: "cloudflare", Name: "Cloudflare", Category: plugin.CategoryInfrastructure, Homepage: "https://www.cloudflare.com", - Sources: []plugin.Source{ - sdk(page, "typescript", CloudflareTypeScript, "npm:cloudflare"), - sdk(page, "python", CloudflarePython, "pypi:cloudflare"), - sdk(page, "go", CloudflareGo, "go:github.com/cloudflare/cloudflare-go/v7"), - sdk(page, "terraform", CloudflareTerraform), - }, - }) -} - -// Cloudflare's Stainless SDKs and its Terraform provider: release-please -// CHANGELOG.md, "## X.Y.Z (date)" with "### ⚠ BREAKING CHANGES" and bullets -// that start with an area ("**accounts:** ..."); tagged vX.Y.Z. -var ( - CloudflareTypeScript = File{API: "cloudflare/typescript", Package: "cloudflare", Ecosystem: "npm", - Repo: "cloudflare/cloudflare-typescript", TagPrefix: "v", Path: "CHANGELOG.md"} - CloudflarePython = File{API: "cloudflare/python", Package: "cloudflare", Ecosystem: "pypi", Module: "cloudflare", - Repo: "cloudflare/cloudflare-python", TagPrefix: "v", Path: "CHANGELOG.md"} - CloudflareGo = File{API: "cloudflare/go", Package: "github.com/cloudflare/cloudflare-go", Ecosystem: "go", - Repo: "cloudflare/cloudflare-go", TagPrefix: "v", Path: "CHANGELOG.md"} - CloudflareTerraform = File{API: "cloudflare/terraform", Package: "cloudflare/cloudflare", Ecosystem: "terraform", - Repo: "cloudflare/terraform-provider-cloudflare", TagPrefix: "v", Path: "CHANGELOG.md"} -) diff --git a/plugins/changelog/cloudflare_test.go b/plugins/changelog/cloudflare_test.go deleted file mode 100644 index 5241672..0000000 --- a/plugins/changelog/cloudflare_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package changelog - -import "testing" - -func TestCloudflareSDKs(t *testing.T) { - checkSDKs(t, []sdkCase{ - {CloudflareTypeScript, "7.1.0", "7.0.0", "cloudflare-typescript-7.1.0-CHANGELOG.md", "", "7.0.0"}, - {CloudflarePython, "5.6.0", "5.5.0", "cloudflare-python-5.6.0-CHANGELOG.md", "", "5.4.0"}, - {CloudflareGo, "7.15.0", "7.14.0", "cloudflare-go-7.15.0-CHANGELOG.md", "", "7.13.1"}, - {CloudflareTerraform, "5.29.0", "5.28.1", "cloudflare-terraform-5.29.0-CHANGELOG.md", "", "5.28.1"}, - }) -} diff --git a/plugins/changelog/ioredis.go b/plugins/changelog/ioredis.go deleted file mode 100644 index 31a7cdb..0000000 --- a/plugins/changelog/ioredis.go +++ /dev/null @@ -1,16 +0,0 @@ -package changelog - -import "github.com/patch-it-dev/patch-it-plugins/core/plugin" - -func init() { - const page = "providers/redis-ioredis.md" - plugin.RegisterProvider(plugin.Provider{ - ID: "redis", Name: "Redis", Category: plugin.CategoryDatabases, Homepage: "https://redis.io", - Sources: []plugin.Source{sdk(page, "ioredis", RedisIoredis, "npm:ioredis")}, - }) -} - -// RedisIoredis is ioredis' semantic-release CHANGELOG.md: "## [X.Y.Z](...)" -// with "### BREAKING CHANGES"; tagged vX.Y.Z. -var RedisIoredis = File{API: "redis/ioredis", Package: "ioredis", Ecosystem: "npm", - Repo: "redis/ioredis", TagPrefix: "v", Path: "CHANGELOG.md"} diff --git a/plugins/changelog/ioredis_test.go b/plugins/changelog/ioredis_test.go deleted file mode 100644 index ace38d9..0000000 --- a/plugins/changelog/ioredis_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package changelog - -import "testing" - -func TestIoredisSDKs(t *testing.T) { - checkSDKs(t, []sdkCase{ - {RedisIoredis, "5.0.0", "4.31.0", "redis-ioredis-5.0.0-CHANGELOG.md", "", "5.0.0-beta.4"}, - }) -} diff --git a/plugins/changelog/octokit.go b/plugins/changelog/octokit.go deleted file mode 100644 index aefa520..0000000 --- a/plugins/changelog/octokit.go +++ /dev/null @@ -1,24 +0,0 @@ -package changelog - -import "github.com/patch-it-dev/patch-it-plugins/core/plugin" - -func init() { - const page = "providers/github-octokit.md" - plugin.RegisterProvider(plugin.Provider{ - ID: "github", Name: "GitHub", Category: plugin.CategoryDevTools, Homepage: "https://github.com", - Sources: []plugin.Source{ - sdk(page, "octokit-rest", OctokitRest, "npm:@octokit/rest"), - sdk(page, "octokit-net", OctokitNet, "nuget:Octokit"), - }, - }) -} - -// Octokit's SDKs keep no changelog file: each GitHub release's notes are it -// (semantic-release's "### BREAKING CHANGES" for rest.js, "Breaking -// changes" lists for octokit.net); tagged vX.Y.Z. -var ( - OctokitRest = File{API: "github/octokit-rest", Package: "@octokit/rest", Ecosystem: "npm", - Repo: "octokit/rest.js", TagPrefix: "v", Notes: true} - OctokitNet = File{API: "github/octokit-net", Package: "Octokit", Ecosystem: "nuget", - Repo: "octokit/octokit.net", TagPrefix: "v", Notes: true} -) diff --git a/plugins/changelog/octokit_test.go b/plugins/changelog/octokit_test.go deleted file mode 100644 index 6e4c47b..0000000 --- a/plugins/changelog/octokit_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package changelog - -import "testing" - -func TestOctokitSDKs(t *testing.T) { - checkSDKs(t, []sdkCase{ - {OctokitRest, "18.0.0", "17.11.2", "github-octokit-rest-18.0.0-release.json", "github-octokit-rest-17.11.2-release.json", "17.11.2"}, - {OctokitNet, "0.5.2", "0.5.1", "github-octokit-net-0.5.2-release.json", "github-octokit-net-0.5.1-release.json", "0.5.1"}, - }) -} diff --git a/plugins/changelog/pinned_test.go b/plugins/changelog/pinned_test.go deleted file mode 100644 index f048a7b..0000000 --- a/plugins/changelog/pinned_test.go +++ /dev/null @@ -1,8 +0,0 @@ -package changelog - -// The releases the golden files pin. Only a test names a release: the -// registered sources list theirs from PyPI. -var ( - Textual0860 = Textual.At("0.86.0") - Urllib3200 = Urllib3.At("2.0.0") -) diff --git a/plugins/changelog/posthog.go b/plugins/changelog/posthog.go deleted file mode 100644 index c2977fc..0000000 --- a/plugins/changelog/posthog.go +++ /dev/null @@ -1,16 +0,0 @@ -package changelog - -import "github.com/patch-it-dev/patch-it-plugins/core/plugin" - -func init() { - const page = "providers/posthog-go.md" - plugin.RegisterProvider(plugin.Provider{ - ID: "posthog", Name: "PostHog", Category: plugin.CategoryAnalytics, Homepage: "https://posthog.com", - Sources: []plugin.Source{sdk(page, "go", PostHogGo, "go:github.com/posthog/posthog-go")}, - }) -} - -// PostHogGo is posthog-go's changesets CHANGELOG.md: "## X.Y.Z" with "### -// Major Changes", each bullet starting with its commit; tagged vX.Y.Z. -var PostHogGo = File{API: "posthog/go", Package: "github.com/posthog/posthog-go", Ecosystem: "go", Module: "posthog", - Repo: "PostHog/posthog-go", TagPrefix: "v", Path: "CHANGELOG.md"} diff --git a/plugins/changelog/posthog_test.go b/plugins/changelog/posthog_test.go deleted file mode 100644 index 54fdebd..0000000 --- a/plugins/changelog/posthog_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package changelog - -import "testing" - -func TestPostHogGoSDKs(t *testing.T) { - checkSDKs(t, []sdkCase{ - {PostHogGo, "2.0.0", "1.44.1", "posthog-go-2.0.0-CHANGELOG.md", "", "1.44.1"}, - }) -} diff --git a/plugins/changelog/registered_test.go b/plugins/changelog/registered_test.go deleted file mode 100644 index df91f1e..0000000 --- a/plugins/changelog/registered_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package changelog - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" -) - -func TestRegistersItself(t *testing.T) { - for _, f := range []File{Textual0860, Urllib3200} { - kittest.Registered(t, Plugin{File: f}) - } - kittest.Registered(t, Plugin{Log: MongoDBAtlas}) -} diff --git a/plugins/changelog/sdks_test.go b/plugins/changelog/sdks_test.go deleted file mode 100644 index d8cfb4b..0000000 --- a/plugins/changelog/sdks_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package changelog - -import ( - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" -) - -// sdkCase is one SDK's changelog, saved at a release's tag -// (testdata/README.md), and the release its golden pins: the pair from the -// release before (on the registry, or among the repo's tags) to it. drop is -// another release in the same saved file (for Notes, in dropped, its own -// saved release) whose notes name nothing removed: it must read as no event. -type sdkCase struct { - file File - release, prev string - saved, dropped string - drop string -} - -// checkSDKs runs each case's golden, its drop test and its registration. -func checkSDKs(t *testing.T, cases []sdkCase) { - t.Helper() - for _, c := range cases { - t.Run(c.file.API, func(t *testing.T) { - kittest.Registered(t, Plugin{File: c.file}) - got := release(t, c.file.At(c.release), "testdata/"+c.saved, c.prev) - if len(got) == 0 { - t.Fatal("no events: the golden must pin a release with some") - } - kittest.Golden(t, "testdata/golden/"+strings.ReplaceAll(c.file.API, "/", "-")+".json", got) - - saved := c.saved - if c.dropped != "" { - saved = c.dropped - } - _, fs, err := c.file.At(c.drop).Read(kittest.Read(t, "testdata/"+saved)) - if err != nil { - t.Fatal(err) - } - for _, f := range fs { - if f.Dropped == "" { - t.Errorf("drop test %s: an event from %q", c.drop, f.Bullet.Text) - } - } - }) - } -} diff --git a/plugins/changelog/sentry.go b/plugins/changelog/sentry.go deleted file mode 100644 index e6c6e07..0000000 --- a/plugins/changelog/sentry.go +++ /dev/null @@ -1,30 +0,0 @@ -package changelog - -import "github.com/patch-it-dev/patch-it-plugins/core/plugin" - -func init() { - const page = "providers/sentry-sdks.md" - plugin.RegisterProvider(plugin.Provider{ - ID: "sentry", Name: "Sentry", Category: plugin.CategoryMonitoring, Homepage: "https://sentry.io", - Sources: []plugin.Source{ - sdk(page, "python-changelog", SentryPython, "pypi:sentry-sdk"), - sdk(page, "javascript-changelog", SentryJavaScript, "npm:@sentry/node", "npm:@sentry/browser"), - sdk(page, "go", SentryGo, "go:github.com/getsentry/sentry-go"), - sdk(page, "dotnet", SentryDotnet, "nuget:Sentry"), - }, - }) -} - -// Sentry's SDKs: CHANGELOG.md, "## X.Y.Z", with "### Breaking Changes" / -// "### Removed" / "### Deprecations" sections or conventional-commit bullets -// ("feat(core)!: Remove `x`"); tagged X.Y.Z, except sentry-go's vX.Y.Z. -var ( - SentryPython = File{API: "sentry/python-changelog", Package: "sentry-sdk", Ecosystem: "pypi", Module: "sentry_sdk", - Repo: "getsentry/sentry-python", Path: "CHANGELOG.md"} - SentryJavaScript = File{API: "sentry/javascript-changelog", Package: "@sentry/node", Ecosystem: "npm", - Repo: "getsentry/sentry-javascript", Path: "CHANGELOG.md"} - SentryGo = File{API: "sentry/go", Package: "github.com/getsentry/sentry-go", Ecosystem: "go", Module: "sentry", - Repo: "getsentry/sentry-go", TagPrefix: "v", Path: "CHANGELOG.md"} - SentryDotnet = File{API: "sentry/dotnet", Package: "Sentry", Ecosystem: "nuget", - Repo: "getsentry/sentry-dotnet", Path: "CHANGELOG.md"} -) diff --git a/plugins/changelog/sentry_test.go b/plugins/changelog/sentry_test.go deleted file mode 100644 index 4ca4a07..0000000 --- a/plugins/changelog/sentry_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package changelog - -import "testing" - -func TestSentrySDKs(t *testing.T) { - checkSDKs(t, []sdkCase{ - {SentryPython, "2.0.0", "1.45.1", "sentry-python-changelog-2.0.0-CHANGELOG.md", "", "1.45.0"}, - {SentryJavaScript, "10.0.0", "9.47.2", "sentry-javascript-changelog-10.0.0-CHANGELOG.md", "", "9.40.0"}, - {SentryGo, "0.31.0", "0.30.0", "sentry-go-0.31.0-CHANGELOG.md", "", "0.30.0"}, - {SentryDotnet, "4.0.0", "3.41.4", "sentry-dotnet-4.0.0-CHANGELOG.md", "", "3.41.4"}, - }) -} diff --git a/plugins/changelog/stripe.go b/plugins/changelog/stripe.go deleted file mode 100644 index 5164d28..0000000 --- a/plugins/changelog/stripe.go +++ /dev/null @@ -1,41 +0,0 @@ -package changelog - -import "github.com/patch-it-dev/patch-it-plugins/core/plugin" - -func init() { - const page = "providers/stripe-sdks.md" - plugin.RegisterProvider(plugin.Provider{ - ID: "stripe", Name: "Stripe", Category: plugin.CategoryPayments, Homepage: "https://stripe.com", - Sources: []plugin.Source{ - sdk(page, "python", StripePython, "pypi:stripe"), - sdk(page, "node", StripeNode, "npm:stripe"), - sdk(page, "go", StripeGo, "go:github.com/stripe/stripe-go/v87"), - sdk(page, "java", StripeJava, "maven:com.stripe:stripe-java"), - sdk(page, "ruby", StripeRuby, "rubygems:stripe"), - sdk(page, "dotnet", StripeDotnet, "nuget:Stripe.net"), - sdk(page, "php", StripePHP, "packagist:stripe/stripe-php"), - }, - }) -} - -// Stripe's SDKs: one CHANGELOG.md each, "## X.Y.Z - date" -// (older ones "## X.Y.Z - date"), every breaking bullet marked "⚠️"; each -// release tagged vX.Y.Z. A release that changes the API version the SDK -// pins says so in its section, "This release changes the pinned API version -// to `2026-11-18.endive`." (pins.go): its MapsTo is that stripe/api version. -var ( - StripePython = File{API: "stripe/python", Package: "stripe", Ecosystem: "pypi", Module: "stripe", - Repo: "stripe/stripe-python", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} - StripeNode = File{API: "stripe/node", Package: "stripe", Ecosystem: "npm", - Repo: "stripe/stripe-node", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} - StripeGo = File{API: "stripe/go", Package: "github.com/stripe/stripe-go", Ecosystem: "go", - Repo: "stripe/stripe-go", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} - StripeJava = File{API: "stripe/java", Package: "com.stripe:stripe-java", Ecosystem: "maven", - Repo: "stripe/stripe-java", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} - StripeRuby = File{API: "stripe/ruby", Package: "stripe", Ecosystem: "rubygems", - Repo: "stripe/stripe-ruby", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} - StripeDotnet = File{API: "stripe/dotnet", Package: "Stripe.net", Ecosystem: "nuget", - Repo: "stripe/stripe-dotnet", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} - StripePHP = File{API: "stripe/php", Package: "stripe/stripe-php", Ecosystem: "packagist", - Repo: "stripe/stripe-php", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} -) diff --git a/plugins/changelog/stripe_test.go b/plugins/changelog/stripe_test.go deleted file mode 100644 index 1a2a3e5..0000000 --- a/plugins/changelog/stripe_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package changelog - -import "testing" - -func TestStripeSDKs(t *testing.T) { - checkSDKs(t, []sdkCase{ - {StripePython, "4.0.0", "3.5.0", "stripe-python-4.0.0-CHANGELOG.md", "", "3.5.0"}, - {StripeNode, "10.0.0", "9.16.0", "stripe-node-10.0.0-CHANGELOG.md", "", "9.16.0"}, - {StripeGo, "73.0.0", "72.122.0", "stripe-go-73.0.0-CHANGELOG.md", "", "72.122.0"}, - {StripeJava, "21.0.0", "20.136.0", "stripe-java-21.0.0-CHANGELOG.md", "", "20.136.0"}, - {StripeRuby, "7.0.0", "6.5.0", "stripe-ruby-7.0.0-CHANGELOG.md", "", "6.5.0"}, - {StripeDotnet, "40.0.0", "39.126.0", "stripe-dotnet-40.0.0-CHANGELOG.md", "", "39.126.0"}, - {StripePHP, "9.0.0", "8.12.1", "stripe-php-9.0.0-CHANGELOG.md", "", "8.12.0"}, - }) -} diff --git a/plugins/changelog/testdata/README.md b/plugins/changelog/testdata/README.md deleted file mode 100644 index af05dd0..0000000 --- a/plugins/changelog/testdata/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# Saved changelogs - -Real copies, saved once with `curl` from the release tag and never edited. The -golden files under `golden/` are what the plugin stores from them -(`go test ./plugins/changelog -update`). - -| File | URL | Tag commit | Saved | License | Quote | -|---|---|---|---|---|---| -| `textual-v0.86.0-CHANGELOG.md` | https://raw.githubusercontent.com/Textualize/textual/v0.86.0/CHANGELOG.md | `5a738fa` | 2026-11-14 08:36 UTC | MIT (Textual), kept whole | "Breaking change: Removed `App.dark` reactive attribute" | -| `urllib3-2.0.0-CHANGES.rst` | https://raw.githubusercontent.com/urllib3/urllib3/2.0.0/CHANGES.rst | `303ba81` | 2026-11-14 08:35 UTC | MIT (urllib3), kept whole | "Removed support for Python 2.7, 3.5, and 3.6" | - -## SDK changelogs - -Read with `Plugin{File: ...}` (`sdks.go`); `golden/-.json` is what each stores from its release (`sdks_test.go`), the pair from the release before it on the registry (or among the repo's tags). Every file is the changelog at the release's tag, saved with `curl`, **trimmed** to two releases' sections, each kept whole and unchanged: the release the golden pins and one more release from the same file whose notes remove nothing the reader can name (the drop test). Only the pinned release's own section is read for the golden, so the trimmed copy gives the same events as the whole file (checked when each copy was made). - -| File | URL | Tag commit | Saved | License; trimming | Quote | -|---|---|---|---|---|---| -| `stripe-python-4.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-python/v4.0.0/CHANGELOG.md | `e65630a` | 2026-11-20 | MIT (stripe-python); trimmed to the sections of 4.0.0 (the golden) and 3.5.0 (the drop test), each unchanged | "Removed deprecated `AlipayAccount`, `BitcoinReceiver`, `BitcoinTransaction`, `IssuerFraudRecord`, `Recipient`, `Recip…" | -| `stripe-node-10.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-node/v10.0.0/CHANGELOG.md | `321d2fd` | 2026-11-20 | MIT (stripe-node); trimmed to the sections of 10.0.0 (the golden) and 9.16.0 (the drop test), each unchanged | "Remove `AlipayAccount` and `BitcoinReceiver` from `CustomerSource`." | -| `stripe-go-73.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-go/v73.0.0/CHANGELOG.md | `234502c` | 2026-11-20 | MIT (stripe-go); trimmed to the sections of 73.0.0 (the golden) and 72.122.0 (the drop test), each unchanged | "Remove `BalanceTransactionStatus`. It was meant to be an enum, but none of the enum values were defined, so it was ju…" | -| `stripe-java-21.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-java/v21.0.0/CHANGELOG.md | `cd2b023` | 2026-11-20 | MIT (stripe-java); trimmed to the sections of 21.0.0 (the golden) and 20.136.0 (the drop test), each unchanged | "Removed `CashBalance.retrieveCashBalance` method. Prefer `CashBalance.retrieve`." | -| `stripe-ruby-7.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-ruby/v7.0.0/CHANGELOG.md | `6081371` | 2026-11-20 | MIT (stripe-ruby); trimmed to the sections of 7.0.0 (the golden) and 6.5.0 (the drop test), each unchanged | "Remove `details` method from `Issuing.Card` resource. The method was not supported." | -| `stripe-dotnet-40.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-dotnet/v40.0.0/CHANGELOG.md | `e07ebe7` | 2026-11-20 | Apache-2.0 (stripe-dotnet); trimmed to the sections of 40.0.0 (the golden) and 39.126.0 (the drop test), each unchanged | "Remove `CustomerPaymentSettingsOptions`, `CustomerPaymentSettingsPaymentMethodOptionsBancontactOptions`, `CustomerPay…" | -| `stripe-php-9.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-php/v9.0.0/CHANGELOG.md | `e405c17` | 2026-11-20 | MIT (stripe-php); trimmed to the sections of 9.0.0 (the golden) and 8.12.0 (the drop test), each unchanged | "Remove deprecated `AlipayAccount`, `BitcoinReceiver`, `BitcoinTransaction`, `Recipient`, `RecipientTransfer`, and `Th…" | -| `sentry-python-changelog-2.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-python/2.0.0/CHANGELOG.md | `38bbb8d` | 2026-11-20 | MIT (sentry-python); trimmed to the sections of 2.0.0 (the golden) and 1.45.0 (the drop test), each unchanged | "Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead." | -| `sentry-javascript-changelog-10.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-javascript/10.0.0/CHANGELOG.md | `19f754a` | 2026-11-20 | MIT (sentry-javascript); trimmed to the sections of 10.0.0 (the golden) and 9.40.0 (the drop test), each unchanged | "feat(core)!: Remove `BaseClient` ([#17071](https://github.com/getsentry/sentry-javascript/pull/17071))" | -| `sentry-go-0.31.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-go/v0.31.0/CHANGELOG.md | `17ceb6c` | 2026-11-20 | MIT (sentry-go); trimmed to the sections of 0.31.0 (the golden) and 0.30.0 (the drop test), each unchanged | "Remove `Segment` field from the `User` struct. This field is no longer used in the Sentry product. ([#928](https://gi…" | -| `sentry-dotnet-4.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-dotnet/4.0.0/CHANGELOG.md | `d4d8af5` | 2026-11-20 | MIT (sentry-dotnet); trimmed to the sections of 4.0.0 (the golden) and 3.41.4 (the drop test), each unchanged | "`ITransaction` has been renamed to `ITransactionTracer`. You will need to update any references to these interfaces i…" | -| `cloudflare-typescript-7.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/cloudflare-typescript/v7.1.0/CHANGELOG.md | `f41ff03` | 2026-11-20 | Apache-2.0 (cloudflare-typescript); trimmed to the sections of 7.1.0 (the golden) and 7.0.0 (the drop test), each unchanged | "`cloudforceOne.threatEvents.indicatorTypes` has been renamed to `cloudforceOne.threatEvents.indicators`" | -| `cloudflare-python-5.6.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/cloudflare-python/v5.6.0/CHANGELOG.md | `02ab9a9` | 2026-11-20 | Apache-2.0 (cloudflare-python); trimmed to the sections of 5.6.0 (the golden) and 5.4.0 (the drop test), each unchanged | "accounts:** The `create()` and `get()` methods have been removed from `client.accounts.subscriptions`. The `Subscript…" | -| `cloudflare-go-7.15.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/cloudflare-go/v7.15.0/CHANGELOG.md | `d2f77a0` | 2026-11-20 | Apache-2.0 (cloudflare-go); trimmed to the sections of 7.15.0 (the golden) and 7.13.1 (the drop test), each unchanged | "rules:** the `ListCursor` and `ListCursorParam` types are removed." | -| `cloudflare-terraform-5.29.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/terraform-provider-cloudflare/v5.29.0/CHANGELOG.md | `8e7a366` | 2026-11-20 | Apache-2.0 (terraform-provider-cloudflare); trimmed to the sections of 5.29.0 (the golden) and 5.28.1 (the drop test), each unchanged | "zone_dns_settings, account_dns_settings:** the deprecated `foundation_dns` attribute has been removed. On `cloudflare…" | -| `redis-ioredis-5.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/redis/ioredis/v5.0.0/CHANGELOG.md | `b8e99b4` | 2026-11-20 | MIT (ioredis); trimmed to the sections of 5.0.0 (the golden) and 5.0.0-beta.4 (the drop test), each unchanged | "you very likely have never used it." | -| `posthog-go-2.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/PostHog/posthog-go/v2.0.0/CHANGELOG.md | `ee5c496` | 2026-11-20 | MIT (posthog-go); trimmed to the sections of 2.0.0 (the golden) and 1.44.1 (the drop test), each unchanged | "fc05013: Remove `Capture.Library` and `Exception.Library`. Set `$lib` in the event's `Properties` instead, and set `$…" | - -## SDK release notes - -Read with `Plugin{File: ...}` and `Notes: true` (`sdks.go`): an SDK whose changelog is its GitHub releases' notes. Each file is one release as GitHub's API returns it, trimmed to the fields the reader uses. - -| File | URL | Tag commit | Saved | License; trimming | Use | -|---|---|---|---|---|---| -| `github-octokit-rest-18.0.0-release.json` | https://api.github.com/repos/octokit/rest.js/releases/tags/v18.0.0 | `b4ab0db` | 2026-11-20 | MIT (rest.js); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | golden | -| `github-octokit-rest-17.11.2-release.json` | https://api.github.com/repos/octokit/rest.js/releases/tags/v17.11.2 | `5306f37` | 2026-11-20 | MIT (rest.js); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | drop test | -| `github-octokit-net-0.5.2-release.json` | https://api.github.com/repos/octokit/octokit.net/releases/tags/v0.5.2 | `4b61105` | 2026-11-20 | MIT (octokit.net); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | golden | -| `github-octokit-net-0.5.1-release.json` | https://api.github.com/repos/octokit/octokit.net/releases/tags/v0.5.1 | `8a9e828` | 2026-11-20 | MIT (octokit.net); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | drop test | - -## What a release pins - -Read by `pins.go`; `pins_test.go` checks each release's stated pin. Every file is the SDK's `CHANGELOG.md` at its newest release tag, saved with `curl` on 2026-11-20, **trimmed** to the sections listed, each kept whole and unchanged. - -| File | URL | Tag commit | Sections kept | License | Quote | -|---|---|---|---|---|---| -| `pins/stripe-python-17.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-python/v17.1.0/CHANGELOG.md | `2bbff43` | 17.1.0 (changes the pin), 17.0.0 (says nothing) | MIT (stripe-python) | "This release changes the pinned API version to `2026-11-18.endive`." | -| `pins/stripe-node-23.2.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-node/v23.2.0/CHANGELOG.md | `dd92429` | 23.2.0, 23.0.1 (says nothing), 22.0.0 ("uses the same pinned API version to") | MIT (stripe-node) | "This release uses the same pinned API version to `2026-03-25.dahlia` as the last major release." | -| `pins/stripe-go-87.2.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-go/v87.2.0/CHANGELOG.md | `c97713a` | 87.2.0, 86.4.2 (says nothing), 86.0.0 ("doesn't change") | MIT (stripe-go) | "This release **doesn't** change the pinned API version; it still uses `2026-05-27.dahlia`." | -| `pins/stripe-java-34.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-java/v34.1.0/CHANGELOG.md | `d1dcf1a` | 34.1.0, 33.4.2 (says nothing), 33.0.0 ("doesn't change") | MIT (stripe-java) | "This release changes the pinned API version to `2026-10-28.endive`." | -| `pins/stripe-ruby-21.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-ruby/v21.1.0/CHANGELOG.md | `6605e66` | 21.1.0, 21.0.0 (says nothing) | MIT (stripe-ruby) | "This release changes the pinned API version to `2026-11-18.endive`." | -| `pins/stripe-dotnet-53.2.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-dotnet/v53.2.0/CHANGELOG.md | `a32d3eb` | 53.2.0, 52.4.2 (says nothing), 52.0.0 ("doesn't change") | Apache-2.0 (stripe-dotnet) | "This release changes the pinned API version to `2026-11-18.endive`." | -| `pins/stripe-php-23.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-php/v23.1.0/CHANGELOG.md | `6694b4d` | 23.1.0, 23.0.0 (says nothing), 21.0.0 ("does not change") | MIT (stripe-php) | "This release **does not** change the pinned API version. It's still `2026-06-24.dahlia`." | - -## Version lists - -| File | URL | Saved | License | Use | -|---|---|---|---|---| -| `versions/stripe-go-tags.json`, `versions/stripe-go-tags-pins.json`, `versions/octokit-rest-releases.json` | https://api.github.com/repos/stripe/stripe-go/tags, https://api.github.com/repos/octokit/rest.js/releases (shape only) | written for the test, 2026-11-20 | not saved copies: a few real tag names and releases in the shape of GitHub's API (a pre-release, a draft and a tag of another series among them) | for the version-listing test only (tags for an ecosystem with no registry lister, releases for release notes); no golden reads them | -| `pypi-urllib3-excerpt.json` | https://pypi.org/pypi/urllib3/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | - -## JSON changelogs - -Read with `Plugin{Log: ...}` (json.go); `golden/mongodb-atlas.json` is what it stores from the first file. - -| File | URL | Saved | License | Quote | -|---|---|---|---|---| -| `mongodb-atlas-changelog-c0f99ca9.json` | https://raw.githubusercontent.com/mongodb/openapi/c0f99ca9145e5aa74d08ae4451020857e93b5f28/changelog/changelog.json (the "Release API Changelog" commit of 2026-11-18 20:15 UTC; the same file as `main` on 2026-11-19) | 2026-11-19 | Apache-2.0 (mongodb/openapi) | "endpoint with API Version '2023-01-01' was removed as it has reached its sunset date '2026-01-22'" | -| `mongodb-atlas-changelog-2026-11-18-day.json` | The same file's newest day (`2026-11-18`), kept whole and unchanged: the drop test | 2026-11-19 | Apache-2.0 (mongodb/openapi) | `"changeCode": "request-property-one-of-removed"`, `"backwardCompatible": false` | - -**Trimmed, positions kept:** the real file is 10 MB. `mongodb-atlas-changelog-c0f99ca9.json` keeps every day, endpoint, API version and change in place. Every change the plugin doesn't read is replaced by `{}`: all but the three life-cycle codes and `endpoint-reactivated`. So is every endpoint or version left with none. So every JSON pointer in `golden/mongodb-atlas.json` names the same change in the real file. The 105 kept changes are copied unchanged. The plugin reads exactly the same 81 findings from this copy as from the real file (checked when the copy was made). The copy is re-indented. - -| File | URL | Saved | License | Use | -|---|---|---|---|---| -| `log-history/commits.json`, `log-history/changelog-{1,2,3}.json` | Stand-ins for the GitHub commits list of `changelog/changelog.json` and the file at three commits, in the real file's shape | written for the test, 2026-11-20 | n/a (test fixtures) | for the pair-by-pair test only (three versions, two pairs); no golden reads them | diff --git a/plugins/migrationguide/members/golden_test.go b/plugins/migrationguide/members/golden_test.go deleted file mode 100644 index e28bb60..0000000 --- a/plugins/migrationguide/members/golden_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package members_test - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/core/versions" - - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide" - . "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" // the reader under test -) - -// The guide at tag v2.0.0 (saved 2026-11-04) in, every event out: the pair -// from 1.26.4, the release before on PyPI. -func TestGolden(t *testing.T) { - got := release(t, NumPy, "testdata/numpy_2_0_migration_guide-v2.0.0.rst", "1.26.4", "2.0.0") - kittest.Golden(t, "../testdata/golden/numpy-2.0.0.json", got) -} - -// release is the pair previous -> rel, the first release of a major, over -// the guide saved as file, as patch-it's hosted ingestion service extracts -// it. previous isn't a major's first release: it has no guide, and nothing -// is fetched for it. -func release(t *testing.T, g Guide, file, previous, rel string) []event.Event { - t.Helper() - return kittest.Versions(t, guideEnv(t, g, file, rel), migrationguide.Plugin{Guide: g}, plugin.Version{ID: previous}, plugin.Version{ID: rel}) -} - -// newrelicCommit is the docs-website commit New Relic's saved release note -// was fetched at, and newrelicCommits GitHub's answer naming it as the -// newest commit that changed the note. -const ( - newrelicCommit = "f0b4f817bf9a7b76a78e26609369a8a7ce764c8e" - newrelicCommits = "testdata/github-commits-python-agent-110000.json" -) - -// guideEnv serves file as g's guide for rel: at rel's tag, or (Untagged) at -// the commit GitHub names for it. -func guideEnv(t *testing.T, g Guide, file, rel string) plugin.Env { - t.Helper() - major := versions.Major(rel) - pages := kittest.Pages{g.RawURL(g.TagOf(rel), major): file} - if g.Untagged { - pages = kittest.Pages{g.CommitsURL(major): newrelicCommits, g.RawURL(newrelicCommit, major): file} - } - return kittest.Env(t, pages) -} diff --git a/plugins/migrationguide/members/members_test.go b/plugins/migrationguide/members/members_test.go deleted file mode 100644 index c568650..0000000 --- a/plugins/migrationguide/members/members_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package members_test - -import ( - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - - . "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" // the reader under test -) - -// The guide as published at tag v2.0.0 (fetched 2026-11-04). -func guide(t *testing.T) []byte { - t.Helper() - return kittest.Read(t, "testdata/numpy_2_0_migration_guide-v2.0.0.rst") -} - -func byMember(t *testing.T) map[string]Removal { - t.Helper() - rs, err := Parse(guide(t), NumPy) - if err != nil { - t.Fatal(err) - } - out := map[string]Removal{} - for _, r := range rs { - out[r.Member] = r - } - return out -} - -func TestEveryRemovedMemberOfTheMainNamespaceIsRead(t *testing.T) { - got := byMember(t) - if len(got) != 56 { - t.Errorf("%d removed members, want the table's 56", len(got)) - } - // A guideline continued over several lines is read whole. - if r := got["find_common_type"]; !strings.Contains(r.Guideline, "``0.0``, or ``0j``") { - t.Errorf("find_common_type: %q", r.Guideline) - } - // The table's escaped underscore is the member's own. - if _, ok := got["float_"]; !ok { - t.Error(`no "float_": the \_ escape wasn't undone`) - } -} - -// Only a guideline naming exactly one member of np is a rename; anything else -// (a builtin, an expression, advice) is a removal the patch-it client -// opens as an issue. -func TestOnlyOnePlainReplacementInNpIsARename(t *testing.T) { - got := byMember(t) - for member, want := range map[string]string{ - "float_": "float64", - "NaN": "nan", - "product": "prod", - "cumproduct": "cumprod", - "string_": "bytes_", - "Inf": "inf", - "alltrue": "", // "Use ``all`` instead.": the builtin, or np.all? Not said - "NINF": "", // "Use ``-np.inf`` instead.": an expression - "asfarray": "", // "Use ``np.asarray`` with a float dtype instead." - "compat": "", // no replacement - "who": "", - } { - if r, ok := got[member]; !ok || r.Replacement != want { - t.Errorf("%s: replacement %q, want %q", member, r.Replacement, want) - } - } -} - -func TestTheGuideStoresOneEventPerMemberAndARerunNothing(t *testing.T) { - // The guide at the v2.0.0 tag, and nothing else; kittest extracts the - // pair again and fails on anything new. - events := release(t, NumPy, "testdata/numpy_2_0_migration_guide-v2.0.0.rst", "1.26.4", "2.0.0") - if len(events) != 56 { - t.Fatalf("%d events, want 56", len(events)) - } - var float *event.Event - for i := range events { - if events[i].Subject.Symbols[0] == "float_" { - float = &events[i] - } - } - if float == nil || float.Subject.Change != event.PackageRenamedSymbol || float.Subject.Replacement != "float64" || - float.API != "numpy/numpy" || float.Version != "2.0.0" || !strings.Contains(float.SourceExcerpt, "float\\_") { - t.Errorf("float_: %+v", float) - } -} diff --git a/plugins/migrationguide/members/registered_test.go b/plugins/migrationguide/members/registered_test.go deleted file mode 100644 index d405937..0000000 --- a/plugins/migrationguide/members/registered_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package members_test - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide" - . "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" // the reader under test -) - -func TestRegistersItself(t *testing.T) { - kittest.Registered(t, migrationguide.Plugin{Guide: NumPy}) -} diff --git a/plugins/migrationguide/members/versions_test.go b/plugins/migrationguide/members/versions_test.go deleted file mode 100644 index 42ac3cf..0000000 --- a/plugins/migrationguide/members/versions_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package members_test - -import ( - "context" - "errors" - "fmt" - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/core/versions" - - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide" - . "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" // the reader under test -) - -// The package's releases come from PyPI; only the pair into the release the -// guide documents has events (the golden's, with previous_version set). -func TestOnlyTheGuidesReleaseHasEvents(t *testing.T) { - env := kittest.Env(t, kittest.Pages{ - "https://pypi.org/pypi/numpy/json": "testdata/pypi-numpy-excerpt.json", - NumPy.RawURL("v2.0.0", 2): "testdata/numpy_2_0_migration_guide-v2.0.0.rst", - }) - p := migrationguide.Plugin{Guide: NumPy} - ctx := context.Background() - vs, err := p.ListVersions(ctx, env) - if err != nil { - t.Fatal(err) - } - pinned := release(t, NumPy, "testdata/numpy_2_0_migration_guide-v2.0.0.rst", "1.26.4", "2.0.0") - var got []string - for _, pair := range versions.Pairs(vs) { - from, err := p.ReadAt(ctx, env, pair[0]) - if err != nil { - t.Fatal(err) - } - to, err := p.ReadAt(ctx, env, pair[1]) - if err != nil { - t.Fatal(err) - } - res, err := p.Extract(ctx, env, from, to) - if err != nil || len(res.Rejected) > 0 { - t.Fatalf("%v %v", err, res.Rejected) - } - for i, e := range res.Events { - if e.PreviousVersion != pair[0].ID || e.Fingerprint != pinned[i].Fingerprint { - t.Errorf("event %d: previous %q, fingerprint differs from the golden's: %v", i, e.PreviousVersion, e.Fingerprint != pinned[i].Fingerprint) - } - } - got = append(got, fmt.Sprintf("%s->%s:%d", pair[0].ID, pair[1].ID, len(res.Events))) - } - want := fmt.Sprintf("1.26.4->2.0.0:%d 2.0.0->2.0.1:0", len(pinned)) - if strings.Join(got, " ") != want || len(pinned) == 0 { - t.Errorf("got %s, want %s", strings.Join(got, " "), want) - } -} - -// Each guide is read where its package publishes it: at the major's first -// tag (TagPrefix + version), or, for a docs repo with no tags, at the newest -// commit that changed the major's note. -func TestEachGuideIsReadWhereItsPublished(t *testing.T) { - ctx := context.Background() - for _, c := range []struct { - g Guide - rel string - want string - }{ - {NumPy, "2.0.0", "https://raw.githubusercontent.com/numpy/numpy/v2.0.0/doc/source/numpy_2_0_migration_guide.rst"}, - {PostHog, "8.0.0", "https://raw.githubusercontent.com/PostHog/posthog-python/posthog-v8.0.0/docs/migration-7.x-to-8.0.md"}, - {NewRelic, "11.0.0", "https://raw.githubusercontent.com/newrelic/docs-website/" + newrelicCommit + "/src/content/docs/release-notes/agent-release-notes/python-release-notes/python-agent-110000.mdx"}, - } { - got, err := c.g.GuideURL(ctx, guideEnv(t, c.g, "testdata/README.md", c.rel), plugin.Version{ID: c.rel}) - if err != nil || got != c.want { - t.Errorf("%s %s: %q, %v; want %q", c.g.Package, c.rel, got, err, c.want) - } - if got, err := c.g.GuideURL(ctx, plugin.Env{}, plugin.Version{ID: c.rel[:len(c.rel)-1] + "1"}); got != "" || err != nil { - t.Errorf("%s: a release that isn't a major's first has no guide: %q, %v", c.g.Package, got, err) - } - } -} - -// A major with no guide has nothing to read: a 404 at its tag, or (docs -// repo) no commit ever changed its note's path. The pair is skipped, not -// failed, and not a release without changes. -func TestAMajorWithNoGuideHasNothingToRead(t *testing.T) { - ctx := context.Background() - env := kittest.Env(t, kittest.Pages{NewRelic.CommitsURL(14): "testdata/github-commits-none.json"}) - if _, err := (migrationguide.Plugin{Guide: NewRelic}).ReadAt(ctx, env, plugin.Version{ID: "14.0.0"}); !errors.Is(err, plugin.ErrNothingToRead) { - t.Errorf("no commit for the note: %v, want plugin.ErrNothingToRead", err) - } - notFound := plugin.Env{Get: func(context.Context, string) ([]byte, error) { return nil, &fetch.StatusError{StatusCode: 404} }} - if _, err := (migrationguide.Plugin{Guide: NumPy}).ReadAt(ctx, notFound, plugin.Version{ID: "3.0.0"}); !errors.Is(err, plugin.ErrNothingToRead) { - t.Errorf("no guide at the tag: %v, want plugin.ErrNothingToRead", err) - } -} diff --git a/plugins/migrationguide/registered_test.go b/plugins/migrationguide/registered_test.go deleted file mode 100644 index 3b659bb..0000000 --- a/plugins/migrationguide/registered_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrationguide - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" -) - -func TestRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Guide: anthropicGuideV1}) -} diff --git a/plugins/migrationguide/sdkguide/pinned_test.go b/plugins/migrationguide/sdkguide/pinned_test.go deleted file mode 100644 index f914705..0000000 --- a/plugins/migrationguide/sdkguide/pinned_test.go +++ /dev/null @@ -1,5 +0,0 @@ -package sdkguide - -// AnthropicV1 is anthropic-sdk-python's guide to 1.0.0: what the tests pin. -// Only a test names a release. -var AnthropicV1 = Anthropic.At(1) diff --git a/plugins/migrationguide/sdkguide/testdata/README.md b/plugins/migrationguide/sdkguide/testdata/README.md deleted file mode 100644 index 98f2199..0000000 --- a/plugins/migrationguide/sdkguide/testdata/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Saved SDK migration guide - -| File | URL | Fetched | License | Quote | -|---|---|---|---|---| -| `anthropic-MIGRATION-v1.0.0.md` | https://github.com/anthropics/anthropic-sdk-python/blob/v1.0.0/MIGRATION.md | 2026-10-17 | MIT (anthropic-sdk-python), kept whole | "Removed: deprecated request parameters" | - -Also read by the `anthropic` plugin's golden test (`plugins/migrationguide`). diff --git a/plugins/migrationguide/testdata/README.md b/plugins/migrationguide/testdata/README.md deleted file mode 100644 index 5362a94..0000000 --- a/plugins/migrationguide/testdata/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Golden events - -`golden/anthropic-1.0.0.json` is what the `anthropic` plugin stores from anthropic-sdk-python's MIGRATION.md at v1.0.0. The saved guide itself is shared with the `sdkguide` package: see [`sdkguide/testdata/README.md`](../sdkguide/testdata/README.md) for its URL, date and license. - -`golden/numpy-2.0.0.json`, `golden/posthog-8.0.0.json` and `golden/newrelic-11.0.0.json` are what the removed-members reader's sources store; their saved guides are in [`members/testdata/`](../members/testdata/README.md), and their tests in `members/` (`go test ./plugins/migrationguide/members -update`). - -Rewrite it after an intended change with `go test ./plugins/migrationguide -update`, and say in the PR why the new output is right. - -## Version lists - -| File | URL | Saved | License | Use | -|---|---|---|---|---| -| `pypi-anthropic-excerpt.json` | https://pypi.org/pypi/anthropic/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | diff --git a/plugins/notices/feed/readers.go b/plugins/notices/feed/readers.go deleted file mode 100644 index 2e69318..0000000 --- a/plugins/notices/feed/readers.go +++ /dev/null @@ -1,346 +0,0 @@ -package feed - -import ( - "fmt" - "regexp" - "strings" - "time" - - "github.com/patch-it-dev/patch-it-plugins/core/event" -) - -// GitHubActions is the GitHub changelog's Actions label, RSS 2.0 (checked -// 2026-11-14: the latest 10 posts, each with its labels as , the -// post's HTML in content:encoded). A retirement is labelled "Retired"; a -// runner image retirement names the date ("The macOS 14 runner image will be -// retired on November 2, 2026.") and lists the `runs-on` labels it removes. -var GitHubActions = Feed{ - API: "github/actions", - Vendor: "GitHub", - URL: "https://github.blog/changelog/label/actions/feed/", - Read: readGitHubActions, -} - -// VertexAIModels is Google Cloud's "Generative AI on Vertex AI" release -// notes, Atom (checked 2026-11-14: one entry per day, each change under an -//

    naming its kind: Feature, Change, Announcement, Deprecated). A model -// deprecation is a "Deprecated" section with a table of model ids in -// (discontinued, recommended migration) and the date to move by. -var VertexAIModels = Feed{ - API: "google/vertex-ai-models", - Vendor: "Google", - URL: "https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml", - Read: readVertexAI, -} - -// CloudflareAPI is Cloudflare's API deprecations page as RSS 2.0 (checked -// 2026-11-19: every announcement since 2020, 50 items, newest first, no -// categories). Every item is a deprecation, so none needs marking. An item -// names what it deprecates under "Deprecated APIs:", one `METHOD /path` per -// list item, kept apart from "Affected APIs:" (endpoints that only change), -// and gives "Deprecation date:" and, for most since 2025, "End of life date:". -var CloudflareAPI = Feed{ - API: "cloudflare/api", - Vendor: "Cloudflare", - URL: "https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml", - Read: readCloudflareAPI, -} - -var ( - runnerImage = regexp.MustCompile(`(?i)\brunner images?\b`) - willStop = regexp.MustCompile(`(?i)\bwill be (retired|removed|shut down|discontinued)\b`) - willSoften = regexp.MustCompile(`(?i)\b(will be deprecated|is deprecated|are deprecated|before)\b`) - labelsList = regexp.MustCompile(`(?is)

    ([^<]*following labels[^<]*)

    \s*
      (.*?)
    `) - listItem = regexp.MustCompile(`(?is)
  • (.*?)
  • `) - tableRow = regexp.MustCompile(`(?is)(.*?)`) - tableCell = regexp.MustCompile(`(?is)]*>(.*?)`) - plainModelID = regexp.MustCompile(`^[a-z0-9][a-z0-9.@_-]*$`) -) - -func marked(labels []string, words ...string) bool { - for _, l := range labels { - for _, w := range words { - if strings.EqualFold(l, w) { - return true - } - } - } - return false -} - -// dated is the first line holding a date and saying what happens on it: -// breaking when the thing stops on the date, deprecation when the vendor only -// asks to move by it. "" when no line says either. -func dated(lines []string) (line, date string, ct event.ChangeType) { - for _, l := range lines { - // The date after the words, not the first on the line: "deprecated - // as of February 23, 2026 and will be shut down on August 23, 2026". - if m := willStop.FindStringIndex(l); m != nil { - if d := Date(l[m[1]:]); d != "" { - return l, d, event.ChangeTypeBreaking - } - } - if m := willSoften.FindStringIndex(l); m != nil { - if d := Date(l[m[1]:]); d != "" { - return l, d, event.ChangeTypeDeprecation - } - } - } - return "", "", "" -} - -func excerpt(lines ...string) string { - s := strings.Join(lines, "\n") - if r := []rune(s); len(r) > 2000 { - s = string(r[:1999]) + "…" - } - return s -} - -func readGitHubActions(e Entry) []Finding { - if !marked(e.Categories, "Retired", "Deprecation", "Deprecated", "Breaking change", "Breaking changes") { - return nil - } - drop := func(why string) []Finding { return []Finding{{Entry: e.Link, Dropped: why}} } - if !runnerImage.MatchString(e.Title) { - return drop("not a runner image retirement: no ci_runtime this reader can name") - } - line, date, ct := dated(Lines(e.HTML)) - if date == "" { - return drop("no sentence giving the date the image is removed") - } - m := labelsList.FindStringSubmatch(e.HTML) - if m == nil { - return drop("lists no runner labels") - } - intro := Text(m[1]) - var out []Finding - for _, li := range listItem.FindAllStringSubmatch(m[2], -1) { - codes := Codes(li[1]) - if len(codes) != 1 || Text(li[1]) != codes[0] { - out = append(out, Finding{Entry: e.Link, Dropped: fmt.Sprintf("label item %q isn't one plain label", Text(li[1]))}) - continue - } - label := codes[0] - desc := fmt.Sprintf("GitHub-hosted runner label %q is retired on %s: jobs that run on it fail from that date.", label, date) - if ct == event.ChangeTypeDeprecation { - desc = fmt.Sprintf("GitHub-hosted runner label %q is deprecated; GitHub names %s for it.", label, date) - } - out = append(out, Finding{ - ChangeType: ct, - Version: date, - Subject: event.Subject{Type: event.SubjectCIRuntime, Platform: "github-actions", Runtime: label}, - Description: desc, - Hint: "Move `runs-on` to a supported label; GitHub's announcement lists them: " + e.Link, - Excerpt: excerpt(e.Title, line, intro, label), - Entry: e.Link, - }) - } - if len(out) == 0 { - return drop("lists no runner labels") - } - return out -} - -func readVertexAI(e Entry) []Finding { - var out []Finding - for _, s := range SplitBy(e.HTML, 3) { - if !marked([]string{s.Heading}, "Deprecated", "Breaking") { - continue - } - lines := Lines(s.HTML) - drop := func(why string) { - title := "" - if len(lines) > 0 { - title = lines[0] - } - out = append(out, Finding{Entry: e.Link, Dropped: fmt.Sprintf("%q: %s", title, why)}) - } - rows := tableRow.FindAllStringSubmatch(s.HTML, -1) - if len(rows) < 2 { - drop("names no model id in a table") - continue - } - header := cells(rows[0][1]) - if len(header) < 2 || !strings.Contains(strings.ToLower(header[0]), "discontinued") { - drop(fmt.Sprintf("a table that isn't discontinued models: %q", header)) - continue - } - line, date, ct := dated(lines) - if date == "" { - drop("no sentence giving the date to move by") - continue - } - for _, r := range rows[1:] { - raw := tableCell.FindAllStringSubmatch(r[1], -1) - if len(raw) < 2 { - continue - } - names := Codes(raw[0][1]) - if len(names) != 1 || !plainModelID.MatchString(names[0]) || Text(raw[0][1]) != names[0] { - drop(fmt.Sprintf("row %q doesn't name one model id", Text(raw[0][1]))) - continue - } - name, migrate := names[0], Text(raw[1][1]) - subject := event.Subject{Type: event.SubjectModel, Provider: "google", Name: name} - hint := fmt.Sprintf("Google recommends: %s.", migrate) - // Exactly one plain model, and not the model itself (the feed has a - // row whose migration is its own name): anything else stays a hint. - if repl := Codes(raw[1][1]); len(repl) == 1 && Text(raw[1][1]) == repl[0] && repl[0] != name { - subject.Replacement = repl[0] - hint = fmt.Sprintf("Use `%s` instead: Google's recommended migration.", repl[0]) - } - desc := fmt.Sprintf("Model %q is deprecated on Vertex AI: Google asks to move off it before %s to avoid service disruption.", name, date) - if ct == event.ChangeTypeBreaking { - desc = fmt.Sprintf("Model %q is shut down on Vertex AI on %s: requests naming it fail from that date.", name, date) - } - out = append(out, Finding{ - ChangeType: ct, - Version: date, - Subject: subject, - Description: desc, - Hint: hint, - Excerpt: excerpt(s.Heading, lines[0], line, strings.Join(header, " | "), name+" | "+migrate), - Entry: e.Link, - }) - } - } - return out -} - -func cells(row string) []string { - var out []string - for _, c := range tableCell.FindAllStringSubmatch(row, -1) { - out = append(out, Text(c[1])) - } - return out -} - -var ( - // cfDeprecatedList is the "Deprecated APIs:" paragraph and the list after - // it. Only the first: no item on the feed (2026-11-19) has two. - cfDeprecatedList = regexp.MustCompile(`(?is)

    \s*Deprecated APIs?:\s*

    \s*
      (.*?)
    `) - // cfOperation is a list item that starts with one operation in code: - // "GET /zones/{zone_id}/settings", or as the oldest entries write it, - // "GET zones/:zone_identifier/analytics/dashboard" or "GET/zones/...". - cfOperation = regexp.MustCompile(`^(GET|POST|PUT|PATCH|DELETE) ?/?([A-Za-z0-9_{}:@.\-]+(?:/[A-Za-z0-9_{}:@.\-]*)*)$`) - cfColonParam = regexp.MustCompile(`:([A-Za-z_][A-Za-z0-9_]*)`) - cfEOL = regexp.MustCompile(`(?i)^End of life date:`) - cfDeprecated = regexp.MustCompile(`(?i)^Deprecation date:`) - // cfStops is the item saying the endpoints stop, with the endpoints as - // what stops: "After this date, the legacy endpoints will no longer be - // available." Only a paragraph counts: a list item under "Affected APIs:" - // saying "Mirage parameter will be removed" is about a field. And not a - // sentence that only mentions the API: "Service Key authentication for - // the Cloudflare API is deprecated and will be removed" is about the - // authentication. - cfStops = regexp.MustCompile(`(?i)\b(endpoints?|APIs?|operations?) will (no longer be (available|accessible|served)|be (removed|shut down|turned off))\b`) - cfParagraph = regexp.MustCompile(`(?is)

    (.*?)

    `) - // cfNoAction is an item telling direct API callers nothing changes for - // them: "For users calling the API directly (not via the Cloudflare SDK), - // no action is required." - cfNoAction = regexp.MustCompile(`(?i)calling the API directly[^.]*no action is required`) - // cfSentence is text after an operation that says something about it - // ("— creating rules with action: audit_ssh is no longer accepted"), as - // opposed to a name for it ("— List domains", "(DNS Analytics API)"). - cfSentence = regexp.MustCompile(`(?i)\b(is|are|was|were|will|no longer|must|only|with)\b`) -) - -func readCloudflareAPI(e Entry) []Finding { - title := strings.TrimPrefix(e.Title, "API deprecations - ") - drop := func(why string) []Finding { - return []Finding{{Entry: e.Link, Dropped: fmt.Sprintf("%q: %s", title, why)}} - } - m := cfDeprecatedList.FindStringSubmatch(e.HTML) - if m == nil { - // Behavior changes, fields or settings, cipher suites: no operation - // is deprecated, so there's no api_operation to name. - return drop(`no "Deprecated APIs:" list of operations`) - } - - lines := Lines(e.HTML) - for _, l := range lines { - if cfNoAction.MatchString(l) { - // The URL keeps working; only an SDK method moves (the Radar - // summary endpoints, folded into /summary/{dimension}). - return drop("says direct API callers need no action: " + l) - } - } - - // Breaking needs the item to say the endpoints stop ("will no longer be - // available") and a full end-of-life date. An end-of-life date alone isn't - // enough: of the 11 items with one on 2026-11-19, only 2 say the - // endpoints stop, and one tells API callers no action is required. - // Anything else is a deprecation, dated by the deprecation date, else the - // day the item was published. - var eolLine, depLine, stopLine string - for _, l := range lines { - switch { - case eolLine == "" && cfEOL.MatchString(l): - eolLine = l - case depLine == "" && cfDeprecated.MatchString(l): - depLine = l - } - } - for _, p := range cfParagraph.FindAllStringSubmatch(e.HTML, -1) { - if l := Text(p[1]); cfStops.MatchString(l) { - stopLine = l - break - } - } - ct, date, dateLine := event.ChangeTypeDeprecation, Date(depLine), depLine - if d := Date(eolLine); d != "" && stopLine != "" { - ct, date, dateLine = event.ChangeTypeBreaking, d, eolLine - } - if date == "" { - if t, err := time.Parse(time.RFC1123, strings.TrimSpace(e.Published)); err == nil { - date, dateLine = t.UTC().Format("2006-01-02"), "" - } - } - if date == "" { - return drop("no date: neither an end of life, a deprecation date nor a publication date") - } - - var out []Finding - for _, li := range listItem.FindAllStringSubmatch(m[1], -1) { - codes := Codes(li[1]) - text := Text(li[1]) - // One operation, in code, first, and at most a name after it: "GET - // /path — List domains". Not "GET and POST /path", a hostname, nor - // "POST /path — creating rules with action: audit_ssh is no longer - // accepted", which deprecates a value, not the operation. - if len(codes) < 1 || !strings.HasPrefix(text, codes[0]) || cfSentence.MatchString(strings.TrimPrefix(text, codes[0])) { - out = append(out, Finding{Entry: e.Link, Dropped: fmt.Sprintf("%q: list item %q isn't one operation", title, text)}) - continue - } - op := cfOperation.FindStringSubmatch(codes[0]) - if op == nil { - out = append(out, Finding{Entry: e.Link, Dropped: fmt.Sprintf("%q: list item %q isn't one operation", title, text)}) - continue - } - path := "/" + strings.TrimSuffix(cfColonParam.ReplaceAllString(op[2], "{$1}"), "/") - operation := op[1] + " " + path - - desc := fmt.Sprintf("Cloudflare API operation %s is deprecated (%s).", operation, date) - if ct == event.ChangeTypeBreaking { - desc = fmt.Sprintf("Cloudflare API operation %s reaches end of life on %s, the date Cloudflare stops serving it.", operation, date) - } - quote := []string{e.Title} - if dateLine != "" { - quote = append(quote, dateLine) - } - if ct == event.ChangeTypeBreaking { - quote = append(quote, stopLine) - } - out = append(out, Finding{ - ChangeType: ct, - Version: date, - Subject: event.Subject{Type: event.SubjectAPIOperation, Kind: event.KindOperation, Side: event.SideRequest, Operation: operation}, - Description: desc, - Hint: "Move to the replacement Cloudflare names in its deprecation notice: " + e.Link, - Excerpt: excerpt(append(quote, "Deprecated APIs:", text)...), - Entry: e.Link, - }) - } - return out -} diff --git a/plugins/notices/feed/testdata/README.md b/plugins/notices/feed/testdata/README.md deleted file mode 100644 index 47ec016..0000000 --- a/plugins/notices/feed/testdata/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Saved feeds - -Real copies, saved once with `curl`. The golden files, `../../testdata/golden/-.json`, -are what the notices kind stores from them (`go test ./plugins/notices -update`). - -| File | URL | Saved | License | Quote | -|---|---|---|---|---| -| `github-changelog-actions.rss.xml` | https://github.blog/changelog/label/actions/feed/ (RSS 2.0; `ETag` and `Last-Modified` sent) | 2026-11-14 08:27 UTC | Excerpt for testing; © GitHub, Inc. | "The macOS 14 runner image will be retired on November 2, 2026." | -| `vertex-ai-generative-ai.atom.xml` | https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml (Atom; `https://cloud.google.com/feeds/...` 301s here; `Last-Modified` sent) | 2026-11-14 08:27 UTC | CC BY 4.0 (Google Cloud documentation), kept whole | "Vertex AI Extensions is deprecated and will be shut down after November 26, 2026." | -| `cloudflare-api-deprecations.rss.xml` | https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml (RSS 2.0; `ETag` sent) | 2026-11-19 15:44 UTC | CC BY 4.0 (Cloudflare's documentation, cloudflare/cloudflare-docs), kept whole | "End of life date: September 27, 2026" (Legacy Registrar Domain Management API) | - -**Trimmed:** `github-changelog-actions.rss.xml` keeps the channel header and the three items the `github-actions` reader acts on (the macOS 14 retirement, which becomes events, and the two marked entries it drops: the ARM32 retirement and the `pull_request_target` change), copied unchanged. The seven unmarked items were left out; the reader ignores them, so its findings and the golden file are unchanged. diff --git a/plugins/notices/feed_golden_test.go b/plugins/notices/feed_golden_test.go deleted file mode 100644 index 7213308..0000000 --- a/plugins/notices/feed_golden_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package notices - -import ( - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/feed" -) - -// The two feeds as saved on 2026-11-14 (feed/testdata/README.md), each through the -// whole plugin: live feed and snapshot are the same copy, so the events cite -// the snapshot, and kittest's second read of the unchanged feed asks for no -// second snapshot and stores nothing new. -func TestFeedsGolden(t *testing.T) { - for _, c := range []struct { - feed feed.Feed - file string - }{ - {feed.GitHubActions, "feed/testdata/github-changelog-actions.rss.xml"}, - {feed.VertexAIModels, "feed/testdata/vertex-ai-generative-ai.atom.xml"}, - {feed.CloudflareAPI, "feed/testdata/cloudflare-api-deprecations.rss.xml"}, - } { - t.Run(c.feed.API, func(t *testing.T) { - saved := kittest.Pages{c.feed.URL: c.file} - archive := &kittest.Archive{T: t, Pages: saved} - got := kittest.Page(t, kittest.Env(t, saved), Plugin{Page: c.feed, Archiver: archive}) - if archive.Calls != 1 { - t.Errorf("%d snapshots, want 1", archive.Calls) - } - kittest.Golden(t, "testdata/golden/"+strings.ReplaceAll(c.feed.API, "/", "-")+".json", got) - }) - } -} diff --git a/plugins/notices/feed_registered_test.go b/plugins/notices/feed_registered_test.go deleted file mode 100644 index 646800c..0000000 --- a/plugins/notices/feed_registered_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package notices - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/feed" -) - -func TestFeedsRegisterThemselves(t *testing.T) { - for _, f := range []feed.Feed{feed.GitHubActions, feed.VertexAIModels, feed.CloudflareAPI} { - kittest.Registered(t, Plugin{Page: f}) - } -} diff --git a/plugins/notices/retire/providers.go b/plugins/notices/retire/providers.go deleted file mode 100644 index 882cdf0..0000000 --- a/plugins/notices/retire/providers.go +++ /dev/null @@ -1,88 +0,0 @@ -package retire - -import ( - "regexp" - "strings" -) - -// OpenAI's deprecations page (checked 2026-10-13). Its tables cover every -// kind of model; these events are for the text models the Chat Completions -// and Responses APIs take. Fine-tuned bases ("ft-gpt-4") aren't names code -// sends (a fine-tuned model is "ft:gpt-4-0613:org::id"), and the "-completions" -// aliases belong to the legacy Completions endpoint. -var OpenAI = Page{ - API: "openai/models", - Provider: "openai", - Vendor: "OpenAI", - URL: "https://developers.openai.com/api/docs/deprecations.md", - Keep: openAIText, -} - -// Anthropic's model deprecations page (checked 2026-10-13): every model in -// its deprecation history is a Messages API model. -var Anthropic = Page{ - API: "anthropic/models", - Provider: "anthropic", - Vendor: "Anthropic", - URL: "https://platform.claude.com/docs/en/about-claude/model-deprecations.md", - Keep: func(name string) bool { return strings.HasPrefix(name, "claude-") }, -} - -var ( - openAIFamilies = []string{"gpt-3.5", "gpt-4", "gpt-5", "o1", "o3", "o4", "chatgpt-", "computer-use", "codex-"} - openAINotText = []string{"image", "dall-e", "tts", "whisper", "transcribe", "realtime", "audio", "sora", "embedding", "moderation"} -) - -func openAIText(name string) bool { - if strings.HasPrefix(name, "ft-") || strings.HasSuffix(name, "-completions") { - return false - } - for _, s := range openAINotText { - if strings.Contains(name, s) { - return false - } - } - for _, p := range openAIFamilies { - if strings.HasPrefix(name, p) { - return true - } - } - return false -} - -// googleModel is a model id as code sends it, nothing around it: a cell -// with a footnote mark ("textembedding-gecko@003 *") isn't read. -var googleModel = regexp.MustCompile(`^[a-z0-9][a-z0-9.@_-]*$`) - -// Gemini is the Gemini API's deprecations page (ai.google.dev, served by -// aistudio.google.com as markdown, checked 2026-11-21): one Markdoc table per -// model family, | Model | Release date | Shutdown date | Recommended -// replacement |, current models with "No shutdown date announced", shut-down -// ones under "Deprecated models". Every model there is one code names in a -// request (text, image, video, audio, embedding: all through the same SDK); -// the managed agents' tables name an agent, not a model, and are skipped. -// Google says its dates are the earliest a model may be shut down. -var Gemini = Page{ - API: "google/gemini-models", - Provider: "google", - Vendor: "Google", - URL: "https://aistudio.google.com/docs/deprecations", - Format: FormatMarkdoc, - Keep: googleModel.MatchString, - Earliest: true, -} - -// Vertex is Google Cloud's Vertex AI model versions page (checked -// 2026-11-21): HTML tables of | Model ID | Release date | Retirement date | -// Replacement model ID | (or Recommended upgrade). A GA model's date is a -// minimum lifetime ("October 13, 2027 or later", "No sooner than May 20, -// 2028"), not a notice, and isn't read as a date; a retired or retiring -// model's is a plain date ("June 30, 2026"). -var Vertex = Page{ - API: "google/vertex-model-retirements", - Provider: "google", - Vendor: "Google", - URL: "https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions", - Format: FormatHTML, - Keep: googleModel.MatchString, -} diff --git a/plugins/notices/retire/retire_test.go b/plugins/notices/retire/retire_test.go deleted file mode 100644 index 84153e7..0000000 --- a/plugins/notices/retire/retire_test.go +++ /dev/null @@ -1,213 +0,0 @@ -package retire - -import ( - "errors" - "os" - "strings" - "testing" - "time" - - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" -) - -func read(t *testing.T, name string) []byte { - t.Helper() - b, err := os.ReadFile("testdata/" + name) - if err != nil { - t.Fatal(err) - } - return b -} - -func byModel(t *testing.T, p Page, file string) map[string]Retirement { - t.Helper() - rs, err := Parse(read(t, file), p.Keep) - if err != nil { - t.Fatal(err) - } - out := map[string]Retirement{} - for _, r := range rs { - if _, dup := out[r.Model]; dup { - t.Fatalf("%s listed twice", r.Model) - } - out[r.Model] = r - } - return out -} - -// The batch OpenAI shuts down on 2026-10-23, every alias its own name, each -// with the replacement the page names (saved copy of the page, 2026-10-13). -func TestOpenAIsOctober23Batch(t *testing.T) { - got := byModel(t, OpenAI, "openai-deprecations.md") - want := map[string]string{ - "gpt-3.5-turbo-0125": "gpt-5.6-terra", "gpt-3.5-turbo": "gpt-5.6-terra", - "gpt-4-0613": "gpt-5.6-sol", "gpt-4": "gpt-5.6-sol", - "gpt-4-1106-preview": "gpt-5.6-sol", - "gpt-4-turbo": "gpt-5.6-sol", "gpt-4-turbo-2024-04-09": "gpt-5.6-sol", - "gpt-4.1-nano": "gpt-5.6-luna", "gpt-4.1-nano-2025-04-14": "gpt-5.6-luna", - "gpt-4o-2024-05-13": "gpt-5.6-sol", - "o1-2024-12-17": "gpt-5.6-sol", "o1": "gpt-5.6-sol", - "o1-pro-2025-03-19": "gpt-5.6-sol", "o1-pro": "gpt-5.6-sol", - "o3-mini-2025-01-31": "gpt-5.6-sol", "o3-mini": "gpt-5.6-sol", - "o4-mini-2025-04-16": "gpt-5.6-terra", "o4-mini": "gpt-5.6-terra", - } - n := 0 - for _, r := range got { - if r.Date == "2026-10-23" { - n++ - if want[r.Model] == "" { - t.Errorf("unexpected in the batch: %s", r.Model) - } - } - } - if n != len(want) { - t.Errorf("%d models on 2026-10-23, want %d", n, len(want)) - } - for m, repl := range want { - r, ok := got[m] - if !ok || r.Date != "2026-10-23" || First(r.Replacement) != repl { - t.Errorf("%s: got %+v, want 2026-10-23 -> %s", m, r, repl) - } - } - if !strings.Contains(got["o1-pro"].Replacement, "reasoning.mode: pro") { - t.Errorf("the replacement's note is lost: %q", got["o1-pro"].Replacement) - } - gpt4 := got["gpt-4"].Excerpt - if !strings.Contains(gpt4, "### 2026-04-22: Legacy GPT model snapshots") || !strings.Contains(gpt4, "| Shutdown date") || !strings.Contains(gpt4, "`gpt-4-0613` \\| `gpt-4`") { - t.Errorf("the excerpt should be the heading, the header and the row:\n%s", gpt4) - } -} - -// Not text models, or not names code sends: image, audio, embeddings, -// fine-tuned bases, the legacy "-completions" aliases, endpoints. -func TestOnlyTextModelsCodeSendsAreKept(t *testing.T) { - got := byModel(t, OpenAI, "openai-deprecations.md") - for _, m := range []string{"gpt-image-1", "ft-gpt-4", "gpt-4-0613-completions", "gpt-3.5-turbo-completions", "tts-1-hd-1106", "dall-e-2", "/v1/fine-tunes", "babbage-002", "text-embedding-ada-002"} { - if _, ok := got[m]; ok { - t.Errorf("%s should not be an event", m) - } - } -} - -// A replacement that is itself retired is followed to one that works: -// gpt-3.5-turbo-0613 was told to move to gpt-3.5-turbo, which goes on 2026-10-23. -func TestARetiredReplacementIsFollowed(t *testing.T) { - got := byModel(t, OpenAI, "openai-deprecations.md") - r := got["gpt-3.5-turbo-0613"] - if First(r.Replacement) != "gpt-5.6-terra" || len(r.Via) != 1 || r.Via[0] != "gpt-3.5-turbo" { - t.Errorf("got %+v", r) - } - if h := hint("OpenAI", r); !strings.Contains(h, "gpt-5.6-terra") || !strings.Contains(h, "first named gpt-3.5-turbo") { - t.Errorf("hint: %q", h) - } -} - -func TestAnthropicsRetirements(t *testing.T) { - got := byModel(t, Anthropic, "anthropic-deprecations.md") - want := map[string][2]string{ - "claude-sonnet-4-5-20250929": {"2026-11-30", "claude-sonnet-5-5"}, - "claude-opus-4-1-20250805": {"2026-08-05", "claude-opus-4-8"}, - "claude-3-opus-20240229": {"2026-01-05", "claude-opus-4-8"}, - "claude-3-5-sonnet-20241022": {"2025-10-28", "claude-sonnet-5-5"}, - "claude-3-haiku-20240307": {"2026-04-20", "claude-haiku-4-5-20251001"}, - } - for m, w := range want { - if r := got[m]; r.Date != w[0] || First(r.Replacement) != w[1] { - t.Errorf("%s: got %+v, want %v", m, r, w) - } - } - if len(got) != 20 { - t.Errorf("%d retired Claude models, want 20", len(got)) - } - if _, ok := got["claude-mythos-preview"]; ok { - t.Error("a model with no retirement date yet is not an event") - } -} - -func TestTableEdgeCases(t *testing.T) { - page := strings.Join([]string{ - "### 2026-05-01: newer announcement", - "| Shutdown date | Model | Recommended replacement |", - "| --- | --- | --- |", - "| Jun 1, 2026 | `gpt-4-x` \\| `gpt-4-x-alias` | `gpt-5.6-sol` |", - "| To be announced | `gpt-4-later` | `gpt-5.6-sol` |", - "", - "### 2026-01-01: older announcement", - "| Shutdown date | Model | Recommended replacement |", - "| --- | --- | --- |", - "| 2026-03-01 | `gpt-4-x` | `gpt-4o` |", - "| 2026-03-01 | `gpt-4-later` | `gpt-4o` |", - "", - "| Shutdown date | System | Recommended replacement |", - "| --- | --- | --- |", - "| 2024-01-04 | `/v1/fine-tunes` | `/v1/fine_tuning/jobs` |", - }, "\n") - rs, err := Parse([]byte(page), openAIText) - if err != nil { - t.Fatal(err) - } - got := map[string]Retirement{} - for _, r := range rs { - got[r.Model] = r - } - if len(got) != 2 || got["gpt-4-x"].Date != "2026-06-01" || got["gpt-4-x-alias"].Date != "2026-06-01" { - t.Errorf("the newest announcement wins, aliases split on the escaped pipe, no date means no event: %+v", got) - } - if _, ok := got["gpt-4-later"]; ok { - t.Error("a newer \"To be announced\" withdraws an older row's date: no stale event") - } - if _, err := Parse([]byte("# Deprecations\n\nnothing here\n"), openAIText); !errors.Is(err, plugin.ErrNothingToRead) { - t.Errorf("a page with no retirement tables must be plugin.ErrNothingToRead, not zero events: %v", err) - } -} - -func TestEventsOnePerModel(t *testing.T) { - rs := []Retirement{{Model: "gpt-4", Date: "2026-10-23", Replacement: "`gpt-5.6-sol`", Excerpt: "### h\n| Shutdown date | … |\n| October 23, 2026 | `gpt-4` | `gpt-5.6-sol` |"}} - src := "https://web.archive.org/web/20261013115538/https://developers.openai.com/api/docs/deprecations.md" - events, errs := Events(OpenAI, rs, src, time.Date(2026, 10, 13, 0, 0, 0, 0, time.UTC)) - if len(errs) != 0 || len(events) != 1 { - t.Fatalf("events %d, errs %v", len(events), errs) - } - e := events[0] - want := event.Subject{Type: event.SubjectModel, Provider: "openai", Name: "gpt-4", Replacement: "gpt-5.6-sol"} - if e.Subject.Type != want.Type || e.Subject.Provider != want.Provider || e.Subject.Name != want.Name || e.Subject.Replacement != want.Replacement { - t.Errorf("subject: %+v", e.Subject) - } - if e.API != "openai/models" || e.Version != "2026-10-23" || e.PreviousVersion != "" || !e.Breaking || - e.SourceURL != src || e.SourceExcerpt != rs[0].Excerpt || e.Confidence != 1.0 { - t.Errorf("event: %+v", e) - } - if e.Fingerprint != event.Fingerprint("openai/models", "2026-10-23", event.ChangeTypeBreaking, e.Subject, "") { - t.Error("the fingerprint is the contract's formula over the model subject") - } - // The replacement is set only when the provider names exactly one model. - for cell, want := range map[string]string{"`gpt-5.6-sol`": "gpt-5.6-sol", "`a` or `b`": "", "`gpt-5.6-sol` (`reasoning.mode: pro`)": "", "none": ""} { - if got := replacement(cell); got != want { - t.Errorf("replacement(%q) = %q, want %q", cell, got, want) - } - } - if !strings.Contains(e.Description, `"gpt-4"`) || !strings.Contains(e.MigrationHint, "gpt-5.6-sol") { - t.Errorf("%q / %q", e.Description, e.MigrationHint) - } - moved, _ := Events(OpenAI, []Retirement{{Model: "gpt-4", Date: "2026-11-23", Replacement: "`gpt-5.6-sol`", Excerpt: "x"}}, src, time.Now()) - if moved[0].Fingerprint == e.Fingerprint { - t.Error("a moved shutdown date is a new event") - } -} - -func TestEveryRealRetirementBecomesValidEvents(t *testing.T) { - for _, c := range []struct { - p Page - file string - }{{OpenAI, "openai-deprecations.md"}, {Anthropic, "anthropic-deprecations.md"}} { - rs, err := Parse(read(t, c.file), c.p.Keep) - if err != nil { - t.Fatal(err) - } - events, errs := Events(c.p, rs, "https://web.archive.org/web/1/x", time.Now()) - if len(errs) != 0 || len(events) != len(rs) { - t.Errorf("%s: %d events from %d retirements, errors %v", c.p.API, len(events), len(rs), errs) - } - } -} diff --git a/plugins/notices/retire/testdata/README.md b/plugins/notices/retire/testdata/README.md deleted file mode 100644 index 05a2b3c..0000000 --- a/plugins/notices/retire/testdata/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Saved model deprecations pages - -The two providers' deprecations pages, as markdown (each page's URL plus `.md`). `retire`'s tests and the `openai-models` / `anthropic-models` golden tests (`plugins/notices`) read them. - -**License:** excerpts for testing; © OpenAI and © Anthropic respectively. Not covered by this repo's license. Google's two pages are © Google, CC BY 4.0 (Google's developer documentation). - -**Trimmed.** Each file keeps the page title and, for every retirement table that names at least one model the plugin keeps (text models code sends), the section heading above it and the whole table, copied unchanged. Prose, notice-period policy, endpoint tables and tables of only image, audio or embedding models were left out. `retire.Parse` returns exactly the same retirements from the trimmed and the full pages, so the golden files didn't change. - -| File | URL | Fetched | Quote | -|---|---|---|---| -| `openai-deprecations.md` | https://developers.openai.com/api/docs/deprecations.md | 2026-10-13 | "\| October 23, 2026 \| `gpt-4-0613` \\\| `gpt-4`, … \| `gpt-5.6-sol` \|" | -| `anthropic-deprecations.md` | https://platform.claude.com/docs/en/about-claude/model-deprecations.md | 2026-10-13 | "\| November 30, 2026 \| `claude-sonnet-4-5-20250929` \| `claude-sonnet-5-5` \|" | -| `gemini-deprecations.md` | https://aistudio.google.com/docs/deprecations (where https://ai.google.dev/gemini-api/docs/deprecations redirects; served as Markdown). Kept whole, byte for byte | 2026-11-21 | "\| `gemini-2.0-flash` \| February 5, 2025 \| June 1, 2026 \| `gemini-3.6-flash` \|", as Markdoc `* cell` lines | -| `vertex-model-versions.html` | https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions. Excerpt: every `

    `/`

    ` line and every line of every `` (982 of 10,074 lines), unchanged; scripts, navigation and prose left out. `retire.Parse` finds the same 39 retirements in the excerpt as in the full page | 2026-11-21 | "<td>June 30, 2026</td>" in the "Retired models" table | diff --git a/plugins/notices/retirements_golden_test.go b/plugins/notices/retirements_golden_test.go deleted file mode 100644 index 28b3d25..0000000 --- a/plugins/notices/retirements_golden_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package notices - -import ( - "strings" - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" -) - -// Each provider's saved page (OpenAI's and Anthropic's 2026-10-13, Google's -// 2026-11-21) in, every event out. The archive -// serves the same copy as the snapshot, so the events cite it; a second read -// of the unchanged page asks for no snapshot. -func TestRetirementsGolden(t *testing.T) { - for file, page := range map[string]retire.Page{ - "openai-deprecations.md": retire.OpenAI, - "anthropic-deprecations.md": retire.Anthropic, - "gemini-deprecations.md": retire.Gemini, - "vertex-model-versions.html": retire.Vertex, - } { - t.Run(page.API, func(t *testing.T) { - saved := kittest.Pages{page.URL: "retire/testdata/" + file} - archive := &kittest.Archive{T: t, Pages: saved} - got := kittest.Page(t, kittest.Env(t, saved), Plugin{Page: page, Archiver: archive}) - if archive.Calls != 1 { - t.Errorf("%d snapshots, want 1: the second read's page is unchanged", archive.Calls) - } - kittest.Golden(t, "testdata/golden/"+strings.ReplaceAll(page.API, "/", "-")+".json", got) - }) - } -} diff --git a/plugins/notices/retirements_registered_test.go b/plugins/notices/retirements_registered_test.go deleted file mode 100644 index 7d020eb..0000000 --- a/plugins/notices/retirements_registered_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package notices - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" -) - -func TestRetirementsRegisterThemselves(t *testing.T) { - for _, p := range []retire.Page{retire.OpenAI, retire.Anthropic, retire.Gemini, retire.Vertex} { - kittest.Registered(t, Plugin{Page: p}) - } -} diff --git a/plugins/notices/testdata/README.md b/plugins/notices/testdata/README.md deleted file mode 100644 index fb557f5..0000000 --- a/plugins/notices/testdata/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Golden events - -`golden/openai-models.json` and `golden/anthropic-models.json` are what the `openai-models` and `anthropic-models` plugins store from the saved deprecations pages. The pages themselves are shared with the `retire` package: see [`retire/testdata/README.md`](../retire/testdata/README.md) for their URLs, dates and licenses. - -`golden/github-actions.json`, `golden/google-vertex-ai-models.json` and `golden/cloudflare-api.json` come from the saved feeds in [`feed/testdata/`](../feed/testdata/README.md); `golden/salesforce.json` from the saved page in [`eol/testdata/`](../eol/testdata/README.md). - -Rewrite them after an intended change with `go test ./plugins/notices -update`, and say in the PR why the new output is right. diff --git a/plugins/openapi/adapter/neon.go b/plugins/openapi/adapter/neon.go deleted file mode 100644 index 1de323b..0000000 --- a/plugins/openapi/adapter/neon.go +++ /dev/null @@ -1,86 +0,0 @@ -package adapter - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/github" -) - -// Variables, not constants, only so tests can point them at a local server. -var ( - // neonCommitsURL lists the commits that changed the Neon API spec in - // neondatabase/neon-pkgs, newest first; with per_page=1, the newest. - neonCommitsURL = "https://api.github.com/repos/neondatabase/neon-pkgs/commits?path=packages/sdk/spec/neon-openapi.json&per_page=1" - // neonCommitURL is one commit, for its date. - neonCommitURL = "https://api.github.com/repos/neondatabase/neon-pkgs/commits/%s" - // neonSpecURLTemplate is the Neon API spec (console.neon.tech/api/v2) at - // one commit. Neon serves it live at - // https://neon.com/api_spec/release/v2.json, which has no versions; the - // copy in neondatabase/neon-pkgs is pulled from there and committed when - // a daily drift check sees it change (23 commits from 2026-06-24 to - // 2026-11-17), and a commit never changes. - neonSpecURLTemplate = "https://raw.githubusercontent.com/neondatabase/neon-pkgs/%s/packages/sdk/spec/neon-openapi.json" -) - -// Neon adapts the Neon API spec in neondatabase/neon-pkgs for the openapi -// plugin. The repo tags no spec releases, so a tag here is the commit that -// last changed the spec. -type Neon struct{} - -var _ Adapter = Neon{} - -func (Neon) API() string { return "neon/api" } - -// LatestTag is the SHA of the newest commit that changed the spec. -func (Neon) LatestTag(ctx context.Context) (string, error) { - sha, err := github.LatestCommit(ctx, github.Get, neonCommitsURL) - if err != nil { - return "", fmt.Errorf("looking up neon's latest spec commit: %w", err) - } - return sha, nil -} - -// Fetch downloads the spec at commit sha and moves the server URL's path into -// the paths: see ServerBasePath. -// -// Version is the commit's date (YYYY-MM-DD): the API's only version is the -// `/api/v2` in its URL (info.version a fixed "v2" in all 23 commits, checked -// 2026-11-19), so the date the spec changed is the closest thing to "the API -// version the change arrived in". -func (Neon) Fetch(ctx context.Context, sha string) (Spec, error) { - fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(neonCommitURL, sha)) - if err != nil { - return Spec{}, fmt.Errorf("looking up neon spec commit %s: %w", sha, err) - } - if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) - } - // Pin to the full SHA even when given a short one: the citation must - // name exactly one document. - url := fmt.Sprintf(neonSpecURLTemplate, fullSHA) - body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth - if err != nil { - return Spec{}, fmt.Errorf("fetching neon spec %s: %w", sha, err) - } - if !json.Valid(body) { - return Spec{}, fmt.Errorf("neon spec %s is not valid json", sha) - } - // The server is "https://console.neon.tech/api/v2" and the paths don't - // repeat /api/v2 (all 23 commits, checked 2026-11-19). Moved into the - // paths, an operation is named by the path a caller sends, and a spec - // that ever moved it (as Sentry's did) can't read as every deprecated - // operation removed. - content, err := ServerBasePath(body) - if err != nil { - return Spec{}, fmt.Errorf("neon spec %s: %w", sha, err) - } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil -} - -// SourcePointer: see BasePathPointer. -func (Neon) SourcePointer(content []byte) func(string) string { return BasePathPointer(content) } - -var _ Reshaper = Neon{} diff --git a/plugins/openapi/adapter/planetscale.go b/plugins/openapi/adapter/planetscale.go deleted file mode 100644 index 3d77cf9..0000000 --- a/plugins/openapi/adapter/planetscale.go +++ /dev/null @@ -1,106 +0,0 @@ -package adapter - -import ( - "cmp" - "context" - "encoding/json" - "fmt" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/github" - "gopkg.in/yaml.v3" -) - -const ( - // planetscaleRepo is PlanetScale's Terraform provider, which keeps a copy - // of the PlanetScale API spec at planetscaleSpecPath. - planetscaleRepo = "planetscale/terraform-provider-planetscale" - // planetscaleSpecPath is the spec in that repo: a copy of - // https://planetscale.com/docs/openapi.yaml, which has no versions, - // committed when it changes. - planetscaleSpecPath = "schemas/openapi.yaml" -) - -// PlanetScale adapts the PlanetScale API spec for the openapi plugin. The -// repo tags no spec releases, so a tag here is the commit that last changed -// the spec, as for Supabase. -// -// The zero value reads GitHub. The fields point it at another server, for -// tests. -type PlanetScale struct { - APIBase string // GitHub's REST API; "" is https://api.github.com - RawBase string // files at a commit; "" is https://raw.githubusercontent.com -} - -var _ Adapter = PlanetScale{} - -func (PlanetScale) API() string { return "planetscale/api" } - -func (p PlanetScale) api(path string) string { - return cmp.Or(p.APIBase, "https://api.github.com") + "/repos/" + planetscaleRepo + path -} - -// LatestTag is the SHA of the newest commit that changed the spec. -func (p PlanetScale) LatestTag(ctx context.Context) (string, error) { - sha, err := github.LatestCommit(ctx, github.Get, p.api("/commits?path="+planetscaleSpecPath+"&per_page=1")) - if err != nil { - return "", fmt.Errorf("looking up planetscale's latest spec commit: %w", err) - } - return sha, nil -} - -// Fetch downloads the spec at commit sha and converts it from YAML to JSON, -// which is what diff.Parse reads (as for Algolia). -// -// Version is the commit's date (YYYY-MM-DD): the API has no version of its -// own (`info.version` is a fixed "v1", checked 2026-11-19), so the date the -// spec changed is the closest thing to "the API version the change arrived -// in". -// -// A file that isn't a spec is an error, not an empty API: diffed against the -// last one, it would read as every operation removed. The commits that -// changed the file include one that deleted it (f33a0c3b35, 2025-12-04; -// it came back the same day), where the raw URL answers 404: fetch.Get's -// error. A file served 200 that has no paths (emptied, or a stub page like -// "404: Not Found", which YAML reads as a one-key mapping) is refused here. -func (p PlanetScale) Fetch(ctx context.Context, sha string) (Spec, error) { - fullSHA, date, err := github.Commit(ctx, github.Get, p.api("/commits/"+sha)) - if err != nil { - return Spec{}, fmt.Errorf("looking up planetscale spec commit %s: %w", sha, err) - } - if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) - } - // Pin to the full SHA even when given a short one: the citation must - // name exactly one document. - url := cmp.Or(p.RawBase, "https://raw.githubusercontent.com") + "/" + planetscaleRepo + "/" + fullSHA + "/" + planetscaleSpecPath - body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth - if err != nil { - return Spec{}, fmt.Errorf("fetching planetscale spec %s: %w", sha, err) - } - var doc map[string]any - if err := yaml.Unmarshal(body, &doc); err != nil { - return Spec{}, fmt.Errorf("parsing planetscale spec %s as yaml: %w", sha, err) - } - if paths, _ := doc["paths"].(map[string]any); len(paths) == 0 { - return Spec{}, fmt.Errorf("planetscale spec %s has no paths: not a spec", sha) - } - content, err := json.Marshal(doc) - if err != nil { - return Spec{}, fmt.Errorf("converting planetscale spec %s to json: %w", sha, err) - } - // The server is "https://api.planetscale.com/v1" and the paths leave out - // /v1 (all 32 versions, checked 2026-11-19). Moved into the paths, an - // operation is named by the path a caller sends, and a spec that ever - // moved it (as Sentry's did) can't read as every deprecated operation - // removed. - if content, err = ServerBasePath(content); err != nil { - return Spec{}, fmt.Errorf("planetscale spec %s: %w", sha, err) - } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil -} - -// SourcePointer: see BasePathPointer. -func (PlanetScale) SourcePointer(content []byte) func(string) string { return BasePathPointer(content) } - -var _ Reshaper = PlanetScale{} diff --git a/plugins/openapi/adapter/stripe.go b/plugins/openapi/adapter/stripe.go deleted file mode 100644 index 40cd89c..0000000 --- a/plugins/openapi/adapter/stripe.go +++ /dev/null @@ -1,64 +0,0 @@ -package adapter - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/github" -) - -// Variables, not constants, only so tests can point them at a local server. -var ( - stripeReleasesURL = "https://api.github.com/repos/stripe/openapi/releases/latest" - // stripeSpecURLTemplate is Stripe's recommended file: v1 + v2 endpoints. - // Every release that names its API version (Versions) has it. - stripeSpecURLTemplate = "https://raw.githubusercontent.com/stripe/openapi/%s/latest/openapi.spec3.json" -) - -// Stripe is the reference adapter: the pattern every future adapter follows. -// It has no state, so its zero value is ready to use. -type Stripe struct{} - -// Compile-time check that Stripe actually satisfies Adapter. -var _ Adapter = Stripe{} - -func (Stripe) API() string { return "stripe/api" } - -// LatestTag asks GitHub for Stripe's newest openapi release tag, e.g. "v2468". -func (Stripe) LatestTag(ctx context.Context) (string, error) { - tag, err := github.LatestRelease(ctx, github.Get, stripeReleasesURL) - if err != nil { - return "", fmt.Errorf("looking up stripe's latest release: %w", err) - } - return tag, nil -} - -// Fetch downloads the spec pinned to tag and reads its declared API version -// out of info.version — the only version field the spec has. -func (Stripe) Fetch(ctx context.Context, tag string) (Spec, error) { - url := fmt.Sprintf(stripeSpecURLTemplate, tag) - body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth - if err != nil { - return Spec{}, fmt.Errorf("fetching stripe spec %s: %w", tag, err) - } - - var parsed struct { - Info struct { - Version string `json:"version"` - } `json:"info"` - } - if err := json.Unmarshal(body, &parsed); err != nil { - return Spec{}, fmt.Errorf("parsing stripe spec %s: %w", tag, err) - } - if parsed.Info.Version == "" { - return Spec{}, fmt.Errorf("stripe spec %s has no info.version", tag) - } - - return Spec{ - Content: body, - Version: parsed.Info.Version, - SourceURL: url, - }, nil -} diff --git a/plugins/openapi/adapter/stripe_test.go b/plugins/openapi/adapter/stripe_test.go deleted file mode 100644 index 80e73f2..0000000 --- a/plugins/openapi/adapter/stripe_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package adapter - -import ( - "context" - "net/http" - "net/http/httptest" - "strings" - "testing" -) - -// fakeGitHub serves a latest-release endpoint and specs by path. Paths missing -// from specs return 404, like raw.githubusercontent.com does. -func fakeGitHub(t *testing.T, releaseJSON string, specs map[string]string) *httptest.Server { - t.Helper() - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.Path == "/releases/latest" { - w.Write([]byte(releaseJSON)) - return - } - body, ok := specs[r.URL.Path] - if !ok { - http.NotFound(w, r) - return - } - w.Write([]byte(body)) - })) - t.Cleanup(srv.Close) - - oldRel, oldSpec := stripeReleasesURL, stripeSpecURLTemplate - stripeReleasesURL = srv.URL + "/releases/latest" - stripeSpecURLTemplate = srv.URL + "/%s/latest/openapi.spec3.json" - t.Cleanup(func() { stripeReleasesURL, stripeSpecURLTemplate = oldRel, oldSpec }) - return srv -} - -func TestLatestTagReadsTheReleaseTag(t *testing.T) { - fakeGitHub(t, `{"tag_name":"v2484"}`, nil) - tag, err := Stripe{}.LatestTag(context.Background()) - if err != nil || tag != "v2484" { - t.Errorf("got %q, %v; want v2484", tag, err) - } -} - -func TestLatestTagRejectsAReleaseWithoutATag(t *testing.T) { - fakeGitHub(t, `{"name":"something"}`, nil) - if _, err := (Stripe{}).LatestTag(context.Background()); err == nil { - t.Error("release without tag_name: want an error") - } -} - -func TestFetchUsesTheRecommendedSpec(t *testing.T) { - srv := fakeGitHub(t, "", map[string]string{ - "/v2468/latest/openapi.spec3.json": `{"info":{"version":"2026-08-26.dahlia"}}`, - }) - spec, err := Stripe{}.Fetch(context.Background(), "v2468") - if err != nil { - t.Fatal(err) - } - if spec.Version != "2026-08-26.dahlia" || spec.SourceURL != srv.URL+"/v2468/latest/openapi.spec3.json" { - t.Errorf("got version %q from %s; want the latest/ file", spec.Version, spec.SourceURL) - } -} - -func TestFetchRejectsASpecWithoutAVersion(t *testing.T) { - fakeGitHub(t, "", map[string]string{"/v1/latest/openapi.spec3.json": `{"info":{}}`}) - _, err := Stripe{}.Fetch(context.Background(), "v1") - if err == nil || !strings.Contains(err.Error(), "info.version") { - t.Errorf("got %v, want an info.version error", err) - } -} - -func TestFetchFailsWhenNeitherSpecExists(t *testing.T) { - fakeGitHub(t, "", nil) - if _, err := (Stripe{}).Fetch(context.Background(), "v999999"); err == nil { - t.Error("missing tag: want an error") - } -} diff --git a/plugins/openapi/adapter/supabase.go b/plugins/openapi/adapter/supabase.go deleted file mode 100644 index fc7291d..0000000 --- a/plugins/openapi/adapter/supabase.go +++ /dev/null @@ -1,70 +0,0 @@ -package adapter - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/github" -) - -// Variables, not constants, only so tests can point them at a local server. -var ( - // supabaseCommitsURL lists the commits that changed the Management API - // spec in supabase/supabase, newest first; with per_page=1, the newest. - supabaseCommitsURL = "https://api.github.com/repos/supabase/supabase/commits?path=apps/docs/spec/api_v1_openapi.json&per_page=1" - // supabaseCommitURL is one commit, for its date. - supabaseCommitURL = "https://api.github.com/repos/supabase/supabase/commits/%s" - // supabaseSpecURLTemplate is the Management API spec (api.supabase.com) - // at one commit. Supabase serves it live at - // https://api.supabase.com/api/v1-json, which has no versions; the docs - // copy in supabase/supabase is the same spec, committed when it changes - // (90 commits from 2024-05-31 to 2026-11-18), and a commit never changes. - supabaseSpecURLTemplate = "https://raw.githubusercontent.com/supabase/supabase/%s/apps/docs/spec/api_v1_openapi.json" -) - -// Supabase adapts the Supabase Management API spec in supabase/supabase for -// the openapi plugin. The repo tags no spec releases, so a tag here is the -// commit that last changed the spec. -type Supabase struct{} - -var _ Adapter = Supabase{} - -func (Supabase) API() string { return "supabase/management-api" } - -// LatestTag is the SHA of the newest commit that changed the spec. -func (Supabase) LatestTag(ctx context.Context) (string, error) { - sha, err := github.LatestCommit(ctx, github.Get, supabaseCommitsURL) - if err != nil { - return "", fmt.Errorf("looking up supabase's latest spec commit: %w", err) - } - return sha, nil -} - -// Fetch downloads the spec at commit sha. -// -// Version is the commit's date (YYYY-MM-DD): the Management API has no -// version of its own (`/v1`, info.version a fixed "1.0.0", checked -// 2026-11-19), so the date the spec changed is the closest thing to "the API -// version the change arrived in". -func (Supabase) Fetch(ctx context.Context, sha string) (Spec, error) { - fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(supabaseCommitURL, sha)) - if err != nil { - return Spec{}, fmt.Errorf("looking up supabase spec commit %s: %w", sha, err) - } - if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) - } - // Pin to the full SHA even when given a short one: the citation must - // name exactly one document. - url := fmt.Sprintf(supabaseSpecURLTemplate, fullSHA) - body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth - if err != nil { - return Spec{}, fmt.Errorf("fetching supabase spec %s: %w", sha, err) - } - if !json.Valid(body) { - return Spec{}, fmt.Errorf("supabase spec %s is not valid json", sha) - } - return Spec{Content: body, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil -} diff --git a/plugins/openapi/adapter/testdata/README.md b/plugins/openapi/adapter/testdata/README.md deleted file mode 100644 index ae38714..0000000 --- a/plugins/openapi/adapter/testdata/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Recorded API responses - -The version-listing tests (`versions_test.go`) read these instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. - -| File | Recorded from | Trimmed to | -|---|---|---| -| `versions/github-versions.json` | `https://api.github.com/versions` | whole | -| `versions/gitlab-tags-1.json` | `https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/tags?order_by=version&sort=desc&per_page=100&page=1` | all 100 tags; `name` and `commit.created_at` | -| `versions/gitlab-tags-2.json` | the same, `page=2` | 14 tags (18.10.0, 18.10.1, 18.9.x, 18.1.4); same fields | -| `versions/es-releases.json` | `https://api.github.com/repos/elastic/elasticsearch/releases?per_page=100` | all 100; `tag_name`, `prerelease`, `draft` | -| `versions/es-branches.json` | `https://api.github.com/repos/elastic/elasticsearch-specification/git/matching-refs/heads/` | the minor branches, `main` and `gh-pages` (33 of 250) | -| `versions/sentry-api-releases.json` | `https://api.github.com/repos/getsentry/sentry/releases?per_page=100&page=1` | the 19 `api@` releases; `tag_name`, `draft`, `prerelease`, `published_at`, asset names | -| `versions/sentry-schema-releases.json` | `https://api.github.com/repos/getsentry/sentry-api-schema/releases` (pages 1-4) | 2.3.2 and 2.4.0; same fields | -| `versions/algolia-refs.json` | `https://api.github.com/repos/algolia/api-clients-automation/git/matching-refs/tags/released-` | 9 of 186 tags, five of them on two days with several releases | -| `versions/algolia-commit-*.json` | `https://api.github.com/repos/algolia/api-clients-automation/commits/` | `sha` and the committer date | -| `versions/stripe-openapi-releases.json` | `https://api.github.com/repos/stripe/openapi/releases/tags/`, one per release, in the order `releases?per_page=100` lists them | 21 of 2,591: the first and the last release of each of the 10 API versions their notes name (v2191 to v2602), and v2190, the newest whose notes name none; `tag_name`, `name`, `draft`, `prerelease`, `published_at`, `html_url`, `body` | -| `versions/appwrite-commits.json` | `https://api.github.com/repos/appwrite/specs/commits?path=specs&per_page=100&page=1` | the 40 newest commits; `sha`, `html_url`, the committer date | - -Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. diff --git a/plugins/openapi/adapter/vercel.go b/plugins/openapi/adapter/vercel.go deleted file mode 100644 index 7d3afb3..0000000 --- a/plugins/openapi/adapter/vercel.go +++ /dev/null @@ -1,61 +0,0 @@ -package adapter - -import ( - "context" - "encoding/json" - "fmt" - "strings" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/github" -) - -// Variables, not constants, only so tests can point them at a local server. -var ( - vercelReleasesURL = "https://api.github.com/repos/vercel/sdk/releases/latest" - // vercelSpecURLTemplate is the REST API spec @vercel/sdk is generated from, - // committed at the root of vercel/sdk and regenerated on every release. - // Vercel also serves it live at https://openapi.vercel.sh/, but that URL - // has no versions to pin or replay. The SDK repo's copy is the same spec, - // a release behind at most (on 2026-11-18 the live one had 3 paths more - // out of 356), and tagged on every release. - vercelSpecURLTemplate = "https://raw.githubusercontent.com/vercel/sdk/%s/vercel-spec.json" -) - -// Vercel adapts the OpenAPI spec bundled in vercel/sdk for the openapi plugin. -type Vercel struct{} - -var _ Adapter = Vercel{} - -func (Vercel) API() string { return "vercel/api" } - -// LatestTag asks GitHub for vercel/sdk's newest release tag, e.g. "v1.28.65". -// The canary tags (v14.0.0-canary.9) aren't releases, so releases/latest never -// returns them (checked 2026-11-18). -func (Vercel) LatestTag(ctx context.Context) (string, error) { - tag, err := github.LatestRelease(ctx, github.Get, vercelReleasesURL) - if err != nil { - return "", fmt.Errorf("looking up vercel's latest release: %w", err) - } - return tag, nil -} - -// Fetch downloads the spec pinned to tag. It's JSON already, so it's passed -// through unchanged. -// -// Version is the release tag without its "v", not info.version: that is a -// fixed "0.0.1" in every release (checked 2026-11-18). The tag is what a -// customer pins in package.json ("@vercel/sdk": "1.28.65"). Vercel's REST API -// has no version of its own: each endpoint carries its own in the path -// (/v13/deployments, /v6/user/tokens). -func (Vercel) Fetch(ctx context.Context, tag string) (Spec, error) { - url := fmt.Sprintf(vercelSpecURLTemplate, tag) - body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth - if err != nil { - return Spec{}, fmt.Errorf("fetching vercel spec %s: %w", tag, err) - } - if !json.Valid(body) { - return Spec{}, fmt.Errorf("vercel spec %s is not valid json", tag) - } - return Spec{Content: body, Version: strings.TrimPrefix(tag, "v"), SourceURL: url}, nil -} diff --git a/plugins/openapi/adapter/versions.go b/plugins/openapi/adapter/versions.go deleted file mode 100644 index f8f90b1..0000000 --- a/plugins/openapi/adapter/versions.go +++ /dev/null @@ -1,341 +0,0 @@ -package adapter - -import ( - "cmp" - "context" - "encoding/json" - "fmt" - "regexp" - "slices" - "strings" - "time" - - "github.com/patch-it-dev/patch-it-plugins/core/fetch" - "github.com/patch-it-dev/patch-it-plugins/core/github" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/core/versions" -) - -// Every version of each spec, oldest first (Lister): the repo's releases for -// the adapters whose LatestTag is releases/latest, the commits that changed -// the spec for those that follow a file, and each other adapter's own -// listing (GitHub's dated versions, GitLab's release tags, Elasticsearch's -// released minors, Sentry's releases, Algolia's release tags, Appwrite's -// spec commits). Every adapter is a Lister. - -func releases(ctx context.Context, repo string, keep func(string) bool) ([]plugin.Version, error) { - return versions.GitHubReleases(ctx, github.Get, repo, keep) -} - -// commits are the days a file changed, each read at the day's last commit -// (Daily). -func commits(ctx context.Context, repo, path string) ([]plugin.Version, error) { - vs, err := versions.GitHubCommits(ctx, github.Get, repo, path) - if err != nil { - return nil, err - } - return Daily(vs), nil -} - -// stripeSDKSpecVersion is the API version a stripe/openapi release's notes -// say its SDK spec carries, the version Stripe's SDKs pin (every release -// since v2191, 2026-03-11, checked 2026-11-20): -// -// | openapi/spec3.sdk.{json,yaml} | 2026-11-18.endive | -var stripeSDKSpecVersion = regexp.MustCompile(`(?m)^\|\s*openapi/spec3\.sdk\.\{json,yaml\}\s*\|\s*(\d{4}-\d{2}-\d{2}(?:\.[a-z]+)?)\s*\|`) - -// Versions are Stripe's API versions ("2026-11-18.endive"), oldest first, as -// stripe/openapi's releases name them in their notes: each is read at the -// newest release that carries it (Ref, URL) and dated by the first -// (Released). A release whose notes name no version (every one before v2191) -// is left out: its version would have to be guessed. -func (Stripe) Versions(ctx context.Context) ([]plugin.Version, error) { - rs, err := versions.GitHubPages[stripeRelease](ctx, github.Get, versions.GitHubAPI+"/repos/stripe/openapi/releases") - if err != nil { - return nil, fmt.Errorf("listing stripe/openapi's releases: %w", err) - } - slices.SortStableFunc(rs, func(a, b stripeRelease) int { return a.Published.Compare(b.Published) }) - byID := map[string]*plugin.Version{} - var out []*plugin.Version - for _, r := range rs { - m := stripeSDKSpecVersion.FindStringSubmatch(r.Body) - if r.Draft || r.Prerelease || r.Tag == "" || m == nil { - continue - } - v, ok := byID[m[1]] - if !ok { - v = &plugin.Version{ID: m[1], Released: r.Published} - byID[m[1]], out = v, append(out, v) - } - v.Ref, v.URL = r.Tag, r.URL - } - vs := make([]plugin.Version, len(out)) - for i, v := range out { - vs[i] = *v - } - slices.SortStableFunc(vs, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) - return vs, nil -} - -// stripeRelease is a stripe/openapi release as GitHub's API lists it. -type stripeRelease struct { - Tag string `json:"tag_name"` - Draft bool `json:"draft"` - Prerelease bool `json:"prerelease"` - Published time.Time `json:"published_at"` - URL string `json:"html_url"` - Body string `json:"body"` -} - -// ListsSpecVersions: Stripe's version ids are the specs' info.version. -func (Stripe) ListsSpecVersions() {} - -// Versions are datadog-api-client-python's releases. -func (Datadog) Versions(ctx context.Context) ([]plugin.Version, error) { - return releases(ctx, "DataDog/datadog-api-client-python", nil) -} - -// Versions are vercel/sdk's releases, canaries left out (as LatestTag does). -func (Vercel) Versions(ctx context.Context) ([]plugin.Version, error) { - return releases(ctx, "vercel/sdk", func(tag string) bool { return !strings.Contains(tag, "canary") }) -} - -// Versions are Flagsmith's releases. -func (Flagsmith) Versions(ctx context.Context) ([]plugin.Version, error) { - return releases(ctx, "Flagsmith/flagsmith", nil) -} - -// Versions are the commits that changed the Management API spec. -func (Supabase) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, "supabase/supabase", "apps/docs/spec/api_v1_openapi.json") -} - -// Versions are the commits that changed Neon's spec. -func (Neon) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, "neondatabase/neon-pkgs", "packages/sdk/spec/neon-openapi.json") -} - -// Versions are the commits that changed Convex's deployment API spec. -func (Convex) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, "convex/convex-backend", "npm-packages/@convex-dev/platform/deployment-openapi.json") -} - -// Versions are the commits that changed PlanetScale's spec. -func (PlanetScale) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, planetscaleRepo, planetscaleSpecPath) -} - -var ( - _ SpecVersioned = Stripe{} - _ Lister = Datadog{} - _ Lister = Vercel{} - _ Lister = Flagsmith{} - _ Lister = Supabase{} - _ Lister = Neon{} - _ Lister = Convex{} - _ Lister = PlanetScale{} -) - -// Versions are every API version GitHub supports, oldest first: each is a -// spec file of its own, and what a client sends as X-GitHub-Api-Version. -// GitHub publishes no spec for a version it no longer supports. -func (GitHub) Versions(ctx context.Context) ([]plugin.Version, error) { - body, err := fetch.Get(ctx, githubVersionsURL, github.Headers()) - if err != nil { - return nil, fmt.Errorf("looking up github's supported api versions: %w", err) - } - var ids []string - if err := json.Unmarshal(body, &ids); err != nil { - return nil, fmt.Errorf("parsing github versions response: %w", err) - } - slices.Sort(ids) - var out []plugin.Version - for _, id := range ids { - released, _ := time.Parse(time.DateOnly, id) - out = append(out, plugin.Version{ID: id, Released: released, Ref: id, URL: "https://docs.github.com/rest/about-the-rest-api/api-versions"}) - } - return out, nil -} - -// gitlabFirstSpec is the first release whose tag carries openapi_v3.yaml. -var gitlabFirstSpec = [3]int{18, 10, 0} - -// Versions are every stable GitLab release with the OpenAPI 3 spec -// (v18.10.0-ee on), oldest first by version: patch releases of an older -// minor (18.11.14) sit before the next minor's first release. The tags -// listing is read page by page, newest version first, until it passes -// v18.10.0-ee. -func (g GitLab) Versions(ctx context.Context) ([]plugin.Version, error) { - type tag struct { - Name string `json:"name"` - Commit struct { - Created time.Time `json:"created_at"` - } `json:"commit"` - } - var out []plugin.Version - for page := 1; page <= versions.MaxPages; page++ { - body, err := fetch.Get(ctx, fmt.Sprintf("%s&page=%d", cmp.Or(g.TagsURL, gitlabTagsURL), page), nil) - if err != nil { - return nil, fmt.Errorf("listing gitlab's tags: %w", err) - } - var tags []tag - if err := json.Unmarshal(body, &tags); err != nil { - return nil, fmt.Errorf("parsing gitlab tags response: %w", err) - } - older := false - for _, t := range tags { - m := gitlabRelease.FindStringSubmatch(t.Name) - if m == nil { - continue - } - v := [3]int{atoi(m[1]), atoi(m[2]), atoi(m[3])} - if slices.Compare(v[:], gitlabFirstSpec[:]) < 0 { - older = true - continue - } - out = append(out, plugin.Version{ID: gitlabVersion(t.Name), Released: t.Commit.Created.UTC(), Ref: t.Name, - URL: "https://gitlab.com/gitlab-org/gitlab/-/tags/" + t.Name}) - } - if older || len(tags) < 100 { - break - } - } - slices.SortStableFunc(out, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) - return out, nil -} - -// esFirstSpec is the first minor whose branch has the OpenAPI output. -var esFirstSpec = [2]int{8, 14} - -// Versions are every released minor with the OpenAPI output (8.14 on), its -// branch the ref: up to the newest minor Elastic has released (LatestTag), -// never the next, unreleased one. -func (e Elasticsearch) Versions(ctx context.Context) ([]plugin.Version, error) { - newest, branches, err := esMinors(ctx) - if err != nil { - return nil, err - } - var out []plugin.Version - for _, b := range branches { - m := esBranch.FindStringSubmatch(b) - v := [2]int{atoi(m[1]), atoi(m[2])} - if slices.Compare(v[:], esFirstSpec[:]) < 0 || slices.Compare(v[:], newest[:]) > 0 { - continue - } - out = append(out, plugin.Version{ID: b + ".0", Ref: b, URL: "https://github.com/elastic/elasticsearch-specification/tree/" + b}) - } - slices.SortStableFunc(out, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) - return out, nil -} - -// Versions are every release of the spec, oldest first by date: the -// getsentry/sentry-api-schema release tags (0.1.0 to 2.4.0, the archived -// repo) and then getsentry/sentry's api@X.Y.Z releases with the spec -// attached. The ID is the release's date, as Fetch's Version. The schema -// repo's commits before its first tag aren't listed; Fetch still reads one -// by its SHA. -func (s Sentry) Versions(ctx context.Context) ([]plugin.Version, error) { - var out []plugin.Version - for _, src := range []struct { - repo string - keep func(sentryReleaseInfo) bool - }{ - {"getsentry/sentry-api-schema", func(r sentryReleaseInfo) bool { return sentrySchemaTag.MatchString(r.Tag) }}, - {"getsentry/sentry", func(r sentryReleaseInfo) bool { return sentryRelease.MatchString(r.Tag) && r.hasSpec() }}, - } { - rs, err := versions.GitHubPages[sentryReleaseInfo](ctx, github.Get, s.api("/repos/"+src.repo+"/releases")) - if err != nil { - return nil, fmt.Errorf("listing %s's releases: %w", src.repo, err) - } - for _, r := range rs { - if r.Draft || r.Prerelease || !src.keep(r) { - continue - } - at := r.PublishedAt.UTC() - out = append(out, plugin.Version{ID: at.Format(time.DateOnly), Released: at, Ref: r.Tag, - URL: "https://github.com/" + src.repo + "/releases/tag/" + strings.ReplaceAll(r.Tag, "@", "%40")}) - } - } - slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) - return out, nil -} - -// Versions are every release tag, oldest first. A day with several releases -// is ordered by each tag's commit date (LatestTag's rule), one lookup per -// tag on such a day only. -func (a Algolia) Versions(ctx context.Context) ([]plugin.Version, error) { - tags, err := algoliaTags(ctx) - if err != nil { - return nil, err - } - days := map[string]int{} - for _, t := range tags { - days[algoliaTag.FindStringSubmatch(t)[1]]++ - } - var out []plugin.Version - for _, t := range tags { - day := algoliaTag.FindStringSubmatch(t)[1] - released, _ := time.Parse(time.DateOnly, day) - if days[day] > 1 { - if released, err = algoliaCommitDate(ctx, t); err != nil { - return nil, err - } - } - out = append(out, plugin.Version{ID: day, Released: released.UTC(), Ref: t, - URL: "https://github.com/algolia/api-clients-automation/releases/tag/" + t}) - } - slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) - return out, nil -} - -// Versions are the days appwrite/specs' default branch changed specs/, -// oldest first, each at the day's last commit (Daily): the ID is the date -// (Fetch's Version), the Ref the SHA, read at the newest minor's directory. -func (a Appwrite) Versions(ctx context.Context) ([]plugin.Version, error) { - cs, err := versions.GitHubPages[struct { - SHA string `json:"sha"` - URL string `json:"html_url"` - Commit struct { - Committer struct { - Date time.Time `json:"date"` - } `json:"committer"` - } `json:"commit"` - }](ctx, github.Get, a.api("/commits?path=specs")) - if err != nil { - return nil, fmt.Errorf("listing the commits that changed appwrite's specs: %w", err) - } - var out []plugin.Version - for _, c := range cs { - if !appwriteCommit.MatchString(c.SHA) || c.Commit.Committer.Date.IsZero() { - continue - } - at := c.Commit.Committer.Date.UTC() - out = append(out, plugin.Version{ID: at.Format(time.DateOnly), Released: at, Ref: c.SHA, URL: c.URL}) - } - slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) - return Daily(out), nil -} - -var ( - _ Lister = GitHub{} - _ Lister = GitLab{} - _ Lister = Elasticsearch{} - _ Lister = Sentry{} - _ Lister = Algolia{} - _ Lister = Appwrite{} -) - -// Daily keeps one version per day of vs (oldest first, IDs dates, as -// versions.GitHubCommits lists them): the day's last commit, so a spec -// committed several times a day has one version per day, each ID once. -func Daily(vs []plugin.Version) []plugin.Version { - var out []plugin.Version - for _, v := range vs { - if n := len(out); n > 0 && out[n-1].ID == v.ID { - out[n-1] = v - continue - } - out = append(out, v) - } - return out -} diff --git a/plugins/openapi/adapter/versions_test.go b/plugins/openapi/adapter/versions_test.go deleted file mode 100644 index 63aa99b..0000000 --- a/plugins/openapi/adapter/versions_test.go +++ /dev/null @@ -1,207 +0,0 @@ -package adapter - -import ( - "context" - "net/http" - "net/http/httptest" - "os" - "slices" - "strings" - "testing" - "time" - - "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/core/versions" -) - -// recorded serves saved API responses (testdata/versions/, recorded -// 2026-11-20 and trimmed: testdata/README.md) by request path and query; -// any other request fails the test. -func recorded(t *testing.T, files map[string]string) *httptest.Server { - t.Helper() - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - key := r.URL.Path - if r.URL.RawQuery != "" { - key += "?" + r.URL.RawQuery - } - file, ok := files[key] - if !ok { - t.Errorf("unexpected request %s", key) - http.NotFound(w, r) - return - } - b, err := os.ReadFile("testdata/versions/" + file) - if err != nil { - t.Error(err) - } - w.Write(b) - })) - t.Cleanup(srv.Close) - return srv -} - -func ids(vs []plugin.Version) string { - var out []string - for _, v := range vs { - out = append(out, v.ID+"@"+v.Ref) - } - return strings.Join(out, " ") -} - -func TestGitHubListsEverySupportedVersion(t *testing.T) { - srv := recorded(t, map[string]string{"/versions": "github-versions.json"}) - old := githubVersionsURL - githubVersionsURL = srv.URL + "/versions" - t.Cleanup(func() { githubVersionsURL = old }) - vs, err := GitHub{}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - if got := ids(vs); got != "2022-11-28@2022-11-28 2026-03-10@2026-03-10" { - t.Errorf("versions %s", got) - } -} - -// Every stable release from v18.10.0-ee (the first with openapi_v3.yaml), in -// version order, release candidates left out; the listing is read a second -// page, and no further once it passes v18.10.0-ee. -func TestGitLabListsEveryReleaseWithTheSpec(t *testing.T) { - srv := recorded(t, map[string]string{ - "/tags?order_by=version&sort=desc&per_page=100&page=1": "gitlab-tags-1.json", - "/tags?order_by=version&sort=desc&per_page=100&page=2": "gitlab-tags-2.json", - }) - vs, err := GitLab{TagsURL: srv.URL + "/tags?order_by=version&sort=desc&per_page=100"}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - if vs[0].ID != "18.10.0" || vs[0].Ref != "v18.10.0-ee" || vs[len(vs)-1].ID != "19.6.1" { - t.Errorf("first %v, last %v", vs[0], vs[len(vs)-1]) - } - seen := map[string]bool{} - for _, v := range vs { - if strings.Contains(v.Ref, "rc") || v.Released.IsZero() || seen[v.ID] { - t.Errorf("version %v", v) - } - seen[v.ID] = true - } - at := func(id string) int { return slices.IndexFunc(vs, func(v plugin.Version) bool { return v.ID == id }) } - if !(at("18.11.14") < at("19.0.0") && at("19.0.0") < at("19.6.0") && at("18.10.1") > at("18.10.0")) { - t.Errorf("not in version order: %s", ids(vs)) - } -} - -// Every released minor from 8.14 (the first with the OpenAPI output) to the -// newest released one, 9.5: not 9.6, the next minor's branch. -func TestElasticsearchListsEveryReleasedMinor(t *testing.T) { - srv := recorded(t, map[string]string{"/releases": "es-releases.json", "/branches": "es-branches.json"}) - a, b := esReleasesURL, esBranchesURL - esReleasesURL, esBranchesURL = srv.URL+"/releases", srv.URL+"/branches" - t.Cleanup(func() { esReleasesURL, esBranchesURL = a, b }) - vs, err := Elasticsearch{}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - want := "8.14.0@8.14 8.15.0@8.15 8.16.0@8.16 8.17.0@8.17 8.18.0@8.18 8.19.0@8.19 9.0.0@9.0 9.1.0@9.1 9.2.0@9.2 9.3.0@9.3 9.4.0@9.4 9.5.0@9.5" - if got := ids(vs); got != want { - t.Errorf("versions\n %s\nwant\n %s", got, want) - } -} - -// The archived schema repo's tags, then getsentry/sentry's api@ releases, -// by date; the IDs are dates, as Fetch's Version. -func TestSentryListsBothRepos(t *testing.T) { - srv := recorded(t, map[string]string{ - "/repos/getsentry/sentry-api-schema/releases?per_page=100&page=1": "sentry-schema-releases.json", - "/repos/getsentry/sentry/releases?per_page=100&page=1": "sentry-api-releases.json", - }) - vs, err := Sentry{APIBase: srv.URL}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - if len(vs) != 21 || vs[0].Ref != "2.3.2" || vs[1].Ref != "2.4.0" || vs[2].Ref != "api@2.5.0" || vs[len(vs)-1].Ref != "api@2.16.0" { - t.Fatalf("versions %s", ids(vs)) - } - for i := 1; i < len(vs); i++ { - if vs[i].Released.Before(vs[i-1].Released) || vs[i].ID != vs[i].Released.Format("2006-01-02") { - t.Errorf("%v after %v", vs[i], vs[i-1]) - } - } -} - -// Every release tag, oldest first; the five tags of 2024-09-18 and -19 are -// ordered by their commits' dates, not their names. -func TestAlgoliaListsEveryReleaseTag(t *testing.T) { - files := map[string]string{"/refs": "algolia-refs.json"} - for _, tag := range []string{"2024-09-18-45edcd844", "2024-09-18-cc190fae3", "2024-09-19-6e91dbf55", "2024-09-19-a62c27d3b", "2024-09-19-e47df6533"} { - files["/commits/released-"+tag] = "algolia-commit-released-" + tag + ".json" - } - srv := recorded(t, files) - a, b := algoliaRefsURL, algoliaCommitURL - algoliaRefsURL, algoliaCommitURL = srv.URL+"/refs", srv.URL+"/commits/%s" - t.Cleanup(func() { algoliaRefsURL, algoliaCommitURL = a, b }) - vs, err := Algolia{Spec: "search"}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - var refs []string - for _, v := range vs { - refs = append(refs, strings.TrimPrefix(v.Ref, "released-")) - } - want := "2023-08-22 2023-08-29 2024-09-18-45edcd844 2024-09-18-cc190fae3 2024-09-19-a62c27d3b 2024-09-19-6e91dbf55 2024-09-19-e47df6533 2026-11-10-8d91e3d8a3 2026-11-17-31c309fe2a" - if got := strings.Join(refs, " "); got != want { - t.Errorf("refs\n %s\nwant\n %s", got, want) - } -} - -// Every day specs/ changed, oldest first, at the day's last commit: the 40 -// commits saved fall on 16 days, and a version ID (the date) is named once. -func TestAppwriteListsEverySpecCommit(t *testing.T) { - srv := recorded(t, map[string]string{"/repos/appwrite/specs/commits?path=specs&per_page=100&page=1": "appwrite-commits.json"}) - vs, err := Appwrite{APIBase: srv.URL}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - if len(vs) != 16 { - t.Fatalf("%d versions, want 16", len(vs)) - } - for i := 1; i < len(vs); i++ { - if !vs[i].Released.After(vs[i-1].Released) || vs[i].ID == vs[i-1].ID || len(vs[i].Ref) != 40 { - t.Errorf("%v after %v", vs[i], vs[i-1]) - } - } -} - -// Daily keeps each day's last commit, in order. -func TestDailyKeepsEachDaysLastCommit(t *testing.T) { - in := []plugin.Version{{ID: "2026-10-27", Ref: "a"}, {ID: "2026-10-28", Ref: "b"}, {ID: "2026-10-28", Ref: "c"}, {ID: "2026-10-30", Ref: "d"}} - var got []string - for _, v := range Daily(in) { - got = append(got, v.ID+" "+v.Ref) - } - if want := "2026-10-27 a,2026-10-28 c,2026-10-30 d"; strings.Join(got, ",") != want { - t.Errorf("got %v, want %s", got, want) - } -} - -// Stripe's versions are its API versions, as each release's notes name -// them: one per version, oldest first, read at the newest release carrying -// it and dated by the first; v2190, whose notes name none, is left out. -func TestStripeListsAPIVersions(t *testing.T) { - srv := recorded(t, map[string]string{"/repos/stripe/openapi/releases?per_page=100&page=1": "stripe-openapi-releases.json"}) - old := versions.GitHubAPI - versions.GitHubAPI = srv.URL - t.Cleanup(func() { versions.GitHubAPI = old }) - vs, err := Stripe{}.Versions(context.Background()) - if err != nil { - t.Fatal(err) - } - want := "2026-02-25.clover@v2203 2026-03-25.dahlia@v2248 2026-04-22.dahlia@v2275 2026-05-27.dahlia@v2323 2026-06-24.dahlia@v2348 " + - "2026-07-29.dahlia@v2441 2026-08-26.dahlia@v2516 2026-09-30.endive@v2592 2026-10-28.endive@v2600 2026-11-18.endive@v2602" - if got := ids(vs); got != want { - t.Fatalf("got %s\nwant %s", got, want) - } - last := vs[len(vs)-1] - if !last.Released.Equal(time.Date(2026, 11, 17, 22, 34, 17, 0, time.UTC)) || last.URL != "https://github.com/stripe/openapi/releases/tag/v2602" { - t.Errorf("newest: released %s (want v2601's date), url %s", last.Released, last.URL) - } -} diff --git a/plugins/openapi/algolia.go b/plugins/openapi/algolia.go deleted file mode 100644 index 9362faa..0000000 --- a/plugins/openapi/algolia.go +++ /dev/null @@ -1,49 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// algoliaDiff reads Algolia's specs like Supabase's: deprecations by the -// `deprecated` flag, quoting the whole operation, and path templates matched. -var algoliaDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// algoliaKeep keeps operation deprecations, and removals of operations -// marked deprecated first, of REST operations only. Algolia's specs also -// describe what only its API clients do, and a change to one of those isn't -// an API change: -// -// - helpers, marked `x-helper: true`: /saveObjects, /waitForTask, -// /replaceAllObjects, … (16 in the Search API on 2026-11-17); -// - the "custom request" methods for any path, operationId customGet, -// customPost, customPut and customDelete on /{path} (before 2024-03-25, -// /1{path}). -// -// In every release from 2023-08-22 to 2026-11-17 this keeps 9 Search API -// deprecations (the multi-cluster /1/clusters endpoints, 2025-04-01) and 9 -// Ingestion API ones (the /1/tasks endpoints, 2025-01-22, and PUT -// /1/tasks/{taskID}/disable, 2024-07-26). None of the 17 removals in that -// history was deprecated first; 13 were the client-only entries above (the -// custom-request methods in all three specs on 2024-03-25, and /saveObjects). -func algoliaKeep(c diff.Change) bool { - // c.Node is the operation only because algoliaDiff sets - // QuoteDeprecatedOperation (a removal carries the old operation anyway); - // TestAlgoliaClientOnlyFilterThroughTheDiffer pins that. - op, _ := c.Node.(map[string]any) - if clientOnly(op) { - return false - } - return deprecationsOnly(algoliaDiff)(c) -} - -// clientOnly is an Algolia spec entry for an API-client method, not a REST -// operation. -func clientOnly(op map[string]any) bool { - if helper, _ := op["x-helper"].(bool); helper { - return true - } - id, _ := op["operationId"].(string) - switch id { - case "customGet", "customPost", "customPut", "customDelete": - return true - } - return false -} diff --git a/plugins/openapi/appwrite.go b/plugins/openapi/appwrite.go deleted file mode 100644 index 7055d9f..0000000 --- a/plugins/openapi/appwrite.go +++ /dev/null @@ -1,74 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// appwriteDiff is how Appwrite's spec says what it says: -// -// - A deprecation is the `deprecated` flag plus x-appwrite.deprecated, -// {"since": "1.8.0", "replaceWith": "tablesDB.createTransaction"}: the -// only place the spec says what to use instead (the description doesn't). -// x-appwrite sorts last in the operation, after parameters and -// responses, so quoting the whole operation can lose it to the -// 2,000-character cut: the event quotes x-appwrite.deprecated itself. -// The flag without it is quoted as the flag (never seen so far). -// - The flag also marks an operation one of whose SDK method names was -// renamed: POST /account/mfa/challenges is flagged with "replaceWith": -// "account.createMFAChallenge", which is the same operation's other -// name in x-appwrite.methods (createMfaChallenge became -// createMFAChallenge). The route isn't deprecated, so that flag isn't -// read as a deprecation: see appwriteMethodLevel. -// - Path parameters are matched by place, as for the other specs. -var appwriteDiff = diff.Options{ - PathTemplates: true, - QuoteDeprecated: "/x-appwrite/deprecated", - FlagNotDeprecation: appwriteMethodLevel, -} - -// appwriteMethodLevel reports whether an operation's `deprecated` flag is -// about its SDK methods, not its route: -// -// - x-appwrite.deprecated.replaceWith names a method of the same -// operation's x-appwrite.methods ("."): a rename; -// - or a method in x-appwrite.methods isn't itself deprecated: the -// operation still has a live SDK method, so the route stays. -// -// An operation with no methods listed (the 14 of the golden test have -// "methods": []) is read by its flag. In 2.7.x's server operations the two -// rules pick the same 23 of the 99 flagged, all flagged since 1.8.0 -// (1.8.x's server document at ac705cd3 has the same 23); each has a live -// method named by replaceWith. -func appwriteMethodLevel(op map[string]any) bool { - xa, _ := op["x-appwrite"].(map[string]any) - dep, _ := xa["deprecated"].(map[string]any) - replaceWith, _ := dep["replaceWith"].(string) - methods, _ := xa["methods"].([]any) - for _, m := range methods { - method, _ := m.(map[string]any) - namespace, _ := method["namespace"].(string) - name, _ := method["name"].(string) - if replaceWith != "" && name != "" && namespace+"."+name == replaceWith { - return true - } - if d, ok := method["deprecated"]; !ok || d == nil || d == false { - return true - } - } - return false -} - -// appwriteKeep keeps operation deprecations only: not even a deprecated -// operation's removal. Read as Fetch reads it (the newest minor's server -// operations at each of the 139 commits on appwrite/specs' main, 2026-02-17 -// to 2026-11-17), the spec's history has 14 deprecations, all on -// 2026-06-24 (see the golden test), and 78 operations leaving it (from -// the spec, or from the server platform). Only one was marked deprecated -// first, and that one was a path move: PATCH -// /databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship -// became .../attributes/relationship/{key} on 2026-03-20. Of the others, 13 -// are back now: 2.4.x's single document took the server platform off them -// on 2026-10-12 as not yet in a released SDK, and 2.5.x had them on it again -// the next day. Nothing in the spec says when an operation stops answering, -// so a removal isn't an event. -// -// Property changes and new operations are dropped too, as for vercel. -func appwriteKeep(c diff.Change) bool { return c.Kind == diff.OperationDeprecated } diff --git a/plugins/openapi/cloudflare.go b/plugins/openapi/cloudflare.go deleted file mode 100644 index 1a1a364..0000000 --- a/plugins/openapi/cloudflare.go +++ /dev/null @@ -1,39 +0,0 @@ -package openapi - -import ( - "regexp" - - "github.com/patch-it-dev/patch-it-plugins/core/diff" -) - -// cloudflareDiff is how Cloudflare's spec says what it says: -// -// - Most deprecations use the `deprecated` flag (329 operations in the spec -// of 2026-11-20), and a few only the summary, written as Vercel's are: "List -// datasets (deprecated)", "Deprecated: Retrieve legacy embed code HTML" -// (11 of them). Other summaries and descriptions that say "deprecated" -// are about a parameter or a model, not the operation, so the -// description isn't read. -// - Path parameters are renamed without the URL changing: -// /zones/{zone_identifier}/analytics/dashboard became -// /zones/{zone_id}/analytics/dashboard on 2026-10-30. Matching by path -// template keeps that from reading as a removal. -var cloudflareDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true, DeprecatedSummary: cloudflareDeprecatedSummary} - -// cloudflareDeprecatedWords: a summary that starts "Deprecated:" or ends -// "(deprecated)". Not "deprecat" anywhere ("Omitting `datasetId` is -// deprecated" is about a parameter). -var cloudflareDeprecatedWords = regexp.MustCompile(`(?i)^deprecated:|\(deprecated\)\s*$`) - -func cloudflareDeprecatedSummary(summary string) bool { - return cloudflareDeprecatedWords.MatchString(summary) -} - -// cloudflareKeep keeps operation deprecations, and removals of operations the -// old spec had marked deprecated. Everything else is dropped: a bot commits -// the 30 MB spec several times a day, and an operation can leave it without -// leaving the API or without notice (between 2026-10-29 and 2026-10-30 POST -// /accounts/move and four GET /tenants/{tenant_id} operations left it, never -// marked deprecated: the drop test), while property changes in the -// generated schemas are mostly the generator's. -var cloudflareKeep = deprecationsOnly(cloudflareDiff) diff --git a/plugins/openapi/convex.go b/plugins/openapi/convex.go deleted file mode 100644 index 3a52769..0000000 --- a/plugins/openapi/convex.go +++ /dev/null @@ -1,29 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// convexDiff is how the Convex Deployment API spec says what it says: -// -// - Deprecations use the `deprecated` flag, and the description says what -// to use instead ("Deprecated: use `GET /integrations` instead."), so the -// event quotes the whole operation, not the bare `true`. Convex's docs -// build drops flagged operations, "since they stay served only for -// existing callers" (npm-packages/docs/scripts/prepare-openapi-specs.js). -// - PathTemplates, as for every spec here: a renamed path parameter isn't a -// change for callers. None has been renamed in this spec yet. -var convexDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// convexKeep keeps operation deprecations, and removals of operations the old -// spec had marked deprecated. In the spec's history (68 commits, 2025-08-19 -// to 2026-11-16) that's 6 events, all on 2026-11-05: the six log stream -// operations, deprecated for the /integrations ones added on 2026-10-30. -// No operation has left the spec. Everything else is dropped: -// -// - Request and response property changes: 18 property removals, 16 type -// changes, 10 schema removals and 3 properties no longer required over -// the history, most of them in the -// data sync, usage-limit and S3 export APIs. On 2026-07-14 the optional -// `name` left the usage-limit request and response, while the server -// didn't refuse a request that still sent it: see the drop test. -// - New operations: nobody has to fix code for a new endpoint. -var convexKeep = deprecationsOnly(convexDiff) diff --git a/plugins/openapi/elasticsearch.go b/plugins/openapi/elasticsearch.go deleted file mode 100644 index c8c9090..0000000 --- a/plugins/openapi/elasticsearch.go +++ /dev/null @@ -1,24 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// elasticsearchDiff reads Elastic's spec like Supabase's: deprecations by the -// `deprecated` flag, quoting the whole operation, and path templates matched. -var elasticsearchDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// elasticsearchKeep keeps operation deprecations, and removals of operations -// marked deprecated first. Over the minor versions with an OpenAPI output -// (8.14 to 9.6, compared in version order) that's 23 deprecations and 3 -// removals, all in 9.0: GET and POST /{index}/_knn_search, and POST -// /{index}/_unfreeze ("Remove unfreeze REST endpoint", Elastic's 9.0.0 -// breaking changes). The 31 other removals weren't deprecated first and -// mostly weren't removals from Elasticsearch: -// -// - APIs a later minor of the older major had and the newer major's -// branch, cut earlier, didn't yet: 8.19 to 9.0 drops -// /_data_stream/{name}/_options, which is back in 9.1; -// - APIs Elastic documents as not for direct use ("designed for indirect -// use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic -// Cloud on Kubernetes. Direct use is not supported."), left out of the -// spec from 9.2: /_autoscaling, /_nodes/{node_id}/shutdown. -var elasticsearchKeep = deprecationsOnly(elasticsearchDiff) diff --git a/plugins/openapi/mongodb.go b/plugins/openapi/mongodb.go deleted file mode 100644 index 70e1657..0000000 --- a/plugins/openapi/mongodb.go +++ /dev/null @@ -1,24 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// atlasDiff is how the Atlas Administration API's spec says what it says: -// -// - Deprecations use the `deprecated` flag (53 operations on 2026-11-19). -// Fourteen operations mention "deprecated" in their description without -// it, each about the deprecated invitation flow ("This resource cannot -// be used to view details about users invited via the deprecated -// Invite One MongoDB Cloud User to Join One Project endpoint"), not the -// operation itself, so the description isn't read. -// - Matching by path template keeps a renamed path parameter from reading -// as a removal. -var atlasDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// atlasKeep keeps operation deprecations, and removals of operations the old -// spec had marked deprecated (the tenant backup operations, deprecated and -// then gone between 2025-10 and 2026-11). Everything else is dropped: -// operations that leave the spec unmarked (GET /rest/unauth/version on -// 2024-08-07: the drop test), and schema and property changes, which the -// API's own changelog (mongodb/atlas-admin-api, kind changelog) reports per -// resource version. -var atlasKeep = deprecationsOnly(atlasDiff) diff --git a/plugins/openapi/neon.go b/plugins/openapi/neon.go deleted file mode 100644 index 3facc5b..0000000 --- a/plugins/openapi/neon.go +++ /dev/null @@ -1,33 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// neonDiff is how the Neon API spec says what it says: -// -// - Deprecations use the `deprecated` flag, and only the flag: in the 23 -// commits of neondatabase/neon-pkgs's copy (2026-06-24 to 2026-11-17) no -// operation is described as deprecated without it. (Two unflagged -// operations deprecate a parameter in words; those aren't operation -// deprecations.) -// A flagged operation's description says why or when ("Deprecated: to -// test a branch's already-saved configuration, use -// `sendNeonAuthEmailProviderTest`", "Removal scheduled for March 1, -// 2026"), and every one carries an `x-sunset` date, so the event quotes -// the whole operation, not the bare `true`. -// - Path parameters could be renamed without the URL changing; none was in -// this history, but matching by path template costs nothing here and -// keeps a rename from reading as a removal. -var neonDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// neonKeep keeps operation deprecations, and removals of operations the old -// spec had marked deprecated. In the spec's history that's 1 event: POST -// /projects/{project_id}/branches/{branch_id}/auth/send_test_email, -// deprecated on 2026-08-23. Everything else is dropped: -// -// - One operation left the spec, not deprecated first: POST -// /projects/{project_id}/branches/{branch_id}/recover on 2026-08-09. -// neon-pkgs's own PR for it (#408) says it "was not removed from the API. -// It was removed from the published spec": it still routes. -// - Request and response property changes, new operations: not changes a -// caller has to fix, or not ones the spec's history shows reliably. -var neonKeep = deprecationsOnly(neonDiff) diff --git a/plugins/openapi/openai.go b/plugins/openapi/openai.go deleted file mode 100644 index 6ece003..0000000 --- a/plugins/openapi/openai.go +++ /dev/null @@ -1,24 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// openaiDiff is how OpenAI's spec says what it says: -// -// - Deprecations use the `deprecated` flag: in the spec of 2026-11-21, 17 -// operations carry it and none is called deprecated only in its summary -// or description (one description mentions deprecated models, not the -// operation). A flagged operation's description says why and when ("The -// endpoint and model are deprecated and scheduled to shut down on -// February 26, 2027"), so the event quotes the whole operation. -// - Path parameters could be renamed without the URL changing; matching by -// path template keeps a rename from reading as a removal. -var openaiDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// openaiKeep keeps operation deprecations, and removals of operations the old -// spec had marked deprecated. Everything else is dropped: the spec is -// committed several times a day, and most of what changes is the spec's own -// shape, not the API (enum lists rewritten as const, schemas regenerated), -// or work in progress pulled the day after it was added (the session -// spending-limit schemas, added on 2026-11-17 and gone on 2026-11-18: the -// drop test). New operations aren't something to fix either. -var openaiKeep = deprecationsOnly(openaiDiff) diff --git a/plugins/openapi/openapi.go b/plugins/openapi/openapi.go deleted file mode 100644 index eed033a..0000000 --- a/plugins/openapi/openapi.go +++ /dev/null @@ -1,376 +0,0 @@ -// Package openapi is the kind for an API that publishes an OpenAPI spec per -// release (a tag, a release, or the commits that changed the spec): every -// release is listed, each consecutive pair diffed (ListVersions, ReadAt, -// Extract), the changes normalized into events, and migration hints -// attached from the API's changelog when it has one. -package openapi - -import ( - "context" - "fmt" - "log" - - "github.com/patch-it-dev/patch-it-plugins/core/diff" - "github.com/patch-it-dev/patch-it-plugins/core/event" - "github.com/patch-it-dev/patch-it-plugins/core/hint" - "github.com/patch-it-dev/patch-it-plugins/core/normalize" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" -) - -func init() { - plugin.RegisterProvider(plugin.Provider{ - ID: "stripe", Name: "Stripe", Category: plugin.CategoryPayments, Homepage: "https://stripe.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/stripe.md", - Watches: "REST API changes between OpenAPI spec releases (removed and renamed endpoints, parameters and fields), with migration hints from Stripe's API changelog", - URLs: []string{"https://github.com/stripe/openapi"}, - Packages: []string{"pypi:stripe", "npm:stripe"}, - Plugin: Plugin{Adapter: adapter.Stripe{}, Hints: hint.Stripe{}}, - }}, - }) - // No Hints yet: Datadog's changelog isn't Stripe's per-parameter table - // shape, so there's no hint.Source for it to read. - plugin.RegisterProvider(plugin.Provider{ - ID: "datadog", Name: "Datadog", Category: plugin.CategoryMonitoring, Homepage: "https://www.datadoghq.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/datadog.md", - Watches: "API v2 changes between OpenAPI spec releases", - URLs: []string{"https://github.com/DataDog/datadog-api-client-python"}, - Packages: []string{"pypi:datadog-api-client", "npm:@datadog/datadog-api-client"}, - Plugin: Plugin{Adapter: adapter.Datadog{}}, - }}, - }) - // No Hints: GitLab's deprecations are prose per feature, not a changelog - // keyed by API version, so there's nothing for hint.Source to look up. - plugin.RegisterProvider(plugin.Provider{ - ID: "gitlab", Name: "GitLab", Category: plugin.CategoryDevTools, Homepage: "https://about.gitlab.com", - Sources: []plugin.Source{{ - ID: "rest-api", Layer: plugin.LayerAPI, Page: "providers/gitlab.md", - Watches: "REST API changes between releases, request side only (what callers send)", - URLs: []string{"https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc/api/openapi"}, - Plugin: Plugin{Adapter: adapter.GitLab{}, Keep: requestSide}, - }}, - }) - // No Hints yet: GitHub's per-version CHANGELOG.md is prose with no table - // at all, so there's nothing for hint.Source to key on. (GitHub's Actions - // source is registered by plugins/notices.) - plugin.RegisterProvider(plugin.Provider{ - ID: "github", Name: "GitHub", Category: plugin.CategoryDevTools, Homepage: "https://github.com", - Sources: []plugin.Source{{ - ID: "rest-api", Layer: plugin.LayerAPI, Page: "providers/github.md", - Watches: "REST API changes between dated API versions", - URLs: []string{"https://github.com/github/rest-api-description"}, - Plugin: Plugin{Adapter: adapter.GitHub{}}, - }}, - }) - // No Hints: Vercel's changelog is product news, not keyed by API change. - // Only operation deprecations and removals are kept: see vercelKeep. - plugin.RegisterProvider(plugin.Provider{ - ID: "vercel", Name: "Vercel", Category: plugin.CategoryHosting, Homepage: "https://vercel.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/vercel.md", - Watches: "REST API operations deprecated, and deprecated operations removed, between SDK releases of the spec", - URLs: []string{"https://github.com/vercel/sdk"}, - Packages: []string{"npm:@vercel/sdk"}, - Plugin: Plugin{Adapter: adapter.Vercel{}, Diff: vercelDiff, Keep: vercelKeep}, - }}, - }) - // No Hints: Supabase's changelog is platform news, not keyed by - // operation. Only operation deprecations and removals: see supabase.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "supabase", Name: "Supabase", Category: plugin.CategoryDatabases, Homepage: "https://supabase.com", - Sources: []plugin.Source{{ - ID: "management-api", Layer: plugin.LayerAPI, Page: "providers/supabase.md", - Watches: "Management API operations deprecated, and deprecated operations removed, between commits of the spec", - URLs: []string{"https://github.com/supabase/supabase"}, - Plugin: Plugin{Adapter: adapter.Supabase{}, Diff: supabaseDiff, Keep: supabaseKeep}, - }}, - }) - // No Hints: Algolia's changelog is a hosted product feed, not keyed by - // operation. One source per API spec: see algolia.go. - algolia := plugin.Provider{ID: "algolia", Name: "Algolia", Category: plugin.CategorySearch, Homepage: "https://www.algolia.com"} - for _, spec := range []struct{ name, title string }{{"search", "Search"}, {"ingestion", "Ingestion"}, {"recommend", "Recommend"}} { - algolia.Sources = append(algolia.Sources, plugin.Source{ - ID: spec.name + "-api", Layer: plugin.LayerAPI, Page: "providers/algolia.md", - Watches: spec.title + " API operations deprecated, and deprecated operations removed, between releases of the spec", - URLs: []string{"https://github.com/algolia/api-clients-automation", "https://github.com/algolia/api-clients-automation/blob/main/specs/bundled/" + spec.name + ".yml"}, - Packages: []string{"pypi:algoliasearch", "npm:algoliasearch"}, - Plugin: Plugin{Adapter: adapter.Algolia{Spec: spec.name}, Diff: algoliaDiff, Keep: algoliaKeep}, - }) - } - plugin.RegisterProvider(algolia) - // No Hints: Elastic's breaking-changes page is prose per area, not keyed - // by operation. See elasticsearch.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "elastic", Name: "Elastic", Category: plugin.CategorySearch, Homepage: "https://www.elastic.co", - Sources: []plugin.Source{{ - ID: "elasticsearch-api", Layer: plugin.LayerAPI, Page: "providers/elasticsearch.md", - Watches: "Elasticsearch REST API operations deprecated, and deprecated operations removed, between released minor versions of the spec", - URLs: []string{"https://github.com/elastic/elasticsearch-specification"}, - Packages: []string{"pypi:elasticsearch", "npm:@elastic/elasticsearch"}, - Plugin: Plugin{Adapter: adapter.Elasticsearch{}, Diff: elasticsearchDiff, Keep: elasticsearchKeep, RemovalsNeedANewVersion: true}, - }}, - }) - // No Hints: Sentry's changelog is product news, not keyed by operation. - // Operation deprecations only, most said in the description: see - // sentry.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "sentry", Name: "Sentry", Category: plugin.CategoryMonitoring, Homepage: "https://sentry.io", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/sentry.md", - Watches: "REST API operations deprecated between releases of the spec, most of them in the operation's description", - URLs: []string{"https://github.com/getsentry/sentry/releases"}, - Plugin: Plugin{Adapter: adapter.Sentry{}, Diff: sentryDiff, Keep: sentryKeep}, - }}, - }) - // No Hints: Neon's changelog is a weekly digest, not keyed by operation. - // Only operation deprecations and removals: see neon.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "neon", Name: "Neon", Category: plugin.CategoryDatabases, Homepage: "https://neon.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/neon.md", - Watches: "Neon API operations deprecated, and deprecated operations removed, between commits of the spec", - URLs: []string{"https://github.com/neondatabase/neon-pkgs"}, - Packages: []string{"npm:@neondatabase/api-client"}, - Plugin: Plugin{Adapter: adapter.Neon{}, Diff: neonDiff, Keep: neonKeep}, - }}, - }) - // No Hints: Convex has no API changelog; its news feed is product news. - // Only operation deprecations and removals: see convex.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "convex", Name: "Convex", Category: plugin.CategoryDatabases, Homepage: "https://www.convex.dev", - Sources: []plugin.Source{{ - ID: "deployment-api", Layer: plugin.LayerAPI, Page: "providers/convex.md", - Watches: "Deployment API operations deprecated, and deprecated operations removed, between commits of the spec", - URLs: []string{"https://github.com/convex/convex-backend"}, - Plugin: Plugin{Adapter: adapter.Convex{}, Diff: convexDiff, Keep: convexKeep}, - }}, - }) - // No Hints: PlanetScale's changelog is product news, not keyed by - // operation. Operation deprecations only, said in the description: see - // planetscale.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "planetscale", Name: "PlanetScale", Category: plugin.CategoryDatabases, Homepage: "https://planetscale.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/planetscale.md", - Watches: "API operations deprecated, and deprecated operations removed, between commits of the spec, said in the operation's description", - URLs: []string{"https://github.com/planetscale/terraform-provider-planetscale"}, - Plugin: Plugin{Adapter: adapter.PlanetScale{}, Diff: planetscaleDiff, Keep: planetscaleKeep}, - }}, - }) - // No Hints: Appwrite's changelog is product news, not keyed by operation. - // Operation deprecations only, SDK method renames left out: see - // appwrite.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "appwrite", Name: "Appwrite", Category: plugin.CategoryHosting, Homepage: "https://appwrite.io", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/appwrite.md", - Watches: "REST API operations a server SDK calls that are deprecated between commits of the spec, SDK method renames left out", - URLs: []string{"https://github.com/appwrite/specs"}, - Packages: []string{"pypi:appwrite", "npm:node-appwrite"}, - Plugin: Plugin{Adapter: adapter.Appwrite{}, Diff: appwriteDiff, Keep: appwriteKeep}, - }}, - }) - // No Hints: Flagsmith's release notes are product news, not keyed by - // operation. requestSide, same reason as GitLab's: a named request-body - // schema shared by several operations (FeatureValue, SegmentOverride) - // reads as its own removal, side "response" by the differ's default, - // whether or not any operation that used it is actually gone. - plugin.RegisterProvider(plugin.Provider{ - ID: "flagsmith", Name: "Flagsmith", Category: plugin.CategoryDevTools, Homepage: "https://www.flagsmith.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/flagsmith.md", - Watches: "REST API changes between releases of Flagsmith's own OpenAPI spec (removed endpoints and request parameters)", - URLs: []string{"https://github.com/Flagsmith/flagsmith/blob/main/openapi.yaml"}, - Plugin: Plugin{Adapter: adapter.Flagsmith{}, Keep: requestSide}, - }}, - }) - // No Hints: OpenAI's changelog is product news, not keyed by operation. - // Only operation deprecations and removals: see openai.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "openai", Name: "OpenAI", Category: plugin.CategoryAI, Homepage: "https://openai.com", - Sources: []plugin.Source{{ - ID: "api", Layer: plugin.LayerAPI, Page: "providers/openai-api.md", - Watches: "REST API operations deprecated, and deprecated operations removed, day by day in the spec OpenAI's SDKs are generated from", - URLs: []string{"https://github.com/openai/openai-openapi/blob/main/openapi.yaml"}, - Packages: []string{"pypi:openai", "npm:openai"}, - Plugin: Plugin{Adapter: adapter.OpenAI{}, Diff: openaiDiff, Keep: openaiKeep}, - }}, - }) - // No Hints: Cloudflare's changelog is product news, not keyed by - // operation. Only operation deprecations and removals: see cloudflare.go. - // (cloudflare/api is the deprecations feed, registered by plugins/notices.) - plugin.RegisterProvider(plugin.Provider{ - ID: "cloudflare", Name: "Cloudflare", Category: plugin.CategoryInfrastructure, Homepage: "https://www.cloudflare.com", - Sources: []plugin.Source{{ - ID: "api-spec", Layer: plugin.LayerAPI, Page: "providers/cloudflare-api-spec.md", - Watches: "API operations deprecated, and deprecated operations removed, day by day in the spec Cloudflare's SDKs and Terraform provider are generated from", - URLs: []string{"https://github.com/cloudflare/api-schemas/blob/main/openapi.json"}, - Packages: []string{"pypi:cloudflare", "npm:cloudflare"}, - Plugin: Plugin{Adapter: adapter.Cloudflare{}, Diff: cloudflareDiff, Keep: cloudflareKeep}, - }}, - }) - // No Hints: the Atlas changelog is its own source (mongodb/atlas-admin-api, - // kind changelog). Only operation deprecations and removals: see - // mongodb.go. - plugin.RegisterProvider(plugin.Provider{ - ID: "mongodb", Name: "MongoDB", Category: plugin.CategoryDatabases, Homepage: "https://www.mongodb.com", - Sources: []plugin.Source{{ - ID: "atlas-admin-spec", Layer: plugin.LayerAPI, Page: "providers/mongodb-atlas-admin-spec.md", - Watches: "Atlas Administration API v2 operations deprecated, and deprecated operations removed, day by day in MongoDB's published spec", - URLs: []string{"https://github.com/mongodb/openapi/blob/main/openapi/v2.json"}, - Plugin: Plugin{Adapter: adapter.MongoDBAtlas{}, Diff: atlasDiff, Keep: atlasKeep}, - }}, - }) -} - -// requestSide keeps the changes to what callers send. GitLab's response -// schemas are generated from entity docs it is still backfilling: between -// v18.11.0-ee and v19.0.0-ee, 280 response properties went from the generator's -// default "string" to their real type and 74 schemas were folded into others, -// while the API returned the same JSON. That reads as ~360 breaking changes -// nobody would hit, so response-side changes are dropped, not guessed at. -func requestSide(c diff.Change) bool { return c.Side == event.SideRequest } - -// Plugin runs one API's spec adapter. -type Plugin struct { - Adapter adapter.Adapter - // Hints fills migration_hint from the API's own changelog. Optional: nil, - // or a changelog that can't be reached, leaves the normalizer's hints. - Hints hint.Source - // Keep, when set, drops the changes it returns false for, before they - // become events: for a spec whose structure changes more often than its - // API does. Nil keeps every change. - Keep func(diff.Change) bool - // Diff adapts the differ to the spec's conventions. The zero value is - // right for Stripe's. - Diff diff.Options - // RemovalsNeedANewVersion drops operation removals between two specs of - // the same version: for an API whose spec is fixed up on a release - // branch after the release, where a removal there is a correction to the - // spec, not a release removing an API (Elasticsearch removes APIs in a - // new minor or major, never in a patch). - RemovalsNeedANewVersion bool -} - -func (p Plugin) Name() string { return p.Adapter.API() } - -// ListVersions is every release of the spec, oldest first, when the adapter -// can list them (adapter.Lister); otherwise only the newest (LatestTag). -func (p Plugin) ListVersions(ctx context.Context, _ plugin.Env) ([]plugin.Version, error) { - if l, ok := p.Adapter.(adapter.Lister); ok { - return l.Versions(ctx) - } - tag, err := p.Adapter.LatestTag(ctx) - if err != nil { - return nil, fmt.Errorf("finding latest tag: %w", err) - } - return []plugin.Version{{ID: tag, Ref: tag}}, nil -} - -// ReadAt fetches the spec at v.Ref. The snapshot's version ID is the version -// the spec itself declares (what events carry), which may differ from the tag; -// for an adapter that lists the specs' own versions (SpecVersioned) it must -// be v's. -func (p Plugin) ReadAt(ctx context.Context, _ plugin.Env, v plugin.Version) (plugin.Snapshot, error) { - s, err := p.Adapter.Fetch(ctx, v.Ref) - if err != nil { - return plugin.Snapshot{}, fmt.Errorf("fetching %s %s: %w", p.Adapter.API(), v.Ref, err) - } - if _, ok := p.Adapter.(adapter.SpecVersioned); ok && s.Version != v.ID { - return plugin.Snapshot{}, fmt.Errorf("%s %s: the spec at %s declares %s: not published there yet", p.Adapter.API(), v.ID, v.Ref, s.Version) - } - v.ID = s.Version - return plugin.Snapshot{Version: v, Content: s.Content, SourceURL: s.SourceURL}, nil -} - -// Extract diffs two snapshots of the spec into events, with to's version and -// from's as previous_version. A zero from is an empty spec before the first. -func (p Plugin) Extract(ctx context.Context, env plugin.Env, from, to plugin.Snapshot) (plugin.Result, error) { - var oldParsed *diff.Spec - if !from.IsZero() { - var err error - if oldParsed, err = diff.Parse(from.Content); err != nil { - return plugin.Result{}, fmt.Errorf("parsing the %s spec at %s: %w", p.Adapter.API(), from.Version.ID, err) - } - } - newParsed, err := diff.Parse(to.Content) - if err != nil { - return plugin.Result{}, fmt.Errorf("parsing the %s spec at %s: %w", p.Adapter.API(), to.Version.ID, err) - } - events, errs := p.events(oldParsed, newParsed, from.Content, to.Content, normalize.Source{ - API: p.Adapter.API(), - Version: to.Version.ID, - PreviousVersion: from.Version.ID, - NewSpecURL: to.SourceURL, - OldSpecURL: from.SourceURL, - DetectedAt: env.Now().UTC(), - }) - p.attachHints(ctx, to.Version.ID, events) - return plugin.Result{Events: events, Rejected: errs}, nil -} - -var _ plugin.Versioned = Plugin{} - -// events diffs two parsed specs into events, applying Keep, and pointing each -// event's source_pointer into the published file when the adapter reshaped it. -func (p Plugin) events(oldParsed, newParsed *diff.Spec, oldContent, newContent []byte, src normalize.Source) ([]event.Event, []error) { - changes := diff.ChangesWith(oldParsed, newParsed, p.Diff) - if p.Keep != nil { - kept := changes[:0:0] - for _, c := range changes { - if p.Keep(c) { - kept = append(kept, c) - } - } - if dropped := len(changes) - len(kept); dropped > 0 { - log.Printf("%s %s: %d of %d changes dropped by the source's filter", src.API, src.Version, dropped, len(changes)) - } - changes = kept - } - if p.RemovalsNeedANewVersion && src.Version == src.PreviousVersion { - kept := changes[:0:0] - for _, c := range changes { - if c.Kind != diff.OperationRemoved { - kept = append(kept, c) - } - } - if dropped := len(changes) - len(kept); dropped > 0 { - log.Printf("%s %s: %d removals dropped: same version as the last spec", src.API, src.Version, dropped) - } - changes = kept - } - events, errs := normalize.Events(changes, src) - rp, ok := p.Adapter.(adapter.Reshaper) - if !ok || len(events) == 0 { - return events, errs - } - oldPtr, newPtr := rp.SourcePointer(oldContent), rp.SourcePointer(newContent) - for i := range events { - e := &events[i] - // normalize cites the old spec only for evidence that lives there. - if e.SourceURL == src.OldSpecURL && e.SourceURL != src.NewSpecURL { - e.SourcePointer = oldPtr(e.SourcePointer) - } else { - e.SourcePointer = newPtr(e.SourcePointer) - } - } - return events, errs -} - -// attachHints looks the events up in the API's changelog for their version. -// Never fails the run: a hint is help for the fix, not provenance for the event. -func (p Plugin) attachHints(ctx context.Context, version string, events []event.Event) { - if p.Hints == nil || len(events) == 0 { - return - } - api := p.Adapter.API() - ix, err := p.Hints.Index(ctx, version) - if err != nil { - log.Printf("%s %s: migration hints unavailable: %v", api, version, err) - return - } - n := ix.Attach(events) - log.Printf("%s %s: migration hints on %d of %d events, from %d changelog entries", api, version, n, len(events), len(ix.Entries)) -} diff --git a/plugins/openapi/planetscale.go b/plugins/openapi/planetscale.go deleted file mode 100644 index 7531942..0000000 --- a/plugins/openapi/planetscale.go +++ /dev/null @@ -1,49 +0,0 @@ -package openapi - -import ( - "regexp" - - "github.com/patch-it-dev/patch-it-plugins/core/diff" -) - -// planetscaleDiff is how the PlanetScale API spec says what it says: -// -// - Deprecations are only in the description's first words, "Deprecated. -// Use GET /organizations/:organization/databases/:database/branches/:branch/change-requests -// instead.": the spec has never set the `deprecated` flag (none in any -// of the 32 versions of schemas/openapi.yaml in -// planetscale/terraform-provider-planetscale, 2025-11-11 to 2026-11-09, -// nor in the live https://planetscale.com/docs/openapi.yaml on -// 2026-11-19). If it ever does, the operation is quoted whole, so the -// words come with it. -// - Path parameters get renamed, and that isn't a change for callers. -var planetscaleDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true, DeprecatedDescription: planetscaleDeprecatedDescription} - -// planetscaleDeprecatedWords is the way every deprecation in the history is -// written: the description starts "Deprecated." (the others start with what -// the operation does, or with an empty line, then "### Authorization"). Only -// at the start, -// so not a description that mentions deprecation further on; and with the -// period or a colon, so not "Deprecated, storage shrinking is part of -// storage autoscaling.", which the spec writes on properties. -var planetscaleDeprecatedWords = regexp.MustCompile(`(?i)^\s*deprecated[.:]`) - -func planetscaleDeprecatedDescription(description string) bool { - return planetscaleDeprecatedWords.MatchString(description) -} - -// planetscaleKeep keeps operation deprecations, and removals of operations -// the old spec had marked deprecated. Over the 31 consecutive pairs of the -// spec's history that's 5 events, all on 2026-11-09 (fc13e09d): GET and -// DELETE .../bouncers/{bouncer}/resizes, GET .../neki-changes, GET and -// DELETE .../neki-changes/{id}. Everything else is dropped: -// -// - 41 operations left the spec, none deprecated first. 6 of them, on -// 2026-10-03, were the read-only replica operations renamed to -// dedicated read replicas, and planetscale/planetscale-go still sends -// the old paths ("the deprecated read-only-replicas path", main on -// 2026-11-19): left the spec isn't stopped working. -// - Property changes and new operations, as for vercel: 226 type changes -// on 2025-12-06 alone, when the spec switched whole numbers to -// `integer`. -var planetscaleKeep = deprecationsOnly(planetscaleDiff) diff --git a/plugins/openapi/registered_test.go b/plugins/openapi/registered_test.go deleted file mode 100644 index f4f07f5..0000000 --- a/plugins/openapi/registered_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package openapi - -import ( - "testing" - - "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" -) - -func TestRegistersItself(t *testing.T) { - for _, a := range []adapter.Adapter{adapter.Stripe{}, adapter.Datadog{}, adapter.GitLab{}, adapter.GitHub{}, adapter.Vercel{}, adapter.Supabase{}, adapter.Algolia{Spec: "search"}, adapter.Algolia{Spec: "ingestion"}, adapter.Algolia{Spec: "recommend"}, adapter.Elasticsearch{}, adapter.Sentry{}, adapter.Neon{}, adapter.Convex{}, adapter.PlanetScale{}, adapter.Appwrite{}, adapter.OpenAI{}, adapter.Cloudflare{}, adapter.MongoDBAtlas{}} { - kittest.Registered(t, Plugin{Adapter: a}) - } -} diff --git a/plugins/openapi/sentry.go b/plugins/openapi/sentry.go deleted file mode 100644 index dc0fa5a..0000000 --- a/plugins/openapi/sentry.go +++ /dev/null @@ -1,62 +0,0 @@ -package openapi - -import ( - "regexp" - - "github.com/patch-it-dev/patch-it-plugins/core/diff" -) - -// sentryDiff is how Sentry's spec says what it says: -// -// - Deprecations are mostly in the operation's description, not the flag. -// Over the spec's history (the 1,130 commits that changed it in -// getsentry/sentry-api-schema, 2020-08-25 to 2026-11-14, then the 19 -// api@ releases to api@2.16.0) the flag deprecates 3 operations and the -// description 13, those 3 included, never later than the flag: the 10 -// issue and metric alert-rule operations on 2026-01-22, never flagged; -// POST .../user-feedback/ on 2024-07-31 and GET .../issues/ on -// 2025-07-25, both flagged on 2026-06-16; GET .../stats/, words and flag -// together on 2022-03-01. -// - The flag, when it's set, comes with the reason in the description, so -// a flagged operation is quoted whole. -// - Path parameters get renamed ({organization_slug} became -// {organization_id_or_slug} on 2024-05-10), and that isn't a change for -// callers. -var sentryDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true, DeprecatedDescription: sentryDeprecatedDescription} - -// sentryDeprecatedWords are the three ways the descriptions say it, over the -// whole history: a "## Deprecated" heading with nothing else on its line, a -// line starting "**Deprecated**:", and "This endpoint is deprecated" in any -// case ("*This endpoint is DEPRECATED."). Also "**Deprecated:**", the colon -// inside the bold: never used for a deprecation yet, but how Sentry writes -// its other notes ("**Experimental:**", 45 times in api@2.16.0). Not a heading -// with more words ("## Deprecated fields"), which would be about part of the -// operation. Not "deprecat" anywhere: that also matches -// three descriptions that aren't deprecations, GET .../events/'s "**Eventsv2 -// Deprecation Note**" (about another endpoint; 2022-06-16, and again under -// the 2024-05-10 rename) and GET .../trace-items/attributes/'s "examples, and -// deprecation details" (2026-10-15). -var sentryDeprecatedWords = regexp.MustCompile(`(?im)^\s*#+\s*deprecated[^\p{L}\p{N}\n]*$|^\s*\*\*deprecated(\*\*:|:\*\*)|\bthis endpoint is deprecated\b`) - -func sentryDeprecatedDescription(description string) bool { - return sentryDeprecatedWords.MatchString(description) -} - -// sentryKeep keeps operation deprecations only: not even a deprecated -// operation's removal. An operation leaving Sentry's spec means Sentry -// stopped documenting it, and the history doesn't show when, or whether, it -// stopped working. -// -// - 157 operations left the spec (by path template, with /api/0 in every -// path: see adapter.Sentry). 11 had been deprecated first: GET -// /api/0/organizations/{organization_slug}/stats/, gone on 2024-01-22 -// and still routed in getsentry/sentry's src/sentry/api/urls.py on -// 2026-11-19, and the 10 alert-rule operations, gone on 2026-05-08 (the -// day after Sentry's "Monitors & Alerts — Now Generally Available"), -// with nothing from Sentry saying they stopped answering then. -// - Compared as published, 289 more left on 2026-11-13, when /api/0 -// moved into the server URL, GET .../issues/ and POST .../user-feedback/ -// among them, both flagged deprecated. -// -// Property changes and new operations are dropped too, as for vercel. -func sentryKeep(c diff.Change) bool { return c.Kind == diff.OperationDeprecated } diff --git a/plugins/openapi/supabase.go b/plugins/openapi/supabase.go deleted file mode 100644 index 20d4f3a..0000000 --- a/plugins/openapi/supabase.go +++ /dev/null @@ -1,28 +0,0 @@ -package openapi - -import "github.com/patch-it-dev/patch-it-plugins/core/diff" - -// supabaseDiff is how the Supabase Management API spec says what it says: -// -// - Deprecations use the `deprecated` flag, and the description sometimes -// says why ("This endpoint is deprecated - use the deploy endpoint."), so -// the event quotes the whole operation, not the bare `true`. -// - Path parameters get renamed, and that isn't a change for callers: -// /v1/branches/{branch_id}/merge became .../{branch_id_or_ref}/merge on -// 2025-09-11. -var supabaseDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} - -// supabaseKeep keeps operation deprecations, and removals of operations the -// old spec had marked deprecated. In the spec's history (90 commits, -// 2024-05-31 to 2026-11-18) that's 2 events: POST /v1/projects/{ref}/functions -// deprecated on 2025-02-19, GET /v1/projects/{ref}/analytics/endpoints/logs.all -// on 2026-06-29. Everything else is dropped: -// -// - 22 operations left the spec, none of them deprecated first: 14 -// analytics warehouse operations on 2024-07-15, 7 path-parameter renames -// (which PathTemplates pairs up anyway), and one that came back 12 -// days later. Without credentials every route answers 401, so whether a -// removed one still works can't be checked from outside. -// - Request and response property changes, new operations: not changes a -// caller has to fix, or not ones the spec's history shows reliably. -var supabaseKeep = deprecationsOnly(supabaseDiff) diff --git a/plugins/openapi/testdata/README.md b/plugins/openapi/testdata/README.md deleted file mode 100644 index c544076..0000000 --- a/plugins/openapi/testdata/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Saved OpenAPI spec excerpts - -Each pair is a real breaking change between two releases of a provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. - -| Files | Source | Checked | License | Quote | -|---|---|---|---|---| -| `datadog-2.60.0.yaml`, `datadog-2.61.0.yaml` | https://raw.githubusercontent.com/DataDog/datadog-api-client-python/2.60.0/.generator/schemas/v2/openapi.yaml (and `2.61.0`) | 2026-11-13 | Apache-2.0 (datadog-api-client-python) | `queried_tags_window_seconds:` (in 2.60.0, gone in 2.61.0) | -| `github-2022-11-28.json`, `github-2026-03-10.json` | https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.2022-11-28.json (and `.2026-03-10.json`) | 2026-11-14 | MIT (github/rest-api-description) | "Remove deprecated rate property from rate limit endpoint" (GitHub's breaking-changes page for 2026-03-10) | -| `gitlab-v18.11.0-ee.yaml`, `gitlab-v19.0.0-ee.yaml` | https://gitlab.com/gitlab-org/gitlab/-/raw/v18.11.0-ee/doc/api/openapi/openapi_v3.yaml (and `v19.0.0-ee`) | 2026-11-15 | CC BY-SA 4.0 (GitLab's `doc/` directory) | `bitbucket_app_password:` (in v18.11.0-ee, gone in v19.0.0-ee) | -| `vercel-v1.13.4.json`, `vercel-v1.13.5.json` | https://raw.githubusercontent.com/vercel/sdk/v1.13.4/vercel-spec.json (and `v1.13.5`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | "Check the price for a domain (deprecated)" (summary of `GET /v4/domains/price`, new in v1.13.5) | -| `vercel-v1.18.6.json`, `vercel-v1.18.7.json` | https://raw.githubusercontent.com/vercel/sdk/v1.18.6/vercel-spec.json (and `v1.18.7`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v4/domains/price": {` (in v1.18.6, gone in v1.18.7) | -| `vercel-v1.6.2.json`, `vercel-v1.6.3.json` | https://raw.githubusercontent.com/vercel/sdk/v1.6.2/vercel-spec.json (and `v1.6.3`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v1/log-drains": {` (in v1.6.2, gone in v1.6.3 without being deprecated, back in v1.15.0): the drop test | -| `vercel-v1.28.64.json`, `vercel-v1.28.65.json` | https://raw.githubusercontent.com/vercel/sdk/v1.28.64/vercel-spec.json (and `v1.28.65`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v2/sandboxes/drives/{nameOrId}": {` (`DELETE` moved here from `.../{name}` in v1.28.65) | -| `supabase-57d668c6.json`, `supabase-bf04ff66.json` | https://raw.githubusercontent.com/supabase/supabase/57d668c6ce265d40cdc009ecadf8e3d80d17a310/apps/docs/spec/api_v1_openapi.json (and `bf04ff6681062bde3edf9d646054b9a8b2ef286c`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | "This endpoint is deprecated - use the deploy endpoint." (`POST /v1/projects/{ref}/functions`, new in `bf04ff66`) | -| `supabase-693bdc38.json`, `supabase-eb21ae25.json` | https://raw.githubusercontent.com/supabase/supabase/693bdc38d045353e5782f86febff4fddc82bb93a/apps/docs/spec/api_v1_openapi.json (and `eb21ae25f7954ea1e5db34209ff69fce597b0ae3`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `"deprecated": true` on `GET /v1/projects/{ref}/analytics/endpoints/logs.all` (new in `eb21ae25`) | -| `supabase-8aef4a08.json`, `supabase-90b71e3e.json` | https://raw.githubusercontent.com/supabase/supabase/8aef4a08bf56e1e0e1eb8af316f7f0b2bcfd2e88/apps/docs/spec/api_v1_openapi.json (and `90b71e3e42c5f933013e1a62acdc37c07e9378d7`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `/v1/projects/{ref}/analytics/warehouse/...` (14 operations in `8aef4a08`, none deprecated, all gone in `90b71e3e`): the drop test | -| `supabase-de806266.json`, `supabase-a5fc0527.json` | https://raw.githubusercontent.com/supabase/supabase/de806266717abddb08e285f9dd6d17ad7d262b34/apps/docs/spec/api_v1_openapi.json (and `a5fc0527045daaafd2a661146cac0b430adad20b`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `/v1/branches/{branch_id}` (in `de806266`), `/v1/branches/{branch_id_or_ref}` (in `a5fc0527`) | -| `algolia-search-2025-03-25-5c28957ec.yml`, `algolia-search-2025-04-01-c19ee6afb.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2025-03-25-5c28957ec/specs/bundled/search.yml (and `released-2025-04-01-c19ee6afb`) | 2026-11-19 | MIT (algolia/api-clients-automation) | `deprecated: true` under `/1/clusters:` `get:` (new in `2025-04-01`) | -| `algolia-ingestion-2025-01-07-d0417f325.yml`, `algolia-ingestion-2025-01-22-232affcac.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2025-01-07-d0417f325/specs/bundled/ingestion.yml (and `released-2025-01-22-232affcac`) | 2026-11-19 | MIT (algolia/api-clients-automation) | "Retrieves a list of tasks using the v1 endpoint, please use `getTasks` instead." (`GET /1/tasks`) | -| `algolia-recommend-2024-03-19-2eac6f410.yml`, `algolia-recommend-2024-03-25-30207fcd0.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2024-03-19-2eac6f410/specs/bundled/recommend.yml (and `released-2024-03-25-30207fcd0`) | 2026-11-19 | MIT (algolia/api-clients-automation) | `/1{path}:` (in `2024-03-19`), `/{path}:` (in `2024-03-25`): `algolia-recommend`'s drop test | -| `algolia-ingestion-2024-09-18-cc190fae3.yml`, `algolia-ingestion-2024-09-19-a62c27d3b.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2024-09-18-cc190fae3/specs/bundled/ingestion.yml (and `released-2024-09-19-a62c27d3b`) | 2026-11-19 | MIT (algolia/api-clients-automation) | `/1/transformations/models:` (in `2024-09-18`, never deprecated, gone in `2024-09-19`): the drop test | -| `elasticsearch-8.19-fd5d063c.json`, `elasticsearch-9.0-57ecfe5f.json` | https://raw.githubusercontent.com/elastic/elasticsearch-specification/fd5d063c4824de5d33618b7fca4df0e6c1b8489f/output/openapi/elasticsearch-openapi.json (the head of `8.19`; and `57ecfe5fda6976b94fc8b8830ecb51f4969dccd6`, the head of `9.0`) | 2026-11-19 | Apache-2.0 (elastic/elasticsearch-specification) | `"/{index}/_unfreeze": {` (in 8.19, deprecated; gone in 9.0) | -| `elasticsearch-9.1-12639d0e.json`, `elasticsearch-9.2-87a82640.json` | https://raw.githubusercontent.com/elastic/elasticsearch-specification/12639d0e5ec07f064c909f15160ff68d608dbc2c/output/openapi/elasticsearch-openapi.json (the head of `9.1`; and `87a82640d8aa1139163dc7071bf00f971ce5e453`, the head of `9.2`) | 2026-11-19 | Apache-2.0 (elastic/elasticsearch-specification) | "designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported." (`/_autoscaling/capacity`, in 9.1, gone in 9.2): the drop test | -| `sentry-ead7f0cf.json`, `sentry-4650a66a.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/ead7f0cf9ccb8ac817105ac11bb94fe316fcb337/openapi-derefed.json (and `4650a66a859e015cccef2c171b115633321768e9`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "*This endpoint is DEPRECATED. We document it here for older SDKs" (`POST .../user-feedback/`, new in `4650a66a`) | -| `sentry-d64149d6.json`, `sentry-c2f638f6.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/d64149d65723484ca4d34c956ad017a66e1a4e07/openapi-derefed.json (and `c2f638f601baadcb055aec4ca3c2ba9f2654c087`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "**Deprecated**: This endpoint has been replaced with the [Organization Issues endpoint]" (`GET .../issues/`, new in `c2f638f6`) | -| `sentry-47231e61.json`, `sentry-1da1f31f.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/47231e6180b34f222ed462b1d0cb3cdb951cc4e7/openapi-derefed.json (and `1da1f31fac696201b1a7d20046fc199c8b1324b6`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "## Deprecated" then "🚧 Use [Fetch an Organization's Monitors](/api/monitors/fetch-an-organizations-monitors)" (`GET .../alert-rules/` and 9 more alert-rule operations, new in `1da1f31f`) | -| `sentry-0.223.0.json`, `sentry-0.224.0.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/0.223.0/openapi-derefed.json (and `0.224.0`) | 2026-11-19 | FSL-1.1-Apache-2.0 (getsentry/sentry-api-schema; the spec's own `info.license` says Apache 2.0) | `"deprecated": true` on `POST .../user-feedback/` and `GET .../issues/` (new in `0.224.0`, long after their descriptions said so) | -| `sentry-2.0.1.json`, `sentry-2.1.0.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/2.0.1/openapi-derefed.json (and `2.1.0`) | 2026-11-19 | FSL-1.1-Apache-2.0 (getsentry/sentry-api-schema; the spec's own `info.license` says Apache 2.0) | `"url": "https://{region}.sentry.io"` and `"/api/0/organizations/": {` (in `2.0.1`), `"url": "https://{region}.sentry.io/api/0"` and `"/organizations/": {` (in `2.1.0`): the drop test | -| `sentry-94bc6e59.json`, `sentry-d15557ff.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/94bc6e593eaf8a3800341abd429d2949895926fd/openapi-derefed.json (and `d15557ff7472748887043ab8a72687b20214a9bd`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "**Eventsv2 Deprecation Note**: Users who may be using the `eventsv2` endpoint should update their requests to the `events` endpoint" (`GET .../events/`, new in `d15557ff`; not a deprecation of it) | -| `sentry-e8ec23b4.json`, `sentry-1ef7f21a.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/e8ec23b4c9601dea2d51205983ec1d7b89550b85/openapi-derefed.json (and `1ef7f21a0501fae9490d69e3ae29f0d5acbfb61c`) | 2026-11-19 | FSL-1.1-Apache-2.0 (getsentry/sentry-api-schema; the spec's own `info.license` says Apache 2.0) | "a brief description, examples, and deprecation details." (`GET .../trace-items/attributes/`, new in `1ef7f21a`; not a deprecation) | -| `neon-5c57d009.json`, `neon-93b93dc9.json` | https://raw.githubusercontent.com/neondatabase/neon-pkgs/5c57d0095a9a4594a3c8b09d499b132902e7c42e/packages/sdk/spec/neon-openapi.json (and `93b93dc9e4d1b4ab48dac6c8ccba76b35541b476`) | 2026-11-19 | Excerpt for testing; © Neon. neondatabase/neon-pkgs is Apache-2.0, but the spec's own `info.license` says "Proprietary" | "Deprecated: to test a branch's already-saved configuration, use `sendNeonAuthEmailProviderTest`" (`POST /projects/{project_id}/branches/{branch_id}/auth/send_test_email`, new in `93b93dc9`) | -| `neon-4c6b3be4.json`, `neon-4497de89.json` | https://raw.githubusercontent.com/neondatabase/neon-pkgs/4c6b3be46b1b333e7f910db51218ad144de27179/packages/sdk/spec/neon-openapi.json (and `4497de89a5e84b38956fde686d271f99317b8fdb`) | 2026-11-19 | Excerpt for testing; © Neon. neondatabase/neon-pkgs is Apache-2.0, but the spec's own `info.license` says "Proprietary" | `"/projects/{project_id}/branches/{branch_id}/recover": {` (in `4c6b3be4`, gone in `4497de89` without being deprecated): the drop test | -| `neon-api-client-2.7.2.yaml`, `neon-api-client-2.7.3.yaml` | `public-v2-for-users.gen.yaml` in https://registry.npmjs.org/@neondatabase/api-client/-/api-client-2.7.2.tgz (and `api-client-2.7.3.tgz`) | 2026-11-19 | Excerpt for testing; © Neon. The package is MIT, but the spec's own `info.license` says "Proprietary" | "**Deprecated.** Use `GET /consumption_history/projects` (`getConsumptionHistoryPerProject`)" (`GET /consumption_history/account`, in 2.7.2, gone in 2.7.3) | -| `convex-f35879bb.json`, `convex-5e5159cb.json` | https://raw.githubusercontent.com/convex/convex-backend/f35879bb396491942bf8ecbc8ef5e4280499f89f/npm-packages/@convex-dev/platform/deployment-openapi.json (and `5e5159cbea5188e9da5400febda1b031a233eea0`) | 2026-11-19 | FSL-1.1-Apache-2.0 (convex/convex-backend `LICENSE.md`; the spec's own `info.license` is `LicenseRef-FSL-1.1-Apache-2.0`): excerpt for testing, © Convex, Inc.; maintainers, please confirm | "Deprecated: use `GET /integrations` instead." (`GET /list_log_streams`, and five more log stream operations, new in `5e5159cb`) | -| `convex-3f6edf7a.json`, `convex-3ead9091.json` | https://raw.githubusercontent.com/convex/convex-backend/3f6edf7ab8f3f98e027f317633246a19348eabcc/npm-packages/@convex-dev/platform/deployment-openapi.json (and `3ead909103b7f5897f529c031e80991ad174b07e`) | 2026-11-19 | FSL-1.1-Apache-2.0 (convex/convex-backend `LICENSE.md`; the spec's own `info.license` is `LicenseRef-FSL-1.1-Apache-2.0`): excerpt for testing, © Convex, Inc.; maintainers, please confirm | `"name": {` in `UsageLimitConfigRequest` and `UsageLimitConfigResponse` (in `3f6edf7a`, gone in `3ead9091` without being deprecated): the drop test | -| `planetscale-e631095a.yaml`, `planetscale-fc13e09d.yaml` | https://raw.githubusercontent.com/planetscale/terraform-provider-planetscale/e631095aa649a6797578a1d51d861b91e0568aa1/schemas/openapi.yaml (and `fc13e09d0c18b893aabd3e02d175d13957bba677`) | 2026-11-19 | none stated for the file (its `info` says "© 2026 PlanetScale, Inc."); the repo, planetscale/terraform-provider-planetscale, is Apache-2.0. Excerpt for testing; © PlanetScale | "Deprecated. Use GET /organizations/:organization/databases/:database/branches/:branch/change-requests instead." (`GET .../neki-changes`, new in `fc13e09d`) | -| `planetscale-b49c3540.yaml`, `planetscale-f6d6ad4d.yaml` | https://raw.githubusercontent.com/planetscale/terraform-provider-planetscale/b49c354080667638b79781801f0517ae07bc55b8/schemas/openapi.yaml (and `f6d6ad4d3929f6c1ef021eb13c1541ba31f72107`) | 2026-11-19 | none stated for the file (its `info` says "© 2026 PlanetScale, Inc."); the repo, planetscale/terraform-provider-planetscale, is Apache-2.0. Excerpt for testing; © PlanetScale | `/organizations/{organization}/databases/{database}/branches/{branch}/read-only-replicas:` (in `b49c3540`, never deprecated, gone in `f6d6ad4d`, where `.../dedicated-read-replicas:` is): the drop test | -| `appwrite-1.9.x-8c00ba35-server.json`, `appwrite-1.9.x-7d74bf9f-server.json` | https://raw.githubusercontent.com/appwrite/specs/8c00ba356b01d43fbc6c88c60fb2a4fc99e04b40/specs/1.9.x/open-api3-1.9.x-server.json (and `7d74bf9f3c0c990745e822f5935bcfaca310fd06`) | 2026-11-19 | BSD-3-Clause (appwrite/specs) | `"replaceWith": "tablesDB.createTransaction"` (`x-appwrite.deprecated` of `POST /databases/transactions`, flagged in `7d74bf9f` with 13 more) | -| `appwrite-2.4.x-98cc1a25.json`, `appwrite-2.4.x-06e6fafa.json` | https://raw.githubusercontent.com/appwrite/specs/98cc1a25215d3cead3a64f9bd4574a9c5b1ec87b/specs/2.4.x/open-api3-2.4.x.json (and `06e6fafa4d1ae3c815843ff0b02a56e6e5582756`) | 2026-11-19 | BSD-3-Clause (appwrite/specs) | `"server"` in `x-appwrite.platforms` of `POST /account/recovery/otp` and 12 more operations (in `98cc1a25`, none deprecated; off them in `06e6fafa`, on again in 2.5.x the next day): the drop test | -| `appwrite-1.7.x-ac705cd3-server.json`, `appwrite-1.8.x-ac705cd3-server.json` | https://raw.githubusercontent.com/appwrite/specs/ac705cd3e9d5e3a0693b7e40189eb1e66883e341/specs/1.7.x/open-api3-1.7.x-server.json (and `specs/1.8.x/open-api3-1.8.x-server.json` at the same commit) | 2026-11-19 | BSD-3-Clause (appwrite/specs) | `"replaceWith": "account.createMFAAuthenticator"` on `POST /account/mfa/authenticators/{type}`, whose `x-appwrite.methods` are `createMfaAuthenticator` and `createMFAAuthenticator` (one of 21 SDK method renames flagged in 1.8.x) | -| `flagsmith-v2.286.0.yaml`, `flagsmith-v2.287.0.yaml` | https://raw.githubusercontent.com/Flagsmith/flagsmith/v2.286.0/openapi.yaml (and `v2.287.0`) | 2026-11-19 | BSD-3-Clause (Flagsmith/flagsmith; also the spec's own `info.license`) | "**EXPERIMENTAL ENDPOINT** - Subject to change without notice." (`POST .../delete-segment-override/` and two more, removed in `v2.287.0`) | -| `flagsmith-desc-c3ef832.yaml`, `flagsmith-desc-f504f16.yaml` | https://raw.githubusercontent.com/Flagsmith/flagsmith/c3ef83244bfb4b1d65ab6fc5ff45412659dd61f3/openapi.yaml (and `f504f160dcf40b16baace0506a04dfda8fd6332c`, commits not tags) | 2026-11-19 | BSD-3-Clause (Flagsmith/flagsmith; also the spec's own `info.license`) | "Short-lived access token for the Admin API." (in `c3ef832`), "...for the Management API." (in `f504f16`, the same commit as "feat: rename admin api to management" #8464): the drop test | - -The Elasticsearch copies keep `openapi`, `info` and the paths involved, every line unchanged; the 9.2 copy's paths are all gone in 9.2, so its `"paths": {}` is the one line that isn't in the original. - -The Algolia copies are trimmed by lines: `openapi`, `info` and the paths involved, every line copied unchanged; `components` left out. - -The Supabase copies keep each value unchanged but are re-indented: the source is Prettier-formatted (objects on one line where they fit), and minified on one line before 2025. - -The Sentry copies keep `openapi`, `info`, `servers` and the path items involved, whole, in their original order except that `servers` comes before `paths`, every line copied unchanged (bar the trailing comma after a path item that's now last); `components` and `tags` left out. Each pair gives the same events as the full files, with the filter and with the variants the tests use (flag only, "deprecat" anywhere). The tests serve them as GitHub would, with each commit's date and each tag's release date. - -The Neon copies are excerpts, not whole files: the spec says its license is "Proprietary" whatever the license of the repo or package that ships it. The JSON copies keep `openapi`, `servers`, `info` (without its `contact`) and the path items involved, whole and in their original order, every line copied unchanged (bar the trailing comma after a member that's now last); `components` left out. The YAML copies keep, by lines, `openapi`, `servers`, `info`'s `title`, `version` and `license`, and the path items involved; they're a different source from the plugin's (the npm package @neondatabase/api-client, succeeded by @neon/sdk and not released since 2.7.3), used only to check that the removal of an operation marked deprecated is kept. -The Convex copies keep `openapi`, `info`, `servers` and the path items involved, whole and in their original order, every line copied unchanged (bar the trailing comma after a path item or schema that's now last); the usage-limit pair also keeps the component schemas those operations reach, the log stream pair none. The source is FSL-1.1-Apache-2.0 (each version becomes Apache-2.0 two years after it's published), which allows copying for a permitted purpose; these are short excerpts kept for testing, but a maintainer should confirm that before release. Each pair gives the same changes as the full files, with and without the filter. The management API spec (`management-openapi.json`, `info.license` `LicenseRef-Convex`, not defined anywhere in the repo) is neither read nor saved. -The PlanetScale copies are trimmed by lines: everything before `paths:` (`openapi`, `info`), then the path items involved, whole, and the two-line `servers` block (`https://api.planetscale.com/v1`, the same in every version), every line copied unchanged; the other paths, `tags`, `security`, `x-readme` and `components` left out. The file states no license, so only what the tests need is kept. The golden pair gives the full files' 5 deprecations (their only ones), the drop-test pair their 7 removals (their only ones). The tests serve them as GitHub would, with each commit's date. - -The Appwrite copies keep `openapi`, `info`, `servers` and the path items involved, whole and in their original order; `tags`, `components` and `externalDocs` left out. They're re-serialized the way the originals are written (4-space indent, `/` written `\/`, non-ASCII as `\u` escapes), which gives every original line back byte for byte when nothing is left out, so every kept line is unchanged bar a trailing comma. The 1.9.x pair keeps the paths of the 14 operations deprecated in `7d74bf9f`, the 2.4.x pair the paths of the 13 operations that lost the server platform in `06e6fafa`, the 1.7.x and 1.8.x pair the paths of the 21 operations flagged only for an SDK method rename. With the full files the plugin gives the same results: 14 events, none, and none (50, from the rest of 1.8.x's Databases deprecations, with the 21 renames still left out). - -Stripe's spec isn't saved here: its tests use small specs written inline. - -The Flagsmith copies are trimmed by lines: `openapi`, `info` and `servers`, then the path items involved (`paths: {}` where none remain, the one line in `v2.287.0.yaml` that isn't in the original) and, under `components: schemas:`, every schema those paths' request bodies reach, transitively, whole and in original order, every line copied unchanged; `tags` and `security` left out. `FeatureValue`, `FeatureValueTypeEnum` and `MultivariateValue` are kept unchanged in both files because the real spec still has them at `v2.287.0` (other, unremoved operations use them too); every other schema the removed paths reached (`DeleteSegmentOverride`, `EnvironmentDefault`, `FeatureIdentifier`, `FeatureUpdateSegmentData`, `SegmentIdentifier`, `SegmentOverride`, `UpdateFlag`, `UpdateFlagV2`) really is gone in `v2.287.0`, confirmed against the full file. The drop-test pair is two commits, not tags, kept whole but for the same trim (`TokenExchangeResponse` and the `Master API Key` security scheme, the only two places that commit touched `openapi.yaml`). -| `openai-2026-10-27.yaml`, `openai-2026-10-28.yaml` | https://raw.githubusercontent.com/openai/openai-openapi/54640e1ce5465c6f2e597ac4b030f9b92ba6d044/openapi.yaml (and `aa880040fa7b23c8a7e3618b5ca757ecec71de95`), the last commits of 2026-10-27 and 2026-10-28; trimmed to `info`, `servers` and the paths `/audio/translations`, `/audio/transcriptions` (and `/organization/external_keys`, new on 2026-10-28) | 2026-11-21 | MIT (openai/openai-openapi) | "The endpoint and model are deprecated and scheduled to shut down on February 26, 2027." (`POST /audio/translations`, flagged on 2026-10-28) | -| `openai-2026-11-17.yaml`, `openai-2026-11-18.yaml` | https://raw.githubusercontent.com/openai/openai-openapi/b2fe5a5d9eb3a580da5aed1d3ff2a03b3853e4f8/openapi.yaml (and `d4eae433ac22ac1b1f9af8ecfdbd529d6cea082e`); trimmed to `info`, `servers` and the schemas `SessionBudgetControlParams`, `SessionBudgetControlResource`, `SessionEventAgentSessionBudgetReached` | 2026-11-21 | MIT (openai/openai-openapi) | `SessionBudgetControlParams:` (in 2026-11-17, gone in 2026-11-18, "Remove session spending limit features"): the drop test | -| `cloudflare-2026-10-29.json`, `cloudflare-2026-10-30.json` | https://raw.githubusercontent.com/cloudflare/api-schemas/46a48d5eba1d8a839cd8cc5712d2b9368e21e654/openapi.json (and `319dc756af2a642b3122b4db7e3b79ac1fbec7d8`), the last commits of 2026-10-29 and 2026-10-30; trimmed to `openapi`, `info`, `servers` and five paths, re-indented as published (2 spaces) | 2026-11-21 | BSD-3-Clause (cloudflare/api-schemas) | "This operation is deprecated and will reach end of life on September 27, 2026." (`GET /accounts/{account_id}/registrar/domains`, in 2026-10-29, gone in 2026-10-30) | -| `mongodb-atlas-2025-02-18.json`, `mongodb-atlas-2025-02-20.json` | https://raw.githubusercontent.com/mongodb/openapi/f7b9298adb18b804230c8516cb533196538a8db9/openapi/v2.json (and `28b2c6fc35a44b3272d7afbcaae380e1d28f0e45`), the last commits of 2025-02-18 and 2025-02-20; trimmed to `openapi`, `info`, `servers` and four `/api/atlas/v2/users` and `/orgs/{orgId}/users` paths | 2026-11-21 | Excerpt for testing; © MongoDB, CC BY-NC-SA 3.0 US (the spec's `info.license`) | `"deprecated": true` (`GET /api/atlas/v2/users/byName/{userName}`, new in 2025-02-20) | -| `mongodb-atlas-2024-07-25.json`, `mongodb-atlas-2024-08-07.json` | https://raw.githubusercontent.com/mongodb/openapi/6ae1e79533409017d2c3251e645aae28aa54bd8b/openapi/v2.json (and `96b0555285636db831afeb5a0e9b2dfddbfab2c6`); trimmed to `openapi`, `info`, `servers` and the paths `/rest/unauth/version`, `/api/atlas/v2` | 2026-11-21 | Excerpt for testing; © MongoDB, CC BY-NC-SA 3.0 US | `"/rest/unauth/version": {` (in 2024-07-25, gone in 2024-08-07, never deprecated): the drop test | diff --git a/plugins/openapi/vercel.go b/plugins/openapi/vercel.go deleted file mode 100644 index 191be09..0000000 --- a/plugins/openapi/vercel.go +++ /dev/null @@ -1,67 +0,0 @@ -package openapi - -import ( - "regexp" - - "github.com/patch-it-dev/patch-it-plugins/core/diff" -) - -// vercelDiff is how Vercel's spec says what it says: -// -// - Most deprecations are in the summary, not the flag. Of the 22 operations -// deprecated between 2024-11 and 2026-11 in vercel/sdk's spec history, 16 -// said so only in words: "Check the price for a domain (deprecated)", -// "Deprecated: Use DELETE /v1/drives/:name. ...". -// - Renaming a path parameter isn't a change for callers, and Vercel does it: -// DELETE /v2/sandboxes/drives/{name} became .../{nameOrId} in v1.28.65. -var vercelDiff = diff.Options{PathTemplates: true, DeprecatedSummary: vercelDeprecatedSummary} - -// vercelDeprecatedWords are the two ways every word-only deprecation in the -// history is written: a summary that starts "Deprecated:" or ends -// "(deprecated)". Not "deprecat" anywhere, nor a bare leading "Deprecated", -// which would match an operation about deprecated things ("Deprecated -// runtimes for a project"). -var vercelDeprecatedWords = regexp.MustCompile(`(?i)^deprecated:|\(deprecated\)\s*$`) - -func vercelDeprecatedSummary(summary string) bool { - return vercelDeprecatedWords.MatchString(summary) -} - -// vercelKeep keeps operation deprecations, and removals of operations the old -// spec had marked deprecated. Everything else is dropped, because in -// vercel/sdk's spec history (207 releases, 2024-11 to 2026-11) it was mostly -// not a change to the API: -// -// - 108 operations left the spec, and only 5 had been marked deprecated: the -// four Legacy Domains endpoints, which Vercel did shut down on 2025-11-09 -// (they now answer "This endpoint has been sunsetted"), and the drives -// rename PathTemplates already pairs up. Of the other 103, 16 came back in -// a later release, and the edge-config ones were the product's rename to -// Global Config. -// - The response side reported 67,048 removed properties, about a thousand a -// release, from the generated schemas reshuffling. -// - The request side reported 478 breaking property changes, most of them -// union members compared by position as their order moved; outside unions -// there were still 142, and 27 of those reverted later. -// -// Additions are dropped too: nobody has to fix code for a new endpoint, and a -// re-added one isn't new. -func vercelKeep(c diff.Change) bool { return deprecationsOnly(vercelDiff)(c) } - -// deprecationsOnly keeps operation deprecations, and removals of operations -// the old spec had marked deprecated (by opts' reading of "marked"): -// everything else is dropped. For a spec whose removals and property changes -// were mostly not changes to the API (vercel, supabase). -func deprecationsOnly(opts diff.Options) func(diff.Change) bool { - return func(c diff.Change) bool { - switch c.Kind { - case diff.OperationDeprecated: - return true - case diff.OperationRemoved: - op, _ := c.Node.(map[string]any) - return opts.OperationDeprecated(op) - default: - return false - } - } -} diff --git a/providers/README.md b/providers/README.md index 56d8d6d..0790a58 100644 --- a/providers/README.md +++ b/providers/README.md @@ -1,11 +1,13 @@ # Providers -One page per provider: `providers/-.md`, or the provider's own page shared by its sources. Start from [`_template.md`](_template.md). Each page says: +What patch-it reads: one folder per provider, `providers//`, holding everything about that provider and nothing about any other. -- **What the plugin watches.** -- **Why this source:** the link the plugin reads, when it was checked, why it's the most reliable place this provider announces breaking changes, which other sources were considered and why they weren't used, and one short quote from it. -- **How often** it changes, and how the provider announces breaking changes. -- **What the plugin reads** from it, and what it deliberately ignores (and why). -- **Known gaps**: changes the provider makes that this plugin can't see yet. +- `provider.go`: the provider's registration (`plugin.RegisterProvider`): its id, name, category and homepage, and every source of it, whatever its kind, with the source's layer, what it watches, the URLs it reads and the packages it covers. Sources are built from the kinds' exported types (`kinds/`, how to read). +- `README.md`: the provider's page, one section per source: what it watches, **why this source** (the link, the date it was checked, why it's the best source, the alternatives not used, a short quote), how the provider announces changes, what the source reads and ignores, and its known gaps. Start from [`docs/provider-template.md`](../docs/provider-template.md). +- `.go`: only when a source needs code of its own: an OpenAPI adapter (where the spec is, how its versions are listed, what the differ keeps), a feed's reader. +- `testdata/`: the saved copies the tests replay, each with a row in `testdata/README.md` (URL, date fetched, license, quote), and the golden files, `testdata/golden/`, with every event the tests must store. +- `*_test.go`: each source's golden test and its pinned drop test. -Each source's registration names its page (`Page: "providers/.md"`); a provider's sources may share one. There's no list of pages here: `go run ./cmd/list-plugins` prints every provider and source with its page, and each release carries that list as `plugins.json`. +[`all/`](all/) imports every provider, so a program that imports it runs every source; its tests fail when a provider's folder isn't imported, a source's metadata or page is missing, or a package imports what it shouldn't (a kind imports no provider; a provider imports only `core/` and `kinds/`). + +There's no list of providers or sources here: `go run ./cmd/list-plugins` prints them from the registry, and each release carries that list as `plugins.json`. diff --git a/providers/_template.md b/providers/_template.md deleted file mode 100644 index b7eab39..0000000 --- a/providers/_template.md +++ /dev/null @@ -1,28 +0,0 @@ -# (`/`) - -Copy this file to `providers/-.md` and fill every section. Delete these instructions. - -## What it watches - -One or two sentences: which API, SDK, package or runtime, and which kinds of change (removed fields, model shutdowns, major releases…). - -## Why this source - -The link (or links) the plugin reads, and **why this one**: - -- **Source:** ``, checked on ``. -- **Why this one:** why it's the most reliable place this provider announces breaking changes (an official spec beats a changelog; a changelog beats a blog post; a blog post beats a forum). -- **Alternatives considered:** other places the provider publishes changes, and why the plugin doesn't read them (incomplete, not machine-readable, published late, marketing only…). -- **Quote:** one short line copied from the source that shows the kind of change the plugin turns into an event. - -## How the provider announces changes - -How often it changes, how it versions its API, and how much notice it gives before something breaks. - -## What the plugin reads and ignores - -What becomes an event, and what is deliberately dropped (and why). Precision over recall: when unsure, drop. - -## Known gaps - -Changes this provider makes that the plugin can't see yet. diff --git a/providers/algolia-python-surface.md b/providers/algolia-python-surface.md deleted file mode 100644 index 336a5b2..0000000 --- a/providers/algolia-python-surface.md +++ /dev/null @@ -1,35 +0,0 @@ -# Algolia Python client (`algolia/python-surface`) - -## What it watches - -The public API of the `algoliasearch` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install algoliasearch==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md; the specs themselves (the HTTP API). -- **Quote:** `class FacetFilters(BaseModel)` (`algoliasearch/recommend/models/facet_filters.py` line 21) at 4.44.1, gone at 4.44.3 (back at 4.44.4). - -## How the provider announces changes - -- The client is generated from Algolia's API specs (the `algolia/*-api` sources) and released every week or two. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `algoliasearch/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/providers/algolia.md b/providers/algolia/README.md similarity index 52% rename from providers/algolia.md rename to providers/algolia/README.md index 5fbd906..1e347c5 100644 --- a/providers/algolia.md +++ b/providers/algolia/README.md @@ -1,12 +1,16 @@ -# Algolia (`algolia/search-api`, `algolia/ingestion-api`, `algolia/recommend-api`) +# Algolia -## What it watches +Every source patch-it reads for Algolia, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Algolia (`algolia/search-api`, `algolia/ingestion-api`, `algolia/recommend-api`) + +### What it watches Three of Algolia's REST APIs, one plugin each: the Search API (`algolia-search`), the Ingestion API (`algolia-ingestion`) and the Recommend API (`algolia-recommend`). Each reports operations Algolia marks deprecated, and removals of operations it had marked deprecated, between two releases of that API's OpenAPI spec. -Kind: `openapi` (`plugins/openapi`), with `adapter.Algolia`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `Algolia` ([`specs.go`](specs.go)). -## Why this source +### Why this source - **Source:** `specs/bundled/.yml` in [algolia/api-clients-automation](https://github.com/algolia/api-clients-automation), pinned to a release tag (`https://raw.githubusercontent.com/algolia/api-clients-automation//specs/bundled/search.yml`). The newest tag comes from the GitHub refs API. Checked on 2026-11-19. - **Why this one:** @@ -20,12 +24,12 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Algolia`. - **The API clients' own changelogs.** They're generated from the same specs. - **Quote:** "Retrieves a list of tasks using the v1 endpoint, please use `getTasks` instead." (`GET /1/tasks`, deprecated in the Ingestion API spec in `released-2025-01-22-232affcac`) -## How the provider announces changes +### How the provider announces changes - **No API version beyond `/1/` in the paths.** Each API client has its own version numbers, so the event's `version` is the date of the spec release (`2025-04-01`). - **The specs get a release a few times a week.** Deprecations are rare: in the history, 9 in the Search API and 9 in the Ingestion API, none in Recommend. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** each API's spec at the newest release tag, diffed against the last one. Two events come out of it: - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so a replacement Algolia names in the description is in the excerpt. @@ -42,7 +46,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Algolia`. - **Ingestion API:** 8 v1 `/1/tasks` operations (2025-01-22) and `PUT /1/tasks/{taskID}/disable` (2024-07-26). - **The golden tests** replay the Search and Ingestion deprecations. The drop tests replay the `/1/transformations/models` removal and, for `algolia-recommend`, the custom-request move of 2024-03-25. -## Known gaps +### Known gaps - **Only three APIs are watched.** Analytics, Insights, A/B testing, Query Suggestions, Personalization, Monitoring and others have specs in the same repo, but no deprecations in them yet. - **Removals Algolia didn't mark first aren't events,** even if the endpoint really went away. @@ -50,3 +54,39 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Algolia`. - **Changes to the API clients themselves aren't covered:** method renames between major versions, the helpers. - **Two releases on one day share a `version`.** - **The patch-it client can't place these events yet.** Their `version` is a date, because the API has no version. It needs the same rule for date-versioned API events that `cloudflare`'s and `supabase`'s need. + +## Algolia Python client (`algolia/python-surface`) + +### What it watches + +The public API of the `algoliasearch` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install algoliasearch==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md; the specs themselves (the HTTP API). +- **Quote:** `class FacetFilters(BaseModel)` (`algoliasearch/recommend/models/facet_filters.py` line 21) at 4.44.1, gone at 4.44.3 (back at 4.44.4). + +### How the provider announces changes + +- The client is generated from Algolia's API specs (the `algolia/*-api` sources) and released every week or two. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `algoliasearch/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/providers/algolia/provider.go b/providers/algolia/provider.go new file mode 100644 index 0000000..727ac2a --- /dev/null +++ b/providers/algolia/provider.go @@ -0,0 +1,41 @@ +// Package algolia is what patch-it reads for Algolia: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package algolia + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "algolia", Name: "Algolia", Category: plugin.CategorySearch, Homepage: "https://www.algolia.com", + Sources: append(specs(), + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/algolia/algoliasearch-client-python"), + ), + }) +} + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "algolia/python-surface", Name: "algoliasearch", Ecosystem: "pypi", Module: "algoliasearch"} +) + +// specs are the API specs' sources, one per spec, each read by Algolia's +// adapter (specs.go). No Hints: Algolia's changelog is a hosted product +// feed, not keyed by operation. +func specs() []plugin.Source { + var out []plugin.Source + for _, spec := range []struct{ name, title string }{{"search", "Search"}, {"ingestion", "Ingestion"}, {"recommend", "Recommend"}} { + out = append(out, plugin.Source{ + ID: spec.name + "-api", Layer: plugin.LayerAPI, + Watches: spec.title + " API operations deprecated, and deprecated operations removed, between releases of the spec", + URLs: []string{"https://github.com/algolia/api-clients-automation", "https://github.com/algolia/api-clients-automation/blob/main/specs/bundled/" + spec.name + ".yml"}, + Packages: []string{"pypi:algoliasearch", "npm:algoliasearch"}, + Plugin: openapi.Plugin{Adapter: Algolia{Spec: spec.name}, Diff: algoliaDiff, Keep: algoliaKeep}, + }) + } + return out +} diff --git a/providers/algolia/python_surface_test.go b/providers/algolia/python_surface_test.go new file mode 100644 index 0000000..5df1ab5 --- /dev/null +++ b/providers/algolia/python_surface_test.go @@ -0,0 +1,15 @@ +package algolia + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// algoliasearch 4.44.3 dropped recommend's FacetFilters (4.44.4 brought +// it back: an addition, no event). +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"4.44.1", "4.44.3"}, Want: []string{ + "removed_symbol recommend.models.FacetFilters,recommend.models.facet_filters.FacetFilters ", + }, Drop: [2]string{"4.44.3", "4.44.4"}}) +} diff --git a/plugins/openapi/adapter/algolia.go b/providers/algolia/specs.go similarity index 52% rename from plugins/openapi/adapter/algolia.go rename to providers/algolia/specs.go index b49cff2..0cd6f21 100644 --- a/plugins/openapi/adapter/algolia.go +++ b/providers/algolia/specs.go @@ -1,15 +1,20 @@ -package adapter +package algolia import ( "context" "encoding/json" "fmt" "regexp" + "slices" "strings" "time" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" "gopkg.in/yaml.v3" ) @@ -33,7 +38,7 @@ type Algolia struct { Spec string } -var _ Adapter = Algolia{} +var _ adapter.Adapter = Algolia{} func (a Algolia) API() string { return "algolia/" + a.Spec + "-api" } @@ -115,23 +120,97 @@ func algoliaCommitDate(ctx context.Context, tag string) (time.Time, error) { // has no version beyond the /1/ in its paths, and each API client has its own // version numbers, so the day the spec was released is the closest thing to // "the API version the change arrived in". -func (a Algolia) Fetch(ctx context.Context, tag string) (Spec, error) { +func (a Algolia) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { m := algoliaTag.FindStringSubmatch(tag) if m == nil { - return Spec{}, fmt.Errorf("%q isn't an algolia release tag", tag) + return adapter.Spec{}, fmt.Errorf("%q isn't an algolia release tag", tag) } url := fmt.Sprintf(algoliaSpecURLTemplate, tag, a.Spec) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching algolia %s spec %s: %w", a.Spec, tag, err) + return adapter.Spec{}, fmt.Errorf("fetching algolia %s spec %s: %w", a.Spec, tag, err) } var doc any if err := yaml.Unmarshal(body, &doc); err != nil { - return Spec{}, fmt.Errorf("parsing algolia %s spec %s as yaml: %w", a.Spec, tag, err) + return adapter.Spec{}, fmt.Errorf("parsing algolia %s spec %s as yaml: %w", a.Spec, tag, err) } content, err := json.Marshal(doc) if err != nil { - return Spec{}, fmt.Errorf("converting algolia %s spec %s to json: %w", a.Spec, tag, err) + return adapter.Spec{}, fmt.Errorf("converting algolia %s spec %s to json: %w", a.Spec, tag, err) } - return Spec{Content: content, Version: m[1], SourceURL: url}, nil + return adapter.Spec{Content: content, Version: m[1], SourceURL: url}, nil +} + +// Versions are every release tag, oldest first. A day with several releases +// is ordered by each tag's commit date (LatestTag's rule), one lookup per +// tag on such a day only. +func (a Algolia) Versions(ctx context.Context) ([]plugin.Version, error) { + tags, err := algoliaTags(ctx) + if err != nil { + return nil, err + } + days := map[string]int{} + for _, t := range tags { + days[algoliaTag.FindStringSubmatch(t)[1]]++ + } + var out []plugin.Version + for _, t := range tags { + day := algoliaTag.FindStringSubmatch(t)[1] + released, _ := time.Parse(time.DateOnly, day) + if days[day] > 1 { + if released, err = algoliaCommitDate(ctx, t); err != nil { + return nil, err + } + } + out = append(out, plugin.Version{ID: day, Released: released.UTC(), Ref: t, + URL: "https://github.com/algolia/api-clients-automation/releases/tag/" + t}) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return out, nil +} + +// algoliaDiff reads Algolia's specs like Supabase's: deprecations by the +// `deprecated` flag, quoting the whole operation, and path templates matched. +var algoliaDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// algoliaKeep keeps operation deprecations, and removals of operations +// marked deprecated first, of REST operations only. Algolia's specs also +// describe what only its API clients do, and a change to one of those isn't +// an API change: +// +// - helpers, marked `x-helper: true`: /saveObjects, /waitForTask, +// /replaceAllObjects, … (16 in the Search API on 2026-11-17); +// - the "custom request" methods for any path, operationId customGet, +// customPost, customPut and customDelete on /{path} (before 2024-03-25, +// /1{path}). +// +// In every release from 2023-08-22 to 2026-11-17 this keeps 9 Search API +// deprecations (the multi-cluster /1/clusters endpoints, 2025-04-01) and 9 +// Ingestion API ones (the /1/tasks endpoints, 2025-01-22, and PUT +// /1/tasks/{taskID}/disable, 2024-07-26). None of the 17 removals in that +// history was deprecated first; 13 were the client-only entries above (the +// custom-request methods in all three specs on 2024-03-25, and /saveObjects). +func algoliaKeep(c diff.Change) bool { + // c.Node is the operation only because algoliaDiff sets + // QuoteDeprecatedOperation (a removal carries the old operation anyway); + // TestAlgoliaClientOnlyFilterThroughTheDiffer pins that. + op, _ := c.Node.(map[string]any) + if clientOnly(op) { + return false + } + return openapi.DeprecationsOnly(algoliaDiff)(c) +} + +// clientOnly is an Algolia spec entry for an API-client method, not a REST +// operation. +func clientOnly(op map[string]any) bool { + if helper, _ := op["x-helper"].(bool); helper { + return true + } + id, _ := op["operationId"].(string) + switch id { + case "customGet", "customPost", "customPut", "customDelete": + return true + } + return false } diff --git a/plugins/openapi/adapter/algolia_test.go b/providers/algolia/specs_fetch_test.go similarity index 77% rename from plugins/openapi/adapter/algolia_test.go rename to providers/algolia/specs_fetch_test.go index 80432a2..2dacad2 100644 --- a/plugins/openapi/adapter/algolia_test.go +++ b/providers/algolia/specs_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package algolia import ( "context" @@ -6,6 +6,8 @@ import ( "net/http/httptest" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) func fakeAlgoliaGitHub(t *testing.T, refs string, commitDates, specs map[string]string) { @@ -106,3 +108,28 @@ func TestAlgoliaFetch(t *testing.T) { t.Error("invalid yaml: want an error") } } + +// Every release tag, oldest first; the five tags of 2024-09-18 and -19 are +// ordered by their commits' dates, not their names. +func TestAlgoliaListsEveryReleaseTag(t *testing.T) { + files := map[string]string{"/refs": "algolia-refs.json"} + for _, tag := range []string{"2024-09-18-45edcd844", "2024-09-18-cc190fae3", "2024-09-19-6e91dbf55", "2024-09-19-a62c27d3b", "2024-09-19-e47df6533"} { + files["/commits/released-"+tag] = "algolia-commit-released-" + tag + ".json" + } + srv := openapitest.Recorded(t, files) + a, b := algoliaRefsURL, algoliaCommitURL + algoliaRefsURL, algoliaCommitURL = srv.URL+"/refs", srv.URL+"/commits/%s" + t.Cleanup(func() { algoliaRefsURL, algoliaCommitURL = a, b }) + vs, err := Algolia{Spec: "search"}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + var refs []string + for _, v := range vs { + refs = append(refs, strings.TrimPrefix(v.Ref, "released-")) + } + want := "2023-08-22 2023-08-29 2024-09-18-45edcd844 2024-09-18-cc190fae3 2024-09-19-a62c27d3b 2024-09-19-6e91dbf55 2024-09-19-e47df6533 2026-11-10-8d91e3d8a3 2026-11-17-31c309fe2a" + if got := strings.Join(refs, " "); got != want { + t.Errorf("refs\n %s\nwant\n %s", got, want) + } +} diff --git a/plugins/openapi/algolia_test.go b/providers/algolia/specs_test.go similarity index 86% rename from plugins/openapi/algolia_test.go rename to providers/algolia/specs_test.go index edc34ef..5527ec2 100644 --- a/plugins/openapi/algolia_test.go +++ b/providers/algolia/specs_test.go @@ -1,4 +1,4 @@ -package openapi +package algolia import ( "context" @@ -11,13 +11,15 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" "gopkg.in/yaml.v3" ) // fakeAlgoliaAdapter serves the trimmed copies of specs/bundled/.yml // saved under testdata/ (every line unchanged; checked 2026-11-19), converted -// from YAML to JSON like adapter.Algolia.Fetch, and cited by the real URL. +// from YAML to JSON like Algolia.Fetch, and cited by the real URL. type fakeAlgoliaAdapter struct{ spec string } func (f fakeAlgoliaAdapter) API() string { return "algolia/" + f.spec + "-api" } @@ -51,8 +53,8 @@ func algoliaURL(spec, tag string) string { } // algoliaPlugin is the plugin exactly as registered, over the saved copies. -func algoliaPlugin(spec string) Plugin { - return Plugin{Adapter: fakeAlgoliaAdapter{spec: spec}, Diff: algoliaDiff, Keep: algoliaKeep} +func algoliaPlugin(spec string) openapi.Plugin { + return openapi.Plugin{Adapter: fakeAlgoliaAdapter{spec: spec}, Diff: algoliaDiff, Keep: algoliaKeep} } // The golden tests, one per API with deprecations in its history, each a @@ -75,8 +77,8 @@ func TestAlgoliaGolden(t *testing.T) { } { t.Run(c.spec, func(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, algoliaPlugin(c.spec), c.from, c.to); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, algoliaPlugin(c.spec), c.from, c.to); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) @@ -96,7 +98,7 @@ func TestAlgoliaGolden(t *testing.T) { if c.spec == "search" && !strings.HasPrefix(e.Subject.Operation, "GET /1/clusters") && !strings.HasPrefix(e.Subject.Operation, "POST /1/clusters") && !strings.HasPrefix(e.Subject.Operation, "DELETE /1/clusters") { t.Errorf("unexpected search event %s", e.Subject.Operation) } - if node := yamlNodeJSON(t, algoliaFile(c.spec, c.to), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.YAMLNodeJSON(t, algoliaFile(c.spec, c.to), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt doesn't match %s#%s", e.Subject.Operation, c.to, e.SourcePointer) } } @@ -112,17 +114,17 @@ func TestAlgoliaGolden(t *testing.T) { func TestAlgoliaDropsRemovalsThatWerentDeprecated(t *testing.T) { ctx := context.Background() const from, to = "released-2024-09-18-cc190fae3", "released-2024-09-19-a62c27d3b" - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, algoliaPlugin("ingestion"), from, to); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, algoliaPlugin("ingestion"), from, to); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { t.Fatalf("%d events, want none", len(events)) } - s = openStore(t) + s = kittest.NewMem() p := algoliaPlugin("ingestion") p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, from, to); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, from, to); err != nil { t.Fatal(err) } var removed int @@ -164,17 +166,17 @@ func TestAlgoliaClientOnlyEntriesMakeNoEvent(t *testing.T) { func TestAlgoliaRecommendCustomRequestMoveIsNoEvent(t *testing.T) { ctx := context.Background() const from, to = "released-2024-03-19-2eac6f410", "released-2024-03-25-30207fcd0" - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, algoliaPlugin("recommend"), from, to); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, algoliaPlugin("recommend"), from, to); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { t.Fatalf("%d events, want none", len(events)) } - s = openStore(t) + s = kittest.NewMem() p := algoliaPlugin("recommend") p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, from, to); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, from, to); err != nil { t.Fatal(err) } var removed int diff --git a/providers/algolia/testdata/README.md b/providers/algolia/testdata/README.md new file mode 100644 index 0000000..da8a081 --- /dev/null +++ b/providers/algolia/testdata/README.md @@ -0,0 +1,34 @@ +# Algolia: saved copies and goldens + +Real copies of what Algolia publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/algolia -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `algolia-search-2025-03-25-5c28957ec.yml`, `algolia-search-2025-04-01-c19ee6afb.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2025-03-25-5c28957ec/specs/bundled/search.yml (and `released-2025-04-01-c19ee6afb`) | 2026-11-19 | MIT (algolia/api-clients-automation) | `deprecated: true` under `/1/clusters:` `get:` (new in `2025-04-01`) | +| `algolia-ingestion-2025-01-07-d0417f325.yml`, `algolia-ingestion-2025-01-22-232affcac.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2025-01-07-d0417f325/specs/bundled/ingestion.yml (and `released-2025-01-22-232affcac`) | 2026-11-19 | MIT (algolia/api-clients-automation) | "Retrieves a list of tasks using the v1 endpoint, please use `getTasks` instead." (`GET /1/tasks`) | +| `algolia-recommend-2024-03-19-2eac6f410.yml`, `algolia-recommend-2024-03-25-30207fcd0.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2024-03-19-2eac6f410/specs/bundled/recommend.yml (and `released-2024-03-25-30207fcd0`) | 2026-11-19 | MIT (algolia/api-clients-automation) | `/1{path}:` (in `2024-03-19`), `/{path}:` (in `2024-03-25`): `algolia-recommend`'s drop test | +| `algolia-ingestion-2024-09-18-cc190fae3.yml`, `algolia-ingestion-2024-09-19-a62c27d3b.yml` | https://raw.githubusercontent.com/algolia/api-clients-automation/released-2024-09-18-cc190fae3/specs/bundled/ingestion.yml (and `released-2024-09-19-a62c27d3b`) | 2026-11-19 | MIT (algolia/api-clients-automation) | `/1/transformations/models:` (in `2024-09-18`, never deprecated, gone in `2024-09-19`): the drop test | + +The Algolia copies are trimmed by lines: `openapi`, `info` and the paths involved, every line copied unchanged; `components` left out. + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/algolia-refs.json` | `https://api.github.com/repos/algolia/api-clients-automation/git/matching-refs/tags/released-` | 9 of 186 tags, five of them on two days with several releases | +| `versions/algolia-commit-*.json` | `https://api.github.com/repos/algolia/api-clients-automation/commits/` | `sha` and the committer date | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/algoliasearch/`: `algoliasearch-4.44.1-py3-none-any.trimmed.whl`, `algoliasearch-4.44.3-py3-none-any.trimmed.whl`, `algoliasearch-4.44.4-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/a8/a7/74795993b739e721583653812155f0719159b79268b6eb4452594dc103fa/algoliasearch-4.44.1-py3-none-any.whl; https://files.pythonhosted.org/packages/32/05/84c46d0844055735c1192ba1a0364d871251dbf03e26a465eedf148e63f1/algoliasearch-4.44.3-py3-none-any.whl; https://files.pythonhosted.org/packages/39/53/d20cdf0238aa64a31aaea58e359aa761fe76515a7ff9872c345b5b06eaab/algoliasearch-4.44.4-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `algoliasearch/__init__.py`, `algoliasearch/recommend/__init__.py`, `algoliasearch/recommend/models/__init__.py`, `algoliasearch/recommend/models/facet_filters.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/algoliasearch/`: `pypi-algoliasearch-excerpt.json` and `pypi-algoliasearch-4.44.1.json`, `pypi-algoliasearch-4.44.3.json`, `pypi-algoliasearch-4.44.4.json` | https://pypi.org/pypi/algoliasearch/json, https://pypi.org/pypi/algoliasearch/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | diff --git a/plugins/openapi/testdata/algolia-ingestion-2024-09-18-cc190fae3.yml b/providers/algolia/testdata/algolia-ingestion-2024-09-18-cc190fae3.yml similarity index 100% rename from plugins/openapi/testdata/algolia-ingestion-2024-09-18-cc190fae3.yml rename to providers/algolia/testdata/algolia-ingestion-2024-09-18-cc190fae3.yml diff --git a/plugins/openapi/testdata/algolia-ingestion-2024-09-19-a62c27d3b.yml b/providers/algolia/testdata/algolia-ingestion-2024-09-19-a62c27d3b.yml similarity index 100% rename from plugins/openapi/testdata/algolia-ingestion-2024-09-19-a62c27d3b.yml rename to providers/algolia/testdata/algolia-ingestion-2024-09-19-a62c27d3b.yml diff --git a/plugins/openapi/testdata/algolia-ingestion-2025-01-07-d0417f325.yml b/providers/algolia/testdata/algolia-ingestion-2025-01-07-d0417f325.yml similarity index 100% rename from plugins/openapi/testdata/algolia-ingestion-2025-01-07-d0417f325.yml rename to providers/algolia/testdata/algolia-ingestion-2025-01-07-d0417f325.yml diff --git a/plugins/openapi/testdata/algolia-ingestion-2025-01-22-232affcac.yml b/providers/algolia/testdata/algolia-ingestion-2025-01-22-232affcac.yml similarity index 100% rename from plugins/openapi/testdata/algolia-ingestion-2025-01-22-232affcac.yml rename to providers/algolia/testdata/algolia-ingestion-2025-01-22-232affcac.yml diff --git a/plugins/openapi/testdata/algolia-recommend-2024-03-19-2eac6f410.yml b/providers/algolia/testdata/algolia-recommend-2024-03-19-2eac6f410.yml similarity index 100% rename from plugins/openapi/testdata/algolia-recommend-2024-03-19-2eac6f410.yml rename to providers/algolia/testdata/algolia-recommend-2024-03-19-2eac6f410.yml diff --git a/plugins/openapi/testdata/algolia-recommend-2024-03-25-30207fcd0.yml b/providers/algolia/testdata/algolia-recommend-2024-03-25-30207fcd0.yml similarity index 100% rename from plugins/openapi/testdata/algolia-recommend-2024-03-25-30207fcd0.yml rename to providers/algolia/testdata/algolia-recommend-2024-03-25-30207fcd0.yml diff --git a/plugins/openapi/testdata/algolia-search-2025-03-25-5c28957ec.yml b/providers/algolia/testdata/algolia-search-2025-03-25-5c28957ec.yml similarity index 100% rename from plugins/openapi/testdata/algolia-search-2025-03-25-5c28957ec.yml rename to providers/algolia/testdata/algolia-search-2025-03-25-5c28957ec.yml diff --git a/plugins/openapi/testdata/algolia-search-2025-04-01-c19ee6afb.yml b/providers/algolia/testdata/algolia-search-2025-04-01-c19ee6afb.yml similarity index 100% rename from plugins/openapi/testdata/algolia-search-2025-04-01-c19ee6afb.yml rename to providers/algolia/testdata/algolia-search-2025-04-01-c19ee6afb.yml diff --git a/plugins/openapi/testdata/golden/algolia-ingestion.json b/providers/algolia/testdata/golden/algolia-ingestion.json similarity index 100% rename from plugins/openapi/testdata/golden/algolia-ingestion.json rename to providers/algolia/testdata/golden/algolia-ingestion.json diff --git a/plugins/apisurface/testdata/golden/algolia-python-surface.json b/providers/algolia/testdata/golden/algolia-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/algolia-python-surface.json rename to providers/algolia/testdata/golden/algolia-python-surface.json diff --git a/plugins/openapi/testdata/golden/algolia-search.json b/providers/algolia/testdata/golden/algolia-search.json similarity index 100% rename from plugins/openapi/testdata/golden/algolia-search.json rename to providers/algolia/testdata/golden/algolia-search.json diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/algoliasearch-4.44.1-py3-none-any.trimmed.whl b/providers/algolia/testdata/pypi/algoliasearch/algoliasearch-4.44.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/algoliasearch-4.44.1-py3-none-any.trimmed.whl rename to providers/algolia/testdata/pypi/algoliasearch/algoliasearch-4.44.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/algoliasearch-4.44.3-py3-none-any.trimmed.whl b/providers/algolia/testdata/pypi/algoliasearch/algoliasearch-4.44.3-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/algoliasearch-4.44.3-py3-none-any.trimmed.whl rename to providers/algolia/testdata/pypi/algoliasearch/algoliasearch-4.44.3-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/algoliasearch-4.44.4-py3-none-any.trimmed.whl b/providers/algolia/testdata/pypi/algoliasearch/algoliasearch-4.44.4-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/algoliasearch-4.44.4-py3-none-any.trimmed.whl rename to providers/algolia/testdata/pypi/algoliasearch/algoliasearch-4.44.4-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.1.json b/providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.1.json rename to providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.1.json diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.3.json b/providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.3.json similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.3.json rename to providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.3.json diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.4.json b/providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.4.json similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.4.json rename to providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-4.44.4.json diff --git a/plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-excerpt.json b/providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/algoliasearch/pypi-algoliasearch-excerpt.json rename to providers/algolia/testdata/pypi/algoliasearch/pypi-algoliasearch-excerpt.json diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json b/providers/algolia/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json rename to providers/algolia/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json b/providers/algolia/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json rename to providers/algolia/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json b/providers/algolia/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json rename to providers/algolia/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json b/providers/algolia/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json rename to providers/algolia/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json b/providers/algolia/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json rename to providers/algolia/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json diff --git a/plugins/openapi/adapter/testdata/versions/algolia-refs.json b/providers/algolia/testdata/versions/algolia-refs.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/algolia-refs.json rename to providers/algolia/testdata/versions/algolia-refs.json diff --git a/providers/all/all.go b/providers/all/all.go new file mode 100644 index 0000000..d65e3b8 --- /dev/null +++ b/providers/all/all.go @@ -0,0 +1,33 @@ +// Package all imports every provider, so each registers itself: a program +// that runs sources imports this one package. A new provider's package is +// added here (TestEveryProviderIsImported fails until it is). +package all + +import ( + _ "github.com/patch-it-dev/patch-it-plugins/providers/algolia" + _ "github.com/patch-it-dev/patch-it-plugins/providers/anthropic" + _ "github.com/patch-it-dev/patch-it-plugins/providers/appwrite" + _ "github.com/patch-it-dev/patch-it-plugins/providers/cloudflare" + _ "github.com/patch-it-dev/patch-it-plugins/providers/convex" + _ "github.com/patch-it-dev/patch-it-plugins/providers/datadog" + _ "github.com/patch-it-dev/patch-it-plugins/providers/elastic" + _ "github.com/patch-it-dev/patch-it-plugins/providers/flagsmith" + _ "github.com/patch-it-dev/patch-it-plugins/providers/github" + _ "github.com/patch-it-dev/patch-it-plugins/providers/gitlab" + _ "github.com/patch-it-dev/patch-it-plugins/providers/google" + _ "github.com/patch-it-dev/patch-it-plugins/providers/mongodb" + _ "github.com/patch-it-dev/patch-it-plugins/providers/neon" + _ "github.com/patch-it-dev/patch-it-plugins/providers/newrelic" + _ "github.com/patch-it-dev/patch-it-plugins/providers/numpy" + _ "github.com/patch-it-dev/patch-it-plugins/providers/openai" + _ "github.com/patch-it-dev/patch-it-plugins/providers/planetscale" + _ "github.com/patch-it-dev/patch-it-plugins/providers/posthog" + _ "github.com/patch-it-dev/patch-it-plugins/providers/redis" + _ "github.com/patch-it-dev/patch-it-plugins/providers/salesforce" + _ "github.com/patch-it-dev/patch-it-plugins/providers/sentry" + _ "github.com/patch-it-dev/patch-it-plugins/providers/stripe" + _ "github.com/patch-it-dev/patch-it-plugins/providers/supabase" + _ "github.com/patch-it-dev/patch-it-plugins/providers/textual" + _ "github.com/patch-it-dev/patch-it-plugins/providers/urllib3" + _ "github.com/patch-it-dev/patch-it-plugins/providers/vercel" +) diff --git a/providers/all/all_test.go b/providers/all/all_test.go new file mode 100644 index 0000000..92a8419 --- /dev/null +++ b/providers/all/all_test.go @@ -0,0 +1,266 @@ +package all + +import ( + "go/ast" + "go/parser" + "go/token" + "io/fs" + "os" + "path/filepath" + "slices" + "strconv" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" +) + +const module = "github.com/patch-it-dev/patch-it-plugins/" + +// providerDirs are the folders under providers/, one per provider. +func providerDirs(t *testing.T) []string { + t.Helper() + entries, err := os.ReadDir("..") + if err != nil { + t.Fatal(err) + } + var out []string + for _, e := range entries { + if e.IsDir() && e.Name() != "all" { + out = append(out, e.Name()) + } + } + if len(out) == 0 { + t.Fatal("found no provider folder next to this one") + } + return out +} + +// Every provider folder is imported here, so a program importing all runs +// its sources, and registers exactly its own provider, in its provider.go. +func TestEveryProviderIsImported(t *testing.T) { + f, err := parser.ParseFile(token.NewFileSet(), "all.go", nil, parser.ImportsOnly) + if err != nil { + t.Fatal(err) + } + var imported []string + for _, imp := range f.Imports { + path, _ := strconv.Unquote(imp.Path.Value) + imported = append(imported, strings.TrimPrefix(path, module+"providers/")) + } + registered := map[string]bool{} + for _, p := range plugin.Providers() { + registered[p.ID] = true + } + for _, dir := range providerDirs(t) { + if !slices.Contains(imported, dir) { + t.Errorf("providers/%s isn't imported by all.go", dir) + } + if !registered[dir] { + t.Errorf("providers/%s registers no provider %q (its provider.go calls plugin.RegisterProvider with ID %q)", dir, dir, dir) + } + if ids := registeredIDs(t, filepath.Join("..", dir)); !slices.Equal(ids, []string{dir}) { + t.Errorf("providers/%s: plugin.RegisterProvider is called for %v, want once, for %q, in provider.go", dir, ids, dir) + } + } + for id := range registered { + if !slices.Contains(providerDirs(t), id) { + t.Errorf("provider %q is registered, but there's no providers/%s/", id, id) + } + } +} + +// registeredIDs are the provider IDs a provider's folder registers: the ID +// in each plugin.RegisterProvider call of its non-test code, which must be +// in provider.go. +func registeredIDs(t *testing.T, dir string) []string { + t.Helper() + files, err := filepath.Glob(filepath.Join(dir, "*.go")) + if err != nil { + t.Fatal(err) + } + var ids []string + for _, name := range files { + if strings.HasSuffix(name, "_test.go") { + continue + } + f, err := parser.ParseFile(token.NewFileSet(), name, nil, 0) + if err != nil { + t.Fatal(err) + } + ast.Inspect(f, func(n ast.Node) bool { + call, ok := n.(*ast.CallExpr) + if !ok || !isSelector(call.Fun, "plugin", "RegisterProvider") { + return true + } + if filepath.Base(name) != "provider.go" { + t.Errorf("%s calls plugin.RegisterProvider: only provider.go does", name) + } + ids = append(ids, providerID(call)) + return true + }) + } + return ids +} + +func isSelector(e ast.Expr, pkg, name string) bool { + sel, ok := e.(*ast.SelectorExpr) + if !ok || sel.Sel.Name != name { + return false + } + id, ok := sel.X.(*ast.Ident) + return ok && id.Name == pkg +} + +// providerID is the ID field of a RegisterProvider call's literal, or "?". +func providerID(call *ast.CallExpr) string { + if len(call.Args) != 1 { + return "?" + } + lit, ok := call.Args[0].(*ast.CompositeLit) + if !ok { + return "?" + } + for _, el := range lit.Elts { + kv, ok := el.(*ast.KeyValueExpr) + if !ok { + continue + } + if k, ok := kv.Key.(*ast.Ident); ok && k.Name == "ID" { + if v, ok := kv.Value.(*ast.BasicLit); ok { + s, _ := strconv.Unquote(v.Value) + return s + } + } + } + return "?" +} + +// Importing all registers plugins, under unique names, sorted. +func TestImportingAllRegistersThePlugins(t *testing.T) { + names := plugin.Names() + if len(names) == 0 { + t.Fatal("no plugin registered") + } + if !slices.IsSorted(names) || len(slices.Compact(slices.Clone(names))) != len(names) { + t.Errorf("names %v: want sorted and unique", names) + } +} + +// Every registered source has complete metadata (RegisterProvider checks the +// fields), is found by its id, and its provider's page exists and names it. +func TestEverySourceHasMetadata(t *testing.T) { + for _, s := range plugin.Sources() { + page, err := os.ReadFile(filepath.Join("..", "..", s.Source.Page)) + if err != nil { + t.Errorf("%s: its provider's page %s doesn't exist (copy docs/provider-template.md)", s.FullID(), s.Source.Page) + } else if !strings.Contains(string(page), "`"+s.FullID()+"`") { + t.Errorf("%s: its provider's page %s doesn't name it (`%s`)", s.FullID(), s.Source.Page, s.FullID()) + } + if p, ok := plugin.Lookup(s.FullID()); !ok || p.Name() != s.FullID() { + t.Errorf("Lookup(%q) didn't find it", s.FullID()) + } + } + if len(plugin.Names()) != len(plugin.Sources()) { + t.Errorf("%d plugins, %d sources", len(plugin.Names()), len(plugin.Sources())) + } +} + +// Every registered source's kind is an answer of docs/which-kind.md, so the +// guide sends every source somewhere. +func TestWhichKindNamesEveryKind(t *testing.T) { + guide, err := os.ReadFile("../../docs/which-kind.md") + if err != nil { + t.Fatal(err) + } + for _, s := range plugin.Sources() { + if !strings.Contains(string(guide), "| `"+s.Source.Kind+"` |") { + t.Errorf("%s's kind, %s, isn't an answer in docs/which-kind.md", s.FullID(), s.Source.Kind) + } + } +} + +// Every package under kinds/ is a kind (kinds/, whose plugin type +// every source of that kind runs) or a part of one (kinds///, +// or its test helpers); none registers a provider, and none only forwards +// to another package (type aliases and re-exported values, no code of its +// own). Nor does any provider's. +func TestKindsReadAndProvidersSayWhat(t *testing.T) { + kinds := map[string]bool{} + for _, s := range plugin.Sources() { + kinds[s.Source.Kind] = true + } + entries, err := os.ReadDir("../../kinds") + if err != nil { + t.Fatal(err) + } + for _, e := range entries { + if e.IsDir() && !kinds[e.Name()] { + t.Errorf("kinds/%s: no registered source is of this kind", e.Name()) + } + } + for _, root := range []string{"../../kinds", ".."} { + err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error { + if err != nil || !d.IsDir() { + return err + } + if d.Name() == "testdata" { + return filepath.SkipDir + } + if root == "../../kinds" && len(registeredIDs(t, p)) > 0 { + t.Errorf("%s registers a provider: a provider registers itself, in providers//provider.go", p) + } + if forwardsOnly(t, p) { + t.Errorf("%s only forwards to another package: import that package instead", p) + } + return nil + }) + if err != nil { + t.Fatal(err) + } + } +} + +// forwardsOnly reports whether a package's non-test code is nothing but type +// aliases and values copied from other packages. +func forwardsOnly(t *testing.T, dir string) bool { + t.Helper() + files, err := filepath.Glob(filepath.Join(dir, "*.go")) + if err != nil { + t.Fatal(err) + } + decls := 0 + for _, f := range files { + if strings.HasSuffix(f, "_test.go") { + continue + } + file, err := parser.ParseFile(token.NewFileSet(), f, nil, 0) + if err != nil { + t.Fatal(err) + } + for _, decl := range file.Decls { + g, ok := decl.(*ast.GenDecl) + if !ok { + return false // a func: code of its own + } + for _, spec := range g.Specs { + switch s := spec.(type) { + case *ast.ImportSpec: + continue + case *ast.TypeSpec: + if !s.Assign.IsValid() { + return false + } + case *ast.ValueSpec: + for _, v := range s.Values { + if _, sel := v.(*ast.SelectorExpr); !sel { + return false + } + } + } + decls++ + } + } + } + return decls > 0 +} diff --git a/providers/all/imports_test.go b/providers/all/imports_test.go new file mode 100644 index 0000000..885c4a6 --- /dev/null +++ b/providers/all/imports_test.go @@ -0,0 +1,103 @@ +package all + +import ( + "go/parser" + "go/token" + "io/fs" + "path/filepath" + "strconv" + "strings" + "testing" +) + +// The import graph, tests included: core/ knows no kind and no provider; a +// kind (how to read) knows no provider; a provider (what to read) imports +// only core/ and kinds/, never another provider. Only this package, and the +// commands through it, imports every provider. A test kit (kittest, a +// kind's test) is imported by tests and other test kits only, so what +// it may do (openapitest's net/http) never reaches code that runs. +func TestTheImportGraph(t *testing.T) { + top, err := filepath.Abs("../..") + if err != nil { + t.Fatal(err) + } + checked := 0 + for _, root := range []string{"../../core", "../../kinds", ".."} { + err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() && d.Name() == "testdata" { + return filepath.SkipDir + } + if d.IsDir() || !strings.HasSuffix(p, ".go") { + return nil + } + abs, err := filepath.Abs(p) + if err != nil { + return err + } + rel, err := filepath.Rel(top, abs) + if err != nil { + return err + } + rel = filepath.ToSlash(rel) + if strings.HasPrefix(rel, "providers/all/") { + return nil + } + f, err := parser.ParseFile(token.NewFileSet(), p, nil, parser.ImportsOnly) + if err != nil { + return err + } + checked++ + for _, imp := range f.Imports { + path, _ := strconv.Unquote(imp.Path.Value) + if why := forbidden(rel, path); why != "" { + t.Errorf("%s imports %s: %s", rel, path, why) + } + } + return nil + }) + if err != nil { + t.Fatal(err) + } + } + if checked < 100 { + t.Fatalf("checked %d files: the walk found too little to guard anything", checked) + } +} + +// forbidden is why file (a path from the repo's root) may not import path, +// or "". +func forbidden(file, path string) string { + pkg, ok := strings.CutPrefix(path, module) + if !ok { + return "" + } + if testKit(pkg) && !strings.HasSuffix(file, "_test.go") && !testKit(filepath.ToSlash(filepath.Dir(file))) { + return "a test kit is for tests (and other test kits) only" + } + switch top, _, _ := strings.Cut(file, "/"); top { + case "core": + if strings.HasPrefix(pkg, "kinds/") || strings.HasPrefix(pkg, "providers/") { + return "core/ knows no kind and no provider" + } + case "kinds": + if strings.HasPrefix(pkg, "providers/") { + return "a kind says how to read, never what: it imports no provider" + } + case "providers": + own := strings.SplitN(file, "/", 3)[1] + if !strings.HasPrefix(pkg, "core/") && !strings.HasPrefix(pkg, "kinds/") && pkg != "providers/"+own { + return "a provider imports only core/ and kinds/, never another provider" + } + } + return "" +} + +// testKit reports whether a package (a path from the repo's root) is a test +// kit: core/kit/kittest, or a kind's kinds//test. +func testKit(pkg string) bool { + parts := strings.Split(pkg, "/") + return pkg == "core/kit/kittest" || (len(parts) == 3 && parts[0] == "kinds" && parts[2] == parts[1]+"test") +} diff --git a/plugins/all/pins_test.go b/providers/all/pins_test.go similarity index 73% rename from plugins/all/pins_test.go rename to providers/all/pins_test.go index 62fd2a1..d90d64b 100644 --- a/plugins/all/pins_test.go +++ b/providers/all/pins_test.go @@ -18,12 +18,20 @@ import ( // commits); only a test pins one, through its saved fixtures. var release = regexp.MustCompile(`(^|[^0-9A-Za-z.])v?\d+\.\d+\.\d+([^0-9]|$)|(^|[^0-9a-f])[0-9a-f]{40}([^0-9a-f]|$)`) -// No plugin's code names a specific release or commit: every version comes -// from where the source publishes them. Comments may name the release a -// reader was checked at; a string the code uses may not. +// No kind's or provider's code names a specific release or commit: every +// version comes from where the source publishes them. Comments may name the +// release a reader was checked at; a string the code uses may not. func TestNoPinnedReleaseInPluginCode(t *testing.T) { fset := token.NewFileSet() - err := filepath.WalkDir("..", func(path string, d fs.DirEntry, err error) error { + for _, root := range []string{"../../kinds", ".."} { + walkGo(t, fset, root) + } +} + +// walkGo checks every non-test Go file under root. +func walkGo(t *testing.T, fset *token.FileSet, root string) { + t.Helper() + err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error { if err != nil { return err } diff --git a/providers/anthropic-models.md b/providers/anthropic-models.md deleted file mode 100644 index 56ee9fc..0000000 --- a/providers/anthropic-models.md +++ /dev/null @@ -1,29 +0,0 @@ -# Anthropic model retirements (`anthropic/models`) - -## What it watches - -Claude models that are retired or have a retirement date on the Claude API, with the replacement Anthropic recommends. One breaking event per model name. - -Kind: `notices` (`plugins/notices`), reading with the deprecations-page reader, `plugins/notices/retire/`. - -## Why this source - -- **Source:** [platform.claude.com/docs/en/about-claude/model-deprecations](https://platform.claude.com/docs/en/about-claude/model-deprecations), read as markdown at the same URL plus `.md`. Checked on 2026-10-13. -- **Why this one:** it's Anthropic's own deprecation history, one table per announcement (retirement date, deprecated model, recommended replacement), served as markdown. `robots.txt` disallows only `/api/`. -- **Alternatives considered:** the models API (`GET /v1/models`: what exists now, no dates); release notes and emails (not a complete list); the old docs.anthropic.com URL (redirects here). -- **Quote:** "| November 30, 2026 | `claude-sonnet-4-5-20250929` | `claude-sonnet-5-5` |" (Deprecation history, 2026-09-30: Claude Sonnet 4.5 model). - -## How the provider announces changes - -- A few announcements a year, at least 60 days before retirement (per the page). -- **Forced, by date**, on the Claude API: the event's `version` is the retirement date. Amazon Bedrock and Google Cloud set their own dates, so code calling Claude through them may be affected on a different day. - -## What the plugin reads and ignores - -- Same reader as [`openai-models`](openai-models.md): every dated table with a model and a replacement column, newest row wins, retired replacements followed, every event read from and citing a Wayback snapshot. -- Keeps every `claude-` name. Ignores the "Model status" table (active models with tentative dates) and any model without a date yet. - -## Known gaps - -- Retirements on Amazon Bedrock or Google Cloud aren't on this page. -- The page also documents SDK changes (the Python SDK 1.0 removing sampling parameters); those are the [`anthropic`](anthropic.md) plugin, not this one. diff --git a/providers/anthropic-python-surface.md b/providers/anthropic-python-surface.md deleted file mode 100644 index 5bfe49a..0000000 --- a/providers/anthropic-python-surface.md +++ /dev/null @@ -1,35 +0,0 @@ -# Anthropic Python SDK (`anthropic/python-surface`) - -## What it watches - -The public API of the `anthropic` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install anthropic==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** the repo's CHANGELOG.md (commit titles, read by the `changelog` kind where registered); the migration guide (`anthropic/python-sdk`, kind `migrationguide`: majors only); there is no public OpenAPI spec. -- **Quote:** `class BetaBillingFrozenError(PermissionDeniedError)` (`anthropic/types/beta/beta_billing_frozen_error.py` line 9) at 2.6.0, gone at 2.7.0. - -## How the provider announces changes - -- The SDK is generated from Anthropic's API definition and released every week or two; beta types come and go with the betas. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `anthropic/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/providers/anthropic-typescript-surface.md b/providers/anthropic-typescript-surface.md deleted file mode 100644 index a4272c7..0000000 --- a/providers/anthropic-typescript-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# Anthropic TypeScript SDK (`anthropic/typescript-surface`) - -## What it watches - -The public API of the `@anthropic-ai/sdk` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @anthropic-ai/sdk@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md (commit titles); the migration guide (majors only). -- **Quote:** `class BetaBillingFrozenError extends PermissionDeniedError` (`resources/beta/organization/organization.d.mts` line 45) at 1.6.0, gone at 1.7.0. - -## How the provider announces changes - -- Generated from Anthropic's API definition and released every week or two; beta types come and go with the betas. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@anthropic-ai/sdk/resources/messages.Messages.create`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- The client re-exports every resource through its namespaces, so one removed class has many paths (16 for `BetaBillingFrozenError`), all in one event. diff --git a/providers/anthropic.md b/providers/anthropic.md deleted file mode 100644 index 6b10823..0000000 --- a/providers/anthropic.md +++ /dev/null @@ -1,31 +0,0 @@ -# Anthropic Python SDK (`anthropic/python-sdk`) - -## What it watches - -Request parameters removed from `messages.create()` and its siblings in anthropic-sdk-python 1.0.0 (`temperature`, `top_p`, `top_k`): passing one is a `TypeError`. One breaking event per parameter. Pinned to that release. - -Kind: `migrationguide` (`plugins/migrationguide`), reading with `plugins/migrationguide/sdkguide/`. - -## Why this source - -- **Source:** MIGRATION.md at the first release of each major ([at v1.0.0](https://github.com/anthropics/anthropic-sdk-python/blob/v1.0.0/MIGRATION.md)), the majors listed from PyPI; read raw at the tag (`https://raw.githubusercontent.com/anthropics/anthropic-sdk-python/v1.0.0/MIGRATION.md`). Checked on 2026-10-17. -- **Why this one:** it's the SDK maintainers' own guide to the major release, with a table of the methods, the removed parameter and what to use instead. A tag never changes, so the URL is its own permanent citation. -- **Alternatives considered:** the GitHub release notes and `CHANGELOG.md` (list commits, not "what to use instead"); diffing the SDK's code between versions (finds signature changes but not the maintainers' advice, and is a lot more machinery); Anthropic's model deprecations page (mentions the change, but it's the models page). -- **Quote:** "Removed: deprecated request parameters" (section heading), with the row "`temperature`, `top_p`, `top_k` | Remove them." - -## How the provider announces changes - -- Package versions (PEP 440). 1.0.0 shipped on 2026-08-20. -- **Forced on a fresh install** for a repo whose `anthropic` pin is open above 1.0, otherwise when the team upgrades. -- The fix works on both sides of the upgrade: removing the parameter is right for current models, and `extra_body` passes it through for an older one. - -## What the plugin reads and ignores - -- The guide must be the "Migrating to v1" guide. Every table with a "Removed parameter" and a "Use instead" column; a row counts only when its method cell names the plain `messages.create()`. -- Ignores the beta-only `output_format` row: `output_format=Model` is still valid on the `parse()` / `stream()` helpers, so it isn't a removal everywhere. -- `migration_hint` is the guide's "Use instead" cell, as written. - -## Known gaps - -- Only 1.0.0. A later major's guide is a new entry. -- Removed type aliases, exports and helper arguments in the same guide aren't events yet. diff --git a/providers/anthropic/README.md b/providers/anthropic/README.md new file mode 100644 index 0000000..7bfe44f --- /dev/null +++ b/providers/anthropic/README.md @@ -0,0 +1,139 @@ +# Anthropic + +Every source patch-it reads for Anthropic, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Anthropic Python SDK (`anthropic/python-sdk`) + +### What it watches + +Request parameters removed from `messages.create()` and its siblings in anthropic-sdk-python 1.0.0 (`temperature`, `top_p`, `top_k`): passing one is a `TypeError`. One breaking event per parameter. Pinned to that release. + +Kind: `migrationguide` (`kinds/migrationguide`), reading with `kinds/migrationguide/sdkguide/`. + +### Why this source + +- **Source:** MIGRATION.md at the first release of each major ([at v1.0.0](https://github.com/anthropics/anthropic-sdk-python/blob/v1.0.0/MIGRATION.md)), the majors listed from PyPI; read raw at the tag (`https://raw.githubusercontent.com/anthropics/anthropic-sdk-python/v1.0.0/MIGRATION.md`). Checked on 2026-10-17. +- **Why this one:** it's the SDK maintainers' own guide to the major release, with a table of the methods, the removed parameter and what to use instead. A tag never changes, so the URL is its own permanent citation. +- **Alternatives considered:** the GitHub release notes and `CHANGELOG.md` (list commits, not "what to use instead"); diffing the SDK's code between versions (finds signature changes but not the maintainers' advice, and is a lot more machinery); Anthropic's model deprecations page (mentions the change, but it's the models page). +- **Quote:** "Removed: deprecated request parameters" (section heading), with the row "`temperature`, `top_p`, `top_k` | Remove them." + +### How the provider announces changes + +- Package versions (PEP 440). 1.0.0 shipped on 2026-08-20. +- **Forced on a fresh install** for a repo whose `anthropic` pin is open above 1.0, otherwise when the team upgrades. +- The fix works on both sides of the upgrade: removing the parameter is right for current models, and `extra_body` passes it through for an older one. + +### What the plugin reads and ignores + +- The guide must be the "Migrating to v1" guide. Every table with a "Removed parameter" and a "Use instead" column; a row counts only when its method cell names the plain `messages.create()`. +- Ignores the beta-only `output_format` row: `output_format=Model` is still valid on the `parse()` / `stream()` helpers, so it isn't a removal everywhere. +- `migration_hint` is the guide's "Use instead" cell, as written. + +### Known gaps + +- Only 1.0.0. A later major's guide is a new entry. +- Removed type aliases, exports and helper arguments in the same guide aren't events yet. + +## Anthropic model retirements (`anthropic/models`) + +### What it watches + +Claude models that are retired or have a retirement date on the Claude API, with the replacement Anthropic recommends. One breaking event per model name. + +Kind: `notices` (`kinds/notices`), reading with the deprecations-page reader, `kinds/notices/retire/`. + +### Why this source + +- **Source:** [platform.claude.com/docs/en/about-claude/model-deprecations](https://platform.claude.com/docs/en/about-claude/model-deprecations), read as markdown at the same URL plus `.md`. Checked on 2026-10-13. +- **Why this one:** it's Anthropic's own deprecation history, one table per announcement (retirement date, deprecated model, recommended replacement), served as markdown. `robots.txt` disallows only `/api/`. +- **Alternatives considered:** the models API (`GET /v1/models`: what exists now, no dates); release notes and emails (not a complete list); the old docs.anthropic.com URL (redirects here). +- **Quote:** "| November 30, 2026 | `claude-sonnet-4-5-20250929` | `claude-sonnet-5-5` |" (Deprecation history, 2026-09-30: Claude Sonnet 4.5 model). + +### How the provider announces changes + +- A few announcements a year, at least 60 days before retirement (per the page). +- **Forced, by date**, on the Claude API: the event's `version` is the retirement date. Amazon Bedrock and Google Cloud set their own dates, so code calling Claude through them may be affected on a different day. + +### What the plugin reads and ignores + +- Same reader as [`openai/models`](../openai/README.md#openai-model-retirements-openaimodels): every dated table with a model and a replacement column, newest row wins, retired replacements followed, every event read from and citing a Wayback snapshot. +- Keeps every `claude-` name. Ignores the "Model status" table (active models with tentative dates) and any model without a date yet. + +### Known gaps + +- Retirements on Amazon Bedrock or Google Cloud aren't on this page. +- The page also documents SDK changes (the Python SDK 1.0 removing sampling parameters); those are the [`anthropic/python-sdk`](#anthropic-python-sdk-anthropicpython-sdk) source, not this one. + +## Anthropic Python SDK's public API (`anthropic/python-surface`) + +### What it watches + +The public API of the `anthropic` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install anthropic==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** the repo's CHANGELOG.md (commit titles, read by the `changelog` kind where registered); the migration guide (`anthropic/python-sdk`, kind `migrationguide`: majors only); there is no public OpenAPI spec. +- **Quote:** `class BetaBillingFrozenError(PermissionDeniedError)` (`anthropic/types/beta/beta_billing_frozen_error.py` line 9) at 2.6.0, gone at 2.7.0. + +### How the provider announces changes + +- The SDK is generated from Anthropic's API definition and released every week or two; beta types come and go with the betas. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `anthropic/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. + +## Anthropic TypeScript SDK (`anthropic/typescript-surface`) + +### What it watches + +The public API of the `@anthropic-ai/sdk` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @anthropic-ai/sdk@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md (commit titles); the migration guide (majors only). +- **Quote:** `class BetaBillingFrozenError extends PermissionDeniedError` (`resources/beta/organization/organization.d.mts` line 45) at 1.6.0, gone at 1.7.0. + +### How the provider announces changes + +- Generated from Anthropic's API definition and released every week or two; beta types come and go with the betas. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@anthropic-ai/sdk/resources/messages.Messages.create`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- The client re-exports every resource through its namespaces, so one removed class has many paths (16 for `BetaBillingFrozenError`), all in one event. diff --git a/providers/anthropic/models_test.go b/providers/anthropic/models_test.go new file mode 100644 index 0000000..b0f964e --- /dev/null +++ b/providers/anthropic/models_test.go @@ -0,0 +1,78 @@ +package anthropic + +import ( + "os" + "testing" + "time" + + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" +) + +func TestAnthropicsRetirements(t *testing.T) { + got := byModel(t, Models, "anthropic-deprecations.md") + want := map[string][2]string{ + "claude-sonnet-4-5-20250929": {"2026-11-30", "claude-sonnet-5-5"}, + "claude-opus-4-1-20250805": {"2026-08-05", "claude-opus-4-8"}, + "claude-3-opus-20240229": {"2026-01-05", "claude-opus-4-8"}, + "claude-3-5-sonnet-20241022": {"2025-10-28", "claude-sonnet-5-5"}, + "claude-3-haiku-20240307": {"2026-04-20", "claude-haiku-4-5-20251001"}, + } + for m, w := range want { + if r := got[m]; r.Date != w[0] || retire.First(r.Replacement) != w[1] { + t.Errorf("%s: got %+v, want %v", m, r, w) + } + } + if len(got) != 20 { + t.Errorf("%d retired Claude models, want 20", len(got)) + } + if _, ok := got["claude-mythos-preview"]; ok { + t.Error("a model with no retirement date yet is not an event") + } +} + +// Anthropic's saved page (2026-10-13, testdata/README.md) in, every event out. +func TestModelsGolden(t *testing.T) { + noticestest.Golden(t, Models, "testdata/anthropic-deprecations.md") +} + +func read(t *testing.T, name string) []byte { + t.Helper() + b, err := os.ReadFile("testdata/" + name) + if err != nil { + t.Fatal(err) + } + return b +} + +func byModel(t *testing.T, p retire.Page, file string) map[string]retire.Retirement { + t.Helper() + rs, err := retire.Parse(read(t, file), p.Keep) + if err != nil { + t.Fatal(err) + } + out := map[string]retire.Retirement{} + for _, r := range rs { + if _, dup := out[r.Model]; dup { + t.Fatalf("%s listed twice", r.Model) + } + out[r.Model] = r + } + return out +} + +func TestEveryRealRetirementBecomesValidEvents(t *testing.T) { + for _, c := range []struct { + p retire.Page + file string + }{{Models, "anthropic-deprecations.md"}} { + rs, err := retire.Parse(read(t, c.file), c.p.Keep) + if err != nil { + t.Fatal(err) + } + events, errs := retire.Events(c.p, rs, "https://web.archive.org/web/1/x", time.Now()) + if len(errs) != 0 || len(events) != len(rs) { + t.Errorf("%s: %d events from %d retirements, errors %v", c.p.API, len(events), len(rs), errs) + } + } +} diff --git a/providers/anthropic/provider.go b/providers/anthropic/provider.go new file mode 100644 index 0000000..85fd37a --- /dev/null +++ b/providers/anthropic/provider.go @@ -0,0 +1,66 @@ +// Package anthropic is what patch-it reads for Anthropic: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package anthropic + +import ( + "strings" + + "github.com/patch-it-dev/patch-it-plugins/core/kit" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/sdkguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "anthropic", Name: "Anthropic", Category: plugin.CategoryAI, Homepage: "https://www.anthropic.com", + Sources: []plugin.Source{ + { + ID: "models", Layer: plugin.LayerAIModels, + Watches: "Model deprecations and retirement dates (Messages API models)", + URLs: []string{"https://platform.claude.com/docs/en/about-claude/model-deprecations"}, + Packages: []string{"pypi:anthropic", "npm:@anthropic-ai/sdk"}, + Plugin: notices.Plugin{Page: Models, Archiver: kit.Wayback{}}, + }, + { + ID: "python-sdk", Layer: plugin.LayerSDK, + Watches: "Request parameters each new major of the Python SDK removes from `messages.create()` and friends, from MIGRATION.md at the major's tag", + URLs: []string{"https://github.com/anthropics/anthropic-sdk-python/blob/main/MIGRATION.md", "https://pypi.org/project/anthropic/"}, + Packages: []string{"pypi:anthropic"}, + Plugin: migrationguide.Plugin{Guide: PythonSDK}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/anthropics/anthropic-sdk-python"), + apisurface.NPM(TypescriptSurface, "https://github.com/anthropics/anthropic-sdk-typescript"), + }, + }) +} + +// Models is Anthropic's model deprecations page (checked 2026-10-13): every model in +// its deprecation history is a Messages API model. +var Models = retire.Page{ + API: "anthropic/models", + Provider: "anthropic", + Vendor: "Anthropic", + URL: "https://platform.claude.com/docs/en/about-claude/model-deprecations.md", + Keep: func(name string) bool { return strings.HasPrefix(name, "claude-") }, +} + +// PythonSDK is anthropic-sdk-python's MIGRATION.md, unpinned: read at the +// first release of each major (Major 0; At pins it). +var PythonSDK = sdkguide.Guide{ + API: "anthropic/python-sdk", + Package: "anthropic", + Repo: "anthropics/anthropic-sdk-python", + Methods: "`messages.create()`", + Symbols: []string{"messages.create", "messages.stream", "messages.parse"}, +} + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "anthropic/python-surface", Name: "anthropic", Ecosystem: "pypi", Module: "anthropic"} + TypescriptSurface = apisurface.NPMPackage("anthropic/typescript-surface", "@anthropic-ai/sdk") +) diff --git a/plugins/migrationguide/sdkguide/sdkguide_test.go b/providers/anthropic/python_sdk_guide_test.go similarity index 78% rename from plugins/migrationguide/sdkguide/sdkguide_test.go rename to providers/anthropic/python_sdk_guide_test.go index 6c80392..ba869fb 100644 --- a/plugins/migrationguide/sdkguide/sdkguide_test.go +++ b/providers/anthropic/python_sdk_guide_test.go @@ -1,4 +1,4 @@ -package sdkguide +package anthropic import ( "errors" @@ -9,6 +9,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/sdkguide" ) func guide(t *testing.T) []byte { @@ -23,7 +24,7 @@ func guide(t *testing.T) []byte { // anthropic-sdk-python's MIGRATION.md at v1.0.0 (saved 2026-10-17): the three // sampling parameters, not the beta-only `output_format` row. func TestAnthropicV1RemovesTheSamplingParameters(t *testing.T) { - rs, err := Parse(guide(t), AnthropicV1) + rs, err := sdkguide.Parse(guide(t), PythonSDK.At(1)) if err != nil { t.Fatal(err) } @@ -43,19 +44,19 @@ func TestAnthropicV1RemovesTheSamplingParameters(t *testing.T) { } func TestAnotherMajorsGuideOrNoRowIsAnError(t *testing.T) { - v2 := AnthropicV1 + v2 := PythonSDK.At(1) v2.Major = 2 - if _, err := Parse(guide(t), v2); !errors.Is(err, plugin.ErrNothingToRead) { + if _, err := sdkguide.Parse(guide(t), v2); !errors.Is(err, plugin.ErrNothingToRead) { t.Errorf("the v1 guide read as v2's: %v, want plugin.ErrNothingToRead", err) } - if _, err := Parse([]byte("# Migrating to v1\n\nNothing removed.\n"), AnthropicV1); !errors.Is(err, plugin.ErrNothingToRead) { + if _, err := sdkguide.Parse([]byte("# Migrating to v1\n\nNothing removed.\n"), PythonSDK.At(1)); !errors.Is(err, plugin.ErrNothingToRead) { t.Errorf("no table must be plugin.ErrNothingToRead, not zero events: %v", err) } } func TestEventsAreValidAndCiteTheTag(t *testing.T) { - rs, _ := Parse(guide(t), AnthropicV1) - events, errs := Events(AnthropicV1, rs, "0.75.0", time.Date(2026, 10, 17, 0, 0, 0, 0, time.UTC)) + rs, _ := sdkguide.Parse(guide(t), PythonSDK.At(1)) + events, errs := sdkguide.Events(PythonSDK.At(1), rs, "0.75.0", time.Date(2026, 10, 17, 0, 0, 0, 0, time.UTC)) if len(errs) != 0 || len(events) != 3 { t.Fatalf("%d events, %v", len(events), errs) } diff --git a/plugins/migrationguide/migrationguide_test.go b/providers/anthropic/python_sdk_store_test.go similarity index 95% rename from plugins/migrationguide/migrationguide_test.go rename to providers/anthropic/python_sdk_store_test.go index c193d15..cd1710a 100644 --- a/plugins/migrationguide/migrationguide_test.go +++ b/providers/anthropic/python_sdk_store_test.go @@ -1,4 +1,4 @@ -package migrationguide +package anthropic import ( "strings" diff --git a/plugins/migrationguide/golden_test.go b/providers/anthropic/python_sdk_test.go similarity index 73% rename from plugins/migrationguide/golden_test.go rename to providers/anthropic/python_sdk_test.go index 164eed6..7e0bd01 100644 --- a/plugins/migrationguide/golden_test.go +++ b/providers/anthropic/python_sdk_test.go @@ -1,4 +1,4 @@ -package migrationguide +package anthropic import ( "testing" @@ -6,7 +6,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/sdkguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/sdkguide" ) // The guide at tag v1.0.0 (saved 2026-10-17) in, every event out: the pair @@ -20,16 +21,16 @@ func TestGolden(t *testing.T) { // it has no guide, and nothing is fetched for it. func anthropicV1(t *testing.T, g sdkguide.Guide, more ...kittest.Pages) []event.Event { t.Helper() - pages := kittest.Pages{anthropicGuideV1.URL(): "sdkguide/testdata/anthropic-MIGRATION-v1.0.0.md"} + pages := kittest.Pages{anthropicGuideV1.URL(): "testdata/anthropic-MIGRATION-v1.0.0.md"} for _, m := range more { for k, v := range m { pages[k] = v } } - return kittest.Versions(t, kittest.Env(t, pages), Plugin{Guide: g}, + return kittest.Versions(t, kittest.Env(t, pages), migrationguide.Plugin{Guide: g}, plugin.Version{ID: "0.75.0", Ref: "v0.75.0"}, plugin.Version{ID: "1.0.0", Ref: "v1.0.0"}) } // anthropicGuideV1 is anthropic-sdk-python's guide pinned to 1.0.0: what the // golden pins. Only a test names a release. -var anthropicGuideV1 = sdkguide.Anthropic.At(1) +var anthropicGuideV1 = PythonSDK.At(1) diff --git a/plugins/migrationguide/versions_test.go b/providers/anthropic/python_sdk_versions_test.go similarity index 86% rename from plugins/migrationguide/versions_test.go rename to providers/anthropic/python_sdk_versions_test.go index 9a39cd5..b44613b 100644 --- a/plugins/migrationguide/versions_test.go +++ b/providers/anthropic/python_sdk_versions_test.go @@ -1,4 +1,4 @@ -package migrationguide +package anthropic import ( "context" @@ -8,7 +8,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/versions" - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/sdkguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" ) // Unpinned, the SDK's versions are its releases on PyPI; only the pair that @@ -17,9 +17,9 @@ import ( func TestOnlyANewMajorHasAGuide(t *testing.T) { env := kittest.Env(t, kittest.Pages{ "https://pypi.org/pypi/anthropic/json": "testdata/pypi-anthropic-excerpt.json", - anthropicGuideV1.URL(): "sdkguide/testdata/anthropic-MIGRATION-v1.0.0.md", + anthropicGuideV1.URL(): "testdata/anthropic-MIGRATION-v1.0.0.md", }) - p := Plugin{Guide: sdkguide.Anthropic} + p := migrationguide.Plugin{Guide: PythonSDK} ctx := context.Background() vs, err := p.ListVersions(ctx, env) if err != nil { @@ -54,6 +54,6 @@ func TestOnlyANewMajorHasAGuide(t *testing.T) { // The unpinned guide's pair into the newest major gives the same events as // the pinned golden. func TestTheUnpinnedGuidesPairIsTheGoldens(t *testing.T) { - got := anthropicV1(t, sdkguide.Anthropic) + got := anthropicV1(t, PythonSDK) kittest.CompareGolden(t, "testdata/golden/anthropic-1.0.0.json", got) } diff --git a/providers/anthropic/python_surface_test.go b/providers/anthropic/python_surface_test.go new file mode 100644 index 0000000..f38857d --- /dev/null +++ b/providers/anthropic/python_surface_test.go @@ -0,0 +1,17 @@ +package anthropic + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// anthropic 2.7.0 dropped the beta billing-frozen error types, module +// and all. 2.5.0 made DeadlineExceededError an alias of +// GatewayTimeoutError: still importable, no event. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"2.6.0", "2.7.0"}, Want: []string{ + "removed_symbol types.beta.BetaBillingFrozenError,types.beta.beta_billing_frozen_error.BetaBillingFrozenError ", + "removed_symbol types.beta.BetaBillingFrozenErrorDetails,types.beta.beta_billing_frozen_error_details.BetaBillingFrozenErrorDetails ", + }, Drop: [2]string{"2.4.0", "2.5.0"}}) +} diff --git a/providers/anthropic/testdata/README.md b/providers/anthropic/testdata/README.md new file mode 100644 index 0000000..cce8aed --- /dev/null +++ b/providers/anthropic/testdata/README.md @@ -0,0 +1,38 @@ +# Anthropic: saved copies and goldens + +Real copies of what Anthropic publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/anthropic -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved model deprecations pages + +The deprecations page, as markdown (the page's URL plus `.md`), read by the golden test through the whole `notices` plugin. + +**License:** excerpts for testing; © Anthropic. Not covered by this repo's license. + +| File | URL | Fetched | Quote | +|---|---|---|---| +| `anthropic-deprecations.md` | https://platform.claude.com/docs/en/about-claude/model-deprecations.md | 2026-10-13 | "\| November 30, 2026 \| `claude-sonnet-4-5-20250929` \| `claude-sonnet-5-5` \|" | + +## Saved SDK migration guide + +Read through the `migrationguide` kind's SDK-guide reader; `golden/anthropic-1.0.0.json` is what it stores from MIGRATION.md at v1.0.0. + +| File | URL | Fetched | License | Quote | +|---|---|---|---|---| +| `anthropic-MIGRATION-v1.0.0.md` | https://github.com/anthropics/anthropic-sdk-python/blob/v1.0.0/MIGRATION.md | 2026-10-17 | MIT (anthropic-sdk-python), kept whole | "Removed: deprecated request parameters" | + +## Version lists + +| File | URL | Saved | License | Use | +|---|---|---|---|---| +| `pypi-anthropic-excerpt.json` | https://pypi.org/pypi/anthropic/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/anthropic/`: `anthropic-2.4.0-py3-none-any.trimmed.whl`, `anthropic-2.5.0-py3-none-any.trimmed.whl`, `anthropic-2.6.0-py3-none-any.trimmed.whl`, `anthropic-2.7.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/8b/5d/e399d9028411ce404d7ddbe6b8060d878b2549ed8cd671a7bb496ae20ffc/anthropic-2.4.0-py3-none-any.whl; https://files.pythonhosted.org/packages/f4/10/c4e6f015111c702c2d5a386ad57745b83c79c08eae68e541dbb16b5e3965/anthropic-2.5.0-py3-none-any.whl; https://files.pythonhosted.org/packages/38/0b/705a05ab68558914e725cf1143d7e409fa3bb596c35bca1eceab42402abe/anthropic-2.6.0-py3-none-any.whl; https://files.pythonhosted.org/packages/8a/da/ed144ab553eb2bc7b5febbfb37858f28b33ec332c37f0fdf260012ae3fe2/anthropic-2.7.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `anthropic/__init__.py`, `anthropic/_exceptions.py`, `anthropic/types/__init__.py`, `anthropic/types/beta/__init__.py`, `anthropic/types/beta/beta_billing_frozen_error.py`, `anthropic/types/beta/beta_billing_frozen_error_details.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/anthropic/`: `pypi-anthropic-excerpt.json` and `pypi-anthropic-2.4.0.json`, `pypi-anthropic-2.5.0.json`, `pypi-anthropic-2.6.0.json`, `pypi-anthropic-2.7.0.json` | https://pypi.org/pypi/anthropic/json, https://pypi.org/pypi/anthropic/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/anthropic-ai-sdk/`: `sdk-1.6.0.trimmed.tgz`, `sdk-1.7.0.trimmed.tgz`, `sdk-1.8.0.trimmed.tgz` | https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.6.0.tgz; https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.7.0.tgz; https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.8.0.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `client.d.mts`, `index.d.mts`, `resources/beta.d.mts`, `resources/beta/beta.d.mts`, `resources/beta/index.d.mts`, `resources/beta/organization.d.mts`, `resources/beta/organization/index.d.mts`, `resources/beta/organization/organization.d.mts`, `resources/index.d.mts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/anthropic-ai-sdk/`: `npm-anthropic-ai-sdk-excerpt.json` and `npm-anthropic-ai-sdk-1.6.0.json`, `npm-anthropic-ai-sdk-1.7.0.json`, `npm-anthropic-ai-sdk-1.8.0.json` | https://registry.npmjs.org/@anthropic-ai%2Fsdk, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/migrationguide/sdkguide/testdata/anthropic-MIGRATION-v1.0.0.md b/providers/anthropic/testdata/anthropic-MIGRATION-v1.0.0.md similarity index 100% rename from plugins/migrationguide/sdkguide/testdata/anthropic-MIGRATION-v1.0.0.md rename to providers/anthropic/testdata/anthropic-MIGRATION-v1.0.0.md diff --git a/plugins/notices/retire/testdata/anthropic-deprecations.md b/providers/anthropic/testdata/anthropic-deprecations.md similarity index 100% rename from plugins/notices/retire/testdata/anthropic-deprecations.md rename to providers/anthropic/testdata/anthropic-deprecations.md diff --git a/plugins/migrationguide/testdata/golden/anthropic-1.0.0.json b/providers/anthropic/testdata/golden/anthropic-1.0.0.json similarity index 100% rename from plugins/migrationguide/testdata/golden/anthropic-1.0.0.json rename to providers/anthropic/testdata/golden/anthropic-1.0.0.json diff --git a/plugins/notices/testdata/golden/anthropic-models.json b/providers/anthropic/testdata/golden/anthropic-models.json similarity index 100% rename from plugins/notices/testdata/golden/anthropic-models.json rename to providers/anthropic/testdata/golden/anthropic-models.json diff --git a/plugins/apisurface/testdata/golden/anthropic-python-surface.json b/providers/anthropic/testdata/golden/anthropic-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/anthropic-python-surface.json rename to providers/anthropic/testdata/golden/anthropic-python-surface.json diff --git a/plugins/apisurface/testdata/golden/anthropic-typescript-surface.json b/providers/anthropic/testdata/golden/anthropic-typescript-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/anthropic-typescript-surface.json rename to providers/anthropic/testdata/golden/anthropic-typescript-surface.json diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.6.0.json b/providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.6.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.6.0.json rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.6.0.json diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.7.0.json b/providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.7.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.7.0.json rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.7.0.json diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.8.0.json b/providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.8.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.8.0.json rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-1.8.0.json diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-excerpt.json b/providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-excerpt.json rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/npm-anthropic-ai-sdk-excerpt.json diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/sdk-1.6.0.trimmed.tgz b/providers/anthropic/testdata/npm/anthropic-ai-sdk/sdk-1.6.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/sdk-1.6.0.trimmed.tgz rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/sdk-1.6.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/sdk-1.7.0.trimmed.tgz b/providers/anthropic/testdata/npm/anthropic-ai-sdk/sdk-1.7.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/sdk-1.7.0.trimmed.tgz rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/sdk-1.7.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/anthropic-ai-sdk/sdk-1.8.0.trimmed.tgz b/providers/anthropic/testdata/npm/anthropic-ai-sdk/sdk-1.8.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/anthropic-ai-sdk/sdk-1.8.0.trimmed.tgz rename to providers/anthropic/testdata/npm/anthropic-ai-sdk/sdk-1.8.0.trimmed.tgz diff --git a/plugins/migrationguide/testdata/pypi-anthropic-excerpt.json b/providers/anthropic/testdata/pypi-anthropic-excerpt.json similarity index 100% rename from plugins/migrationguide/testdata/pypi-anthropic-excerpt.json rename to providers/anthropic/testdata/pypi-anthropic-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/anthropic/anthropic-2.4.0-py3-none-any.trimmed.whl b/providers/anthropic/testdata/pypi/anthropic/anthropic-2.4.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/anthropic-2.4.0-py3-none-any.trimmed.whl rename to providers/anthropic/testdata/pypi/anthropic/anthropic-2.4.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/anthropic/anthropic-2.5.0-py3-none-any.trimmed.whl b/providers/anthropic/testdata/pypi/anthropic/anthropic-2.5.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/anthropic-2.5.0-py3-none-any.trimmed.whl rename to providers/anthropic/testdata/pypi/anthropic/anthropic-2.5.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/anthropic/anthropic-2.6.0-py3-none-any.trimmed.whl b/providers/anthropic/testdata/pypi/anthropic/anthropic-2.6.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/anthropic-2.6.0-py3-none-any.trimmed.whl rename to providers/anthropic/testdata/pypi/anthropic/anthropic-2.6.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/anthropic/anthropic-2.7.0-py3-none-any.trimmed.whl b/providers/anthropic/testdata/pypi/anthropic/anthropic-2.7.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/anthropic-2.7.0-py3-none-any.trimmed.whl rename to providers/anthropic/testdata/pypi/anthropic/anthropic-2.7.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.4.0.json b/providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.4.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.4.0.json rename to providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.4.0.json diff --git a/plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.5.0.json b/providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.5.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.5.0.json rename to providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.5.0.json diff --git a/plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.6.0.json b/providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.6.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.6.0.json rename to providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.6.0.json diff --git a/plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.7.0.json b/providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.7.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-2.7.0.json rename to providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-2.7.0.json diff --git a/plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-excerpt.json b/providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/anthropic/pypi-anthropic-excerpt.json rename to providers/anthropic/testdata/pypi/anthropic/pypi-anthropic-excerpt.json diff --git a/providers/anthropic/typescript_surface_test.go b/providers/anthropic/typescript_surface_test.go new file mode 100644 index 0000000..775a8bd --- /dev/null +++ b/providers/anthropic/typescript_surface_test.go @@ -0,0 +1,15 @@ +package anthropic + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// @anthropic-ai/sdk 1.7.0 dropped the beta billing-frozen error. +func TestTypescriptSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: TypescriptSurface, Golden: [2]string{"1.6.0", "1.7.0"}, Want: []string{ + "removed_symbol @anthropic-ai/sdk/resources/beta.BetaBillingFrozenErrorDetails,@anthropic-ai/sdk/resources/beta/organization.BetaBillingFrozenErrorDetails,@anthropic-ai/sdk/resources/beta/organization/organization.BetaBillingFrozenErrorDetails ", + "removed_symbol Anthropic.Beta.BetaBillingFrozenError,Anthropic.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/client.Anthropic.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/client.Anthropic.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/beta.Beta.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/beta.Beta.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization.Organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization/organization.BetaBillingFrozenError,@anthropic-ai/sdk/resources/beta/organization/organization.Organization.BetaBillingFrozenError ", + }, Drop: [2]string{"1.7.0", "1.8.0"}}) +} diff --git a/providers/appwrite.md b/providers/appwrite/README.md similarity index 93% rename from providers/appwrite.md rename to providers/appwrite/README.md index 8d08aee..b0addd4 100644 --- a/providers/appwrite.md +++ b/providers/appwrite/README.md @@ -1,12 +1,16 @@ -# Appwrite (`appwrite/api`) +# Appwrite -## What it watches +Every source patch-it reads for Appwrite, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Appwrite (`appwrite/api`) + +### What it watches The Appwrite REST API as a server SDK calls it (the operations an Appwrite server SDK, in a repo's backend code, can call): operations Appwrite marks deprecated between two commits of its OpenAPI spec. SDK method renames that don't deprecate the route are left out, and so are removals. -Kind: `openapi` (`plugins/openapi`), with `adapter.Appwrite`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `Appwrite` ([`api.go`](api.go)). -## Why this source +### Why this source - **Source:** [appwrite/specs](https://github.com/appwrite/specs) (BSD-3-Clause), the newest minor's spec at the newest commit that changed `specs/`: `https://raw.githubusercontent.com/appwrite/specs//specs/.x/open-api3-.x.json`, or `open-api3-.x-server.json` in a directory without the single document. The newest minor is the highest `.x` directory by number (`specs/latest` is a copy and is skipped). Checked on 2026-11-19. - **Why this one:** @@ -20,7 +24,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Appwrite`. - **The [changelog](https://appwrite.io/changelog)** (RSS at `https://appwrite.io/changelog/rss.xml`): its 50 posts from 2026-09-30 to 2026-11-19 never say "deprecated" or "breaking". Product news. - **Quote:** `"deprecated": {"since": "1.8.0", "replaceWith": "tablesDB.createTransaction"}` (`POST /databases/transactions`, flagged in the 1.9.x server spec on 2026-06-24) -## How the provider announces changes +### How the provider announces changes - **One spec per server minor**, `specs/.x/`, updated on `main` many times per minor. No tags or releases in the repo, so a commit SHA pins a spec. Commits don't line up with Appwrite's releases: on 2026-11-19 the newest spec says `2.7.2` while appwrite/appwrite has released `2.7.4`. - **The layout changed once.** Up to 1.9.x a directory has one document per platform (`-client`, `-console`, `-server`); from 2.0.x there's one document, each operation listing its platforms in `x-appwrite.platforms` (2.3.x and 2.4.x also have the per-platform files). The adapter reads the single document when there is one and keeps the operations on `server`. At `0ccd20ab` (1.9.x and 2.0.x) and `98cc1a25` (2.4.x's two) that gives the operations the server document has. Where they part, the single document is the one kept up: `06e6fafa` changed 2.4.x's single document only. @@ -29,7 +33,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Appwrite`. - **The event's `version` is the date of the spec commit** (UTC, `2026-06-24`), not the spec's `info.version` (the server version, `1.9.5`). A repo pins an SDK, and the SDKs are versioned on their own: node-appwrite 32.0.0 and the Python SDK 28.0.0 both send `X-Appwrite-Response-Format: 2.7.2`. A server version can't be placed against that pin, and spec commits don't line up with server releases anyway. The server version is in the event's source, the spec at that commit. - **Every server URL ends in `/v1`** (`https://cloud.appwrite.io/v1` and the regional `https://{region}.cloud.appwrite.io/v1`, `` up to 1.8.x), at every commit read; the paths don't repeat it. The adapter moves `/v1` into the paths (`adapter.ServerBasePath`), so an operation is named by the path a caller sends, `POST /v1/databases/transactions`; each event's `source_pointer` names the path as published. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** the newest minor's server operations at the newest commit, diffed against the last ones seen. One kind of event comes out: **deprecations**, an operation that gains the `deprecated` flag. The event quotes `x-appwrite.deprecated` (since and replaceWith), which is where the spec says what to use instead; descriptions don't say. Quoting the whole operation could lose it to the 2,000-character cut, because `x-appwrite` sorts last. - **Matches operations by path template**, as the other specs do. @@ -40,7 +44,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Appwrite`. - Over the 139 commits this keeps 14 events, all on 2026-06-24 (`7d74bf9f`): the six `/v1/databases/transactions` operations and the `longtext`, `mediumtext`, `text` and `varchar` attribute operations, each replaced by a `tablesDB` method. None is a rename or has a live method, so the filter drops none of them. - **Reads** a pair of commits (a version pair, as the golden test does from `8c00ba35` to `7d74bf9f`). A tag can name an older minor's directory, `1.7.x@`, as the rename test does. The pinned drop test is the 2.4.x pair (13 removals, no event). A single document where no operation is on `server` (the platforms gone or renamed) fails the fetch, rather than read as nothing deprecated. -## Known gaps +### Known gaps - **Removals aren't events.** The spec doesn't mark them first, so real ones are missed. The SDK changelogs say them ("* Breaking: removed `X`"); a `changelog` plugin per SDK could read them. - **Deprecations from before the plugin's first run aren't events,** nor operations that first appear already flagged. When the newest minor changes, the plugin diffs the new directory against the previous minor's last spec, so an operation that was unflagged there and is flagged in the new one is an event. The Databases to TablesDB deprecations of 1.8.0 can be replayed (`1.7.x@` to ``), and a run never sees them. diff --git a/plugins/openapi/adapter/appwrite.go b/providers/appwrite/api.go similarity index 54% rename from plugins/openapi/adapter/appwrite.go rename to providers/appwrite/api.go index 837c2cf..db9a56d 100644 --- a/plugins/openapi/adapter/appwrite.go +++ b/providers/appwrite/api.go @@ -1,4 +1,4 @@ -package adapter +package appwrite import ( "bytes" @@ -10,9 +10,14 @@ import ( "slices" "strconv" "strings" + "time" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) var ( @@ -57,7 +62,7 @@ type Appwrite struct { RawBase string // files at a commit; "" is https://raw.githubusercontent.com } -var _ Adapter = Appwrite{} +var _ adapter.Adapter = Appwrite{} func (Appwrite) API() string { return "appwrite/api" } @@ -88,30 +93,30 @@ func (a Appwrite) LatestTag(ctx context.Context) (string, error) { // specs commits don't line up with server releases anyway. // // The server URL's path (/v1) is moved into the paths: see ServerBasePath. -func (a Appwrite) Fetch(ctx context.Context, tag string) (Spec, error) { +func (a Appwrite) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { dir, sha, named := strings.Cut(tag, "@") if !named { dir, sha = "", tag } if !appwriteCommit.MatchString(sha) || (named && !appwriteDir.MatchString(dir)) { - return Spec{}, fmt.Errorf("%q is neither a full appwrite/specs commit sha nor .x@", tag) + return adapter.Spec{}, fmt.Errorf("%q is neither a full appwrite/specs commit sha nor .x@", tag) } _, date, err := github.Commit(ctx, github.Get, a.api("/commits/"+sha)) if err != nil { - return Spec{}, fmt.Errorf("looking up appwrite/specs commit %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("looking up appwrite/specs commit %s: %w", sha, err) } if dir == "" { dirs, err := a.list(ctx, "specs", sha) if err != nil { - return Spec{}, err + return adapter.Spec{}, err } if dir = newestAppwriteDir(dirs); dir == "" { - return Spec{}, fmt.Errorf("appwrite/specs %s has no specs/.x directory", sha) + return adapter.Spec{}, fmt.Errorf("appwrite/specs %s has no specs/.x directory", sha) } } files, err := a.list(ctx, "specs/"+dir, sha) if err != nil { - return Spec{}, err + return adapter.Spec{}, err } single, server := "open-api3-"+dir+".json", "open-api3-"+dir+"-server.json" var file string @@ -121,32 +126,34 @@ func (a Appwrite) Fetch(ctx context.Context, tag string) (Spec, error) { case slices.Contains(files, server): file = server default: - return Spec{}, fmt.Errorf("appwrite/specs %s: specs/%s has neither %s nor %s", sha, dir, single, server) + return adapter.Spec{}, fmt.Errorf("appwrite/specs %s: specs/%s has neither %s nor %s", sha, dir, single, server) } url := cmp.Or(a.RawBase, "https://raw.githubusercontent.com") + "/appwrite/specs/" + sha + "/specs/" + dir + "/" + file body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching appwrite spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("fetching appwrite spec %s: %w", tag, err) } if file == single { if body, err = appwriteServerOnly(body); err != nil { - return Spec{}, fmt.Errorf("appwrite spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("appwrite spec %s: %w", tag, err) } } // Every server is "https://cloud.appwrite.io/v1" or a regional // "https://{region}.cloud.appwrite.io/v1" ("" up to 1.8.x), and // the paths don't repeat /v1. - content, err := ServerBasePath(body) + content, err := adapter.ServerBasePath(body) if err != nil { - return Spec{}, fmt.Errorf("appwrite spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("appwrite spec %s: %w", tag, err) } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil } // SourcePointer: see BasePathPointer. -func (Appwrite) SourcePointer(content []byte) func(string) string { return BasePathPointer(content) } +func (Appwrite) SourcePointer(content []byte) func(string) string { + return adapter.BasePathPointer(content) +} -var _ Reshaper = Appwrite{} +var _ adapter.Reshaper = Appwrite{} // list is the names in a directory of appwrite/specs at a commit. func (a Appwrite) list(ctx context.Context, path, sha string) ([]string, error) { @@ -200,16 +207,16 @@ func appwriteServerOnly(body []byte) ([]byte, error) { if err := dec.Decode(&doc); err != nil { return nil, fmt.Errorf("parsing the spec: %w", err) } - paths := asMap(doc["paths"]) + paths := adapter.AsMap(doc["paths"]) for p, v := range paths { - item := asMap(v) + item := adapter.AsMap(v) left := 0 for _, m := range appwriteMethods { op, ok := item[m] if !ok { continue } - platforms := asSlice(asMap(asMap(op)["x-appwrite"])["platforms"]) + platforms := adapter.AsSlice(adapter.AsMap(adapter.AsMap(op)["x-appwrite"])["platforms"]) if slices.Contains(platforms, any("server")) { left++ } else { @@ -225,3 +232,102 @@ func appwriteServerOnly(body []byte) ([]byte, error) { } return json.Marshal(doc) } + +// Versions are the days appwrite/specs' default branch changed specs/, +// oldest first, each at the day's last commit (Daily): the ID is the date +// (Fetch's Version), the Ref the SHA, read at the newest minor's directory. +func (a Appwrite) Versions(ctx context.Context) ([]plugin.Version, error) { + cs, err := versions.GitHubPages[struct { + SHA string `json:"sha"` + URL string `json:"html_url"` + Commit struct { + Committer struct { + Date time.Time `json:"date"` + } `json:"committer"` + } `json:"commit"` + }](ctx, github.Get, a.api("/commits?path=specs")) + if err != nil { + return nil, fmt.Errorf("listing the commits that changed appwrite's specs: %w", err) + } + var out []plugin.Version + for _, c := range cs { + if !appwriteCommit.MatchString(c.SHA) || c.Commit.Committer.Date.IsZero() { + continue + } + at := c.Commit.Committer.Date.UTC() + out = append(out, plugin.Version{ID: at.Format(time.DateOnly), Released: at, Ref: c.SHA, URL: c.URL}) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return adapter.Daily(out), nil +} + +// appwriteDiff is how Appwrite's spec says what it says: +// +// - A deprecation is the `deprecated` flag plus x-appwrite.deprecated, +// {"since": "1.8.0", "replaceWith": "tablesDB.createTransaction"}: the +// only place the spec says what to use instead (the description doesn't). +// x-appwrite sorts last in the operation, after parameters and +// responses, so quoting the whole operation can lose it to the +// 2,000-character cut: the event quotes x-appwrite.deprecated itself. +// The flag without it is quoted as the flag (never seen so far). +// - The flag also marks an operation one of whose SDK method names was +// renamed: POST /account/mfa/challenges is flagged with "replaceWith": +// "account.createMFAChallenge", which is the same operation's other +// name in x-appwrite.methods (createMfaChallenge became +// createMFAChallenge). The route isn't deprecated, so that flag isn't +// read as a deprecation: see appwriteMethodLevel. +// - Path parameters are matched by place, as for the other specs. +var appwriteDiff = diff.Options{ + PathTemplates: true, + QuoteDeprecated: "/x-appwrite/deprecated", + FlagNotDeprecation: appwriteMethodLevel, +} + +// appwriteMethodLevel reports whether an operation's `deprecated` flag is +// about its SDK methods, not its route: +// +// - x-appwrite.deprecated.replaceWith names a method of the same +// operation's x-appwrite.methods ("."): a rename; +// - or a method in x-appwrite.methods isn't itself deprecated: the +// operation still has a live SDK method, so the route stays. +// +// An operation with no methods listed (the 14 of the golden test have +// "methods": []) is read by its flag. In 2.7.x's server operations the two +// rules pick the same 23 of the 99 flagged, all flagged since 1.8.0 +// (1.8.x's server document at ac705cd3 has the same 23); each has a live +// method named by replaceWith. +func appwriteMethodLevel(op map[string]any) bool { + xa, _ := op["x-appwrite"].(map[string]any) + dep, _ := xa["deprecated"].(map[string]any) + replaceWith, _ := dep["replaceWith"].(string) + methods, _ := xa["methods"].([]any) + for _, m := range methods { + method, _ := m.(map[string]any) + namespace, _ := method["namespace"].(string) + name, _ := method["name"].(string) + if replaceWith != "" && name != "" && namespace+"."+name == replaceWith { + return true + } + if d, ok := method["deprecated"]; !ok || d == nil || d == false { + return true + } + } + return false +} + +// appwriteKeep keeps operation deprecations only: not even a deprecated +// operation's removal. Read as Fetch reads it (the newest minor's server +// operations at each of the 139 commits on appwrite/specs' main, 2026-02-17 +// to 2026-11-17), the spec's history has 14 deprecations, all on +// 2026-06-24 (see the golden test), and 78 operations leaving it (from +// the spec, or from the server platform). Only one was marked deprecated +// first, and that one was a path move: PATCH +// /databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship +// became .../attributes/relationship/{key} on 2026-03-20. Of the others, 13 +// are back now: 2.4.x's single document took the server platform off them +// on 2026-10-12 as not yet in a released SDK, and 2.5.x had them on it again +// the next day. Nothing in the spec says when an operation stops answering, +// so a removal isn't an event. +// +// Property changes and new operations are dropped too, as for vercel. +func appwriteKeep(c diff.Change) bool { return c.Kind == diff.OperationDeprecated } diff --git a/plugins/openapi/adapter/appwrite_test.go b/providers/appwrite/api_fetch_test.go similarity index 89% rename from plugins/openapi/adapter/appwrite_test.go rename to providers/appwrite/api_fetch_test.go index ecdb139..9a0527b 100644 --- a/plugins/openapi/adapter/appwrite_test.go +++ b/providers/appwrite/api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package appwrite import ( "context" @@ -7,6 +7,8 @@ import ( "net/http/httptest" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) const appwriteSHA = "06e6fafa4d1ae3c815843ff0b02a56e6e5582756" @@ -155,3 +157,21 @@ func TestAppwriteFetchFailures(t *testing.T) { t.Error("no minor directory: want none") } } + +// Every day specs/ changed, oldest first, at the day's last commit: the 40 +// commits saved fall on 16 days, and a version ID (the date) is named once. +func TestAppwriteListsEverySpecCommit(t *testing.T) { + srv := openapitest.Recorded(t, map[string]string{"/repos/appwrite/specs/commits?path=specs&per_page=100&page=1": "appwrite-commits.json"}) + vs, err := Appwrite{APIBase: srv.URL}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if len(vs) != 16 { + t.Fatalf("%d versions, want 16", len(vs)) + } + for i := 1; i < len(vs); i++ { + if !vs[i].Released.After(vs[i-1].Released) || vs[i].ID == vs[i-1].ID || len(vs[i].Ref) != 40 { + t.Errorf("%v after %v", vs[i], vs[i-1]) + } + } +} diff --git a/plugins/openapi/appwrite_test.go b/providers/appwrite/api_test.go similarity index 93% rename from plugins/openapi/appwrite_test.go rename to providers/appwrite/api_test.go index 047200d..97cb7d6 100644 --- a/plugins/openapi/appwrite_test.go +++ b/providers/appwrite/api_test.go @@ -1,4 +1,4 @@ -package openapi +package appwrite import ( "context" @@ -12,7 +12,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // The appwrite/specs commits the tests read (checked 2026-11-19), and their @@ -58,7 +59,7 @@ var ( // appwritePlugin is the plugin as registered, its adapter reading GitHub's // listings and the saved copies from a local server. It returns the base of // the raw URLs: //specs//. -func appwritePlugin(t *testing.T) (Plugin, string) { +func appwritePlugin(t *testing.T) (openapi.Plugin, string) { t.Helper() const repo = "/api/repos/appwrite/specs" srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -94,21 +95,21 @@ func appwritePlugin(t *testing.T) (Plugin, string) { json.NewEncoder(w).Encode(entries) })) t.Cleanup(srv.Close) - a := adapter.Appwrite{APIBase: srv.URL + "/api", RawBase: srv.URL + "/raw"} - return Plugin{Adapter: a, Diff: appwriteDiff, Keep: appwriteKeep}, srv.URL + "/raw/appwrite/specs" + a := Appwrite{APIBase: srv.URL + "/api", RawBase: srv.URL + "/raw"} + return openapi.Plugin{Adapter: a, Diff: appwriteDiff, Keep: appwriteKeep}, srv.URL + "/raw/appwrite/specs" } -func pairAppwrite(t *testing.T, p Plugin, from, to string) []event.Event { +func pairAppwrite(t *testing.T, p openapi.Plugin, from, to string) []event.Event { t.Helper() - s := openStore(t) - if rejected, err := kittest.Pair(context.Background(), vercelEnv(s), s, p, from, to); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(context.Background(), openapitest.Env(s), s, p, from, to); err != nil || rejected { t.Fatalf("pair %s -> %s: rejected=%v err=%v", from, to, rejected, err) } return kittest.Stored(t, s) } func TestAppwriteRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Adapter: adapter.Appwrite{}, Diff: appwriteDiff, Keep: appwriteKeep}) + kittest.Registered(t, openapi.Plugin{Adapter: Appwrite{}, Diff: appwriteDiff, Keep: appwriteKeep}) } // The golden test: the only deprecations in the spec's history as the @@ -133,7 +134,7 @@ func TestAppwriteGolden(t *testing.T) { !strings.Contains(e.Subject.Operation, " /v1/databases/") || strings.HasPrefix(e.SourcePointer, "/paths/~1v1") { t.Errorf("%s: %s %s from %s", e.Subject.Operation, e.ChangeType, e.Version, e.SourceURL) } - if !strings.HasSuffix(e.SourcePointer, "/x-appwrite/deprecated") || jsonNode(t, file, e.SourcePointer) != e.SourceExcerpt { + if !strings.HasSuffix(e.SourcePointer, "/x-appwrite/deprecated") || openapitest.JSONNode(t, file, e.SourcePointer) != e.SourceExcerpt { t.Errorf("%s: excerpt %s doesn't match %s", e.Subject.Operation, e.SourceExcerpt, e.SourcePointer) } if !strings.Contains(e.SourceExcerpt, `"replaceWith":"tablesDB.`) || !strings.Contains(e.SourceExcerpt, `"since":"1.8.0"`) { diff --git a/providers/appwrite/provider.go b/providers/appwrite/provider.go new file mode 100644 index 0000000..2a73a14 --- /dev/null +++ b/providers/appwrite/provider.go @@ -0,0 +1,27 @@ +// Package appwrite is what patch-it reads for Appwrite: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package appwrite + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "appwrite", Name: "Appwrite", Category: plugin.CategoryHosting, Homepage: "https://appwrite.io", + Sources: []plugin.Source{ + // No Hints: Appwrite's changelog is product news, not keyed by operation. + // Operation deprecations only, SDK method renames left out: see + // api.go. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API operations a server SDK calls that are deprecated between commits of the spec, SDK method renames left out", + URLs: []string{"https://github.com/appwrite/specs"}, + Packages: []string{"pypi:appwrite", "npm:node-appwrite"}, + Plugin: openapi.Plugin{Adapter: Appwrite{}, Diff: appwriteDiff, Keep: appwriteKeep}, + }, + }, + }) +} diff --git a/providers/appwrite/testdata/README.md b/providers/appwrite/testdata/README.md new file mode 100644 index 0000000..d6566e2 --- /dev/null +++ b/providers/appwrite/testdata/README.md @@ -0,0 +1,23 @@ +# Appwrite: saved copies and goldens + +Real copies of what Appwrite publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/appwrite -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `appwrite-1.9.x-8c00ba35-server.json`, `appwrite-1.9.x-7d74bf9f-server.json` | https://raw.githubusercontent.com/appwrite/specs/8c00ba356b01d43fbc6c88c60fb2a4fc99e04b40/specs/1.9.x/open-api3-1.9.x-server.json (and `7d74bf9f3c0c990745e822f5935bcfaca310fd06`) | 2026-11-19 | BSD-3-Clause (appwrite/specs) | `"replaceWith": "tablesDB.createTransaction"` (`x-appwrite.deprecated` of `POST /databases/transactions`, flagged in `7d74bf9f` with 13 more) | +| `appwrite-2.4.x-98cc1a25.json`, `appwrite-2.4.x-06e6fafa.json` | https://raw.githubusercontent.com/appwrite/specs/98cc1a25215d3cead3a64f9bd4574a9c5b1ec87b/specs/2.4.x/open-api3-2.4.x.json (and `06e6fafa4d1ae3c815843ff0b02a56e6e5582756`) | 2026-11-19 | BSD-3-Clause (appwrite/specs) | `"server"` in `x-appwrite.platforms` of `POST /account/recovery/otp` and 12 more operations (in `98cc1a25`, none deprecated; off them in `06e6fafa`, on again in 2.5.x the next day): the drop test | +| `appwrite-1.7.x-ac705cd3-server.json`, `appwrite-1.8.x-ac705cd3-server.json` | https://raw.githubusercontent.com/appwrite/specs/ac705cd3e9d5e3a0693b7e40189eb1e66883e341/specs/1.7.x/open-api3-1.7.x-server.json (and `specs/1.8.x/open-api3-1.8.x-server.json` at the same commit) | 2026-11-19 | BSD-3-Clause (appwrite/specs) | `"replaceWith": "account.createMFAAuthenticator"` on `POST /account/mfa/authenticators/{type}`, whose `x-appwrite.methods` are `createMfaAuthenticator` and `createMFAAuthenticator` (one of 21 SDK method renames flagged in 1.8.x) | + +The Appwrite copies keep `openapi`, `info`, `servers` and the path items involved, whole and in their original order; `tags`, `components` and `externalDocs` left out. They're re-serialized the way the originals are written (4-space indent, `/` written `\/`, non-ASCII as `\u` escapes), which gives every original line back byte for byte when nothing is left out, so every kept line is unchanged bar a trailing comma. The 1.9.x pair keeps the paths of the 14 operations deprecated in `7d74bf9f`, the 2.4.x pair the paths of the 13 operations that lost the server platform in `06e6fafa`, the 1.7.x and 1.8.x pair the paths of the 21 operations flagged only for an SDK method rename. With the full files the plugin gives the same results: 14 events, none, and none (50, from the rest of 1.8.x's Databases deprecations, with the 21 renames still left out). + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/appwrite-commits.json` | `https://api.github.com/repos/appwrite/specs/commits?path=specs&per_page=100&page=1` | the 40 newest commits; `sha`, `html_url`, the committer date | diff --git a/plugins/openapi/testdata/appwrite-1.7.x-ac705cd3-server.json b/providers/appwrite/testdata/appwrite-1.7.x-ac705cd3-server.json similarity index 100% rename from plugins/openapi/testdata/appwrite-1.7.x-ac705cd3-server.json rename to providers/appwrite/testdata/appwrite-1.7.x-ac705cd3-server.json diff --git a/plugins/openapi/testdata/appwrite-1.8.x-ac705cd3-server.json b/providers/appwrite/testdata/appwrite-1.8.x-ac705cd3-server.json similarity index 100% rename from plugins/openapi/testdata/appwrite-1.8.x-ac705cd3-server.json rename to providers/appwrite/testdata/appwrite-1.8.x-ac705cd3-server.json diff --git a/plugins/openapi/testdata/appwrite-1.9.x-7d74bf9f-server.json b/providers/appwrite/testdata/appwrite-1.9.x-7d74bf9f-server.json similarity index 100% rename from plugins/openapi/testdata/appwrite-1.9.x-7d74bf9f-server.json rename to providers/appwrite/testdata/appwrite-1.9.x-7d74bf9f-server.json diff --git a/plugins/openapi/testdata/appwrite-1.9.x-8c00ba35-server.json b/providers/appwrite/testdata/appwrite-1.9.x-8c00ba35-server.json similarity index 100% rename from plugins/openapi/testdata/appwrite-1.9.x-8c00ba35-server.json rename to providers/appwrite/testdata/appwrite-1.9.x-8c00ba35-server.json diff --git a/plugins/openapi/testdata/appwrite-2.4.x-06e6fafa.json b/providers/appwrite/testdata/appwrite-2.4.x-06e6fafa.json similarity index 100% rename from plugins/openapi/testdata/appwrite-2.4.x-06e6fafa.json rename to providers/appwrite/testdata/appwrite-2.4.x-06e6fafa.json diff --git a/plugins/openapi/testdata/appwrite-2.4.x-98cc1a25.json b/providers/appwrite/testdata/appwrite-2.4.x-98cc1a25.json similarity index 100% rename from plugins/openapi/testdata/appwrite-2.4.x-98cc1a25.json rename to providers/appwrite/testdata/appwrite-2.4.x-98cc1a25.json diff --git a/plugins/openapi/testdata/golden/appwrite.json b/providers/appwrite/testdata/golden/appwrite.json similarity index 100% rename from plugins/openapi/testdata/golden/appwrite.json rename to providers/appwrite/testdata/golden/appwrite.json diff --git a/plugins/openapi/adapter/testdata/versions/appwrite-commits.json b/providers/appwrite/testdata/versions/appwrite-commits.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/appwrite-commits.json rename to providers/appwrite/testdata/versions/appwrite-commits.json diff --git a/providers/cloudflare-api-spec.md b/providers/cloudflare-api-spec.md deleted file mode 100644 index fb03c14..0000000 --- a/providers/cloudflare-api-spec.md +++ /dev/null @@ -1,45 +0,0 @@ -# Cloudflare (`cloudflare/api-spec`) - -## What it watches - -The Cloudflare API (`api.cloudflare.com/client/v4`): operations Cloudflare marks deprecated, and removals of operations it had marked deprecated, day by day in the OpenAPI spec its SDKs and Terraform provider are generated from. - -Kind: `openapi` (`plugins/openapi`), with `adapter.Cloudflare`. (`cloudflare/api` is Cloudflare's deprecations feed, read by the `notices` kind.) - -## Why this source - -- **Source:** `openapi.json` in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) (BSD-3-Clause), pinned to a commit (`https://raw.githubusercontent.com/cloudflare/api-schemas//openapi.json`). The versions come from the GitHub commits API. Checked on 2026-11-21. -- **Why this one:** - - It's Cloudflare's own description of the whole API, published by a bot several times a day ("Update schema: openapi.json"), the input to `cloudflare-python`, `cloudflare-typescript` and the Terraform provider. - - It marks deprecated operations with the `deprecated` flag, and most carry `x-stainless-deprecation-message` with the end-of-life date. - - Every commit can be cited and replayed. -- **Alternatives considered:** - - **`openapi.yaml` beside it:** the same spec as YAML. - - **The [API deprecations page](https://developers.cloudflare.com/fundamentals/api/reference/deprecations/)** and its feed: read by `cloudflare/api` (kind `notices`). It announces end-of-life dates in prose; the spec says which operation, and when it's gone. - - **The changelog:** product news, not keyed by operation. -- **Quote:** "This operation is deprecated and will reach end of life on September 27, 2026. Use the new Registrar API endpoints (domain-search, domain-check, registrations) instead." (`GET /accounts/{account_id}/registrar/domains`, removed from the spec on 2026-10-30) - -## How the provider announces changes - -- **One version per day.** The spec is committed several times a day, there are no tags, and `info.version` is a fixed `4.0.0`, so a version is a day: the day's last commit, its date the event's `version`. -- **Operations are named by the path a caller sends** (`GET /client/v4/accounts/…`): the server is `https://api.cloudflare.com/client/v4`, moved into the paths. -- **Deprecations use the flag** (329 operations on 2026-11-20) **or the summary** (11 more, written "List datasets (deprecated)" or "Deprecated: Retrieve legacy embed code HTML"). Other uses of "deprecated" in summaries and descriptions are about a parameter or a model. -- **Path parameters get renamed** (`{zone_identifier}` to `{zone_id}` on 2026-10-30) without the URL changing. -- **Operations leave the spec without notice too:** POST `/accounts/move` and the `/tenants/{tenant_id}` operations on 2026-10-30, never marked. - -## What the plugin reads and ignores - -- **Reads** every day's spec, diffed against the day before. Two events come out of it: - - **Deprecations:** an operation that gains the flag or a summary saying so. A flagged one quotes the whole operation (its deprecation message included). - - **Removals (breaking):** an operation that leaves the spec after the previous day's spec had marked it deprecated. -- **Matches operations by path template,** so a renamed path parameter isn't a removal. -- **Ignores everything else:** removals of operations never marked deprecated, schema and property changes (mostly the generator's), new operations. -- **The golden test** replays 2026-10-29 → 2026-10-30: the three deprecated Registrar domains operations removed, three events. The drop test is the same pair: POST `/accounts/move` and GET `/tenants/{tenant_id}`, gone unmarked, make none. - -## Known gaps - -- **Deprecated parameters and fields** aren't events: only whole operations are. -- **Removals Cloudflare didn't mark first aren't events.** -- **History:** the GitHub commits API lists at most 1,000 commits, about five months of this spec (back to 2026-06-11 on 2026-11-21); older days aren't listed. -- **Size:** each version is a 30 MB download. -- **The patch-it client needs `cloudflare` in its list of date-versioned APIs** to place the events' date `version`; that list is outside this repo. diff --git a/providers/cloudflare-python-surface.md b/providers/cloudflare-python-surface.md deleted file mode 100644 index f1fde29..0000000 --- a/providers/cloudflare-python-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# Cloudflare Python SDK (`cloudflare/python-surface`) - -## What it watches - -The public API of the `cloudflare` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install cloudflare==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** GitHub release notes and CHANGELOG.md (commit titles); the spec (the HTTP API). -- **Quote:** `class AsyncOAuthScopesResource(AsyncAPIResource)` (`cloudflare/resources/iam/oauth_scopes/oauth_scopes.py` line 68) at 5.3.0, gone at 5.4.0. - -## How the provider announces changes - -- The SDK is generated from Cloudflare's API spec (`cloudflare/api-spec`) and every minor removes generated types and resources with the API: hundreds of events in some releases (1,533 at 5.10.0), each a name that no longer imports. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `cloudflare/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. -- Releases are large (about 60,000 public names); a nested response type removed with its API reads as one event per module that defines it. diff --git a/providers/cloudflare-sdks.md b/providers/cloudflare-sdks.md deleted file mode 100644 index 8926fd8..0000000 --- a/providers/cloudflare-sdks.md +++ /dev/null @@ -1,35 +0,0 @@ -# Cloudflare SDKs and Terraform provider (`cloudflare/typescript`, `cloudflare/python`, `cloudflare/go`, `cloudflare/terraform`) - -## What it watches - -Methods, sub-resources, types and attributes removed or renamed in each release of Cloudflare's TypeScript, Python and Go SDKs and its Terraform provider, from that release's section of the repo's `CHANGELOG.md` at its tag. One `package_release` event per bullet that names what it removes plainly. Cloudflare's API notices are a separate source (`cloudflare/api`). - -Kind: `changelog` (`plugins/changelog`, `sdks.go`). - -| Source | Package | Releases listed from | Layer | -|---|---|---|---| -| `cloudflare/typescript` | `npm:cloudflare` | npm | sdk | -| `cloudflare/python` | `pypi:cloudflare` | PyPI | sdk | -| `cloudflare/go` | `go:github.com/cloudflare/cloudflare-go/v7` (events name the module at each release's major) | the repo's `vX.Y.Z` tags | sdk | -| `cloudflare/terraform` | none (Terraform registry `cloudflare/cloudflare`; events carry ecosystem `terraform`) | the repo's `vX.Y.Z` tags | infra | - -## Why this source - -- **Source:** https://github.com/cloudflare/cloudflare-typescript/blob/main/CHANGELOG.md, https://github.com/cloudflare/cloudflare-python/blob/main/CHANGELOG.md, https://github.com/cloudflare/cloudflare-go/blob/main/CHANGELOG.md, https://github.com/cloudflare/terraform-provider-cloudflare/blob/main/CHANGELOG.md, each read raw at the release's `vX.Y.Z` tag; checked on 2026-11-20. -- **Why this one:** the SDKs are generated and breaking changes ship in minors; release-please puts each under "⚠ BREAKING CHANGES", one bullet per area (`**accounts:** …`), naming what was removed. -- **Alternatives considered:** GitHub release notes (the same text); the per-major upgrade guides (`docs/guides/version-5-upgrade.md` for Terraform: one entry per resource, no plain removal sentences); diffing the published packages (`apisurface`, when it's built). -- **Quote:** "**ssl:** The `Host`, `Status`, and `ValidationMethod` types have been removed from `cloudflare.types.ssl`." (cloudflare-python 5.6.0). - -## How the provider announces changes - -Frequent minors, several a month; breaking bullets in a minor's "⚠ BREAKING CHANGES" section. - -## What the plugin reads and ignores - -- Reads the release's section; the area prefix (`**ssl:**`) is read past. Counts `X has been removed (from Y)`, `X and Y types removed`, `Remove X`, `X has been renamed to Y`, and bare names under a removal heading. -- Drops (and logs): changed return types, changed import IDs, simplified responses, renamed enum values, anything that removes a list of names "along with" others in prose. - -## Known gaps - -- A Terraform attribute removed from a block is named by the attribute only when the bullet doesn't name its resource plainly. -- A release whose section is missing at its tag is skipped as nothing to read. diff --git a/providers/cloudflare.md b/providers/cloudflare.md deleted file mode 100644 index 3fbc84b..0000000 --- a/providers/cloudflare.md +++ /dev/null @@ -1,55 +0,0 @@ -# Cloudflare (`cloudflare/api`) - -## What it watches - -Cloudflare's REST API (`api.cloudflare.com/client/v4`): every operation Cloudflare names as deprecated on its API deprecations page. It's a `breaking` event, dated by the end of life, when the item says the endpoints stop on a full end-of-life date. Otherwise it's a `deprecation`. - -Kind: `notices` (`plugins/notices`), with the feed reader (`plugins/notices/feed`) and its `CloudflareAPI` feed. - -## Why this source - -- **Source:** [API deprecations](https://developers.cloudflare.com/fundamentals/api/reference/deprecations/), read as its RSS feed `https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml`. Checked on 2026-11-19. -- **Why this one:** it's where Cloudflare announces API deprecations, by its own description: "When this happens, we will communicate when the API will no longer be available and whether there will be a replacement." - - The feed carries every announcement since 2020, 50 items. - - Since 2024, most items name what they deprecate under "Deprecated APIs:", usually one `METHOD /path` per line. That list is kept apart from "Affected APIs:", which lists endpoints that only change. - - Most items since 2025 give an "End of life date:". - - The deprecated endpoints that are still in Cloudflare's OpenAPI spec are flagged deprecated there too (56 of 58 on 2026-11-19), so the page and the spec agree. -- **Alternatives considered:** - - **Cloudflare's OpenAPI spec, [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas).** It flags more operations deprecated (321 on 2026-11-19), but only 53 of those carry a date (`x-cfDeprecation` or `x-forge-sunset`). - - Its removals can't be trusted as shutdowns. Over 39 snapshots from 2024-11 to 2026-11, 477 operations left the spec and only 38 had been deprecated first. 17 came back later, and 141 were path-parameter renames. - - There's no way to check from outside whether a removed endpoint still answers: without credentials every route returns the same authentication error. - - It has no tags, and changes about ten times a day. - - **The [changelog](https://developers.cloudflare.com/changelog/) feed.** It covers every product, mostly announcements; the deprecations page is its API part. - - **The SDKs** (`cloudflare` on PyPI and npm). They're generated from the spec. The Python SDK's `CHANGELOG.md` lists SDK-level breaking changes (removed methods and types), which is a different subject. -- **Quote:** "End of life date: September 27, 2026" and "After this date, the legacy endpoints will no longer be available." (Legacy Registrar Domain Management API) - -## How the provider announces changes - -- **No API-wide version.** Everything is under `/client/v4`, with no per-endpoint or date versions. -- **The deprecations page** gets a new item for each announcement, newest first. An item gives the deprecation date, usually the end-of-life date, the deprecated operations and the replacement. It's sometimes updated later, for example when an end of life is extended ("previously September 15, 2026"). -- **Notice** runs from three months (Radar's layer 7 attack magnitude parameter, 2025-03-11 to 2025-06-11) to almost two years (Zone Settings Batch API, 2025-04-23 to 2027-03-31, after one extension). - -## What the plugin reads and ignores - -- **Reads:** each item's "Deprecated APIs:" list, one event per operation. The operation is written as the page writes it, normalized to `{param}` with a leading `/` and no trailing `/`; the oldest items write `GET zones/:zone_identifier/...`. -- **Event type:** - - **`breaking`** when the item gives a full "End of life date:" and says the endpoints stop ("After this date, the legacy endpoints will no longer be available."). `version` is the end-of-life date. An end-of-life date alone isn't enough: of the 11 items with one on 2026-11-19, only 2 say the endpoints stop. - - **`deprecation`** otherwise. `version` is the deprecation date, or, when the page gives only a month ("November 2025"), the date the item was published. -- **Drops** (and logs, with why): - - Items with no "Deprecated APIs:" list: behavior changes, cipher suites, fields and settings ("Affected APIs:", "Modified API"). One 2022 item (Cloudflare Images direct upload v1) names its operation inline instead of in a list, and is dropped with them. - - Items that tell direct API callers no action is required. The Radar summary and timeseries groups endpoints have an end of life, but "For users calling the API directly (not via the Cloudflare SDK), no action is required": the URLs still fit the new `/summary/{dimension}` endpoints, and only an SDK method moves. - - List items that aren't one operation: "`GET` and `POST` /…" (the 2026 Workers KV item writes three of its five that way), a DNS-over-HTTPS hostname, "Other similar … endpoints". - - List items where the text after the operation is a sentence about it, not a name for it, such as `POST /accounts/{account_id}/gateway/rules` "— creating rules with action: "audit_ssh" is no longer accepted". What goes is one value; the operation stays, so naming it would be wrong. -- On the feed saved 2026-11-19 this gives 114 events from 27 items: 5 breaking (Zone Settings Batch API and the Legacy Registrar API) and 109 deprecations. It logs 27 drops: 21 whole items and 6 list items. -- **Cites** a Wayback Machine snapshot of the feed, read back and checked against the live feed (`kit.Cite`). -- **Historical change in the golden test:** the Legacy Registrar Domain Management API, deprecated 2026-04-10 with end of life 2026-09-27. Its three operations left Cloudflare's OpenAPI spec in October 2026. - -## Known gaps - -- **Field, value and behavior changes aren't events.** The page describes them in prose ("Affected APIs:"), and there's no operation to name as deprecated. -- **Operations the spec deprecates but the page doesn't list aren't events.** That's most of the spec's 321. -- **An extended end of life is a new event with the new date.** The one with the old date isn't withdrawn. -- **An end of life without "the endpoints stop" is only a deprecation.** That includes items where it likely does mean a shutdown (AMP/SXG, Zero Trust Devices), because the item doesn't say so. Whether an endpoint still answers can't be checked from outside: without credentials every route returns the same authentication error. -- **Path parameter names follow the page,** not always the spec (`{zone_identifier}` in old items, `{zone_id}` in the spec). -- **The patch-it client can't place these events yet.** Its version check reads an `api_operation` event's version as a package version, so a date (`2026-09-27`) doesn't parse and the event is dropped. It needs a rule for date-versioned API events, like the one model retirements have. -- **`previous_version` is a read, not a release.** The events are `api_operation` subjects, which the change-event contract requires to name the version they were compared with. A page of notices has no releases, so it's the dated read the page was compared with (the read before; on the first read, that read itself, `2026-11-14T12:00:00Z` in the golden file). `version` stays the notice's own. diff --git a/providers/cloudflare/README.md b/providers/cloudflare/README.md new file mode 100644 index 0000000..9988127 --- /dev/null +++ b/providers/cloudflare/README.md @@ -0,0 +1,178 @@ +# Cloudflare + +Every source patch-it reads for Cloudflare, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Cloudflare API deprecations (`cloudflare/api`) + +### What it watches + +Cloudflare's REST API (`api.cloudflare.com/client/v4`): every operation Cloudflare names as deprecated on its API deprecations page. It's a `breaking` event, dated by the end of life, when the item says the endpoints stop on a full end-of-life date. Otherwise it's a `deprecation`. + +Kind: `notices` (`kinds/notices`), with the feed reader (`kinds/notices/feed`) and its `API` feed ([`api.go`](api.go)). + +### Why this source + +- **Source:** [API deprecations](https://developers.cloudflare.com/fundamentals/api/reference/deprecations/), read as its RSS feed `https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml`. Checked on 2026-11-19. +- **Why this one:** it's where Cloudflare announces API deprecations, by its own description: "When this happens, we will communicate when the API will no longer be available and whether there will be a replacement." + - The feed carries every announcement since 2020, 50 items. + - Since 2024, most items name what they deprecate under "Deprecated APIs:", usually one `METHOD /path` per line. That list is kept apart from "Affected APIs:", which lists endpoints that only change. + - Most items since 2025 give an "End of life date:". + - The deprecated endpoints that are still in Cloudflare's OpenAPI spec are flagged deprecated there too (56 of 58 on 2026-11-19), so the page and the spec agree. +- **Alternatives considered:** + - **Cloudflare's OpenAPI spec, [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas).** It flags more operations deprecated (321 on 2026-11-19), but only 53 of those carry a date (`x-cfDeprecation` or `x-forge-sunset`). + - Its removals can't be trusted as shutdowns. Over 39 snapshots from 2024-11 to 2026-11, 477 operations left the spec and only 38 had been deprecated first. 17 came back later, and 141 were path-parameter renames. + - There's no way to check from outside whether a removed endpoint still answers: without credentials every route returns the same authentication error. + - It has no tags, and changes about ten times a day. + - **The [changelog](https://developers.cloudflare.com/changelog/) feed.** It covers every product, mostly announcements; the deprecations page is its API part. + - **The SDKs** (`cloudflare` on PyPI and npm). They're generated from the spec. The Python SDK's `CHANGELOG.md` lists SDK-level breaking changes (removed methods and types), which is a different subject. +- **Quote:** "End of life date: September 27, 2026" and "After this date, the legacy endpoints will no longer be available." (Legacy Registrar Domain Management API) + +### How the provider announces changes + +- **No API-wide version.** Everything is under `/client/v4`, with no per-endpoint or date versions. +- **The deprecations page** gets a new item for each announcement, newest first. An item gives the deprecation date, usually the end-of-life date, the deprecated operations and the replacement. It's sometimes updated later, for example when an end of life is extended ("previously September 15, 2026"). +- **Notice** runs from three months (Radar's layer 7 attack magnitude parameter, 2025-03-11 to 2025-06-11) to almost two years (Zone Settings Batch API, 2025-04-23 to 2027-03-31, after one extension). + +### What the plugin reads and ignores + +- **Reads:** each item's "Deprecated APIs:" list, one event per operation. The operation is written as the page writes it, normalized to `{param}` with a leading `/` and no trailing `/`; the oldest items write `GET zones/:zone_identifier/...`. +- **Event type:** + - **`breaking`** when the item gives a full "End of life date:" and says the endpoints stop ("After this date, the legacy endpoints will no longer be available."). `version` is the end-of-life date. An end-of-life date alone isn't enough: of the 11 items with one on 2026-11-19, only 2 say the endpoints stop. + - **`deprecation`** otherwise. `version` is the deprecation date, or, when the page gives only a month ("November 2025"), the date the item was published. +- **Drops** (and logs, with why): + - Items with no "Deprecated APIs:" list: behavior changes, cipher suites, fields and settings ("Affected APIs:", "Modified API"). One 2022 item (Cloudflare Images direct upload v1) names its operation inline instead of in a list, and is dropped with them. + - Items that tell direct API callers no action is required. The Radar summary and timeseries groups endpoints have an end of life, but "For users calling the API directly (not via the Cloudflare SDK), no action is required": the URLs still fit the new `/summary/{dimension}` endpoints, and only an SDK method moves. + - List items that aren't one operation: "`GET` and `POST` /…" (the 2026 Workers KV item writes three of its five that way), a DNS-over-HTTPS hostname, "Other similar … endpoints". + - List items where the text after the operation is a sentence about it, not a name for it, such as `POST /accounts/{account_id}/gateway/rules` "— creating rules with action: "audit_ssh" is no longer accepted". What goes is one value; the operation stays, so naming it would be wrong. +- On the feed saved 2026-11-19 this gives 114 events from 27 items: 5 breaking (Zone Settings Batch API and the Legacy Registrar API) and 109 deprecations. It logs 27 drops: 21 whole items and 6 list items. +- **Cites** a Wayback Machine snapshot of the feed, read back and checked against the live feed (`kit.Cite`). +- **Historical change in the golden test:** the Legacy Registrar Domain Management API, deprecated 2026-04-10 with end of life 2026-09-27. Its three operations left Cloudflare's OpenAPI spec in October 2026. + +### Known gaps + +- **Field, value and behavior changes aren't events.** The page describes them in prose ("Affected APIs:"), and there's no operation to name as deprecated. +- **Operations the spec deprecates but the page doesn't list aren't events.** That's most of the spec's 321. +- **An extended end of life is a new event with the new date.** The one with the old date isn't withdrawn. +- **An end of life without "the endpoints stop" is only a deprecation.** That includes items where it likely does mean a shutdown (AMP/SXG, Zero Trust Devices), because the item doesn't say so. Whether an endpoint still answers can't be checked from outside: without credentials every route returns the same authentication error. +- **Path parameter names follow the page,** not always the spec (`{zone_identifier}` in old items, `{zone_id}` in the spec). +- **The patch-it client can't place these events yet.** Its version check reads an `api_operation` event's version as a package version, so a date (`2026-09-27`) doesn't parse and the event is dropped. It needs a rule for date-versioned API events, like the one model retirements have. +- **`previous_version` is a read, not a release.** The events are `api_operation` subjects, which the change-event contract requires to name the version they were compared with. A page of notices has no releases, so it's the dated read the page was compared with (the read before; on the first read, that read itself, `2026-11-14T12:00:00Z` in the golden file). `version` stays the notice's own. + +## Cloudflare API spec (`cloudflare/api-spec`) + +### What it watches + +The Cloudflare API (`api.cloudflare.com/client/v4`): operations Cloudflare marks deprecated, and removals of operations it had marked deprecated, day by day in the OpenAPI spec its SDKs and Terraform provider are generated from. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `Cloudflare` ([`api_spec.go`](api_spec.go)). (`cloudflare/api` is Cloudflare's deprecations feed, read by the `notices` kind.) + +### Why this source + +- **Source:** `openapi.json` in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) (BSD-3-Clause), pinned to a commit (`https://raw.githubusercontent.com/cloudflare/api-schemas//openapi.json`). The versions come from the GitHub commits API. Checked on 2026-11-21. +- **Why this one:** + - It's Cloudflare's own description of the whole API, published by a bot several times a day ("Update schema: openapi.json"), the input to `cloudflare-python`, `cloudflare-typescript` and the Terraform provider. + - It marks deprecated operations with the `deprecated` flag, and most carry `x-stainless-deprecation-message` with the end-of-life date. + - Every commit can be cited and replayed. +- **Alternatives considered:** + - **`openapi.yaml` beside it:** the same spec as YAML. + - **The [API deprecations page](https://developers.cloudflare.com/fundamentals/api/reference/deprecations/)** and its feed: read by `cloudflare/api` (kind `notices`). It announces end-of-life dates in prose; the spec says which operation, and when it's gone. + - **The changelog:** product news, not keyed by operation. +- **Quote:** "This operation is deprecated and will reach end of life on September 27, 2026. Use the new Registrar API endpoints (domain-search, domain-check, registrations) instead." (`GET /accounts/{account_id}/registrar/domains`, removed from the spec on 2026-10-30) + +### How the provider announces changes + +- **One version per day.** The spec is committed several times a day, there are no tags, and `info.version` is a fixed `4.0.0`, so a version is a day: the day's last commit, its date the event's `version`. +- **Operations are named by the path a caller sends** (`GET /client/v4/accounts/…`): the server is `https://api.cloudflare.com/client/v4`, moved into the paths. +- **Deprecations use the flag** (329 operations on 2026-11-20) **or the summary** (11 more, written "List datasets (deprecated)" or "Deprecated: Retrieve legacy embed code HTML"). Other uses of "deprecated" in summaries and descriptions are about a parameter or a model. +- **Path parameters get renamed** (`{zone_identifier}` to `{zone_id}` on 2026-10-30) without the URL changing. +- **Operations leave the spec without notice too:** POST `/accounts/move` and the `/tenants/{tenant_id}` operations on 2026-10-30, never marked. + +### What the plugin reads and ignores + +- **Reads** every day's spec, diffed against the day before. Two events come out of it: + - **Deprecations:** an operation that gains the flag or a summary saying so. A flagged one quotes the whole operation (its deprecation message included). + - **Removals (breaking):** an operation that leaves the spec after the previous day's spec had marked it deprecated. +- **Matches operations by path template,** so a renamed path parameter isn't a removal. +- **Ignores everything else:** removals of operations never marked deprecated, schema and property changes (mostly the generator's), new operations. +- **The golden test** replays 2026-10-29 → 2026-10-30: the three deprecated Registrar domains operations removed, three events. The drop test is the same pair: POST `/accounts/move` and GET `/tenants/{tenant_id}`, gone unmarked, make none. + +### Known gaps + +- **Deprecated parameters and fields** aren't events: only whole operations are. +- **Removals Cloudflare didn't mark first aren't events.** +- **History:** the GitHub commits API lists at most 1,000 commits, about five months of this spec (back to 2026-06-11 on 2026-11-21); older days aren't listed. +- **Size:** each version is a 30 MB download. +- **The patch-it client needs `cloudflare` in its list of date-versioned APIs** to place the events' date `version`; that list is outside this repo. + +## Cloudflare Python SDK (`cloudflare/python-surface`) + +### What it watches + +The public API of the `cloudflare` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install cloudflare==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** GitHub release notes and CHANGELOG.md (commit titles); the spec (the HTTP API). +- **Quote:** `class AsyncOAuthScopesResource(AsyncAPIResource)` (`cloudflare/resources/iam/oauth_scopes/oauth_scopes.py` line 68) at 5.3.0, gone at 5.4.0. + +### How the provider announces changes + +- The SDK is generated from Cloudflare's API spec (`cloudflare/api-spec`) and every minor removes generated types and resources with the API: hundreds of events in some releases (1,533 at 5.10.0), each a name that no longer imports. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `cloudflare/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. +- Releases are large (about 60,000 public names); a nested response type removed with its API reads as one event per module that defines it. + +## Cloudflare SDKs and Terraform provider (`cloudflare/typescript`, `cloudflare/python`, `cloudflare/go`, `cloudflare/terraform`) + +### What it watches + +Methods, sub-resources, types and attributes removed or renamed in each release of Cloudflare's TypeScript, Python and Go SDKs and its Terraform provider, from that release's section of the repo's `CHANGELOG.md` at its tag. One `package_release` event per bullet that names what it removes plainly. Cloudflare's API notices are a separate source (`cloudflare/api`). + +Kind: `changelog` (`kinds/changelog`, `sdks.go`). + +| Source | Package | Releases listed from | Layer | +|---|---|---|---| +| `cloudflare/typescript` | `npm:cloudflare` | npm | sdk | +| `cloudflare/python` | `pypi:cloudflare` | PyPI | sdk | +| `cloudflare/go` | `go:github.com/cloudflare/cloudflare-go/v7` (events name the module at each release's major) | the repo's `vX.Y.Z` tags | sdk | +| `cloudflare/terraform` | none (Terraform registry `cloudflare/cloudflare`; events carry ecosystem `terraform`) | the repo's `vX.Y.Z` tags | infra | + +### Why this source + +- **Source:** https://github.com/cloudflare/cloudflare-typescript/blob/main/CHANGELOG.md, https://github.com/cloudflare/cloudflare-python/blob/main/CHANGELOG.md, https://github.com/cloudflare/cloudflare-go/blob/main/CHANGELOG.md, https://github.com/cloudflare/terraform-provider-cloudflare/blob/main/CHANGELOG.md, each read raw at the release's `vX.Y.Z` tag; checked on 2026-11-20. +- **Why this one:** the SDKs are generated and breaking changes ship in minors; release-please puts each under "⚠ BREAKING CHANGES", one bullet per area (`**accounts:** …`), naming what was removed. +- **Alternatives considered:** GitHub release notes (the same text); the per-major upgrade guides (`docs/guides/version-5-upgrade.md` for Terraform: one entry per resource, no plain removal sentences); diffing the published packages (`apisurface`, when it's built). +- **Quote:** "**ssl:** The `Host`, `Status`, and `ValidationMethod` types have been removed from `cloudflare.types.ssl`." (cloudflare-python 5.6.0). + +### How the provider announces changes + +Frequent minors, several a month; breaking bullets in a minor's "⚠ BREAKING CHANGES" section. + +### What the plugin reads and ignores + +- Reads the release's section; the area prefix (`**ssl:**`) is read past. Counts `X has been removed (from Y)`, `X and Y types removed`, `Remove X`, `X has been renamed to Y`, and bare names under a removal heading. +- Drops (and logs): changed return types, changed import IDs, simplified responses, renamed enum values, anything that removes a list of names "along with" others in prose. + +### Known gaps + +- A Terraform attribute removed from a block is named by the attribute only when the bullet doesn't name its resource plainly. +- A release whose section is missing at its tag is skipped as nothing to read. diff --git a/providers/cloudflare/api.go b/providers/cloudflare/api.go new file mode 100644 index 0000000..81e11cf --- /dev/null +++ b/providers/cloudflare/api.go @@ -0,0 +1,153 @@ +package cloudflare + +import ( + "fmt" + "regexp" + "strings" + "time" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" +) + +// API is Cloudflare's API deprecations page as RSS 2.0 (checked +// 2026-11-19: every announcement since 2020, 50 items, newest first, no +// categories). Every item is a deprecation, so none needs marking. An item +// names what it deprecates under "Deprecated APIs:", one `METHOD /path` per +// list item, kept apart from "Affected APIs:" (endpoints that only change), +// and gives "Deprecation date:" and, for most since 2025, "End of life date:". +var API = feed.Feed{ + API: "cloudflare/api", + Vendor: "Cloudflare", + URL: "https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml", + Read: readCloudflareAPI, +} + +func readCloudflareAPI(e feed.Entry) []feed.Finding { + title := strings.TrimPrefix(e.Title, "API deprecations - ") + drop := func(why string) []feed.Finding { + return []feed.Finding{{Entry: e.Link, Dropped: fmt.Sprintf("%q: %s", title, why)}} + } + m := cfDeprecatedList.FindStringSubmatch(e.HTML) + if m == nil { + // Behavior changes, fields or settings, cipher suites: no operation + // is deprecated, so there's no api_operation to name. + return drop(`no "Deprecated APIs:" list of operations`) + } + + lines := feed.Lines(e.HTML) + for _, l := range lines { + if cfNoAction.MatchString(l) { + // The URL keeps working; only an SDK method moves (the Radar + // summary endpoints, folded into /summary/{dimension}). + return drop("says direct API callers need no action: " + l) + } + } + + // Breaking needs the item to say the endpoints stop ("will no longer be + // available") and a full end-of-life date. An end-of-life date alone isn't + // enough: of the 11 items with one on 2026-11-19, only 2 say the + // endpoints stop, and one tells API callers no action is required. + // Anything else is a deprecation, dated by the deprecation date, else the + // day the item was published. + var eolLine, depLine, stopLine string + for _, l := range lines { + switch { + case eolLine == "" && cfEOL.MatchString(l): + eolLine = l + case depLine == "" && cfDeprecated.MatchString(l): + depLine = l + } + } + for _, p := range cfParagraph.FindAllStringSubmatch(e.HTML, -1) { + if l := feed.Text(p[1]); cfStops.MatchString(l) { + stopLine = l + break + } + } + ct, date, dateLine := event.ChangeTypeDeprecation, feed.Date(depLine), depLine + if d := feed.Date(eolLine); d != "" && stopLine != "" { + ct, date, dateLine = event.ChangeTypeBreaking, d, eolLine + } + if date == "" { + if t, err := time.Parse(time.RFC1123, strings.TrimSpace(e.Published)); err == nil { + date, dateLine = t.UTC().Format("2006-01-02"), "" + } + } + if date == "" { + return drop("no date: neither an end of life, a deprecation date nor a publication date") + } + + var out []feed.Finding + for _, li := range feed.ListItem.FindAllStringSubmatch(m[1], -1) { + codes := feed.Codes(li[1]) + text := feed.Text(li[1]) + // One operation, in code, first, and at most a name after it: "GET + // /path — List domains". Not "GET and POST /path", a hostname, nor + // "POST /path — creating rules with action: audit_ssh is no longer + // accepted", which deprecates a value, not the operation. + if len(codes) < 1 || !strings.HasPrefix(text, codes[0]) || cfSentence.MatchString(strings.TrimPrefix(text, codes[0])) { + out = append(out, feed.Finding{Entry: e.Link, Dropped: fmt.Sprintf("%q: list item %q isn't one operation", title, text)}) + continue + } + op := cfOperation.FindStringSubmatch(codes[0]) + if op == nil { + out = append(out, feed.Finding{Entry: e.Link, Dropped: fmt.Sprintf("%q: list item %q isn't one operation", title, text)}) + continue + } + path := "/" + strings.TrimSuffix(cfColonParam.ReplaceAllString(op[2], "{$1}"), "/") + operation := op[1] + " " + path + + desc := fmt.Sprintf("Cloudflare API operation %s is deprecated (%s).", operation, date) + if ct == event.ChangeTypeBreaking { + desc = fmt.Sprintf("Cloudflare API operation %s reaches end of life on %s, the date Cloudflare stops serving it.", operation, date) + } + quote := []string{e.Title} + if dateLine != "" { + quote = append(quote, dateLine) + } + if ct == event.ChangeTypeBreaking { + quote = append(quote, stopLine) + } + out = append(out, feed.Finding{ + ChangeType: ct, + Version: date, + Subject: event.Subject{Type: event.SubjectAPIOperation, Kind: event.KindOperation, Side: event.SideRequest, Operation: operation}, + Description: desc, + Hint: "Move to the replacement Cloudflare names in its deprecation notice: " + e.Link, + Excerpt: feed.Excerpt(append(quote, "Deprecated APIs:", text)...), + Entry: e.Link, + }) + } + return out +} + +var ( + // cfDeprecatedList is the "Deprecated APIs:" paragraph and the list after + // it. Only the first: no item on the feed (2026-11-19) has two. + cfDeprecatedList = regexp.MustCompile(`(?is)

    \s*Deprecated APIs?:\s*

    \s*
      (.*?)
    `) + // cfOperation is a list item that starts with one operation in code: + // "GET /zones/{zone_id}/settings", or as the oldest entries write it, + // "GET zones/:zone_identifier/analytics/dashboard" or "GET/zones/...". + cfOperation = regexp.MustCompile(`^(GET|POST|PUT|PATCH|DELETE) ?/?([A-Za-z0-9_{}:@.\-]+(?:/[A-Za-z0-9_{}:@.\-]*)*)$`) + cfColonParam = regexp.MustCompile(`:([A-Za-z_][A-Za-z0-9_]*)`) + cfEOL = regexp.MustCompile(`(?i)^End of life date:`) + cfDeprecated = regexp.MustCompile(`(?i)^Deprecation date:`) + // cfStops is the item saying the endpoints stop, with the endpoints as + // what stops: "After this date, the legacy endpoints will no longer be + // available." Only a paragraph counts: a list item under "Affected APIs:" + // saying "Mirage parameter will be removed" is about a field. And not a + // sentence that only mentions the API: "Service Key authentication for + // the Cloudflare API is deprecated and will be removed" is about the + // authentication. + cfStops = regexp.MustCompile(`(?i)\b(endpoints?|APIs?|operations?) will (no longer be (available|accessible|served)|be (removed|shut down|turned off))\b`) + cfParagraph = regexp.MustCompile(`(?is)

    (.*?)

    `) + // cfNoAction is an item telling direct API callers nothing changes for + // them: "For users calling the API directly (not via the Cloudflare SDK), + // no action is required." + cfNoAction = regexp.MustCompile(`(?i)calling the API directly[^.]*no action is required`) + // cfSentence is text after an operation that says something about it + // ("— creating rules with action: audit_ssh is no longer accepted"), as + // opposed to a name for it ("— List domains", "(DNS Analytics API)"). + cfSentence = regexp.MustCompile(`(?i)\b(is|are|was|were|will|no longer|must|only|with)\b`) +) diff --git a/plugins/openapi/adapter/cloudflare.go b/providers/cloudflare/api_spec.go similarity index 50% rename from plugins/openapi/adapter/cloudflare.go rename to providers/cloudflare/api_spec.go index e30a1e6..2f7d9fb 100644 --- a/plugins/openapi/adapter/cloudflare.go +++ b/providers/cloudflare/api_spec.go @@ -1,13 +1,17 @@ -package adapter +package cloudflare import ( "context" "encoding/json" "fmt" + "regexp" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // Variables, not constants, only so tests can point them at a local server. @@ -33,7 +37,7 @@ var ( // the openapi plugin. A tag here is a commit SHA. type Cloudflare struct{} -var _ Adapter = Cloudflare{} +var _ adapter.Adapter = Cloudflare{} func (Cloudflare) API() string { return "cloudflare/api-spec" } @@ -49,44 +53,76 @@ func (Cloudflare) LatestTag(ctx context.Context) (string, error) { // Versions are the days the spec changed, each read at that day's last // commit (Daily). func (Cloudflare) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, cloudflareRepo, cloudflarePath) + return adapter.Commits(ctx, cloudflareRepo, cloudflarePath) } // Fetch downloads the spec at commit sha and moves the server's /client/v4 // into the paths: see ServerBasePath. Version is the commit's date // (YYYY-MM-DD): info.version is a fixed "4.0.0" (checked 2026-11-21). -func (Cloudflare) Fetch(ctx context.Context, sha string) (Spec, error) { +func (Cloudflare) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(cloudflareCommitURL, sha)) if err != nil { - return Spec{}, fmt.Errorf("looking up cloudflare spec commit %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("looking up cloudflare spec commit %s: %w", sha, err) } if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha", sha) + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha", sha) } url := fmt.Sprintf(cloudflareSpecURLTemplate, fullSHA) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching cloudflare spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("fetching cloudflare spec %s: %w", sha, err) } if !json.Valid(body) { - return Spec{}, fmt.Errorf("cloudflare spec %s is not valid json", sha) + return adapter.Spec{}, fmt.Errorf("cloudflare spec %s is not valid json", sha) } // The one server is "https://api.cloudflare.com/client/v4" and the // paths don't repeat it: moved, an operation is named by the path a // caller sends. - content, err := ServerBasePath(body) + content, err := adapter.ServerBasePath(body) if err != nil { - return Spec{}, fmt.Errorf("cloudflare spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("cloudflare spec %s: %w", sha, err) } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil } // SourcePointer: see BasePathPointer. func (Cloudflare) SourcePointer(content []byte) func(string) string { - return BasePathPointer(content) + return adapter.BasePathPointer(content) } var ( - _ Reshaper = Cloudflare{} - _ Lister = Cloudflare{} + _ adapter.Reshaper = Cloudflare{} + _ adapter.Lister = Cloudflare{} ) + +// cloudflareDiff is how Cloudflare's spec says what it says: +// +// - Most deprecations use the `deprecated` flag (329 operations in the spec +// of 2026-11-20), and a few only the summary, written as Vercel's are: "List +// datasets (deprecated)", "Deprecated: Retrieve legacy embed code HTML" +// (11 of them). Other summaries and descriptions that say "deprecated" +// are about a parameter or a model, not the operation, so the +// description isn't read. +// - Path parameters are renamed without the URL changing: +// /zones/{zone_identifier}/analytics/dashboard became +// /zones/{zone_id}/analytics/dashboard on 2026-10-30. Matching by path +// template keeps that from reading as a removal. +var cloudflareDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true, DeprecatedSummary: cloudflareDeprecatedSummary} + +// cloudflareDeprecatedWords: a summary that starts "Deprecated:" or ends +// "(deprecated)". Not "deprecat" anywhere ("Omitting `datasetId` is +// deprecated" is about a parameter). +var cloudflareDeprecatedWords = regexp.MustCompile(`(?i)^deprecated:|\(deprecated\)\s*$`) + +func cloudflareDeprecatedSummary(summary string) bool { + return cloudflareDeprecatedWords.MatchString(summary) +} + +// cloudflareKeep keeps operation deprecations, and removals of operations the +// old spec had marked deprecated. Everything else is dropped: a bot commits +// the 30 MB spec several times a day, and an operation can leave it without +// leaving the API or without notice (between 2026-10-29 and 2026-10-30 POST +// /accounts/move and four GET /tenants/{tenant_id} operations left it, never +// marked deprecated: the drop test), while property changes in the +// generated schemas are mostly the generator's. +var cloudflareKeep = openapi.DeprecationsOnly(cloudflareDiff) diff --git a/plugins/openapi/cloudflare_test.go b/providers/cloudflare/api_spec_test.go similarity index 85% rename from plugins/openapi/cloudflare_test.go rename to providers/cloudflare/api_spec_test.go index 807619c..8721627 100644 --- a/plugins/openapi/cloudflare_test.go +++ b/providers/cloudflare/api_spec_test.go @@ -1,4 +1,4 @@ -package openapi +package cloudflare import ( "context" @@ -9,7 +9,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // cloudflareDays are the saved excerpts of cloudflare/api-schemas's @@ -24,7 +26,7 @@ func cloudflareURL(day string) string { } // fakeCloudflareAdapter serves the saved excerpts, cited by the real URL each -// was copied from and reshaped as adapter.Cloudflare.Fetch does. +// was copied from and reshaped as Cloudflare.Fetch does. type fakeCloudflareAdapter struct{} func (fakeCloudflareAdapter) API() string { return "cloudflare/api-spec" } @@ -51,7 +53,7 @@ func (fakeCloudflareAdapter) SourcePointer(content []byte) func(string) string { } func TestCloudflareRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Adapter: adapter.Cloudflare{}}) + kittest.Registered(t, openapi.Plugin{Adapter: Cloudflare{}}) } // cloudflarePair stores the 2026-10-29 -> 2026-10-30 pair: the three @@ -60,9 +62,9 @@ func TestCloudflareRegistersItself(t *testing.T) { func cloudflarePair(t *testing.T) []event.Event { t.Helper() ctx := context.Background() - s := openStore(t) - p := Plugin{Adapter: fakeCloudflareAdapter{}, Diff: cloudflareDiff, Keep: cloudflareKeep} - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, p, "2026-10-29", "2026-10-30"); err != nil || rejected { + s := kittest.NewMem() + p := openapi.Plugin{Adapter: fakeCloudflareAdapter{}, Diff: cloudflareDiff, Keep: cloudflareKeep} + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "2026-10-29", "2026-10-30"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } return kittest.Stored(t, s) diff --git a/plugins/notices/feed/cloudflare_test.go b/providers/cloudflare/api_test.go similarity index 93% rename from plugins/notices/feed/cloudflare_test.go rename to providers/cloudflare/api_test.go index 2989a10..d130f12 100644 --- a/plugins/notices/feed/cloudflare_test.go +++ b/providers/cloudflare/api_test.go @@ -1,4 +1,4 @@ -package feed +package cloudflare import ( "strings" @@ -6,13 +6,15 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest" ) const cloudflareFeed = "testdata/cloudflare-api-deprecations.rss.xml" -func cloudflareFindings(t *testing.T) (kept, dropped []Finding) { +func cloudflareFindings(t *testing.T) (kept, dropped []feed.Finding) { t.Helper() - fs, err := CloudflareAPI.Findings(kittest.Read(t, cloudflareFeed)) + fs, err := API.Findings(kittest.Read(t, cloudflareFeed)) if err != nil { t.Fatal(err) } @@ -113,8 +115,8 @@ func TestCloudflareCounts(t *testing.T) { } } -func cfEntry(dates, items string) Entry { - return Entry{Title: "API deprecations - X", Link: "https://x.test/#x", Published: "Mon, 29 Jun 2026 00:00:00 GMT", +func cfEntry(dates, items string) feed.Entry { + return feed.Entry{Title: "API deprecations - X", Link: "https://x.test/#x", Published: "Mon, 29 Jun 2026 00:00:00 GMT", HTML: dates + "

    Deprecated APIs:

    \n
      \n" + items + "
    \n

    Replacement:

    • GET /new
    "} } @@ -202,7 +204,7 @@ func TestCloudflareDates(t *testing.T) { if fs := readCloudflareAPI(noDates); len(fs) != 1 || fs[0].Dropped == "" { t.Errorf("no date at all: %+v, want dropped", fs) } - if fs := readCloudflareAPI(Entry{Title: "API deprecations - Y", HTML: "

    Affected APIs:

    • GET /a
    "}); len(fs) != 1 || fs[0].Dropped == "" { + if fs := readCloudflareAPI(feed.Entry{Title: "API deprecations - Y", HTML: "

    Affected APIs:

    • GET /a
    "}); len(fs) != 1 || fs[0].Dropped == "" { t.Errorf("only affected APIs: %+v, want dropped", fs) } } @@ -230,3 +232,9 @@ func TestCloudflareNoActionForAPICallersIsNoEvent(t *testing.T) { t.Errorf("%d drops logged for the Radar summary item, want 1", n) } } + +// The feed as saved on 2026-11-19 (testdata/README.md) through the whole +// plugin. +func TestAPIGolden(t *testing.T) { + noticestest.Golden(t, API, "testdata/cloudflare-api-deprecations.rss.xml") +} diff --git a/providers/cloudflare/provider.go b/providers/cloudflare/provider.go new file mode 100644 index 0000000..7871bc3 --- /dev/null +++ b/providers/cloudflare/provider.go @@ -0,0 +1,62 @@ +// Package cloudflare is what patch-it reads for Cloudflare: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package cloudflare + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/kit" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "cloudflare", Name: "Cloudflare", Category: plugin.CategoryInfrastructure, Homepage: "https://www.cloudflare.com", + Sources: []plugin.Source{ + // No Hints: Cloudflare's changelog is product news, not keyed by + // operation. Only operation deprecations and removals: see api_spec.go. + // (cloudflare/api is the deprecations feed, read by the notices kind, below.) + { + ID: "api-spec", Layer: plugin.LayerAPI, + Watches: "API operations deprecated, and deprecated operations removed, day by day in the spec Cloudflare's SDKs and Terraform provider are generated from", + URLs: []string{"https://github.com/cloudflare/api-schemas/blob/main/openapi.json"}, + Packages: []string{"pypi:cloudflare", "npm:cloudflare"}, + Plugin: openapi.Plugin{Adapter: Cloudflare{}, Diff: cloudflareDiff, Keep: cloudflareKeep}, + }, + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API operations Cloudflare deprecates, breaking on their end-of-life date when it gives one", + URLs: []string{"https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml"}, + Packages: []string{"pypi:cloudflare", "npm:cloudflare"}, + Plugin: notices.Plugin{Page: API, Archiver: kit.Wayback{}}, + }, + changelog.SDK("typescript", Typescript, "npm:cloudflare"), + changelog.SDK("python", Python, "pypi:cloudflare"), + changelog.SDK("go", Go, "go:github.com/cloudflare/cloudflare-go/v7"), + changelog.SDK("terraform", Terraform), + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/cloudflare/cloudflare-python"), + }, + }) +} + +// Cloudflare's Stainless SDKs and its Terraform provider: release-please +// CHANGELOG.md, "## X.Y.Z (date)" with "### ⚠ BREAKING CHANGES" and bullets +// that start with an area ("**accounts:** ..."); tagged vX.Y.Z. +var ( + Typescript = changelog.File{API: "cloudflare/typescript", Package: "cloudflare", Ecosystem: "npm", + Repo: "cloudflare/cloudflare-typescript", TagPrefix: "v", Path: "CHANGELOG.md"} + Python = changelog.File{API: "cloudflare/python", Package: "cloudflare", Ecosystem: "pypi", Module: "cloudflare", + Repo: "cloudflare/cloudflare-python", TagPrefix: "v", Path: "CHANGELOG.md"} + Go = changelog.File{API: "cloudflare/go", Package: "github.com/cloudflare/cloudflare-go", Ecosystem: "go", + Repo: "cloudflare/cloudflare-go", TagPrefix: "v", Path: "CHANGELOG.md"} + Terraform = changelog.File{API: "cloudflare/terraform", Package: "cloudflare/cloudflare", Ecosystem: "terraform", + Repo: "cloudflare/terraform-provider-cloudflare", TagPrefix: "v", Path: "CHANGELOG.md"} +) + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "cloudflare/python-surface", Name: "cloudflare", Ecosystem: "pypi", Module: "cloudflare"} +) diff --git a/providers/cloudflare/python_surface_test.go b/providers/cloudflare/python_surface_test.go new file mode 100644 index 0000000..8572399 --- /dev/null +++ b/providers/cloudflare/python_surface_test.go @@ -0,0 +1,19 @@ +package cloudflare + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// cloudflare 5.4.0 dropped the web crawler's crawl options from AI +// Search instances, and moved the IAM OAuth scopes resource out of its +// own package (the old package still binds the response wrappers: no +// event for those). +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"5.3.0", "5.4.0"}, Want: []string{ + "removed_symbol resources.iam.oauth_scopes.oauth_scopes.AsyncOAuthScopesResource ", + "removed_symbol resources.iam.oauth_scopes.oauth_scopes.OAuthScopesResource ", + "removed_symbol types.aisearch.instance_create_params.SourceParamsWebCrawlerCrawlOptions ", + }, Drop: [2]string{"4.3.0", "4.3.1"}}) +} diff --git a/providers/cloudflare/sdks_test.go b/providers/cloudflare/sdks_test.go new file mode 100644 index 0000000..8632609 --- /dev/null +++ b/providers/cloudflare/sdks_test.go @@ -0,0 +1,16 @@ +package cloudflare + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +func TestCloudflareSDKs(t *testing.T) { + changelogtest.CheckSDKs(t, []changelogtest.SDKCase{ + {File: Typescript, Release: "7.1.0", Prev: "7.0.0", Saved: "cloudflare-typescript-7.1.0-CHANGELOG.md", Dropped: "", Drop: "7.0.0"}, + {File: Python, Release: "5.6.0", Prev: "5.5.0", Saved: "cloudflare-python-5.6.0-CHANGELOG.md", Dropped: "", Drop: "5.4.0"}, + {File: Go, Release: "7.15.0", Prev: "7.14.0", Saved: "cloudflare-go-7.15.0-CHANGELOG.md", Dropped: "", Drop: "7.13.1"}, + {File: Terraform, Release: "5.29.0", Prev: "5.28.1", Saved: "cloudflare-terraform-5.29.0-CHANGELOG.md", Dropped: "", Drop: "5.28.1"}, + }) +} diff --git a/providers/cloudflare/testdata/README.md b/providers/cloudflare/testdata/README.md new file mode 100644 index 0000000..a911fb4 --- /dev/null +++ b/providers/cloudflare/testdata/README.md @@ -0,0 +1,31 @@ +# Cloudflare: saved copies and goldens + +Real copies of what Cloudflare publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/cloudflare -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved feed + +A real copy, saved once with `curl`; the golden test reads it through the whole `notices` plugin. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `cloudflare-api-deprecations.rss.xml` | https://developers.cloudflare.com/fundamentals/api/reference/deprecations/index.xml (RSS 2.0; `ETag` sent) | 2026-11-19 15:44 UTC | CC BY 4.0 (Cloudflare's documentation, cloudflare/cloudflare-docs), kept whole | "End of life date: September 27, 2026" (Legacy Registrar Domain Management API) | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/cloudflare/`: `cloudflare-4.3.0-py3-none-any.trimmed.whl`, `cloudflare-4.3.1-py3-none-any.trimmed.whl`, `cloudflare-5.3.0-py3-none-any.trimmed.whl`, `cloudflare-5.4.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/83/7f/0f9370a1d2a2e425056134ccfc6b5b8f12ed43be600223bd1612f9f56c32/cloudflare-4.3.0-py3-none-any.whl; https://files.pythonhosted.org/packages/3a/8f/c6c543565efd3144da4304efa5917aac06b6416a8663a6defe0e9b2b7569/cloudflare-4.3.1-py3-none-any.whl; https://files.pythonhosted.org/packages/c5/6f/b7624d3a8f0637b04e883f289f530c88e1c4f683c70d8ebe291e4b430ec1/cloudflare-5.3.0-py3-none-any.whl; https://files.pythonhosted.org/packages/c2/bf/20002f7398cb5dc2f289cccd19777aa8869d40d5b01961ccbe8e25e094a6/cloudflare-5.4.0-py3-none-any.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `cloudflare/resources/iam/__init__.py`, `cloudflare/resources/iam/oauth_scopes.py`, `cloudflare/resources/iam/oauth_scopes/__init__.py`, `cloudflare/resources/iam/oauth_scopes/oauth_scopes.py`, `cloudflare/types/aisearch/__init__.py`, `cloudflare/types/aisearch/instance_create_params.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/cloudflare/`: `pypi-cloudflare-excerpt.json` and `pypi-cloudflare-4.3.0.json`, `pypi-cloudflare-4.3.1.json`, `pypi-cloudflare-5.3.0.json`, `pypi-cloudflare-5.4.0.json` | https://pypi.org/pypi/cloudflare/json, https://pypi.org/pypi/cloudflare/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | + +## SDK changelogs + +Read with `Plugin{File: ...}` (`kinds/changelog/sdks.go`); `golden/-.json` is what each stores from its release (`changelogtest.CheckSDKs`), the pair from the release before it on the registry (or among the repo's tags). Every file is the changelog at the release's tag, saved with `curl`, **trimmed** to two releases' sections, each kept whole and unchanged: the release the golden pins and one more release from the same file whose notes remove nothing the reader can name (the drop test). Only the pinned release's own section is read for the golden, so the trimmed copy gives the same events as the whole file (checked when each copy was made). + +| File | URL | Tag commit | Saved | License; trimming | Quote | +|---|---|---|---|---|---| +| `cloudflare-typescript-7.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/cloudflare-typescript/v7.1.0/CHANGELOG.md | `f41ff03` | 2026-11-20 | Apache-2.0 (cloudflare-typescript); trimmed to the sections of 7.1.0 (the golden) and 7.0.0 (the drop test), each unchanged | "`cloudforceOne.threatEvents.indicatorTypes` has been renamed to `cloudforceOne.threatEvents.indicators`" | +| `cloudflare-python-5.6.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/cloudflare-python/v5.6.0/CHANGELOG.md | `02ab9a9` | 2026-11-20 | Apache-2.0 (cloudflare-python); trimmed to the sections of 5.6.0 (the golden) and 5.4.0 (the drop test), each unchanged | "accounts:** The `create()` and `get()` methods have been removed from `client.accounts.subscriptions`. The `Subscript…" | +| `cloudflare-go-7.15.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/cloudflare-go/v7.15.0/CHANGELOG.md | `d2f77a0` | 2026-11-20 | Apache-2.0 (cloudflare-go); trimmed to the sections of 7.15.0 (the golden) and 7.13.1 (the drop test), each unchanged | "rules:** the `ListCursor` and `ListCursorParam` types are removed." | +| `cloudflare-terraform-5.29.0-CHANGELOG.md` | https://raw.githubusercontent.com/cloudflare/terraform-provider-cloudflare/v5.29.0/CHANGELOG.md | `8e7a366` | 2026-11-20 | Apache-2.0 (terraform-provider-cloudflare); trimmed to the sections of 5.29.0 (the golden) and 5.28.1 (the drop test), each unchanged | "zone_dns_settings, account_dns_settings:** the deprecated `foundation_dns` attribute has been removed. On `cloudflare…" | diff --git a/plugins/openapi/testdata/cloudflare-2026-10-29.json b/providers/cloudflare/testdata/cloudflare-2026-10-29.json similarity index 100% rename from plugins/openapi/testdata/cloudflare-2026-10-29.json rename to providers/cloudflare/testdata/cloudflare-2026-10-29.json diff --git a/plugins/openapi/testdata/cloudflare-2026-10-30.json b/providers/cloudflare/testdata/cloudflare-2026-10-30.json similarity index 100% rename from plugins/openapi/testdata/cloudflare-2026-10-30.json rename to providers/cloudflare/testdata/cloudflare-2026-10-30.json diff --git a/plugins/notices/feed/testdata/cloudflare-api-deprecations.rss.xml b/providers/cloudflare/testdata/cloudflare-api-deprecations.rss.xml similarity index 100% rename from plugins/notices/feed/testdata/cloudflare-api-deprecations.rss.xml rename to providers/cloudflare/testdata/cloudflare-api-deprecations.rss.xml diff --git a/plugins/changelog/testdata/cloudflare-go-7.15.0-CHANGELOG.md b/providers/cloudflare/testdata/cloudflare-go-7.15.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/cloudflare-go-7.15.0-CHANGELOG.md rename to providers/cloudflare/testdata/cloudflare-go-7.15.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/cloudflare-python-5.6.0-CHANGELOG.md b/providers/cloudflare/testdata/cloudflare-python-5.6.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/cloudflare-python-5.6.0-CHANGELOG.md rename to providers/cloudflare/testdata/cloudflare-python-5.6.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/cloudflare-terraform-5.29.0-CHANGELOG.md b/providers/cloudflare/testdata/cloudflare-terraform-5.29.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/cloudflare-terraform-5.29.0-CHANGELOG.md rename to providers/cloudflare/testdata/cloudflare-terraform-5.29.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/cloudflare-typescript-7.1.0-CHANGELOG.md b/providers/cloudflare/testdata/cloudflare-typescript-7.1.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/cloudflare-typescript-7.1.0-CHANGELOG.md rename to providers/cloudflare/testdata/cloudflare-typescript-7.1.0-CHANGELOG.md diff --git a/plugins/openapi/testdata/golden/cloudflare-api-spec.json b/providers/cloudflare/testdata/golden/cloudflare-api-spec.json similarity index 100% rename from plugins/openapi/testdata/golden/cloudflare-api-spec.json rename to providers/cloudflare/testdata/golden/cloudflare-api-spec.json diff --git a/plugins/notices/testdata/golden/cloudflare-api.json b/providers/cloudflare/testdata/golden/cloudflare-api.json similarity index 100% rename from plugins/notices/testdata/golden/cloudflare-api.json rename to providers/cloudflare/testdata/golden/cloudflare-api.json diff --git a/plugins/changelog/testdata/golden/cloudflare-go.json b/providers/cloudflare/testdata/golden/cloudflare-go.json similarity index 100% rename from plugins/changelog/testdata/golden/cloudflare-go.json rename to providers/cloudflare/testdata/golden/cloudflare-go.json diff --git a/plugins/apisurface/testdata/golden/cloudflare-python-surface.json b/providers/cloudflare/testdata/golden/cloudflare-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/cloudflare-python-surface.json rename to providers/cloudflare/testdata/golden/cloudflare-python-surface.json diff --git a/plugins/changelog/testdata/golden/cloudflare-python.json b/providers/cloudflare/testdata/golden/cloudflare-python.json similarity index 100% rename from plugins/changelog/testdata/golden/cloudflare-python.json rename to providers/cloudflare/testdata/golden/cloudflare-python.json diff --git a/plugins/changelog/testdata/golden/cloudflare-terraform.json b/providers/cloudflare/testdata/golden/cloudflare-terraform.json similarity index 100% rename from plugins/changelog/testdata/golden/cloudflare-terraform.json rename to providers/cloudflare/testdata/golden/cloudflare-terraform.json diff --git a/plugins/changelog/testdata/golden/cloudflare-typescript.json b/providers/cloudflare/testdata/golden/cloudflare-typescript.json similarity index 100% rename from plugins/changelog/testdata/golden/cloudflare-typescript.json rename to providers/cloudflare/testdata/golden/cloudflare-typescript.json diff --git a/plugins/apisurface/testdata/pypi/cloudflare/cloudflare-4.3.0-py3-none-any.trimmed.whl b/providers/cloudflare/testdata/pypi/cloudflare/cloudflare-4.3.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/cloudflare-4.3.0-py3-none-any.trimmed.whl rename to providers/cloudflare/testdata/pypi/cloudflare/cloudflare-4.3.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/cloudflare/cloudflare-4.3.1-py3-none-any.trimmed.whl b/providers/cloudflare/testdata/pypi/cloudflare/cloudflare-4.3.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/cloudflare-4.3.1-py3-none-any.trimmed.whl rename to providers/cloudflare/testdata/pypi/cloudflare/cloudflare-4.3.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/cloudflare/cloudflare-5.3.0-py3-none-any.trimmed.whl b/providers/cloudflare/testdata/pypi/cloudflare/cloudflare-5.3.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/cloudflare-5.3.0-py3-none-any.trimmed.whl rename to providers/cloudflare/testdata/pypi/cloudflare/cloudflare-5.3.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/cloudflare/cloudflare-5.4.0-py3-none-any.trimmed.whl b/providers/cloudflare/testdata/pypi/cloudflare/cloudflare-5.4.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/cloudflare-5.4.0-py3-none-any.trimmed.whl rename to providers/cloudflare/testdata/pypi/cloudflare/cloudflare-5.4.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-4.3.0.json b/providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-4.3.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-4.3.0.json rename to providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-4.3.0.json diff --git a/plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-4.3.1.json b/providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-4.3.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-4.3.1.json rename to providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-4.3.1.json diff --git a/plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-5.3.0.json b/providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-5.3.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-5.3.0.json rename to providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-5.3.0.json diff --git a/plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-5.4.0.json b/providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-5.4.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-5.4.0.json rename to providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-5.4.0.json diff --git a/plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-excerpt.json b/providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/cloudflare/pypi-cloudflare-excerpt.json rename to providers/cloudflare/testdata/pypi/cloudflare/pypi-cloudflare-excerpt.json diff --git a/providers/convex-js-surface.md b/providers/convex-js-surface.md deleted file mode 100644 index bc3d93b..0000000 --- a/providers/convex-js-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# Convex JavaScript client (`convex/js-surface`) - -## What it watches - -The public API of the `convex` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install convex@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md. -- **Quote:** `type QueryOptions>` (`dist/esm-types/browser/query_options.d.ts` line 9) at 1.35.0, gone at 1.35.1. - -## How the provider announces changes - -- Has many entry points (`convex/browser`, `convex/react`, `convex/server`, …), released every week or two. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `convex/react.useQuery`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). diff --git a/providers/convex.md b/providers/convex/README.md similarity index 56% rename from providers/convex.md rename to providers/convex/README.md index 6aad30e..2dae7a2 100644 --- a/providers/convex.md +++ b/providers/convex/README.md @@ -1,12 +1,16 @@ -# Convex (`convex/deployment-api`) +# Convex -## What it watches +Every source patch-it reads for Convex, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Convex (`convex/deployment-api`) + +### What it watches The Convex Deployment API (`{deployment-url}/api/v1`, the platform API for managing one deployment: environment variables, log streams and integrations, usage limits, data sync): operations Convex marks deprecated, and removals of operations it had marked deprecated, between two versions of the API's OpenAPI spec. -Kind: `openapi` (`plugins/openapi`), with `adapter.Convex`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `Convex` ([`deployment_api.go`](deployment_api.go)). -## Why this source +### Why this source - **Source:** `npm-packages/@convex-dev/platform/deployment-openapi.json` in [convex/convex-backend](https://github.com/convex/convex-backend) (the org was `get-convex` until 2026; GitHub redirects the old URLs, checked 2026-11-20), pinned to the commit that last changed it (`https://raw.githubusercontent.com/convex/convex-backend//npm-packages/@convex-dev/platform/deployment-openapi.json`). The newest such commit comes from the GitHub commits API. Checked on 2026-11-19. - **Why a commit, not a release tag:** the repo tags `precompiled-YYYY-MM-DD-` builds (1,213 of them), but those are daily builds of the self-hosted backend, not releases of the API. There are several on some days, ordered only by commit date, and the spec is the same in most of them. The spec at a tag is the spec at the last commit before it that changed the file, so the commits see every version a tag would, and finding the newest takes one call instead of paging through the tags. A commit never changes, so it can be cited and replayed. @@ -21,13 +25,13 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Convex`. - **The `@convex-dev/platform` npm package** (0.1.11). Its tarball has only `package.json` and the generated client, not the specs. - **Quote:** "Deprecated: use `GET /integrations` instead." (`GET /api/v1/list_log_streams`, deprecated in the spec on 2026-11-05) -## How the provider announces changes +### How the provider announces changes - **No API version beyond `/api/v1`.** `info.version` is `1.0.0` in every commit, so the event's `version` is the spec commit's committer date (UTC), the closest thing to the API version a change arrived in. The patch-it client keeps a date-versioned API's events only if it's in its list of date-versioned APIs, so `convex` needs to be in it. - **The spec changes a few times a month,** mostly with new operations and properties as Convex builds out the platform API. - **Deprecations are rare:** one so far. On 2026-10-30 (`f35879bb`, "Rename log_streaming to integrations") Convex added six `/integrations` operations; on 2026-11-05 (`5e5159cb`) it marked the six log stream operations deprecated, each naming its replacement. The commit says "The routes still work, so existing callers and older dashboards keep working." -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** the spec at the newest commit, diffed against the last one. Two events come out of it: - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so the replacement Convex names is in the excerpt. @@ -40,9 +44,46 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Convex`. - Over the 68 commits this keeps 6 events, all deprecations on 2026-11-05: `GET /api/v1/list_log_streams`, `GET /api/v1/get_log_stream/{id}`, `POST /api/v1/create_log_stream`, `POST /api/v1/update_log_stream/{id}`, `POST /api/v1/delete_log_stream/{id}`, `POST /api/v1/rotate_webhook_secret/{id}`. - **Reads** a historical pair (a version pair, `f35879bb` → `5e5159cb`) and recreates those six. The drop test replays `3f6edf7a` to `3ead9091`. -## Known gaps +### Known gaps - **Only the Deployment API is covered.** Not the Management API (see above), the client SDKs (`convex` on npm, `convex-py`), or the functions runtime. SDK removals are written as plain bullets in their changelogs, so nothing reads them yet. - **Removals Convex doesn't mark first aren't events,** even if the endpoint really went away. None has happened yet. - **Two spec commits on one day are one version** (13 days in the history), read at the day's last commit: a change made and undone the same day isn't seen. - **The patch-it client can't place these events until `convex` is in its list of date-versioned APIs.** + +## Convex JavaScript client (`convex/js-surface`) + +### What it watches + +The public API of the `convex` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install convex@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md. +- **Quote:** `type QueryOptions>` (`dist/esm-types/browser/query_options.d.ts` line 9) at 1.35.0, gone at 1.35.1. + +### How the provider announces changes + +- Has many entry points (`convex/browser`, `convex/react`, `convex/server`, …), released every week or two. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `convex/react.useQuery`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). diff --git a/plugins/openapi/adapter/convex.go b/providers/convex/deployment_api.go similarity index 53% rename from plugins/openapi/adapter/convex.go rename to providers/convex/deployment_api.go index a66d74d..01c5120 100644 --- a/plugins/openapi/adapter/convex.go +++ b/providers/convex/deployment_api.go @@ -1,12 +1,16 @@ -package adapter +package convex import ( "context" "encoding/json" "fmt" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // Variables, not constants, only so tests can point them at a local server. @@ -35,7 +39,7 @@ var ( // with one GitHub call for the newest instead of paging through the tags. type Convex struct{} -var _ Adapter = Convex{} +var _ adapter.Adapter = Convex{} func (Convex) API() string { return "convex/deployment-api" } @@ -54,37 +58,70 @@ func (Convex) LatestTag(ctx context.Context) (string, error) { // API has no version of its own (`/api/v1`, info.version a fixed "1.0.0" in // every commit, checked 2026-11-19), so the date the spec changed is the // closest thing to "the API version the change arrived in". -func (Convex) Fetch(ctx context.Context, sha string) (Spec, error) { +func (Convex) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(convexCommitURL, sha)) if err != nil { - return Spec{}, fmt.Errorf("looking up convex spec commit %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("looking up convex spec commit %s: %w", sha, err) } if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) } // Pin to the full SHA even when given a short one: the citation must // name exactly one document. url := fmt.Sprintf(convexSpecURLTemplate, fullSHA) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching convex spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("fetching convex spec %s: %w", sha, err) } if !json.Valid(body) { - return Spec{}, fmt.Errorf("convex spec %s is not valid json", sha) + return adapter.Spec{}, fmt.Errorf("convex spec %s is not valid json", sha) } // The server is "{deployment-url}/api/v1" and the paths leave out /api/v1 // (all 68 commits, checked 2026-11-19). Moved into the paths, an // operation is named by the path a caller sends, and a spec that ever // moved it (as Sentry's did) can't read as every deprecated operation // removed. - content, err := ServerBasePath(body) + content, err := adapter.ServerBasePath(body) if err != nil { - return Spec{}, fmt.Errorf("convex spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("convex spec %s: %w", sha, err) } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil } // SourcePointer: see BasePathPointer. -func (Convex) SourcePointer(content []byte) func(string) string { return BasePathPointer(content) } +func (Convex) SourcePointer(content []byte) func(string) string { + return adapter.BasePathPointer(content) +} + +var _ adapter.Reshaper = Convex{} + +// Versions are the commits that changed Convex's deployment API spec. +func (Convex) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Commits(ctx, "convex/convex-backend", "npm-packages/@convex-dev/platform/deployment-openapi.json") +} -var _ Reshaper = Convex{} +// convexDiff is how the Convex Deployment API spec says what it says: +// +// - Deprecations use the `deprecated` flag, and the description says what +// to use instead ("Deprecated: use `GET /integrations` instead."), so the +// event quotes the whole operation, not the bare `true`. Convex's docs +// build drops flagged operations, "since they stay served only for +// existing callers" (npm-packages/docs/scripts/prepare-openapi-specs.js). +// - PathTemplates, as for every spec here: a renamed path parameter isn't a +// change for callers. None has been renamed in this spec yet. +var convexDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// convexKeep keeps operation deprecations, and removals of operations the old +// spec had marked deprecated. In the spec's history (68 commits, 2025-08-19 +// to 2026-11-16) that's 6 events, all on 2026-11-05: the six log stream +// operations, deprecated for the /integrations ones added on 2026-10-30. +// No operation has left the spec. Everything else is dropped: +// +// - Request and response property changes: 18 property removals, 16 type +// changes, 10 schema removals and 3 properties no longer required over +// the history, most of them in the +// data sync, usage-limit and S3 export APIs. On 2026-07-14 the optional +// `name` left the usage-limit request and response, while the server +// didn't refuse a request that still sent it: see the drop test. +// - New operations: nobody has to fix code for a new endpoint. +var convexKeep = openapi.DeprecationsOnly(convexDiff) diff --git a/plugins/openapi/adapter/convex_test.go b/providers/convex/deployment_api_fetch_test.go similarity index 99% rename from plugins/openapi/adapter/convex_test.go rename to providers/convex/deployment_api_fetch_test.go index 0316b4d..14d8ca7 100644 --- a/plugins/openapi/adapter/convex_test.go +++ b/providers/convex/deployment_api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package convex import ( "context" diff --git a/plugins/openapi/convex_test.go b/providers/convex/deployment_api_test.go similarity index 84% rename from plugins/openapi/convex_test.go rename to providers/convex/deployment_api_test.go index f84525f..be6bdea 100644 --- a/plugins/openapi/convex_test.go +++ b/providers/convex/deployment_api_test.go @@ -1,4 +1,4 @@ -package openapi +package convex import ( "context" @@ -9,7 +9,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // convexCommits are the spec commits saved under testdata/ (trimmed to the @@ -23,7 +25,7 @@ var convexCommits = map[string][2]string{ } // fakeConvexAdapter serves the saved copies, cited by the real URL each was -// copied from, as adapter.Convex.Fetch cites it. +// copied from, as Convex.Fetch cites it. type fakeConvexAdapter struct{ latest string } func (fakeConvexAdapter) API() string { return "convex/deployment-api" } @@ -39,7 +41,7 @@ func (fakeConvexAdapter) Fetch(_ context.Context, tag string) (adapter.Spec, err if err != nil { return adapter.Spec{}, err } - // As adapter.Convex.Fetch does: /api/v1 moved from the server URL into + // As Convex.Fetch does: /api/v1 moved from the server URL into // the paths. content, err := adapter.ServerBasePath(body) if err != nil { @@ -59,8 +61,8 @@ func convexURL(tag string) string { } // convexPlugin is the plugin exactly as registered, over the saved copies. -func convexPlugin(latest string) Plugin { - return Plugin{Adapter: fakeConvexAdapter{latest: latest}, Diff: convexDiff, Keep: convexKeep} +func convexPlugin(latest string) openapi.Plugin { + return openapi.Plugin{Adapter: fakeConvexAdapter{latest: latest}, Diff: convexDiff, Keep: convexKeep} } // convexReplacements are the six log stream operations Convex deprecated on @@ -83,8 +85,8 @@ var convexReplacements = map[string]string{ // excerpt. func TestConvexGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, convexPlugin(""), "f35879bb", "5e5159cb"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, convexPlugin(""), "f35879bb", "5e5159cb"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) @@ -106,7 +108,7 @@ func TestConvexGolden(t *testing.T) { if e.SourceURL != convexURL("5e5159cb") { t.Errorf("%s: source_url %s", e.Subject.Operation, e.SourceURL) } - if node := jsonNode(t, convexFile("5e5159cb"), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, convexFile("5e5159cb"), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt doesn't match 5e5159cb#%s", e.Subject.Operation, e.SourcePointer) } if !strings.Contains(e.SourceExcerpt, `"deprecated":true`) || !strings.Contains(e.SourceExcerpt, "Deprecated: use "+instead+" instead.") { @@ -124,8 +126,8 @@ func TestConvexGolden(t *testing.T) { // rejected. No event. func TestConvexDropsPropertyChangesThatWerentDeprecations(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, convexPlugin(""), "3f6edf7a", "3ead9091"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, convexPlugin(""), "3f6edf7a", "3ead9091"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { @@ -133,10 +135,10 @@ func TestConvexDropsPropertyChangesThatWerentDeprecations(t *testing.T) { } // Without the filter the same pair reports two breaking removals of // `name`, one per schema, and nothing else. - s = openStore(t) + s = kittest.NewMem() p := convexPlugin("") p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "3f6edf7a", "3ead9091"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "3f6edf7a", "3ead9091"); err != nil { t.Fatal(err) } unfiltered := kittest.Stored(t, s) diff --git a/providers/convex/js_surface_test.go b/providers/convex/js_surface_test.go new file mode 100644 index 0000000..0c1c76d --- /dev/null +++ b/providers/convex/js_surface_test.go @@ -0,0 +1,15 @@ +package convex + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// convex 1.35.1 removed the react entry's QueryOptions and +// UseQueryResult types. +func TestJSSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: JSSurface, Golden: [2]string{"1.35.0", "1.35.1"}, Want: []string{ + "removed_symbol convex/browser.QueryOptions ", + }, Drop: [2]string{"1.42.2", "1.42.3"}}) +} diff --git a/providers/convex/provider.go b/providers/convex/provider.go new file mode 100644 index 0000000..2176966 --- /dev/null +++ b/providers/convex/provider.go @@ -0,0 +1,32 @@ +// Package convex is what patch-it reads for Convex: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package convex + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "convex", Name: "Convex", Category: plugin.CategoryDatabases, Homepage: "https://www.convex.dev", + Sources: []plugin.Source{ + // No Hints: Convex has no API changelog; its news feed is product news. + // Only operation deprecations and removals: see deployment_api.go. + { + ID: "deployment-api", Layer: plugin.LayerAPI, + Watches: "Deployment API operations deprecated, and deprecated operations removed, between commits of the spec", + URLs: []string{"https://github.com/convex/convex-backend"}, + Plugin: openapi.Plugin{Adapter: Convex{}, Diff: convexDiff, Keep: convexKeep}, + }, + apisurface.NPM(JSSurface, "https://github.com/convex/convex-js"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + JSSurface = apisurface.NPMPackage("convex/js-surface", "convex") +) diff --git a/providers/convex/testdata/README.md b/providers/convex/testdata/README.md new file mode 100644 index 0000000..ee2f9fd --- /dev/null +++ b/providers/convex/testdata/README.md @@ -0,0 +1,23 @@ +# Convex: saved copies and goldens + +Real copies of what Convex publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/convex -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `convex-f35879bb.json`, `convex-5e5159cb.json` | https://raw.githubusercontent.com/convex/convex-backend/f35879bb396491942bf8ecbc8ef5e4280499f89f/npm-packages/@convex-dev/platform/deployment-openapi.json (and `5e5159cbea5188e9da5400febda1b031a233eea0`) | 2026-11-19 | FSL-1.1-Apache-2.0 (convex/convex-backend `LICENSE.md`; the spec's own `info.license` is `LicenseRef-FSL-1.1-Apache-2.0`): excerpt for testing, © Convex, Inc.; maintainers, please confirm | "Deprecated: use `GET /integrations` instead." (`GET /list_log_streams`, and five more log stream operations, new in `5e5159cb`) | +| `convex-3f6edf7a.json`, `convex-3ead9091.json` | https://raw.githubusercontent.com/convex/convex-backend/3f6edf7ab8f3f98e027f317633246a19348eabcc/npm-packages/@convex-dev/platform/deployment-openapi.json (and `3ead909103b7f5897f529c031e80991ad174b07e`) | 2026-11-19 | FSL-1.1-Apache-2.0 (convex/convex-backend `LICENSE.md`; the spec's own `info.license` is `LicenseRef-FSL-1.1-Apache-2.0`): excerpt for testing, © Convex, Inc.; maintainers, please confirm | `"name": {` in `UsageLimitConfigRequest` and `UsageLimitConfigResponse` (in `3f6edf7a`, gone in `3ead9091` without being deprecated): the drop test | + +The Convex copies keep `openapi`, `info`, `servers` and the path items involved, whole and in their original order, every line copied unchanged (bar the trailing comma after a path item or schema that's now last); the usage-limit pair also keeps the component schemas those operations reach, the log stream pair none. The source is FSL-1.1-Apache-2.0 (each version becomes Apache-2.0 two years after it's published), which allows copying for a permitted purpose; these are short excerpts kept for testing, but a maintainer should confirm that before release. Each pair gives the same changes as the full files, with and without the filter. The management API spec (`management-openapi.json`, `info.license` `LicenseRef-Convex`, not defined anywhere in the repo) is neither read nor saved. + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `npm/convex/`: `convex-1.35.0.trimmed.tgz`, `convex-1.35.1.trimmed.tgz`, `convex-1.42.2.trimmed.tgz`, `convex-1.42.3.trimmed.tgz` | https://registry.npmjs.org/convex/-/convex-1.35.0.tgz; https://registry.npmjs.org/convex/-/convex-1.35.1.tgz; https://registry.npmjs.org/convex/-/convex-1.42.2.tgz; https://registry.npmjs.org/convex/-/convex-1.42.3.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/esm-types/browser/index.d.ts`, `dist/esm-types/browser/query_options.d.ts`, `dist/esm-types/react/client.d.ts`, `dist/esm-types/react/index.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/convex/`: `npm-convex-excerpt.json` and `npm-convex-1.35.0.json`, `npm-convex-1.35.1.json`, `npm-convex-1.42.2.json`, `npm-convex-1.42.3.json` | https://registry.npmjs.org/convex, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/openapi/testdata/convex-3ead9091.json b/providers/convex/testdata/convex-3ead9091.json similarity index 100% rename from plugins/openapi/testdata/convex-3ead9091.json rename to providers/convex/testdata/convex-3ead9091.json diff --git a/plugins/openapi/testdata/convex-3f6edf7a.json b/providers/convex/testdata/convex-3f6edf7a.json similarity index 100% rename from plugins/openapi/testdata/convex-3f6edf7a.json rename to providers/convex/testdata/convex-3f6edf7a.json diff --git a/plugins/openapi/testdata/convex-5e5159cb.json b/providers/convex/testdata/convex-5e5159cb.json similarity index 100% rename from plugins/openapi/testdata/convex-5e5159cb.json rename to providers/convex/testdata/convex-5e5159cb.json diff --git a/plugins/openapi/testdata/convex-f35879bb.json b/providers/convex/testdata/convex-f35879bb.json similarity index 100% rename from plugins/openapi/testdata/convex-f35879bb.json rename to providers/convex/testdata/convex-f35879bb.json diff --git a/plugins/apisurface/testdata/golden/convex-js-surface.json b/providers/convex/testdata/golden/convex-js-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/convex-js-surface.json rename to providers/convex/testdata/golden/convex-js-surface.json diff --git a/plugins/openapi/testdata/golden/convex.json b/providers/convex/testdata/golden/convex.json similarity index 100% rename from plugins/openapi/testdata/golden/convex.json rename to providers/convex/testdata/golden/convex.json diff --git a/plugins/apisurface/testdata/npm/convex/convex-1.35.0.trimmed.tgz b/providers/convex/testdata/npm/convex/convex-1.35.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/convex/convex-1.35.0.trimmed.tgz rename to providers/convex/testdata/npm/convex/convex-1.35.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/convex/convex-1.35.1.trimmed.tgz b/providers/convex/testdata/npm/convex/convex-1.35.1.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/convex/convex-1.35.1.trimmed.tgz rename to providers/convex/testdata/npm/convex/convex-1.35.1.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/convex/convex-1.42.2.trimmed.tgz b/providers/convex/testdata/npm/convex/convex-1.42.2.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/convex/convex-1.42.2.trimmed.tgz rename to providers/convex/testdata/npm/convex/convex-1.42.2.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/convex/convex-1.42.3.trimmed.tgz b/providers/convex/testdata/npm/convex/convex-1.42.3.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/convex/convex-1.42.3.trimmed.tgz rename to providers/convex/testdata/npm/convex/convex-1.42.3.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/convex/npm-convex-1.35.0.json b/providers/convex/testdata/npm/convex/npm-convex-1.35.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/convex/npm-convex-1.35.0.json rename to providers/convex/testdata/npm/convex/npm-convex-1.35.0.json diff --git a/plugins/apisurface/testdata/npm/convex/npm-convex-1.35.1.json b/providers/convex/testdata/npm/convex/npm-convex-1.35.1.json similarity index 100% rename from plugins/apisurface/testdata/npm/convex/npm-convex-1.35.1.json rename to providers/convex/testdata/npm/convex/npm-convex-1.35.1.json diff --git a/plugins/apisurface/testdata/npm/convex/npm-convex-1.42.2.json b/providers/convex/testdata/npm/convex/npm-convex-1.42.2.json similarity index 100% rename from plugins/apisurface/testdata/npm/convex/npm-convex-1.42.2.json rename to providers/convex/testdata/npm/convex/npm-convex-1.42.2.json diff --git a/plugins/apisurface/testdata/npm/convex/npm-convex-1.42.3.json b/providers/convex/testdata/npm/convex/npm-convex-1.42.3.json similarity index 100% rename from plugins/apisurface/testdata/npm/convex/npm-convex-1.42.3.json rename to providers/convex/testdata/npm/convex/npm-convex-1.42.3.json diff --git a/plugins/apisurface/testdata/npm/convex/npm-convex-excerpt.json b/providers/convex/testdata/npm/convex/npm-convex-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/convex/npm-convex-excerpt.json rename to providers/convex/testdata/npm/convex/npm-convex-excerpt.json diff --git a/providers/datadog.md b/providers/datadog.md deleted file mode 100644 index 56befde..0000000 --- a/providers/datadog.md +++ /dev/null @@ -1,32 +0,0 @@ -# Datadog (`datadog/api`) - -## What it watches - -Datadog's API v2, release by release: endpoints, request and response properties and schemas removed or changed between two versions of the OpenAPI spec Datadog generates its official clients from. - -Kind: `openapi` (`plugins/openapi`), with `adapter.Datadog`. - -## Why this source - -- **Source:** `.generator/schemas/v2/openapi.yaml` in [DataDog/datadog-api-client-python](https://github.com/DataDog/datadog-api-client-python), pinned to a release tag (`https://raw.githubusercontent.com/DataDog/datadog-api-client-python//.generator/schemas/v2/openapi.yaml`); the newest tag from the GitHub Releases API. Checked on 2026-11-13. -- **Why this one:** Datadog publishes no standalone spec repo. Its generator writes the same spec, byte for byte, into every official client repo on every release, so this file *is* the API as Datadog's own clients see it, versioned by tag. -- **Alternatives considered:** the same file in the Go, Java, Ruby or TypeScript client repos (identical content; reading more than one would report every change twice); the repo's `CHANGELOG.md` (one section per release with `Removed` / `Deprecated` bullets linking each PR; prose, not wired as a hint source yet); the API reference on docs.datadoghq.com (rendered by JavaScript, not readable with a plain fetch). -- **Quote:** "Remove deprecated queried_tags_window_seconds and related_asset_tags fields" ([PR #4045](https://github.com/DataDog/datadog-api-client-python/pull/4045), released in 2.61.0). - -## How the provider announces changes - -- REST paths are versioned by prefix only (`/api/v1/…`, `/api/v2/…`), one spec file each. `info.version` is a fixed `"1.0"` that never moves. -- **Breaking changes are forced**: a removed property is gone from the next release, with no account-level version to stay on. Some go through a `Deprecated` changelog entry first; not all do. -- The client's release tag (`2.61.0`) is the only version signal, and it's what users pin (`datadog-api-client==2.61.0`). So the event's `version` is the release tag. Releases come roughly weekly. -- The spec is YAML only (~10 MB). The adapter converts it to JSON before diffing; excerpts are re-serialized from the node they quote either way. - -## What the plugin reads and ignores - -- Reads: the v2 spec at the newest tag, diffed against the last one. -- Ignores: changes to OpenAPI `tags` (they only rename generated SDK methods; the REST API is unchanged). The v1 spec isn't read yet. -- Reads a historical pair (a version pair, `2.60.0` → `2.61.0`) and recreates the removal of two properties from `TagIndexingRuleDynamicTags` (the golden test uses trimmed excerpts of both specs). - -## Known gaps - -- API v1 (`v1/openapi.yaml`) isn't watched. -- Deprecations announced only in the changelog (with no spec change yet) aren't events. diff --git a/providers/datadog-ddtrace-python-surface.md b/providers/datadog/README.md similarity index 51% rename from providers/datadog-ddtrace-python-surface.md rename to providers/datadog/README.md index f4f2a7c..eaa25d7 100644 --- a/providers/datadog-ddtrace-python-surface.md +++ b/providers/datadog/README.md @@ -1,24 +1,61 @@ -# Datadog ddtrace (Python) (`datadog/ddtrace-python-surface`) +# Datadog -## What it watches +Every source patch-it reads for Datadog, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Datadog (`datadog/api`) + +### What it watches + +Datadog's API v2, release by release: endpoints, request and response properties and schemas removed or changed between two versions of the OpenAPI spec Datadog generates its official clients from. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `Datadog` ([`api.go`](api.go)). + +### Why this source + +- **Source:** `.generator/schemas/v2/openapi.yaml` in [DataDog/datadog-api-client-python](https://github.com/DataDog/datadog-api-client-python), pinned to a release tag (`https://raw.githubusercontent.com/DataDog/datadog-api-client-python//.generator/schemas/v2/openapi.yaml`); the newest tag from the GitHub Releases API. Checked on 2026-11-13. +- **Why this one:** Datadog publishes no standalone spec repo. Its generator writes the same spec, byte for byte, into every official client repo on every release, so this file *is* the API as Datadog's own clients see it, versioned by tag. +- **Alternatives considered:** the same file in the Go, Java, Ruby or TypeScript client repos (identical content; reading more than one would report every change twice); the repo's `CHANGELOG.md` (one section per release with `Removed` / `Deprecated` bullets linking each PR; prose, not wired as a hint source yet); the API reference on docs.datadoghq.com (rendered by JavaScript, not readable with a plain fetch). +- **Quote:** "Remove deprecated queried_tags_window_seconds and related_asset_tags fields" ([PR #4045](https://github.com/DataDog/datadog-api-client-python/pull/4045), released in 2.61.0). + +### How the provider announces changes + +- REST paths are versioned by prefix only (`/api/v1/…`, `/api/v2/…`), one spec file each. `info.version` is a fixed `"1.0"` that never moves. +- **Breaking changes are forced**: a removed property is gone from the next release, with no account-level version to stay on. Some go through a `Deprecated` changelog entry first; not all do. +- The client's release tag (`2.61.0`) is the only version signal, and it's what users pin (`datadog-api-client==2.61.0`). So the event's `version` is the release tag. Releases come roughly weekly. +- The spec is YAML only (~10 MB). The adapter converts it to JSON before diffing; excerpts are re-serialized from the node they quote either way. + +### What the plugin reads and ignores + +- Reads: the v2 spec at the newest tag, diffed against the last one. +- Ignores: changes to OpenAPI `tags` (they only rename generated SDK methods; the REST API is unchanged). The v1 spec isn't read yet. +- Reads a historical pair (a version pair, `2.60.0` → `2.61.0`) and recreates the removal of two properties from `TagIndexingRuleDynamicTags` (the golden test uses trimmed excerpts of both specs). + +### Known gaps + +- API v1 (`v1/openapi.yaml`) isn't watched. +- Deprecations announced only in the changelog (with no spec change yet) aren't events. + +## Datadog ddtrace (Python) (`datadog/ddtrace-python-surface`) + +### What it watches The public API of the `ddtrace` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). -## Why this source +### Why this source - **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. - **Why this one:** the wheel is exactly what `pip install ddtrace==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. - **Alternatives considered:** GitHub release notes; the docs' upgrade notes. - **Quote:** `def resolve_strands_hook_provider() -> type` (`ddtrace/appsec/ai_guard/integrations/__init__.py` line 67) at 4.12.3, gone at 4.13.0. -## How the provider announces changes +### How the provider announces changes - The tracer releases often; most of the package is `ddtrace.internal` and `ddtrace.contrib.internal`, which this source treats as private. Moved APIs keep their old module forwarding names (`__getattr__`) until the next major. - **Forced on upgrade**, for a repo whose pin reaches the release. -## What the plugin reads and ignores +### What the plugin reads and ignores - Reads the `.py` and `.pyi` files under `ddtrace/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. - Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). @@ -26,7 +63,7 @@ Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apis - A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. - Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. -## Known gaps +### Known gaps - A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. - A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. diff --git a/plugins/openapi/adapter/datadog.go b/providers/datadog/api.go similarity index 78% rename from plugins/openapi/adapter/datadog.go rename to providers/datadog/api.go index c25fded..1092281 100644 --- a/plugins/openapi/adapter/datadog.go +++ b/providers/datadog/api.go @@ -1,4 +1,4 @@ -package adapter +package datadog import ( "context" @@ -7,6 +7,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" "gopkg.in/yaml.v3" ) @@ -25,7 +27,7 @@ var ( // in Fetch — see Fetch's comment). type Datadog struct{} -var _ Adapter = Datadog{} +var _ adapter.Adapter = Datadog{} func (Datadog) API() string { return "datadog/api" } @@ -52,25 +54,30 @@ func (Datadog) LatestTag(ctx context.Context) (string, error) { // The tag is also what a customer actually pins in requirements.txt // (datadog-api-client==2.61.0), so the version gate can compare against it // directly — no SDK-version-to-API-version table like Stripe's needed. -func (Datadog) Fetch(ctx context.Context, tag string) (Spec, error) { +func (Datadog) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { url := fmt.Sprintf(datadogSpecURLTemplate, tag) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching datadog spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("fetching datadog spec %s: %w", tag, err) } var doc any if err := yaml.Unmarshal(body, &doc); err != nil { - return Spec{}, fmt.Errorf("parsing datadog spec %s as yaml: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("parsing datadog spec %s as yaml: %w", tag, err) } content, err := json.Marshal(doc) if err != nil { - return Spec{}, fmt.Errorf("converting datadog spec %s to json: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("converting datadog spec %s to json: %w", tag, err) } - return Spec{ + return adapter.Spec{ Content: content, Version: tag, SourceURL: url, }, nil } + +// Versions are datadog-api-client-python's releases. +func (Datadog) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Releases(ctx, "DataDog/datadog-api-client-python", nil) +} diff --git a/plugins/openapi/adapter/datadog_test.go b/providers/datadog/api_fetch_test.go similarity index 99% rename from plugins/openapi/adapter/datadog_test.go rename to providers/datadog/api_fetch_test.go index 6af0a52..6ce055b 100644 --- a/plugins/openapi/adapter/datadog_test.go +++ b/providers/datadog/api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package datadog import ( "context" diff --git a/plugins/openapi/datadog_test.go b/providers/datadog/api_test.go similarity index 83% rename from plugins/openapi/datadog_test.go rename to providers/datadog/api_test.go index fa486e5..8a7d0b3 100644 --- a/plugins/openapi/datadog_test.go +++ b/providers/datadog/api_test.go @@ -1,4 +1,4 @@ -package openapi +package datadog import ( "context" @@ -7,13 +7,16 @@ import ( "os" "testing" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" "gopkg.in/yaml.v3" ) // fakeDatadogAdapter serves the real, trimmed spec excerpts saved under // testdata/ (a saved copy of the source, not invented JSON), converted from -// YAML to JSON the same way adapter.Datadog.Fetch does. +// YAML to JSON the same way Datadog.Fetch does. type fakeDatadogAdapter struct{} func (fakeDatadogAdapter) API() string { return "datadog/api" } @@ -47,9 +50,9 @@ func (fakeDatadogAdapter) Fetch(_ context.Context, tag string) (adapter.Spec, er // the pair 2.60.0 → 2.61.0 recreates. func TestDatadogPairRecreatesTheRealPropertyRemoval(t *testing.T) { ctx := context.Background() - s := openStore(t) + s := kittest.NewMem() - rejected, err := pairWith(ctx, s, Plugin{Adapter: fakeDatadogAdapter{}}, "2.60.0", "2.61.0") + rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, openapi.Plugin{Adapter: fakeDatadogAdapter{}}, "2.60.0", "2.61.0") if err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } @@ -88,7 +91,7 @@ func TestDatadogPairRecreatesTheRealPropertyRemoval(t *testing.T) { } // Reading the same pair again must not duplicate the events. - if _, err := pairWith(ctx, s, Plugin{Adapter: fakeDatadogAdapter{}}, "2.60.0", "2.61.0"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, openapi.Plugin{Adapter: fakeDatadogAdapter{}}, "2.60.0", "2.61.0"); err != nil { t.Fatalf("second read of the pair: %v", err) } if again, _ := s.All(); len(again) != len(events) { diff --git a/providers/datadog/ddtrace_python_surface_test.go b/providers/datadog/ddtrace_python_surface_test.go new file mode 100644 index 0000000..cf86616 --- /dev/null +++ b/providers/datadog/ddtrace_python_surface_test.go @@ -0,0 +1,17 @@ +package datadog + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// ddtrace 4.13.0 moved AI Guard to ddtrace.aiguard: the old module +// forwards its names (__getattr__), so only the two integration helpers +// it dropped are gone. +func TestDdtracePythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: DdtracePythonSurface, Golden: [2]string{"4.12.3", "4.13.0"}, Want: []string{ + "removed_symbol appsec.ai_guard.integrations.resolve_strands_hook_provider ", + "removed_symbol appsec.ai_guard.integrations.resolve_strands_plugin ", + }, Drop: [2]string{"4.16.0", "4.16.1"}}) +} diff --git a/providers/datadog/provider.go b/providers/datadog/provider.go new file mode 100644 index 0000000..70e9b44 --- /dev/null +++ b/providers/datadog/provider.go @@ -0,0 +1,33 @@ +// Package datadog is what patch-it reads for Datadog: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package datadog + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "datadog", Name: "Datadog", Category: plugin.CategoryMonitoring, Homepage: "https://www.datadoghq.com", + Sources: []plugin.Source{ + // No Hints yet: Datadog's changelog isn't Stripe's per-parameter table + // shape, so there's no hint.Source for it to read. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "API v2 changes between OpenAPI spec releases", + URLs: []string{"https://github.com/DataDog/datadog-api-client-python"}, + Packages: []string{"pypi:datadog-api-client", "npm:@datadog/datadog-api-client"}, + Plugin: openapi.Plugin{Adapter: Datadog{}}, + }, + apisurface.PyPI(DdtracePythonSurface, plugin.LayerSDK, "https://github.com/DataDog/dd-trace-py"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + DdtracePythonSurface = apisurface.Package{ID: "datadog/ddtrace-python-surface", Name: "ddtrace", Ecosystem: "pypi", Module: "ddtrace"} +) diff --git a/providers/datadog/testdata/README.md b/providers/datadog/testdata/README.md new file mode 100644 index 0000000..62da225 --- /dev/null +++ b/providers/datadog/testdata/README.md @@ -0,0 +1,20 @@ +# Datadog: saved copies and goldens + +Real copies of what Datadog publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/datadog -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `datadog-2.60.0.yaml`, `datadog-2.61.0.yaml` | https://raw.githubusercontent.com/DataDog/datadog-api-client-python/2.60.0/.generator/schemas/v2/openapi.yaml (and `2.61.0`) | 2026-11-13 | Apache-2.0 (datadog-api-client-python) | `queried_tags_window_seconds:` (in 2.60.0, gone in 2.61.0) | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/ddtrace/`: `ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.trimmed.whl`, `ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl`, `ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl`, `ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.trimmed.whl` | https://files.pythonhosted.org/packages/d7/18/90b574aa3c046bd9f4862b0353d8f8a42aeba504c601c3235bd8d91f057f/ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.whl; https://files.pythonhosted.org/packages/52/97/9d4ec43fa15991f195e62795e1d46fb158cab3df29c370d272889b8f8640/ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.whl; https://files.pythonhosted.org/packages/6d/af/859a2d709008db2c95842aaab04f0d242a9b338cf8279f655b0f5946c9df/ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.whl; https://files.pythonhosted.org/packages/ac/0a/ccaa73a0d201d570b3b4a3e9ef8ff1617056d552dbd3d4f81292ee7af717/ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.whl | 2026-11-21 | Apache-2.0 or BSD-3-Clause (the wheel's own license files are kept in it). Trimmed: only `ddtrace/appsec/ai_guard/__init__.py`, `ddtrace/appsec/ai_guard/_api_client.py`, `ddtrace/appsec/ai_guard/integrations/__init__.py`, `ddtrace/appsec/ai_guard/integrations/litellm.py`, `ddtrace/appsec/ai_guard/integrations/strands.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/ddtrace/`: `pypi-ddtrace-excerpt.json` and `pypi-ddtrace-4.12.3.json`, `pypi-ddtrace-4.13.0.json`, `pypi-ddtrace-4.16.0.json`, `pypi-ddtrace-4.16.1.json` | https://pypi.org/pypi/ddtrace/json, https://pypi.org/pypi/ddtrace/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | diff --git a/plugins/openapi/testdata/datadog-2.60.0.yaml b/providers/datadog/testdata/datadog-2.60.0.yaml similarity index 100% rename from plugins/openapi/testdata/datadog-2.60.0.yaml rename to providers/datadog/testdata/datadog-2.60.0.yaml diff --git a/plugins/openapi/testdata/datadog-2.61.0.yaml b/providers/datadog/testdata/datadog-2.61.0.yaml similarity index 100% rename from plugins/openapi/testdata/datadog-2.61.0.yaml rename to providers/datadog/testdata/datadog-2.61.0.yaml diff --git a/plugins/apisurface/testdata/golden/datadog-ddtrace-python-surface.json b/providers/datadog/testdata/golden/datadog-ddtrace-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/datadog-ddtrace-python-surface.json rename to providers/datadog/testdata/golden/datadog-ddtrace-python-surface.json diff --git a/plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.trimmed.whl b/providers/datadog/testdata/pypi/ddtrace/ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.trimmed.whl rename to providers/datadog/testdata/pypi/ddtrace/ddtrace-4.12.3-cp310-cp310-macosx_14_0_arm64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl b/providers/datadog/testdata/pypi/ddtrace/ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl rename to providers/datadog/testdata/pypi/ddtrace/ddtrace-4.13.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl b/providers/datadog/testdata/pypi/ddtrace/ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl rename to providers/datadog/testdata/pypi/ddtrace/ddtrace-4.16.0-cp310-cp310-macosx_14_0_arm64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.trimmed.whl b/providers/datadog/testdata/pypi/ddtrace/ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.trimmed.whl rename to providers/datadog/testdata/pypi/ddtrace/ddtrace-4.16.1-cp310-cp310-macosx_14_0_arm64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.12.3.json b/providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.12.3.json similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.12.3.json rename to providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.12.3.json diff --git a/plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.13.0.json b/providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.13.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.13.0.json rename to providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.13.0.json diff --git a/plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.16.0.json b/providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.16.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.16.0.json rename to providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.16.0.json diff --git a/plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.16.1.json b/providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.16.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-4.16.1.json rename to providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-4.16.1.json diff --git a/plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-excerpt.json b/providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/ddtrace/pypi-ddtrace-excerpt.json rename to providers/datadog/testdata/pypi/ddtrace/pypi-ddtrace-excerpt.json diff --git a/providers/elastic-python-surface.md b/providers/elastic-python-surface.md deleted file mode 100644 index 89253ef..0000000 --- a/providers/elastic-python-surface.md +++ /dev/null @@ -1,35 +0,0 @@ -# Elasticsearch Python client (`elastic/python-surface`) - -## What it watches - -The public API of the `elasticsearch` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install elasticsearch==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** the docs release notes; the REST spec (`elastic/elasticsearch-api`: the HTTP API). -- **Quote:** `requests_per_second: t.Optional[float] = None,` in `Elasticsearch.delete_by_query_rethrottle` (`elasticsearch/_sync/client/__init__.py`) at 9.1.2; `requests_per_second: float,` at 9.1.3. - -## How the provider announces changes - -- The client is generated from the Elasticsearch specification; a parameter can become required in a patch release. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `elasticsearch/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/providers/elasticsearch.md b/providers/elastic/README.md similarity index 54% rename from providers/elasticsearch.md rename to providers/elastic/README.md index 72667ba..b7e498b 100644 --- a/providers/elasticsearch.md +++ b/providers/elastic/README.md @@ -1,12 +1,52 @@ -# Elasticsearch (`elastic/elasticsearch-api`) +# Elastic -## What it watches +Every source patch-it reads for Elastic, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Elasticsearch Python client (`elastic/python-surface`) + +### What it watches + +The public API of the `elasticsearch` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install elasticsearch==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** the docs release notes; the REST spec (`elastic/elasticsearch-api`: the HTTP API). +- **Quote:** `requests_per_second: t.Optional[float] = None,` in `Elasticsearch.delete_by_query_rethrottle` (`elasticsearch/_sync/client/__init__.py`) at 9.1.2; `requests_per_second: float,` at 9.1.3. + +### How the provider announces changes + +- The client is generated from the Elasticsearch specification; a parameter can become required in a patch release. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `elasticsearch/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. + +## Elasticsearch (`elastic/elasticsearch-api`) + +### What it watches The Elasticsearch REST API, minor version by minor version: operations Elastic marks deprecated, and removals of operations it had marked deprecated, between two versions of the OpenAPI spec generated from Elastic's API specification. -Kind: `openapi` (`plugins/openapi`), with `adapter.Elasticsearch`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `Elasticsearch` ([`elasticsearch_api.go`](elasticsearch_api.go)). -## Why this source +### Why this source - **Source:** `output/openapi/elasticsearch-openapi.json` in [elastic/elasticsearch-specification](https://github.com/elastic/elasticsearch-specification), on the branch of the newest minor version Elastic has released, pinned to that branch's head commit (`https://raw.githubusercontent.com/elastic/elasticsearch-specification//output/openapi/elasticsearch-openapi.json`). - The newest released version comes from [elastic/elasticsearch](https://github.com/elastic/elasticsearch)'s releases. The branch list comes from the GitHub refs API. @@ -21,12 +61,12 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Elasticsearch`. - **The clients' changelogs** (`elasticsearch-py`, `elasticsearch-js`). They're generated from the same specification. - **Quote:** "Remove unfreeze REST endpoint" (Elastic's 9.0.0 breaking changes; `POST /{index}/_unfreeze`, deprecated in the 8.19 spec, is gone from 9.0's) -## How the provider announces changes +### How the provider announces changes - **Versions are the product's:** minor releases (9.5), patch releases on each, and two majors maintained side by side (8.19 patches came out after 9.5's). The event's `version` is the minor's first release (`9.0.0`). That's also what a repo pins: the clients' versions follow the server's (`elasticsearch-py` 9.5.1 for Elasticsearch 9.5). - **An API is deprecated in one version and removed in a later major,** typically. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** the spec at the head of the newest released minor's branch, diffed against the last one read. That covers fixes landing on the branch and, once Elastic releases the next minor, the move to its branch. The next, unreleased minor (9.6 on 2026-11-19) isn't read: its spec can still change before it ships. - **Two events come out of it:** @@ -44,7 +84,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Elasticsearch`. - **3 removals, in 9.0:** GET and POST `/{index}/_knn_search`, and POST `/{index}/_unfreeze`. - **Reads** 8.19 → 9.0 in the golden test. The drop test replays 9.1 → 9.2. -## Known gaps +### Known gaps - **Only from 8.14,** when the specification started generating OpenAPI. - **Deprecations announced only in the release notes aren't events.** That includes settings, parameters described in prose, and behavior changes. diff --git a/plugins/openapi/adapter/elasticsearch.go b/providers/elastic/elasticsearch_api.go similarity index 60% rename from plugins/openapi/adapter/elasticsearch.go rename to providers/elastic/elasticsearch_api.go index 288d249..ebc3408 100644 --- a/plugins/openapi/adapter/elasticsearch.go +++ b/providers/elastic/elasticsearch_api.go @@ -1,4 +1,4 @@ -package adapter +package elastic import ( "context" @@ -9,8 +9,13 @@ import ( "strconv" "strings" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // Variables, not constants, only so tests can point them at a local server. @@ -36,7 +41,7 @@ var ( // by minor version. A tag here is a minor version's branch ("9.5"). type Elasticsearch struct{} -var _ Adapter = Elasticsearch{} +var _ adapter.Adapter = Elasticsearch{} func (Elasticsearch) API() string { return "elastic/elasticsearch-api" } @@ -120,21 +125,66 @@ func atoi(s string) int { // Version is the minor's first release, "9.5.0": what a repo pins, and the // elasticsearch clients' versions follow the server's (elasticsearch-py 9.x // for Elasticsearch 9.x). info.version in the spec is empty. -func (Elasticsearch) Fetch(ctx context.Context, branch string) (Spec, error) { +func (Elasticsearch) Fetch(ctx context.Context, branch string) (adapter.Spec, error) { if !esBranch.MatchString(branch) { - return Spec{}, fmt.Errorf("%q isn't an elasticsearch-specification minor branch", branch) + return adapter.Spec{}, fmt.Errorf("%q isn't an elasticsearch-specification minor branch", branch) } sha, err := github.Head(ctx, github.Get, fmt.Sprintf(esCommitURL, branch)) if err != nil { - return Spec{}, fmt.Errorf("looking up the head of elasticsearch-specification %s: %w", branch, err) + return adapter.Spec{}, fmt.Errorf("looking up the head of elasticsearch-specification %s: %w", branch, err) } url := fmt.Sprintf(esSpecURLTemplate, sha) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching the elasticsearch %s spec: %w", branch, err) + return adapter.Spec{}, fmt.Errorf("fetching the elasticsearch %s spec: %w", branch, err) } if !json.Valid(body) { - return Spec{}, fmt.Errorf("the elasticsearch %s spec is not valid json", branch) + return adapter.Spec{}, fmt.Errorf("the elasticsearch %s spec is not valid json", branch) } - return Spec{Content: body, Version: branch + ".0", SourceURL: url}, nil + return adapter.Spec{Content: body, Version: branch + ".0", SourceURL: url}, nil } + +// esFirstSpec is the first minor whose branch has the OpenAPI output. +var esFirstSpec = [2]int{8, 14} + +// Versions are every released minor with the OpenAPI output (8.14 on), its +// branch the ref: up to the newest minor Elastic has released (LatestTag), +// never the next, unreleased one. +func (e Elasticsearch) Versions(ctx context.Context) ([]plugin.Version, error) { + newest, branches, err := esMinors(ctx) + if err != nil { + return nil, err + } + var out []plugin.Version + for _, b := range branches { + m := esBranch.FindStringSubmatch(b) + v := [2]int{atoi(m[1]), atoi(m[2])} + if slices.Compare(v[:], esFirstSpec[:]) < 0 || slices.Compare(v[:], newest[:]) > 0 { + continue + } + out = append(out, plugin.Version{ID: b + ".0", Ref: b, URL: "https://github.com/elastic/elasticsearch-specification/tree/" + b}) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) + return out, nil +} + +// elasticsearchDiff reads Elastic's spec like Supabase's: deprecations by the +// `deprecated` flag, quoting the whole operation, and path templates matched. +var elasticsearchDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// elasticsearchKeep keeps operation deprecations, and removals of operations +// marked deprecated first. Over the minor versions with an OpenAPI output +// (8.14 to 9.6, compared in version order) that's 23 deprecations and 3 +// removals, all in 9.0: GET and POST /{index}/_knn_search, and POST +// /{index}/_unfreeze ("Remove unfreeze REST endpoint", Elastic's 9.0.0 +// breaking changes). The 31 other removals weren't deprecated first and +// mostly weren't removals from Elasticsearch: +// +// - APIs a later minor of the older major had and the newer major's +// branch, cut earlier, didn't yet: 8.19 to 9.0 drops +// /_data_stream/{name}/_options, which is back in 9.1; +// - APIs Elastic documents as not for direct use ("designed for indirect +// use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic +// Cloud on Kubernetes. Direct use is not supported."), left out of the +// spec from 9.2: /_autoscaling, /_nodes/{node_id}/shutdown. +var elasticsearchKeep = openapi.DeprecationsOnly(elasticsearchDiff) diff --git a/plugins/openapi/adapter/elasticsearch_test.go b/providers/elastic/elasticsearch_api_fetch_test.go similarity index 78% rename from plugins/openapi/adapter/elasticsearch_test.go rename to providers/elastic/elasticsearch_api_fetch_test.go index a84f7b5..8b6b2b1 100644 --- a/plugins/openapi/adapter/elasticsearch_test.go +++ b/providers/elastic/elasticsearch_api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package elastic import ( "context" @@ -6,6 +6,8 @@ import ( "net/http/httptest" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) func fakeESGitHub(t *testing.T, releases, branches string, heads, specs map[string]string) *httptest.Server { @@ -84,3 +86,20 @@ func TestElasticsearchFetchPinsTheHead(t *testing.T) { t.Error("invalid json: want an error") } } + +// Every released minor from 8.14 (the first with the OpenAPI output) to the +// newest released one, 9.5: not 9.6, the next minor's branch. +func TestElasticsearchListsEveryReleasedMinor(t *testing.T) { + srv := openapitest.Recorded(t, map[string]string{"/releases": "es-releases.json", "/branches": "es-branches.json"}) + a, b := esReleasesURL, esBranchesURL + esReleasesURL, esBranchesURL = srv.URL+"/releases", srv.URL+"/branches" + t.Cleanup(func() { esReleasesURL, esBranchesURL = a, b }) + vs, err := Elasticsearch{}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + want := "8.14.0@8.14 8.15.0@8.15 8.16.0@8.16 8.17.0@8.17 8.18.0@8.18 8.19.0@8.19 9.0.0@9.0 9.1.0@9.1 9.2.0@9.2 9.3.0@9.3 9.4.0@9.4 9.5.0@9.5" + if got := openapitest.IDs(vs); got != want { + t.Errorf("versions\n %s\nwant\n %s", got, want) + } +} diff --git a/plugins/openapi/elasticsearch_test.go b/providers/elastic/elasticsearch_api_test.go similarity index 84% rename from plugins/openapi/elasticsearch_test.go rename to providers/elastic/elasticsearch_api_test.go index 10ec11a..0e4605e 100644 --- a/plugins/openapi/elasticsearch_test.go +++ b/providers/elastic/elasticsearch_api_test.go @@ -1,4 +1,4 @@ -package openapi +package elastic import ( "context" @@ -9,7 +9,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // esHeads are the elasticsearch-specification branch heads saved under @@ -47,8 +49,8 @@ func esURL(branch string) string { return "https://raw.githubusercontent.com/elastic/elasticsearch-specification/" + esHeads[branch] + "/output/openapi/elasticsearch-openapi.json" } -func esPlugin() Plugin { - return Plugin{Adapter: fakeESAdapter{}, Diff: elasticsearchDiff, Keep: elasticsearchKeep, RemovalsNeedANewVersion: true} +func esPlugin() openapi.Plugin { + return openapi.Plugin{Adapter: fakeESAdapter{}, Diff: elasticsearchDiff, Keep: elasticsearchKeep, RemovalsNeedANewVersion: true} } // sameMinor serves two saved specs as two commits of one branch: both 9.0.0. @@ -68,10 +70,10 @@ func (s sameMinor) Fetch(ctx context.Context, branch string) (adapter.Spec, erro // deprecations and none of the three removals. func TestElasticsearchNoRemovalWithinAMinor(t *testing.T) { ctx := context.Background() - s := openStore(t) + s := kittest.NewMem() p := esPlugin() p.Adapter = sameMinor{} - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, p, "8.19", "9.0"); err != nil || rejected { + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "8.19", "9.0"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } n := map[event.ChangeType]int{} @@ -91,8 +93,8 @@ func TestElasticsearchNoRemovalWithinAMinor(t *testing.T) { // branch (cut earlier) doesn't, was never deprecated: no event. func TestElasticsearchGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, esPlugin(), "8.19", "9.0"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, esPlugin(), "8.19", "9.0"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) @@ -113,7 +115,7 @@ func TestElasticsearchGolden(t *testing.T) { if e.Breaking { file = esFile("8.19") } - if node := jsonNode(t, file, e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, file, e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt doesn't match %s#%s", e.Subject.Operation, file, e.SourcePointer) } } @@ -141,17 +143,17 @@ func TestElasticsearchGolden(t *testing.T) { // deprecated: no event, though unfiltered the pair reports them removed. func TestElasticsearchDropsUndeprecatedRemovals(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, esPlugin(), "9.1", "9.2"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, esPlugin(), "9.1", "9.2"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { t.Fatalf("%d events, want none", len(events)) } - s = openStore(t) + s = kittest.NewMem() p := esPlugin() p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "9.1", "9.2"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "9.1", "9.2"); err != nil { t.Fatal(err) } var removed int diff --git a/providers/elastic/provider.go b/providers/elastic/provider.go new file mode 100644 index 0000000..34aa384 --- /dev/null +++ b/providers/elastic/provider.go @@ -0,0 +1,33 @@ +// Package elastic is what patch-it reads for Elastic: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package elastic + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "elastic", Name: "Elastic", Category: plugin.CategorySearch, Homepage: "https://www.elastic.co", + Sources: []plugin.Source{ + // No Hints: Elastic's breaking-changes page is prose per area, not keyed + // by operation. See elasticsearch_api.go. + { + ID: "elasticsearch-api", Layer: plugin.LayerAPI, + Watches: "Elasticsearch REST API operations deprecated, and deprecated operations removed, between released minor versions of the spec", + URLs: []string{"https://github.com/elastic/elasticsearch-specification"}, + Packages: []string{"pypi:elasticsearch", "npm:@elastic/elasticsearch"}, + Plugin: openapi.Plugin{Adapter: Elasticsearch{}, Diff: elasticsearchDiff, Keep: elasticsearchKeep, RemovalsNeedANewVersion: true}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/elastic/elasticsearch-py"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "elastic/python-surface", Name: "elasticsearch", Ecosystem: "pypi", Module: "elasticsearch"} +) diff --git a/providers/elastic/python_surface_test.go b/providers/elastic/python_surface_test.go new file mode 100644 index 0000000..6f7c9f9 --- /dev/null +++ b/providers/elastic/python_surface_test.go @@ -0,0 +1,17 @@ +package elastic + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// elasticsearch 9.1.3 made the rethrottle methods' requests_per_second +// required. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"9.1.2", "9.1.3"}, Want: []string{ + "changed_default Elasticsearch.delete_by_query_rethrottle,client.Elasticsearch.delete_by_query_rethrottle requests_per_second", + "changed_default Elasticsearch.reindex_rethrottle,client.Elasticsearch.reindex_rethrottle requests_per_second", + "changed_default Elasticsearch.update_by_query_rethrottle,client.Elasticsearch.update_by_query_rethrottle requests_per_second", + }, Drop: [2]string{"9.1.1", "9.1.2"}}) +} diff --git a/providers/elastic/testdata/README.md b/providers/elastic/testdata/README.md new file mode 100644 index 0000000..f4ebf2f --- /dev/null +++ b/providers/elastic/testdata/README.md @@ -0,0 +1,32 @@ +# Elastic: saved copies and goldens + +Real copies of what Elastic publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/elastic -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `elasticsearch-8.19-fd5d063c.json`, `elasticsearch-9.0-57ecfe5f.json` | https://raw.githubusercontent.com/elastic/elasticsearch-specification/fd5d063c4824de5d33618b7fca4df0e6c1b8489f/output/openapi/elasticsearch-openapi.json (the head of `8.19`; and `57ecfe5fda6976b94fc8b8830ecb51f4969dccd6`, the head of `9.0`) | 2026-11-19 | Apache-2.0 (elastic/elasticsearch-specification) | `"/{index}/_unfreeze": {` (in 8.19, deprecated; gone in 9.0) | +| `elasticsearch-9.1-12639d0e.json`, `elasticsearch-9.2-87a82640.json` | https://raw.githubusercontent.com/elastic/elasticsearch-specification/12639d0e5ec07f064c909f15160ff68d608dbc2c/output/openapi/elasticsearch-openapi.json (the head of `9.1`; and `87a82640d8aa1139163dc7071bf00f971ce5e453`, the head of `9.2`) | 2026-11-19 | Apache-2.0 (elastic/elasticsearch-specification) | "designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported." (`/_autoscaling/capacity`, in 9.1, gone in 9.2): the drop test | + +The Elasticsearch copies keep `openapi`, `info` and the paths involved, every line unchanged; the 9.2 copy's paths are all gone in 9.2, so its `"paths": {}` is the one line that isn't in the original. + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/es-releases.json` | `https://api.github.com/repos/elastic/elasticsearch/releases?per_page=100` | all 100; `tag_name`, `prerelease`, `draft` | +| `versions/es-branches.json` | `https://api.github.com/repos/elastic/elasticsearch-specification/git/matching-refs/heads/` | the minor branches, `main` and `gh-pages` (33 of 250) | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/elasticsearch/`: `elasticsearch-9.1.1-py3-none-any.trimmed.whl`, `elasticsearch-9.1.2-py3-none-any.trimmed.whl`, `elasticsearch-9.1.3-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/cf/4c/c0c95d3d881732a5d1b28e12c9be4dea5953ade71810f94565bd5bd2101a/elasticsearch-9.1.1-py3-none-any.whl; https://files.pythonhosted.org/packages/89/95/ee3bcf867cdbaba15a0118d6ca0b9b4477892ff3b92e7d6135cc42b262af/elasticsearch-9.1.2-py3-none-any.whl; https://files.pythonhosted.org/packages/bf/10/cab92a57625aeb2d787e3f5e3a698948bc5b34c151422afacff1f0f1c691/elasticsearch-9.1.3-py3-none-any.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `elasticsearch/__init__.py`, `elasticsearch/_sync/client/__init__.py`, `elasticsearch/client.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/elasticsearch/`: `pypi-elasticsearch-excerpt.json` and `pypi-elasticsearch-9.1.1.json`, `pypi-elasticsearch-9.1.2.json`, `pypi-elasticsearch-9.1.3.json` | https://pypi.org/pypi/elasticsearch/json, https://pypi.org/pypi/elasticsearch/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | diff --git a/plugins/openapi/testdata/elasticsearch-8.19-fd5d063c.json b/providers/elastic/testdata/elasticsearch-8.19-fd5d063c.json similarity index 100% rename from plugins/openapi/testdata/elasticsearch-8.19-fd5d063c.json rename to providers/elastic/testdata/elasticsearch-8.19-fd5d063c.json diff --git a/plugins/openapi/testdata/elasticsearch-9.0-57ecfe5f.json b/providers/elastic/testdata/elasticsearch-9.0-57ecfe5f.json similarity index 100% rename from plugins/openapi/testdata/elasticsearch-9.0-57ecfe5f.json rename to providers/elastic/testdata/elasticsearch-9.0-57ecfe5f.json diff --git a/plugins/openapi/testdata/elasticsearch-9.1-12639d0e.json b/providers/elastic/testdata/elasticsearch-9.1-12639d0e.json similarity index 100% rename from plugins/openapi/testdata/elasticsearch-9.1-12639d0e.json rename to providers/elastic/testdata/elasticsearch-9.1-12639d0e.json diff --git a/plugins/openapi/testdata/elasticsearch-9.2-87a82640.json b/providers/elastic/testdata/elasticsearch-9.2-87a82640.json similarity index 100% rename from plugins/openapi/testdata/elasticsearch-9.2-87a82640.json rename to providers/elastic/testdata/elasticsearch-9.2-87a82640.json diff --git a/plugins/apisurface/testdata/golden/elastic-python-surface.json b/providers/elastic/testdata/golden/elastic-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/elastic-python-surface.json rename to providers/elastic/testdata/golden/elastic-python-surface.json diff --git a/plugins/openapi/testdata/golden/elasticsearch.json b/providers/elastic/testdata/golden/elasticsearch.json similarity index 100% rename from plugins/openapi/testdata/golden/elasticsearch.json rename to providers/elastic/testdata/golden/elasticsearch.json diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/elasticsearch-9.1.1-py3-none-any.trimmed.whl b/providers/elastic/testdata/pypi/elasticsearch/elasticsearch-9.1.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/elasticsearch-9.1.1-py3-none-any.trimmed.whl rename to providers/elastic/testdata/pypi/elasticsearch/elasticsearch-9.1.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/elasticsearch-9.1.2-py3-none-any.trimmed.whl b/providers/elastic/testdata/pypi/elasticsearch/elasticsearch-9.1.2-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/elasticsearch-9.1.2-py3-none-any.trimmed.whl rename to providers/elastic/testdata/pypi/elasticsearch/elasticsearch-9.1.2-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/elasticsearch-9.1.3-py3-none-any.trimmed.whl b/providers/elastic/testdata/pypi/elasticsearch/elasticsearch-9.1.3-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/elasticsearch-9.1.3-py3-none-any.trimmed.whl rename to providers/elastic/testdata/pypi/elasticsearch/elasticsearch-9.1.3-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.1.json b/providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.1.json rename to providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.1.json diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.2.json b/providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.2.json similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.2.json rename to providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.2.json diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.3.json b/providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.3.json similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.3.json rename to providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-9.1.3.json diff --git a/plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-excerpt.json b/providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/elasticsearch/pypi-elasticsearch-excerpt.json rename to providers/elastic/testdata/pypi/elasticsearch/pypi-elasticsearch-excerpt.json diff --git a/plugins/openapi/adapter/testdata/versions/es-branches.json b/providers/elastic/testdata/versions/es-branches.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/es-branches.json rename to providers/elastic/testdata/versions/es-branches.json diff --git a/plugins/openapi/adapter/testdata/versions/es-releases.json b/providers/elastic/testdata/versions/es-releases.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/es-releases.json rename to providers/elastic/testdata/versions/es-releases.json diff --git a/providers/flagsmith.md b/providers/flagsmith/README.md similarity index 90% rename from providers/flagsmith.md rename to providers/flagsmith/README.md index 555cd71..47eccd0 100644 --- a/providers/flagsmith.md +++ b/providers/flagsmith/README.md @@ -1,12 +1,16 @@ -# Flagsmith (`flagsmith/api`) +# Flagsmith -## What it watches +Every source patch-it reads for Flagsmith, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Flagsmith (`flagsmith/api`) + +### What it watches Flagsmith's REST API (the Admin/Management API and the SDK-facing endpoints together) between releases of Flagsmith's own OpenAPI 3.1 spec: whole operations removed, and request parameters callers send that are removed, renamed or newly required. -Kind: `openapi` (`plugins/openapi`), with `adapter.Flagsmith` and a request-side filter (`openapi.Plugin.Keep`, same `requestSide` GitLab uses). +Kind: `openapi` (`kinds/openapi`), with its adapter, `Flagsmith` ([`api.go`](api.go)) and a request-side filter (`openapi.Plugin.Keep`, `openapi.RequestSide`, as GitLab's). -## Why this source +### Why this source - **Source:** `openapi.yaml` at the root of [Flagsmith/flagsmith](https://github.com/Flagsmith/flagsmith), fetched at a release tag (`https://raw.githubusercontent.com/Flagsmith/flagsmith//openapi.yaml`); the newest tag from `releases/latest`. Checked on 2026-11-19. - **Why this one:** it's generated straight from the Django backend with drf-spectacular (`make generate-full-openapi`) and regenerated on every pull request that touches `api/**` by a bot that commits the result back to the PR branch (`.github/workflows/api-fix-docs-artefacts.yml`), so a release tag always carries the spec for the code it actually ships. Flagsmith tags a release on almost every merge to `main` (release-please), so two consecutive tags are usually one pull request apart. @@ -18,19 +22,19 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Flagsmith` and a request-side - **An RSS or Atom feed.** None found: Flagsmith's own blog and changelog have no feed; `docs.flagsmith.com/releases` is a static page, not a feed. - **Quote:** `"**EXPERIMENTAL ENDPOINT** - Subject to change without notice."` (every operation removed in the replay fixture, below, carried this in its own `description`). -## How the provider announces changes +### How the provider announces changes - **No API version in the path or a header.** `/api/v1/...` is the only prefix, and `v1` hasn't changed; `info.version` in the spec is a fixed `"v1"` that doesn't move between releases (checked 2026-11-19), so the event's `version` is the release tag, not `info.version`. - **A release on almost every merge to `main`**, via release-please; the spec is regenerated and committed in the same pull request, so it's never stale relative to a tag. - **No stated deprecation window.** The one real removal found (below) was tagged "EXPERIMENTAL ENDPOINT - Subject to change without notice" from the day it shipped and removed three releases later with no deprecation period; nothing in the spec or the release notes marks an operation `deprecated: true` before removing it. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads** whole operations removed between two tags, and the request-side changes `core/diff/` already tracks for every `openapi`-format provider (removed or newly-required parameters and request fields). - **Drops response-side changes**, same reason as GitLab (`requestSide`): a request body's schema is a named, shared component (`UpdateFlagV2`, `FeatureValue`), not inlined like GitLab's hash-named bodies, so the differ reports its removal as its own "schema removed" change, side `response` by default, whether or not the operations that used it are actually gone. Of the 11 changes between `v2.286.0` and `v2.287.0`, 8 are these schema-level echoes of the 3 real operation removals; the filter drops them and keeps the 3 operations. - The replay fixture: `v2.286.0` to `v2.287.0` (2026-10-15 to 2026-10-20), where PR [#8736](https://github.com/Flagsmith/flagsmith/pull/8736) ("Remove the experimental flag update endpoints") removed `POST /api/experiments/environments/{environment_key}/delete-segment-override/`, `.../update-flag-v1/` and `.../update-flag-v2/` and their eight request-body schemas, listed under "Features" in the [v2.287.0 release](https://github.com/Flagsmith/flagsmith/releases/tag/v2.287.0). All three were marked experimental from the day they shipped; `/api/__future__/...` is where Flagsmith puts their eventual, stable replacements. -## Known gaps +### Known gaps - **The experimental caveat.** The one real removal this plugin has seen is of endpoints Flagsmith itself called "subject to change without notice", not a stable, long-shipped one. It's still a genuine removal a caller of those three endpoints would have hit, and the mechanism (an operation vanishing between two tagged specs) is the same one that would catch a stable endpoint's removal. - **The Python and JS/TS SDKs aren't watched.** Their `CHANGELOG.md` files don't name removed symbols plainly enough for the `changelog` format plugin (see Alternatives considered); a client-library plugin for either would need its own reader, or a looser classifier. diff --git a/plugins/openapi/adapter/flagsmith.go b/providers/flagsmith/api.go similarity index 80% rename from plugins/openapi/adapter/flagsmith.go rename to providers/flagsmith/api.go index 659b30c..1186193 100644 --- a/plugins/openapi/adapter/flagsmith.go +++ b/providers/flagsmith/api.go @@ -1,4 +1,4 @@ -package adapter +package flagsmith import ( "context" @@ -8,6 +8,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" "gopkg.in/yaml.v3" ) @@ -31,7 +33,7 @@ var ( // Flagsmith adapts Flagsmith's own OpenAPI spec for the openapi plugin. type Flagsmith struct{} -var _ Adapter = Flagsmith{} +var _ adapter.Adapter = Flagsmith{} func (Flagsmith) API() string { return "flagsmith/api" } @@ -56,25 +58,30 @@ func (Flagsmith) LatestTag(ctx context.Context) (string, error) { // tell two releases apart. The bare version is also what a self-hosted // instance reports and what a customer tracks as "the Flagsmith version // we're running". -func (Flagsmith) Fetch(ctx context.Context, tag string) (Spec, error) { +func (Flagsmith) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { url := fmt.Sprintf(flagsmithSpecURLTemplate, tag) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching flagsmith spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("fetching flagsmith spec %s: %w", tag, err) } var doc any if err := yaml.Unmarshal(body, &doc); err != nil { - return Spec{}, fmt.Errorf("parsing flagsmith spec %s as yaml: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("parsing flagsmith spec %s as yaml: %w", tag, err) } content, err := json.Marshal(doc) if err != nil { - return Spec{}, fmt.Errorf("converting flagsmith spec %s to json: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("converting flagsmith spec %s to json: %w", tag, err) } - return Spec{ + return adapter.Spec{ Content: content, Version: strings.TrimPrefix(tag, "v"), SourceURL: url, }, nil } + +// Versions are Flagsmith's releases. +func (Flagsmith) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Releases(ctx, "Flagsmith/flagsmith", nil) +} diff --git a/plugins/openapi/flagsmith_test.go b/providers/flagsmith/api_test.go similarity index 88% rename from plugins/openapi/flagsmith_test.go rename to providers/flagsmith/api_test.go index e3d29c1..d37ee6f 100644 --- a/plugins/openapi/flagsmith_test.go +++ b/providers/flagsmith/api_test.go @@ -1,4 +1,4 @@ -package openapi +package flagsmith import ( "context" @@ -9,7 +9,8 @@ import ( "testing" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" "gopkg.in/yaml.v3" ) @@ -36,12 +37,12 @@ var flagsmithTags = map[string]string{ } func TestFlagsmithRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Adapter: adapter.Flagsmith{}}) + kittest.Registered(t, openapi.Plugin{Adapter: Flagsmith{}}) } // fakeFlagsmithAdapter serves the saved copies, cited by the real URL each // was copied from, converted from YAML to JSON and the tag's leading "v" -// trimmed from Version the same way adapter.Flagsmith.Fetch does. +// trimmed from Version the same way Flagsmith.Fetch does. type fakeFlagsmithAdapter struct{} func (fakeFlagsmithAdapter) API() string { return "flagsmith/api" } @@ -78,7 +79,7 @@ func TestFlagsmithGolden(t *testing.T) { ctx := context.Background() env := kittest.Env(t, nil) sink := kittest.NewMem() - p := Plugin{Adapter: fakeFlagsmithAdapter{}, Keep: requestSide} + p := openapi.Plugin{Adapter: fakeFlagsmithAdapter{}, Keep: openapi.RequestSide} if rejected, err := kittest.Pair(ctx, env, sink, p, "v2.286.0", "v2.287.0"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } @@ -91,7 +92,7 @@ func TestFlagsmithDropsADescriptionOnlyChange(t *testing.T) { ctx := context.Background() env := kittest.Env(t, nil) sink := kittest.NewMem() - p := Plugin{Adapter: fakeFlagsmithAdapter{}, Keep: requestSide} + p := openapi.Plugin{Adapter: fakeFlagsmithAdapter{}, Keep: openapi.RequestSide} if rejected, err := kittest.Pair(ctx, env, sink, p, "c3ef832", "f504f16"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } diff --git a/providers/flagsmith/provider.go b/providers/flagsmith/provider.go new file mode 100644 index 0000000..d9ff679 --- /dev/null +++ b/providers/flagsmith/provider.go @@ -0,0 +1,28 @@ +// Package flagsmith is what patch-it reads for Flagsmith: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package flagsmith + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "flagsmith", Name: "Flagsmith", Category: plugin.CategoryDevTools, Homepage: "https://www.flagsmith.com", + Sources: []plugin.Source{ + // No Hints: Flagsmith's release notes are product news, not keyed by + // operation. RequestSide, same reason as GitLab's: a named request-body + // schema shared by several operations (FeatureValue, SegmentOverride) + // reads as its own removal, side "response" by the differ's default, + // whether or not any operation that used it is actually gone. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API changes between releases of Flagsmith's own OpenAPI spec (removed endpoints and request parameters)", + URLs: []string{"https://github.com/Flagsmith/flagsmith/blob/main/openapi.yaml"}, + Plugin: openapi.Plugin{Adapter: Flagsmith{}, Keep: openapi.RequestSide}, + }, + }, + }) +} diff --git a/providers/flagsmith/testdata/README.md b/providers/flagsmith/testdata/README.md new file mode 100644 index 0000000..3acb0c4 --- /dev/null +++ b/providers/flagsmith/testdata/README.md @@ -0,0 +1,14 @@ +# Flagsmith: saved copies and goldens + +Real copies of what Flagsmith publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/flagsmith -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `flagsmith-v2.286.0.yaml`, `flagsmith-v2.287.0.yaml` | https://raw.githubusercontent.com/Flagsmith/flagsmith/v2.286.0/openapi.yaml (and `v2.287.0`) | 2026-11-19 | BSD-3-Clause (Flagsmith/flagsmith; also the spec's own `info.license`) | "**EXPERIMENTAL ENDPOINT** - Subject to change without notice." (`POST .../delete-segment-override/` and two more, removed in `v2.287.0`) | +| `flagsmith-desc-c3ef832.yaml`, `flagsmith-desc-f504f16.yaml` | https://raw.githubusercontent.com/Flagsmith/flagsmith/c3ef83244bfb4b1d65ab6fc5ff45412659dd61f3/openapi.yaml (and `f504f160dcf40b16baace0506a04dfda8fd6332c`, commits not tags) | 2026-11-19 | BSD-3-Clause (Flagsmith/flagsmith; also the spec's own `info.license`) | "Short-lived access token for the Admin API." (in `c3ef832`), "...for the Management API." (in `f504f16`, the same commit as "feat: rename admin api to management" #8464): the drop test | + +The Flagsmith copies are trimmed by lines: `openapi`, `info` and `servers`, then the path items involved (`paths: {}` where none remain, the one line in `v2.287.0.yaml` that isn't in the original) and, under `components: schemas:`, every schema those paths' request bodies reach, transitively, whole and in original order, every line copied unchanged; `tags` and `security` left out. `FeatureValue`, `FeatureValueTypeEnum` and `MultivariateValue` are kept unchanged in both files because the real spec still has them at `v2.287.0` (other, unremoved operations use them too); every other schema the removed paths reached (`DeleteSegmentOverride`, `EnvironmentDefault`, `FeatureIdentifier`, `FeatureUpdateSegmentData`, `SegmentIdentifier`, `SegmentOverride`, `UpdateFlag`, `UpdateFlagV2`) really is gone in `v2.287.0`, confirmed against the full file. The drop-test pair is two commits, not tags, kept whole but for the same trim (`TokenExchangeResponse` and the `Master API Key` security scheme, the only two places that commit touched `openapi.yaml`). diff --git a/plugins/openapi/testdata/flagsmith-desc-c3ef832.yaml b/providers/flagsmith/testdata/flagsmith-desc-c3ef832.yaml similarity index 100% rename from plugins/openapi/testdata/flagsmith-desc-c3ef832.yaml rename to providers/flagsmith/testdata/flagsmith-desc-c3ef832.yaml diff --git a/plugins/openapi/testdata/flagsmith-desc-f504f16.yaml b/providers/flagsmith/testdata/flagsmith-desc-f504f16.yaml similarity index 100% rename from plugins/openapi/testdata/flagsmith-desc-f504f16.yaml rename to providers/flagsmith/testdata/flagsmith-desc-f504f16.yaml diff --git a/plugins/openapi/testdata/flagsmith-v2.286.0.yaml b/providers/flagsmith/testdata/flagsmith-v2.286.0.yaml similarity index 100% rename from plugins/openapi/testdata/flagsmith-v2.286.0.yaml rename to providers/flagsmith/testdata/flagsmith-v2.286.0.yaml diff --git a/plugins/openapi/testdata/flagsmith-v2.287.0.yaml b/providers/flagsmith/testdata/flagsmith-v2.287.0.yaml similarity index 100% rename from plugins/openapi/testdata/flagsmith-v2.287.0.yaml rename to providers/flagsmith/testdata/flagsmith-v2.287.0.yaml diff --git a/plugins/openapi/testdata/golden/flagsmith.json b/providers/flagsmith/testdata/golden/flagsmith.json similarity index 100% rename from plugins/openapi/testdata/golden/flagsmith.json rename to providers/flagsmith/testdata/golden/flagsmith.json diff --git a/providers/github-actions.md b/providers/github-actions.md deleted file mode 100644 index 25076d6..0000000 --- a/providers/github-actions.md +++ /dev/null @@ -1,32 +0,0 @@ -# GitHub Actions runner images (`github/actions`) - -## What it watches - -GitHub-hosted runner images that GitHub retires: one `ci_runtime` event per `runs-on` label the retirement removes (`macos-14`, `macos-14-large`, …), dated by the removal date. - -Kind: `notices` (`plugins/notices`), with the feed reader (`plugins/notices/feed`) and its `GitHubActions` feed. - -## Why this source - -- **Source:** the [GitHub changelog, Actions label](https://github.blog/changelog/label/actions/), as RSS: `https://github.blog/changelog/label/actions/feed/`. Checked on 2026-11-14. -- **Why this one:** it's GitHub's own changelog feed, built to be machine-read, with labels (`Retired`) as RSS categories. Retirement posts list the affected labels in a fixed shape and give the date. -- **Alternatives considered:** the [actions/runner-images](https://github.com/actions/runner-images) repo's announcement issues (detailed, but issue text varies and they're not a feed); the full GitHub changelog feed (every product, much noisier); the runner images README (says what exists now, not when it goes). -- **Quote:** "The macOS 14 runner image will be retired on November 2, 2026." - -## How the provider announces changes - -- A retirement post weeks or months ahead, often with scheduled "brownouts" where jobs on the old image fail temporarily. -- **Forced**: on the date, jobs using the label stop running. -- The feed carries only the latest 10 posts, so the plugin runs daily and cites a snapshot. - -## What the plugin reads and ignores - -- Only posts labelled `Retired` about a runner image that list `runs-on` labels. -- **Breaking needs GitHub to say it stops on a date** ("will be retired / removed on …"); softer words ("will be deprecated on", "before …") make it a deprecation; no dated sentence and the post is dropped. -- Drops (and logs) retirements with no runner label to name (the ARM32 Linux and Windows retirement) and behavior changes (`pull_request_target` blocked by default). -- Every event cites a Wayback Machine snapshot of the feed and is read from it. - -## Known gaps - -- The patch-it client doesn't fix `ci_runtime` events yet. -- Deprecations of actions themselves (`actions/upload-artifact@v3`, …) aren't read. diff --git a/providers/github-graphql.md b/providers/github-graphql.md deleted file mode 100644 index 134ae57..0000000 --- a/providers/github-graphql.md +++ /dev/null @@ -1,39 +0,0 @@ -# GitHub GraphQL API (`github/graphql`) - -## What it watches - -Removals GitHub announces for its GraphQL API: a field, an argument, an input field or an enum value, with the date it goes. One `deprecation` event per newly announced removal, its `version` the removal date. - -Kind: `catalog` (`plugins/catalog`), the `UpcomingChanges` reader (`plugins/catalog/graphql.go`). - -## Why this source - -- **Source:** [`src/graphql/data/fpt/upcoming-changes.json`](https://github.com/github/docs/blob/main/src/graphql/data/fpt/upcoming-changes.json) in github/docs, read at every commit that changed it (listed from GitHub's commits API, `?path=`). It's the file [Breaking changes](https://docs.github.com/en/graphql/overview/breaking-changes) on docs.github.com is built from. Checked on 2026-11-21: 1,291 entries, every one `"criticality": "breaking"`, 29 commits since 2023-05-01. -- **Why this one:** one JSON object keyed by removal date, each entry naming its location (`RepositoryPermission.TRIAGE_PLUS`), what to do and why, from GitHub's own schema tooling. A commit never changes, so the raw file at it is its own citation. -- **Alternatives considered:** - - **The Breaking changes page** (HTML): the same entries, rendered; the JSON is what it's made from. - - **The GraphQL schema** (`schema.docs.graphql`, `@deprecated(reason: "… Removal on 2027-04-01 UTC.")`): the same dates inside a GraphQL SDL, which needs a schema reader no kind has. - - **The GitHub changelog**: announces some of these, in prose, with no location. -- **Quote:** `{"location": "RepositoryPermission.TRIAGE_PLUS", "description": "

    TRIAGE_PLUS will be removed. Use MODERATE instead.

    ", "date": "2027-04-01", "criticality": "breaking"}`. - -## How the provider announces changes - -- GitHub's GraphQL API has no versions: a change is announced here with its removal date, a quarter's first day (`2026-10-01`, `2027-01-01`). -- Announcements come a few at a time (one or two a month in 2026), sometimes in a batch (1,109 entries on 2025-04-14, the audit-log fields). - -## What the plugin reads and ignores - -- Reads every entry of the file at each commit. An entry (location and date) in the newer commit's file that the older one didn't have is a `deprecation` event: `version` the removal date (the API has no versions; the day it breaks is what a gate compares, as a model's shutdown date is), `previous_version` the older commit's date, the hint the entry's description and reason as text. The excerpt is the entry's fields as the file writes them, its `owner` left out. -- Subject (`api_operation`): an input object's field (`AddPullRequestReviewInput.comments`) or a root field's argument (`Query.sponsorables.dependencyEcosystem`) is a `request_parameter` of `POST /graphql`, its `property` the location; any other location (a root field itself, a type's field or its argument, an enum value) is a `schema_property`, its `schema` the type and its `property` the rest (`RepositoryPermission` / `TRIAGE_PLUS`). -- An entry a commit drops while still upcoming and a later commit restores is the same event (same removal date, same fingerprint), so it isn't announced twice. -- Ignores an entry dated before the commit that adds it: a revert putting back a removal already made, not an announcement. On 2026-01-05 the file lost 17 such entries, got them back the next day and lost them again on 2026-01-08: no event (the pinned drop test). -- Ignores an entry leaving the file: the removal shipped, or GitHub withdrew it, and the file doesn't say which. -- A first read, with no commit before it, has nothing to compare: no events. - -## Known gaps - -- `previous_version` (a commit date) to `version` (the removal date) isn't a range of this source's listed versions: the removal date is when the change breaks, as a model's shutdown date is. Whether the feed's coverage logic should treat such a pair differently is for the contract (patch-it) to say. - -- The removal itself (the day it ships) isn't a separate `breaking` event; the deprecation names the date. -- GitHub Enterprise Server's own files (`ghes-*`) aren't read. -- A location GitHub moves to a new date is a new event (a new `version`), alongside the first. diff --git a/providers/github-octokit.md b/providers/github-octokit.md deleted file mode 100644 index d4e06e1..0000000 --- a/providers/github-octokit.md +++ /dev/null @@ -1,29 +0,0 @@ -# Octokit SDKs (`github/octokit-rest`, `github/octokit-net`) - -## What it watches - -Methods removed or renamed in each release of `@octokit/rest` (JavaScript) and Octokit (.NET), from each GitHub release's notes: neither keeps a changelog file. Packages `npm:@octokit/rest` and `nuget:Octokit`; releases listed from each repo's GitHub releases (`vX.Y.Z`, drafts and pre-releases left out). GitHub's REST API itself is a separate source (`github/rest-api`). - -Kind: `changelog` (`plugins/changelog`, `sdks.go`, with `Notes: true`). - -## Why this source - -- **Source:** https://github.com/octokit/rest.js/releases and https://github.com/octokit/octokit.net/releases, each release read through GitHub's API (`/repos/{repo}/releases/tags/{tag}`) and cited by its release page; checked on 2026-11-20. -- **Why this one:** it's the only per-release record either project publishes. rest.js's semantic-release notes list every removal and rename under "BREAKING CHANGES" (`` `octokit.users.listEmails()` has been renamed to `octokit.users.listEmailsForAuthenticated()` ``). -- **Alternatives considered:** the docs sites (current version only); diffing the published packages (`apisurface`, when it's built). -- **Quote:** "deprecated `octokit.reactions.deleteLegacy()` has been removed" (@octokit/rest 18.0.0). - -## How the provider announces changes - -rest.js ships a major when GitHub removes or renames REST endpoints; octokit.net's notes list "Breaking changes" in prose more often than by name. - -## What the plugin reads and ignores - -- A rename whose new name the same release renames again or removes points to where the chain ends (rest.js 18.0.0: `issues.replaceLabels` → `issues.setLabels`, not the intermediate `replaceAllLabels`), or to nothing when the chain ends in a removal. -- Every heading in a release's notes starts a section; bullets under a breaking or deprecation heading count when they name what they remove or rename plainly. -- Drops (and logs): signature changes (`ISshKeysClient.Get(int id)`), dropped Node.js versions, "remove deprecated endpoints" without names. - -## Known gaps - -- Release notes can be edited after the release: what's read is the notes when the pair is extracted. -- octokit.net's releases describe breaking changes in prose or as signatures: the last plainly named removal is 0.5.2's (`MilestoneUpdate.Number`), the release its golden pins. diff --git a/providers/github.md b/providers/github.md deleted file mode 100644 index aad0118..0000000 --- a/providers/github.md +++ /dev/null @@ -1,31 +0,0 @@ -# GitHub REST API (`github/rest-api`) - -## What it watches - -GitHub's REST API between dated API versions (`2022-11-28` → `2026-03-10`): properties, schemas, parameters and operations removed or changed in a new version. - -Kind: `openapi` (`plugins/openapi`), with `adapter.GitHub`. - -## Why this source - -- **Source:** [github/rest-api-description](https://github.com/github/rest-api-description), one file per supported dated version: `descriptions/api.github.com/api.github.com..json` on `main`. The supported versions come from `GET https://api.github.com/versions`. Checked on 2026-11-14. -- **Why this one:** it's GitHub's own OpenAPI description, generated from the same source as docs.github.com's reference and the Octokit SDKs. A dated version's file is frozen, so two of them diff exactly. -- **Alternatives considered:** the undated `api.github.com.json` (the in-progress spec, moves several times a day with additive changes; not a version anyone pins); the `dereferenced/` variants (every `$ref` inlined, so one schema change would show up on every endpoint using it); the repo's `CHANGELOG.md` (one section per dated version listing affected endpoints; good prose, not wired as a hint source yet); the [Breaking changes](https://docs.github.com/en/rest/about-the-rest-api/breaking-changes) docs page (prose). -- **Quote:** "Remove deprecated `rate` property from rate limit endpoint." ([CHANGELOG.md](https://github.com/github/rest-api-description/blob/main/descriptions/api.github.com/CHANGELOG.md), Version 2026-03-10). - -## How the provider announces changes - -- Clients pick a version per request with `X-GitHub-Api-Version: `; without it GitHub uses `2022-11-28`. -- **Breaking changes only ship in a new dated version**, which is rare: `2022-11-28` was the only one for over three years. -- **Opt-in now, forced later**: a version keeps working for 24 months after a newer one ships, then returns `410 Gone` (with `Deprecation` / `Sunset` headers before that). -- The event's `version` is the dated version string, not `info.version` (a fixed package version, `1.1.4`). - -## What the plugin reads and ignores - -- Reads: the newest dated version's spec, diffed against the last one it saw. `GET /versions`' order isn't documented, so the adapter sorts the versions itself. -- The real `2022-11-28` → `2026-03-10` diff is 108 breaking events. The golden test replays a trimmed pair that keeps one of them: `rate` removed from `rate-limit-overview`. - -## Known gaps - -- Additive changes between dated versions aren't events (they never get a version). -- GraphQL isn't watched. diff --git a/providers/github/README.md b/providers/github/README.md new file mode 100644 index 0000000..99969bf --- /dev/null +++ b/providers/github/README.md @@ -0,0 +1,138 @@ +# GitHub + +Every source patch-it reads for GitHub, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## GitHub REST API (`github/rest-api`) + +### What it watches + +GitHub's REST API between dated API versions (`2022-11-28` → `2026-03-10`): properties, schemas, parameters and operations removed or changed in a new version. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `GitHub` ([`rest_api.go`](rest_api.go)). + +### Why this source + +- **Source:** [github/rest-api-description](https://github.com/github/rest-api-description), one file per supported dated version: `descriptions/api.github.com/api.github.com..json` on `main`. The supported versions come from `GET https://api.github.com/versions`. Checked on 2026-11-14. +- **Why this one:** it's GitHub's own OpenAPI description, generated from the same source as docs.github.com's reference and the Octokit SDKs. A dated version's file is frozen, so two of them diff exactly. +- **Alternatives considered:** the undated `api.github.com.json` (the in-progress spec, moves several times a day with additive changes; not a version anyone pins); the `dereferenced/` variants (every `$ref` inlined, so one schema change would show up on every endpoint using it); the repo's `CHANGELOG.md` (one section per dated version listing affected endpoints; good prose, not wired as a hint source yet); the [Breaking changes](https://docs.github.com/en/rest/about-the-rest-api/breaking-changes) docs page (prose). +- **Quote:** "Remove deprecated `rate` property from rate limit endpoint." ([CHANGELOG.md](https://github.com/github/rest-api-description/blob/main/descriptions/api.github.com/CHANGELOG.md), Version 2026-03-10). + +### How the provider announces changes + +- Clients pick a version per request with `X-GitHub-Api-Version: `; without it GitHub uses `2022-11-28`. +- **Breaking changes only ship in a new dated version**, which is rare: `2022-11-28` was the only one for over three years. +- **Opt-in now, forced later**: a version keeps working for 24 months after a newer one ships, then returns `410 Gone` (with `Deprecation` / `Sunset` headers before that). +- The event's `version` is the dated version string, not `info.version` (a fixed package version, `1.1.4`). + +### What the plugin reads and ignores + +- Reads: the newest dated version's spec, diffed against the last one it saw. `GET /versions`' order isn't documented, so the adapter sorts the versions itself. +- The real `2022-11-28` → `2026-03-10` diff is 108 breaking events. The golden test replays a trimmed pair that keeps one of them: `rate` removed from `rate-limit-overview`. + +### Known gaps + +- Additive changes between dated versions aren't events (they never get a version). +- GraphQL isn't watched. + +## GitHub Actions runner images (`github/actions`) + +### What it watches + +GitHub-hosted runner images that GitHub retires: one `ci_runtime` event per `runs-on` label the retirement removes (`macos-14`, `macos-14-large`, …), dated by the removal date. + +Kind: `notices` (`kinds/notices`), with the feed reader (`kinds/notices/feed`) and its `Actions` feed ([`actions.go`](actions.go)). + +### Why this source + +- **Source:** the [GitHub changelog, Actions label](https://github.blog/changelog/label/actions/), as RSS: `https://github.blog/changelog/label/actions/feed/`. Checked on 2026-11-14. +- **Why this one:** it's GitHub's own changelog feed, built to be machine-read, with labels (`Retired`) as RSS categories. Retirement posts list the affected labels in a fixed shape and give the date. +- **Alternatives considered:** the [actions/runner-images](https://github.com/actions/runner-images) repo's announcement issues (detailed, but issue text varies and they're not a feed); the full GitHub changelog feed (every product, much noisier); the runner images README (says what exists now, not when it goes). +- **Quote:** "The macOS 14 runner image will be retired on November 2, 2026." + +### How the provider announces changes + +- A retirement post weeks or months ahead, often with scheduled "brownouts" where jobs on the old image fail temporarily. +- **Forced**: on the date, jobs using the label stop running. +- The feed carries only the latest 10 posts, so the plugin runs daily and cites a snapshot. + +### What the plugin reads and ignores + +- Only posts labelled `Retired` about a runner image that list `runs-on` labels. +- **Breaking needs GitHub to say it stops on a date** ("will be retired / removed on …"); softer words ("will be deprecated on", "before …") make it a deprecation; no dated sentence and the post is dropped. +- Drops (and logs) retirements with no runner label to name (the ARM32 Linux and Windows retirement) and behavior changes (`pull_request_target` blocked by default). +- Every event cites a Wayback Machine snapshot of the feed and is read from it. + +### Known gaps + +- The patch-it client doesn't fix `ci_runtime` events yet. +- Deprecations of actions themselves (`actions/upload-artifact@v3`, …) aren't read. + +## GitHub GraphQL API (`github/graphql`) + +### What it watches + +Removals GitHub announces for its GraphQL API: a field, an argument, an input field or an enum value, with the date it goes. One `deprecation` event per newly announced removal, its `version` the removal date. + +Kind: `catalog` (`kinds/catalog`), the `UpcomingChanges` reader (`kinds/catalog/upcoming.go`). + +### Why this source + +- **Source:** [`src/graphql/data/fpt/upcoming-changes.json`](https://github.com/github/docs/blob/main/src/graphql/data/fpt/upcoming-changes.json) in github/docs, read at every commit that changed it (listed from GitHub's commits API, `?path=`). It's the file [Breaking changes](https://docs.github.com/en/graphql/overview/breaking-changes) on docs.github.com is built from. Checked on 2026-11-21: 1,291 entries, every one `"criticality": "breaking"`, 29 commits since 2023-05-01. +- **Why this one:** one JSON object keyed by removal date, each entry naming its location (`RepositoryPermission.TRIAGE_PLUS`), what to do and why, from GitHub's own schema tooling. A commit never changes, so the raw file at it is its own citation. +- **Alternatives considered:** + - **The Breaking changes page** (HTML): the same entries, rendered; the JSON is what it's made from. + - **The GraphQL schema** (`schema.docs.graphql`, `@deprecated(reason: "… Removal on 2027-04-01 UTC.")`): the same dates inside a GraphQL SDL, which needs a schema reader no kind has. + - **The GitHub changelog**: announces some of these, in prose, with no location. +- **Quote:** `{"location": "RepositoryPermission.TRIAGE_PLUS", "description": "

    TRIAGE_PLUS will be removed. Use MODERATE instead.

    ", "date": "2027-04-01", "criticality": "breaking"}`. + +### How the provider announces changes + +- GitHub's GraphQL API has no versions: a change is announced here with its removal date, a quarter's first day (`2026-10-01`, `2027-01-01`). +- Announcements come a few at a time (one or two a month in 2026), sometimes in a batch (1,109 entries on 2025-04-14, the audit-log fields). + +### What the plugin reads and ignores + +- Reads every entry of the file at each commit. An entry (location and date) in the newer commit's file that the older one didn't have is a `deprecation` event: `version` the removal date (the API has no versions; the day it breaks is what a gate compares, as a model's shutdown date is), `previous_version` the older commit's date, the hint the entry's description and reason as text. The excerpt is the entry's fields as the file writes them, its `owner` left out. +- Subject (`api_operation`): an input object's field (`AddPullRequestReviewInput.comments`) or a root field's argument (`Query.sponsorables.dependencyEcosystem`) is a `request_parameter` of `POST /graphql`, its `property` the location; any other location (a root field itself, a type's field or its argument, an enum value) is a `schema_property`, its `schema` the type and its `property` the rest (`RepositoryPermission` / `TRIAGE_PLUS`). +- An entry a commit drops while still upcoming and a later commit restores is the same event (same removal date, same fingerprint), so it isn't announced twice. +- Ignores an entry dated before the commit that adds it: a revert putting back a removal already made, not an announcement. On 2026-01-05 the file lost 17 such entries, got them back the next day and lost them again on 2026-01-08: no event (the pinned drop test). +- Ignores an entry leaving the file: the removal shipped, or GitHub withdrew it, and the file doesn't say which. +- A first read, with no commit before it, has nothing to compare: no events. + +### Known gaps + +- `previous_version` (a commit date) to `version` (the removal date) isn't a range of this source's listed versions: the removal date is when the change breaks, as a model's shutdown date is. Whether the feed's coverage logic should treat such a pair differently is for the contract (patch-it) to say. + +- The removal itself (the day it ships) isn't a separate `breaking` event; the deprecation names the date. +- GitHub Enterprise Server's own files (`ghes-*`) aren't read. +- A location GitHub moves to a new date is a new event (a new `version`), alongside the first. + +## Octokit SDKs (`github/octokit-rest`, `github/octokit-net`) + +### What it watches + +Methods removed or renamed in each release of `@octokit/rest` (JavaScript) and Octokit (.NET), from each GitHub release's notes: neither keeps a changelog file. Packages `npm:@octokit/rest` and `nuget:Octokit`; releases listed from each repo's GitHub releases (`vX.Y.Z`, drafts and pre-releases left out). GitHub's REST API itself is a separate source (`github/rest-api`). + +Kind: `changelog` (`kinds/changelog`, `sdks.go`, with `Notes: true`). + +### Why this source + +- **Source:** https://github.com/octokit/rest.js/releases and https://github.com/octokit/octokit.net/releases, each release read through GitHub's API (`/repos/{repo}/releases/tags/{tag}`) and cited by its release page; checked on 2026-11-20. +- **Why this one:** it's the only per-release record either project publishes. rest.js's semantic-release notes list every removal and rename under "BREAKING CHANGES" (`` `octokit.users.listEmails()` has been renamed to `octokit.users.listEmailsForAuthenticated()` ``). +- **Alternatives considered:** the docs sites (current version only); diffing the published packages (`apisurface`, when it's built). +- **Quote:** "deprecated `octokit.reactions.deleteLegacy()` has been removed" (@octokit/rest 18.0.0). + +### How the provider announces changes + +rest.js ships a major when GitHub removes or renames REST endpoints; octokit.net's notes list "Breaking changes" in prose more often than by name. + +### What the plugin reads and ignores + +- A rename whose new name the same release renames again or removes points to where the chain ends (rest.js 18.0.0: `issues.replaceLabels` → `issues.setLabels`, not the intermediate `replaceAllLabels`), or to nothing when the chain ends in a removal. +- Every heading in a release's notes starts a section; bullets under a breaking or deprecation heading count when they name what they remove or rename plainly. +- Drops (and logs): signature changes (`ISshKeysClient.Get(int id)`), dropped Node.js versions, "remove deprecated endpoints" without names. + +### Known gaps + +- Release notes can be edited after the release: what's read is the notes when the pair is extracted. +- octokit.net's releases describe breaking changes in prose or as signatures: the last plainly named removal is 0.5.2's (`MilestoneUpdate.Number`), the release its golden pins. diff --git a/providers/github/actions.go b/providers/github/actions.go new file mode 100644 index 0000000..9d1e979 --- /dev/null +++ b/providers/github/actions.go @@ -0,0 +1,70 @@ +package github + +import ( + "fmt" + "regexp" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" +) + +// Actions is the GitHub changelog's Actions label, RSS 2.0 (checked +// 2026-11-14: the latest 10 posts, each with its labels as , the +// post's HTML in content:encoded). A retirement is labelled "Retired"; a +// runner image retirement names the date ("The macOS 14 runner image will be +// retired on November 2, 2026.") and lists the `runs-on` labels it removes. +var Actions = feed.Feed{ + API: "github/actions", + Vendor: "GitHub", + URL: "https://github.blog/changelog/label/actions/feed/", + Read: readGitHubActions, +} + +var runnerImage = regexp.MustCompile(`(?i)\brunner images?\b`) + +var labelsList = regexp.MustCompile(`(?is)

    ([^<]*following labels[^<]*)

    \s*
      (.*?)
    `) + +func readGitHubActions(e feed.Entry) []feed.Finding { + if !feed.Marked(e.Categories, "Retired", "Deprecation", "Deprecated", "Breaking change", "Breaking changes") { + return nil + } + drop := func(why string) []feed.Finding { return []feed.Finding{{Entry: e.Link, Dropped: why}} } + if !runnerImage.MatchString(e.Title) { + return drop("not a runner image retirement: no ci_runtime this reader can name") + } + line, date, ct := feed.Dated(feed.Lines(e.HTML)) + if date == "" { + return drop("no sentence giving the date the image is removed") + } + m := labelsList.FindStringSubmatch(e.HTML) + if m == nil { + return drop("lists no runner labels") + } + intro := feed.Text(m[1]) + var out []feed.Finding + for _, li := range feed.ListItem.FindAllStringSubmatch(m[2], -1) { + codes := feed.Codes(li[1]) + if len(codes) != 1 || feed.Text(li[1]) != codes[0] { + out = append(out, feed.Finding{Entry: e.Link, Dropped: fmt.Sprintf("label item %q isn't one plain label", feed.Text(li[1]))}) + continue + } + label := codes[0] + desc := fmt.Sprintf("GitHub-hosted runner label %q is retired on %s: jobs that run on it fail from that date.", label, date) + if ct == event.ChangeTypeDeprecation { + desc = fmt.Sprintf("GitHub-hosted runner label %q is deprecated; GitHub names %s for it.", label, date) + } + out = append(out, feed.Finding{ + ChangeType: ct, + Version: date, + Subject: event.Subject{Type: event.SubjectCIRuntime, Platform: "github-actions", Runtime: label}, + Description: desc, + Hint: "Move `runs-on` to a supported label; GitHub's announcement lists them: " + e.Link, + Excerpt: feed.Excerpt(e.Title, line, intro, label), + Entry: e.Link, + }) + } + if len(out) == 0 { + return drop("lists no runner labels") + } + return out +} diff --git a/plugins/notices/feed/feed_test.go b/providers/github/actions_test.go similarity index 54% rename from plugins/notices/feed/feed_test.go rename to providers/github/actions_test.go index 01158cd..8ecde7e 100644 --- a/plugins/notices/feed/feed_test.go +++ b/providers/github/actions_test.go @@ -1,29 +1,33 @@ -package feed +package github import ( "strings" "testing" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest" ) -// What each feed's marked entries came to, kept and dropped: the golden files +// The feed as saved on 2026-11-14 (testdata/README.md) through the whole +// plugin: live feed and snapshot are the same copy, so the events cite the +// snapshot. +func TestActionsGolden(t *testing.T) { + noticestest.Golden(t, Actions, "testdata/github-changelog-actions.rss.xml") +} + +// What the feed's marked entries came to, kept and dropped: the golden files // pin the events, this pins that the unsure ones were dropped, not guessed. -func TestUnsureEntriesAreDropped(t *testing.T) { +func TestActionsUnsureEntriesAreDropped(t *testing.T) { for _, c := range []struct { - feed Feed + feed feed.Feed file string dropped []string // a substring of each drop reason, in order }{ - {GitHubActions, "testdata/github-changelog-actions.rss.xml", []string{ + {Actions, "testdata/github-changelog-actions.rss.xml", []string{ "arm32-linux-windows-retirement", // no runner label: no ci_runtime to name "pull_request_target-blocked-by-default-december-2", // a behavior change, no subject type fits }}, - {VertexAIModels, "testdata/vertex-ai-generative-ai.atom.xml", []string{ - "Vertex AI Extensions deprecation", - "Anthropic's Claude 3 Haiku", // a product name in prose, not a model id - "Anthropic's Claude 3.5 Haiku", - }}, } { fs, err := c.feed.Findings(kittest.Read(t, c.file)) if err != nil { @@ -47,39 +51,11 @@ func TestUnsureEntriesAreDropped(t *testing.T) { } } -func TestParseRefusesWhatIsntAFeed(t *testing.T) { - for name, b := range map[string]string{ - "html": "moved", - "no items": `x`, - "no entry": `x`, - } { - if _, err := Parse([]byte(b)); err == nil { - t.Errorf("%s: want an error, never zero events read as a quiet week", name) - } - } -} - -// RSS without content:encoded falls back to description; Atom takes the -// alternate link and the category terms. -func TestParseReadsBothFormats(t *testing.T) { - r, err := Parse([]byte(`A & Bhttps://x.test/a - Retired<p>text</p>`)) - if err != nil || r[0].Title != "A & B" || r[0].HTML != "

    text

    " || r[0].Categories[0] != "Retired" || r[0].ID != "https://x.test/a" { - t.Errorf("rss: %+v %v", r, err) - } - a, err := Parse([]byte(`iT - - <b>s</b>`)) - if err != nil || a[0].Link != "https://x.test/e" || a[0].HTML != "s" || a[0].Categories[0] != "Deprecated" { - t.Errorf("atom: %+v %v", a, err) - } -} - // Breaking only when the vendor says the thing stops on the date; softer // words downgrade to a deprecation, and no date drops the entry. func TestBreakingNeedsTheVendorToSayItStops(t *testing.T) { - entry := func(sentence string) Entry { - return Entry{Title: "Ubuntu 22.04 runner image retirement", Link: "https://x.test/e", Categories: []string{"Retired"}, + entry := func(sentence string) feed.Entry { + return feed.Entry{Title: "Ubuntu 22.04 runner image retirement", Link: "https://x.test/e", Categories: []string{"Retired"}, HTML: "

    " + sentence + "

    This deprecation includes the following labels:

    • ubuntu-22.04
    "} } for sentence, want := range map[string]string{ diff --git a/plugins/catalog/graphql_test.go b/providers/github/graphql_test.go similarity index 70% rename from plugins/catalog/graphql_test.go rename to providers/github/graphql_test.go index 632ccbd..21a5eab 100644 --- a/plugins/catalog/graphql_test.go +++ b/providers/github/graphql_test.go @@ -1,7 +1,8 @@ -package catalog +package github import ( "context" + "encoding/json" "fmt" "strings" "testing" @@ -27,14 +28,14 @@ var graphqlCommits = []plugin.Version{ func graphqlPages() kittest.Pages { pages := kittest.Pages{} for _, v := range graphqlCommits { - pages[GitHubGraphQL.FileURL(v.Ref)] = "testdata/github-graphql-upcoming-changes-" + v.Ref[:8] + ".json" + pages[GraphQL.FileURL(v.Ref)] = "testdata/github-graphql-upcoming-changes-" + v.Ref[:8] + ".json" } return pages } func graphqlPair(t *testing.T, from, to plugin.Version) []event.Event { t.Helper() - return kittest.Versions(t, kittest.Env(t, graphqlPages()), GitHubGraphQL, from, to) + return kittest.Versions(t, kittest.Env(t, graphqlPages()), GraphQL, from, to) } // The golden test: four consecutive commits, three pairs. 2026-03-03 adds @@ -78,32 +79,10 @@ func TestGraphQLRevertsAreNoAnnouncement(t *testing.T) { } } // The second pair does add entries: what the date check drops. - from, _ := GitHubGraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[0]) - to, _ := GitHubGraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[1]) - a, _ := entries(from.Content) - b, _ := entries(to.Content) - if len(b)-len(a) != 17 { - t.Errorf("the re-added entries: %d, want 17", len(b)-len(a)) - } -} - -// An input object's field and a root field's argument are request -// parameters of POST /graphql; any other location is a property of its type. -func TestGraphQLLocations(t *testing.T) { - for loc, want := range map[string]string{ - "AddPullRequestReviewInput.comments": "request_parameter POST /graphql AddPullRequestReviewInput.comments", - "Query.sponsorables.dependencyEcosystem": "request_parameter POST /graphql Query.sponsorables.dependencyEcosystem", - "RepositoryPermission.TRIAGE_PLUS": "schema_property RepositoryPermission TRIAGE_PLUS", - "Issue.stateReason.enableDuplicate": "schema_property Issue stateReason.enableDuplicate", - } { - s, ok := GitHubGraphQL.subject(loc) - got := strings.Join(strings.Fields(fmt.Sprintf("%s %s %s %s", s.Kind, s.Operation, s.Schema, s.Property)), " ") - if !ok || got != want { - t.Errorf("%s: %q, want %q", loc, got, want) - } - } - if _, ok := GitHubGraphQL.subject("NoDot"); ok { - t.Error("a location without a field isn't read") + from, _ := GraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[0]) + to, _ := GraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[1]) + if a, b := countEntries(t, from.Content), countEntries(t, to.Content); b-a != 17 { + t.Errorf("the re-added entries: %d, want 17", b-a) } } @@ -111,7 +90,7 @@ func TestGraphQLVersionsAreTheFilesCommits(t *testing.T) { env := kittest.Env(t, kittest.Pages{ "https://api.github.com/repos/github/docs/commits?path=src%2Fgraphql%2Fdata%2Ffpt%2Fupcoming-changes.json&per_page=100&page=1": "testdata/github-commits-upcoming-changes-excerpt.json", }) - vs, err := GitHubGraphQL.ListVersions(context.Background(), env) + vs, err := GraphQL.ListVersions(context.Background(), env) if err != nil || len(vs) != 3 || vs[0].Ref != graphqlCommits[3].Ref || vs[2].ID != "2026-05-22" { t.Errorf("%v %v", vs, err) } @@ -123,17 +102,17 @@ func TestGraphQLVersionsAreTheFilesCommits(t *testing.T) { func TestGraphQLARestoredEntryIsTheSameEvent(t *testing.T) { first := graphqlPair(t, graphqlCommits[3], graphqlCommits[4]) // 2026-03-03's file without its two additions, then the file again. - from, err := GitHubGraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[3]) + from, err := GraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[3]) if err != nil { t.Fatal(err) } - to, err := GitHubGraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[4]) + to, err := GraphQL.ReadAt(context.Background(), kittest.Env(t, graphqlPages()), graphqlCommits[4]) if err != nil { t.Fatal(err) } from.Version = plugin.Version{ID: "2026-04-01", Ref: "dropped"} to.Version = plugin.Version{ID: "2026-04-02", Ref: "restored"} - again, err := GitHubGraphQL.Extract(context.Background(), kittest.Env(t, nil), from, to) + again, err := GraphQL.Extract(context.Background(), kittest.Env(t, nil), from, to) if err != nil || len(again.Events) != len(first) { t.Fatalf("%v, %d events", err, len(again.Events)) } @@ -143,3 +122,17 @@ func TestGraphQLARestoredEntryIsTheSameEvent(t *testing.T) { } } } + +// countEntries is how many entries the file holds, on every date. +func countEntries(t *testing.T, body []byte) int { + t.Helper() + var byDate map[string][]json.RawMessage + if err := json.Unmarshal(body, &byDate); err != nil { + t.Fatal(err) + } + n := 0 + for _, es := range byDate { + n += len(es) + } + return n +} diff --git a/providers/github/octokit_test.go b/providers/github/octokit_test.go new file mode 100644 index 0000000..c92e4bf --- /dev/null +++ b/providers/github/octokit_test.go @@ -0,0 +1,14 @@ +package github + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +func TestOctokitSDKs(t *testing.T) { + changelogtest.CheckSDKs(t, []changelogtest.SDKCase{ + {File: OctokitRest, Release: "18.0.0", Prev: "17.11.2", Saved: "github-octokit-rest-18.0.0-release.json", Dropped: "github-octokit-rest-17.11.2-release.json", Drop: "17.11.2"}, + {File: OctokitNet, Release: "0.5.2", Prev: "0.5.1", Saved: "github-octokit-net-0.5.2-release.json", Dropped: "github-octokit-net-0.5.1-release.json", Drop: "0.5.1"}, + }) +} diff --git a/providers/github/provider.go b/providers/github/provider.go new file mode 100644 index 0000000..40ca51d --- /dev/null +++ b/providers/github/provider.go @@ -0,0 +1,64 @@ +// Package github is what patch-it reads for GitHub: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package github + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/kit" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/catalog" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "github", Name: "GitHub", Category: plugin.CategoryDevTools, Homepage: "https://github.com", + Sources: []plugin.Source{ + // No Hints yet: GitHub's per-version CHANGELOG.md is prose with no table + // at all, so there's nothing for hint.Source to key on. (GitHub's Actions + // source is read by the notices kind, below.) + { + ID: "rest-api", Layer: plugin.LayerAPI, + Watches: "REST API changes between dated API versions", + URLs: []string{"https://github.com/github/rest-api-description"}, + Plugin: openapi.Plugin{Adapter: GitHub{}}, + }, + { + ID: "actions", Layer: plugin.LayerCI, + Watches: "GitHub Actions retirements, such as runner images and the `runs-on` labels they remove", + URLs: []string{"https://github.blog/changelog/label/actions/feed/"}, + Plugin: notices.Plugin{Page: Actions, Archiver: kit.Wayback{}}, + }, + { + ID: "graphql", Layer: plugin.LayerAPI, + Watches: "GraphQL API fields, arguments, input fields and enum values GitHub announces it will remove, with the date, from the file its breaking-changes page is built from", + URLs: []string{"https://docs.github.com/en/graphql/overview/breaking-changes", "https://github.com/github/docs/blob/main/src/graphql/data/fpt/upcoming-changes.json"}, + Packages: []string{"npm:@octokit/graphql"}, + Plugin: GraphQL, + }, + changelog.SDK("octokit-rest", OctokitRest, "npm:@octokit/rest"), + changelog.SDK("octokit-net", OctokitNet, "nuget:Octokit"), + }, + }) +} + +// Octokit's SDKs keep no changelog file: each GitHub release's notes are it +// (semantic-release's "### BREAKING CHANGES" for rest.js, "Breaking +// changes" lists for octokit.net); tagged vX.Y.Z. +var ( + OctokitRest = changelog.File{API: "github/octokit-rest", Package: "@octokit/rest", Ecosystem: "npm", + Repo: "octokit/rest.js", TagPrefix: "v", Notes: true} + OctokitNet = changelog.File{API: "github/octokit-net", Package: "Octokit", Ecosystem: "nuget", + Repo: "octokit/octokit.net", TagPrefix: "v", Notes: true} +) + +// GraphQL is GitHub's GraphQL API's upcoming changes (checked +// 2026-11-21: 1,291 entries, every one "criticality": "breaking", 29 +// commits since 2023-05-01). +var GraphQL = catalog.UpcomingChanges{ + API: "github/graphql", Vendor: "GitHub", + Repo: "github/docs", Path: "src/graphql/data/fpt/upcoming-changes.json", + Endpoint: "POST /graphql", +} diff --git a/plugins/openapi/adapter/github.go b/providers/github/rest_api.go similarity index 68% rename from plugins/openapi/adapter/github.go rename to providers/github/rest_api.go index fa9d6b7..83d1de0 100644 --- a/plugins/openapi/adapter/github.go +++ b/providers/github/rest_api.go @@ -1,13 +1,17 @@ -package adapter +package github import ( "context" "encoding/json" "fmt" + "slices" "sort" + "time" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // Variables, not constants, only so tests can point them at a local server. @@ -30,7 +34,7 @@ var ( // exactly what a client sends back on X-GitHub-Api-Version. type GitHub struct{} -var _ Adapter = GitHub{} +var _ adapter.Adapter = GitHub{} func (GitHub) API() string { return "github/rest-api" } @@ -60,19 +64,40 @@ func (GitHub) LatestTag(ctx context.Context) (string, error) { // is a fixed package version ("1.1.4" at the time of checking) identical // across every spec file, so it can't tell two API versions apart — the same // problem Datadog's static info.version has. -func (GitHub) Fetch(ctx context.Context, tag string) (Spec, error) { +func (GitHub) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { url := fmt.Sprintf(githubSpecURLTemplate, tag) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching github spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("fetching github spec %s: %w", tag, err) } if !json.Valid(body) { - return Spec{}, fmt.Errorf("github spec %s is not valid json", tag) + return adapter.Spec{}, fmt.Errorf("github spec %s is not valid json", tag) } - return Spec{ + return adapter.Spec{ Content: body, Version: tag, SourceURL: url, }, nil } + +// Versions are every API version GitHub supports, oldest first: each is a +// spec file of its own, and what a client sends as X-GitHub-Api-Version. +// GitHub publishes no spec for a version it no longer supports. +func (GitHub) Versions(ctx context.Context) ([]plugin.Version, error) { + body, err := fetch.Get(ctx, githubVersionsURL, github.Headers()) + if err != nil { + return nil, fmt.Errorf("looking up github's supported api versions: %w", err) + } + var ids []string + if err := json.Unmarshal(body, &ids); err != nil { + return nil, fmt.Errorf("parsing github versions response: %w", err) + } + slices.Sort(ids) + var out []plugin.Version + for _, id := range ids { + released, _ := time.Parse(time.DateOnly, id) + out = append(out, plugin.Version{ID: id, Released: released, Ref: id, URL: "https://docs.github.com/rest/about-the-rest-api/api-versions"}) + } + return out, nil +} diff --git a/plugins/openapi/adapter/github_test.go b/providers/github/rest_api_fetch_test.go similarity index 86% rename from plugins/openapi/adapter/github_test.go rename to providers/github/rest_api_fetch_test.go index 5b50876..013da0a 100644 --- a/plugins/openapi/adapter/github_test.go +++ b/providers/github/rest_api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package github import ( "context" @@ -6,6 +6,8 @@ import ( "net/http/httptest" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // fakeGitHubVersions serves /versions and spec files by path, like @@ -112,3 +114,17 @@ func TestGitHubFetchFailsWhenSpecDoesNotExist(t *testing.T) { t.Error("missing version: want an error") } } + +func TestGitHubListsEverySupportedVersion(t *testing.T) { + srv := openapitest.Recorded(t, map[string]string{"/versions": "github-versions.json"}) + old := githubVersionsURL + githubVersionsURL = srv.URL + "/versions" + t.Cleanup(func() { githubVersionsURL = old }) + vs, err := GitHub{}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if got := openapitest.IDs(vs); got != "2022-11-28@2022-11-28 2026-03-10@2026-03-10" { + t.Errorf("versions %s", got) + } +} diff --git a/plugins/openapi/github_test.go b/providers/github/rest_api_test.go similarity index 83% rename from plugins/openapi/github_test.go rename to providers/github/rest_api_test.go index 9239b88..f6f3e08 100644 --- a/plugins/openapi/github_test.go +++ b/providers/github/rest_api_test.go @@ -1,4 +1,4 @@ -package openapi +package github import ( "context" @@ -6,7 +6,10 @@ import ( "os" "testing" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // fakeGitHubAdapter serves the real, trimmed spec excerpts saved under @@ -38,9 +41,9 @@ func (fakeGitHubAdapter) Fetch(_ context.Context, tag string) (adapter.Spec, err // the pair 2022-11-28 → 2026-03-10 recreates. func TestGitHubPairRecreatesTheRealPropertyRemoval(t *testing.T) { ctx := context.Background() - s := openStore(t) + s := kittest.NewMem() - rejected, err := pairWith(ctx, s, Plugin{Adapter: fakeGitHubAdapter{}}, "2022-11-28", "2026-03-10") + rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, openapi.Plugin{Adapter: fakeGitHubAdapter{}}, "2022-11-28", "2026-03-10") if err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } @@ -68,7 +71,7 @@ func TestGitHubPairRecreatesTheRealPropertyRemoval(t *testing.T) { } // Reading the same pair again must not duplicate the event. - if _, err := pairWith(ctx, s, Plugin{Adapter: fakeGitHubAdapter{}}, "2022-11-28", "2026-03-10"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, openapi.Plugin{Adapter: fakeGitHubAdapter{}}, "2022-11-28", "2026-03-10"); err != nil { t.Fatalf("second read of the pair: %v", err) } if again, _ := s.All(); len(again) != len(events) { diff --git a/providers/github/testdata/README.md b/providers/github/testdata/README.md new file mode 100644 index 0000000..396b1e9 --- /dev/null +++ b/providers/github/testdata/README.md @@ -0,0 +1,49 @@ +# GitHub: saved copies and goldens + +Real copies of what GitHub publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/github -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `github-2022-11-28.json`, `github-2026-03-10.json` | https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.2022-11-28.json (and `.2026-03-10.json`) | 2026-11-14 | MIT (github/rest-api-description) | "Remove deprecated rate property from rate limit endpoint" (GitHub's breaking-changes page for 2026-03-10) | + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/github-versions.json` | `https://api.github.com/versions` | whole | + +## Saved feed + +A real copy, saved once with `curl`; the golden test reads it through the whole `notices` plugin. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `github-changelog-actions.rss.xml` | https://github.blog/changelog/label/actions/feed/ (RSS 2.0; `ETag` and `Last-Modified` sent) | 2026-11-14 08:27 UTC | Excerpt for testing; © GitHub, Inc. | "The macOS 14 runner image will be retired on November 2, 2026." | + +**Trimmed:** `github-changelog-actions.rss.xml` keeps the channel header and the three items the `github-actions` reader acts on (the macOS 14 retirement, which becomes events, and the two marked entries it drops: the ARM32 retirement and the `pull_request_target` change), copied unchanged. The seven unmarked items were left out; the reader ignores them, so its findings and the golden file are unchanged. + +## Saved catalog snapshots + +Read through the `catalog` kind; the golden file is what it stores from them. + +| File | URL | Fetched | License | Quote | +|---|---|---|---|---| +| `github-graphql-upcoming-changes-.json` (seven) | https://github.com/github/docs/blob//src/graphql/data/fpt/upcoming-changes.json at fc26275f, 54c26c43, 2706f417 (2026-01-05 to 08) and fc7cedfe, 3a14e541, a934f06d, c5738e58 (2026-02-13 to 06-23) | 2026-11-21 | CC BY 4.0 (github/docs content). Excerpts for testing: each keeps the first entry under every date of the first file of its group, and every entry the group's commits add; every kept entry unchanged, in the file's order. The plugin finds the same additions between them as between the full files (2, 1, 1; and 17 re-added, past-dated) | `"location": "CheckAnnotation.databaseId", "description": "

    databaseId will be removed. Use fullDatabaseId instead.

    "` | +| `github-commits-upcoming-changes-excerpt.json` | https://api.github.com/repos/github/docs/commits?path=src/graphql/data/fpt/upcoming-changes.json (shape only) | written for the test, 2026-11-21 | not a saved copy: three of the real commits (SHA, date, URL), newest first as GitHub lists them | for the version-listing test only | + +## SDK release notes + +Read with `Plugin{File: ...}` and `Notes: true` (`kinds/changelog/sdks.go`): an SDK whose changelog is its GitHub releases' notes. Each file is one release as GitHub's API returns it, trimmed to the fields the reader uses. + +| File | URL | Tag commit | Saved | License; trimming | Use | +|---|---|---|---|---|---| +| `github-octokit-rest-18.0.0-release.json` | https://api.github.com/repos/octokit/rest.js/releases/tags/v18.0.0 | `b4ab0db` | 2026-11-20 | MIT (rest.js); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | golden | +| `github-octokit-rest-17.11.2-release.json` | https://api.github.com/repos/octokit/rest.js/releases/tags/v17.11.2 | `5306f37` | 2026-11-20 | MIT (rest.js); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | drop test | +| `github-octokit-net-0.5.2-release.json` | https://api.github.com/repos/octokit/octokit.net/releases/tags/v0.5.2 | `4b61105` | 2026-11-20 | MIT (octokit.net); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | golden | +| `github-octokit-net-0.5.1-release.json` | https://api.github.com/repos/octokit/octokit.net/releases/tags/v0.5.1 | `8a9e828` | 2026-11-20 | MIT (octokit.net); trimmed to `html_url`, `tag_name`, `name`, `published_at` and `body`, re-indented, values unchanged | drop test | diff --git a/plugins/openapi/testdata/github-2022-11-28.json b/providers/github/testdata/github-2022-11-28.json similarity index 100% rename from plugins/openapi/testdata/github-2022-11-28.json rename to providers/github/testdata/github-2022-11-28.json diff --git a/plugins/openapi/testdata/github-2026-03-10.json b/providers/github/testdata/github-2026-03-10.json similarity index 100% rename from plugins/openapi/testdata/github-2026-03-10.json rename to providers/github/testdata/github-2026-03-10.json diff --git a/plugins/notices/feed/testdata/github-changelog-actions.rss.xml b/providers/github/testdata/github-changelog-actions.rss.xml similarity index 100% rename from plugins/notices/feed/testdata/github-changelog-actions.rss.xml rename to providers/github/testdata/github-changelog-actions.rss.xml diff --git a/plugins/catalog/testdata/github-commits-upcoming-changes-excerpt.json b/providers/github/testdata/github-commits-upcoming-changes-excerpt.json similarity index 100% rename from plugins/catalog/testdata/github-commits-upcoming-changes-excerpt.json rename to providers/github/testdata/github-commits-upcoming-changes-excerpt.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-2706f417.json b/providers/github/testdata/github-graphql-upcoming-changes-2706f417.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-2706f417.json rename to providers/github/testdata/github-graphql-upcoming-changes-2706f417.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-3a14e541.json b/providers/github/testdata/github-graphql-upcoming-changes-3a14e541.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-3a14e541.json rename to providers/github/testdata/github-graphql-upcoming-changes-3a14e541.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-54c26c43.json b/providers/github/testdata/github-graphql-upcoming-changes-54c26c43.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-54c26c43.json rename to providers/github/testdata/github-graphql-upcoming-changes-54c26c43.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-a934f06d.json b/providers/github/testdata/github-graphql-upcoming-changes-a934f06d.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-a934f06d.json rename to providers/github/testdata/github-graphql-upcoming-changes-a934f06d.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-c5738e58.json b/providers/github/testdata/github-graphql-upcoming-changes-c5738e58.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-c5738e58.json rename to providers/github/testdata/github-graphql-upcoming-changes-c5738e58.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-fc26275f.json b/providers/github/testdata/github-graphql-upcoming-changes-fc26275f.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-fc26275f.json rename to providers/github/testdata/github-graphql-upcoming-changes-fc26275f.json diff --git a/plugins/catalog/testdata/github-graphql-upcoming-changes-fc7cedfe.json b/providers/github/testdata/github-graphql-upcoming-changes-fc7cedfe.json similarity index 100% rename from plugins/catalog/testdata/github-graphql-upcoming-changes-fc7cedfe.json rename to providers/github/testdata/github-graphql-upcoming-changes-fc7cedfe.json diff --git a/plugins/changelog/testdata/github-octokit-net-0.5.1-release.json b/providers/github/testdata/github-octokit-net-0.5.1-release.json similarity index 100% rename from plugins/changelog/testdata/github-octokit-net-0.5.1-release.json rename to providers/github/testdata/github-octokit-net-0.5.1-release.json diff --git a/plugins/changelog/testdata/github-octokit-net-0.5.2-release.json b/providers/github/testdata/github-octokit-net-0.5.2-release.json similarity index 100% rename from plugins/changelog/testdata/github-octokit-net-0.5.2-release.json rename to providers/github/testdata/github-octokit-net-0.5.2-release.json diff --git a/plugins/changelog/testdata/github-octokit-rest-17.11.2-release.json b/providers/github/testdata/github-octokit-rest-17.11.2-release.json similarity index 100% rename from plugins/changelog/testdata/github-octokit-rest-17.11.2-release.json rename to providers/github/testdata/github-octokit-rest-17.11.2-release.json diff --git a/plugins/changelog/testdata/github-octokit-rest-18.0.0-release.json b/providers/github/testdata/github-octokit-rest-18.0.0-release.json similarity index 100% rename from plugins/changelog/testdata/github-octokit-rest-18.0.0-release.json rename to providers/github/testdata/github-octokit-rest-18.0.0-release.json diff --git a/plugins/notices/testdata/golden/github-actions.json b/providers/github/testdata/golden/github-actions.json similarity index 100% rename from plugins/notices/testdata/golden/github-actions.json rename to providers/github/testdata/golden/github-actions.json diff --git a/plugins/catalog/testdata/golden/github-graphql.json b/providers/github/testdata/golden/github-graphql.json similarity index 100% rename from plugins/catalog/testdata/golden/github-graphql.json rename to providers/github/testdata/golden/github-graphql.json diff --git a/plugins/changelog/testdata/golden/github-octokit-net.json b/providers/github/testdata/golden/github-octokit-net.json similarity index 100% rename from plugins/changelog/testdata/golden/github-octokit-net.json rename to providers/github/testdata/golden/github-octokit-net.json diff --git a/plugins/changelog/testdata/golden/github-octokit-rest.json b/providers/github/testdata/golden/github-octokit-rest.json similarity index 100% rename from plugins/changelog/testdata/golden/github-octokit-rest.json rename to providers/github/testdata/golden/github-octokit-rest.json diff --git a/plugins/openapi/adapter/testdata/versions/github-versions.json b/providers/github/testdata/versions/github-versions.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/github-versions.json rename to providers/github/testdata/versions/github-versions.json diff --git a/providers/gitlab.md b/providers/gitlab/README.md similarity index 80% rename from providers/gitlab.md rename to providers/gitlab/README.md index e068267..4a388e4 100644 --- a/providers/gitlab.md +++ b/providers/gitlab/README.md @@ -1,32 +1,36 @@ -# GitLab REST API (`gitlab/rest-api`) +# GitLab -## What it watches +Every source patch-it reads for GitLab, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## GitLab REST API (`gitlab/rest-api`) + +### What it watches GitLab's REST API (`/api/v4`) between releases, **request side only**: endpoints removed, and parameters callers send that are removed, renamed or newly required. -Kind: `openapi` (`plugins/openapi`), with `adapter.GitLab` and a request-side filter (`openapi.Plugin.Keep`). +Kind: `openapi` (`kinds/openapi`), with its adapter, `GitLab` ([`rest_api.go`](rest_api.go)) and a request-side filter (`openapi.Plugin.Keep`). -## Why this source +### Why this source - **Source:** `doc/api/openapi/openapi_v3.yaml` in [gitlab-org/gitlab](https://gitlab.com/gitlab-org/gitlab) at a release tag, read through GitLab's Repository Files API (`https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/files/doc%2Fapi%2Fopenapi%2Fopenapi_v3.yaml/raw?ref=`); the newest stable `vX.Y.Z-ee` tag from the tags API. Checked on 2026-11-15. - **Why this one:** GitLab generates it from its own API code at every release, and a tag never changes, so two releases diff exactly. The Files API is GitLab's documented interface for programs and returns the same bytes as the web's raw route. - **Alternatives considered:** the [deprecations page](https://docs.gitlab.com/update/deprecations/) and its YAML sources (dated and structured, but *what* changes is prose); the [breaking-changes Atom feed](https://docs.gitlab.com/releases/breaking-changes.xml) (same prose); the REST deprecations page (changes deferred to a v5 that isn't being built); `openapi_v2.yaml` (Swagger 2.0, partial, superseded). - **Quote:** "From GitLab 19.0, if you want to import repositories from Bitbucket Cloud through the GitLab API, you must use user API tokens instead." ([deprecations page](https://docs.gitlab.com/update/deprecations/)). -## How the provider announces changes +### How the provider announces changes - REST is versioned by path (`/api/v4`), never by date or header. Removals ship in major releases (18.0, 19.0) and are listed on the deprecations page beforehand. - **Forced**: on GitLab.com when the release ships; on self-managed instances when they upgrade, so the instance's version is the pin. - A minor release every month, patch releases in between. The event's `version` is the GitLab version (`19.0.0`), not the tag (`v19.0.0-ee`) and not `info.version` (`v4`). -## What the plugin reads and ignores +### What the plugin reads and ignores - **Response-side changes are dropped.** Between 18.11 and 19.0 the generator retyped hundreds of response properties (default `string` to the real type) while GitLab returned the same JSON; reporting them would be wrong pull requests. Precision over recall: only request-side changes are kept. - Request bodies are named by a hash of their content (`RequestBody_`), so adding one field renames the schema. The adapter inlines those bodies back under their operations, and each event's pointer still names the node in the published file. - Release candidates are skipped; tags are sorted numerically. - The OpenAPI 3 file exists from `v18.10.0-ee`; 19.0 is the first major release that can be replayed (the pair `v18.11.0-ee` → `v19.0.0-ee`). -## Known gaps +### Known gaps - Real response-side removals are missed (the deprecations page would recover them; not built). - GraphQL removals aren't watched. diff --git a/providers/gitlab/provider.go b/providers/gitlab/provider.go new file mode 100644 index 0000000..aae78d7 --- /dev/null +++ b/providers/gitlab/provider.go @@ -0,0 +1,25 @@ +// Package gitlab is what patch-it reads for GitLab: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package gitlab + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "gitlab", Name: "GitLab", Category: plugin.CategoryDevTools, Homepage: "https://about.gitlab.com", + Sources: []plugin.Source{ + // No Hints: GitLab's deprecations are prose per feature, not a changelog + // keyed by API version, so there's nothing for hint.Source to look up. + { + ID: "rest-api", Layer: plugin.LayerAPI, + Watches: "REST API changes between releases, request side only (what callers send)", + URLs: []string{"https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc/api/openapi"}, + Plugin: openapi.Plugin{Adapter: GitLab{}, Keep: openapi.RequestSide}, + }, + }, + }) +} diff --git a/plugins/openapi/adapter/gitlab.go b/providers/gitlab/rest_api.go similarity index 72% rename from plugins/openapi/adapter/gitlab.go rename to providers/gitlab/rest_api.go index 461ddf1..f667156 100644 --- a/plugins/openapi/adapter/gitlab.go +++ b/providers/gitlab/rest_api.go @@ -1,4 +1,4 @@ -package adapter +package gitlab import ( "cmp" @@ -9,8 +9,12 @@ import ( "slices" "strconv" "strings" + "time" "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" "gopkg.in/yaml.v3" ) @@ -48,7 +52,7 @@ type GitLab struct { SpecURLTemplate string // the spec, with %s for the tag; "" is gitlabSpecURLTemplate } -var _ Adapter = GitLab{} +var _ adapter.Adapter = GitLab{} func (GitLab) API() string { return "gitlab/rest-api" } @@ -102,26 +106,26 @@ func (g GitLab) LatestTag(ctx context.Context) (string, error) { // releases apart. The bare version is also what a self-managed instance // reports and what patch-it's package gate can read; it refuses "v19.0.0-ee". // A tag that isn't a release (a branch, read as a version) is its own version. -func (g GitLab) Fetch(ctx context.Context, tag string) (Spec, error) { +func (g GitLab) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { url := fmt.Sprintf(cmp.Or(g.SpecURLTemplate, gitlabSpecURLTemplate), tag) body, err := fetch.Get(ctx, url, nil) if err != nil { - return Spec{}, fmt.Errorf("fetching gitlab spec %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("fetching gitlab spec %s: %w", tag, err) } var doc any if err := yaml.Unmarshal(body, &doc); err != nil { - return Spec{}, fmt.Errorf("parsing gitlab spec %s as yaml: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("parsing gitlab spec %s as yaml: %w", tag, err) } m, ok := stringKeys(doc).(map[string]any) if !ok { - return Spec{}, fmt.Errorf("gitlab spec %s is not a yaml mapping", tag) + return adapter.Spec{}, fmt.Errorf("gitlab spec %s is not a yaml mapping", tag) } inlineRequestBodies(m) content, err := json.Marshal(m) if err != nil { - return Spec{}, fmt.Errorf("converting gitlab spec %s to json: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("converting gitlab spec %s to json: %w", tag, err) } - return Spec{Content: content, Version: gitlabVersion(tag), SourceURL: url}, nil + return adapter.Spec{Content: content, Version: gitlabVersion(tag), SourceURL: url}, nil } // gitlabVersion is "19.0.0" for the release tag "v19.0.0-ee". @@ -152,16 +156,16 @@ const gitlabInlined = "x-patch-it-inlined" // named. Only these refs are replaced, one level deep; every $ref inside a // body still points where it did and is compared as a ref. func inlineRequestBodies(doc map[string]any) { - schemas := asMap(asMap(doc["components"])["schemas"]) + schemas := adapter.AsMap(adapter.AsMap(doc["components"])["schemas"]) if schemas == nil { return } inlined := map[string]any{} - for path, item := range asMap(doc["paths"]) { - for method, op := range asMap(item) { - for mediaType, media := range asMap(asMap(asMap(op)["requestBody"])["content"]) { - mm := asMap(media) - ref := asMap(mm["schema"]) + for path, item := range adapter.AsMap(doc["paths"]) { + for method, op := range adapter.AsMap(item) { + for mediaType, media := range adapter.AsMap(adapter.AsMap(adapter.AsMap(op)["requestBody"])["content"]) { + mm := adapter.AsMap(media) + ref := adapter.AsMap(mm["schema"]) r, _ := ref["$ref"].(string) g := gitlabBodyRef.FindStringSubmatch(r) if g == nil || len(ref) != 1 { @@ -172,9 +176,9 @@ func inlineRequestBodies(doc map[string]any) { continue } mm["schema"] = deepCopy(body) - at := "/paths/" + pointerToken(path) + "/" + pointerToken(method) + - "/requestBody/content/" + pointerToken(mediaType) + "/schema" - inlined[at] = "/components/schemas/" + pointerToken(g[1]) + at := "/paths/" + adapter.PointerToken(path) + "/" + adapter.PointerToken(method) + + "/requestBody/content/" + adapter.PointerToken(mediaType) + "/schema" + inlined[at] = "/components/schemas/" + adapter.PointerToken(g[1]) } } } @@ -212,18 +216,7 @@ func (GitLab) SourcePointer(content []byte) func(string) string { } } -var _ Reshaper = GitLab{} - -// pointerToken encodes one JSON Pointer token (RFC 6901), as diff does. -func pointerToken(s string) string { - return strings.NewReplacer("~", "~0", "/", "~1").Replace(s) -} - -// asMap is v as an object, or nil, which reads and ranges as empty. -func asMap(v any) map[string]any { - m, _ := v.(map[string]any) - return m -} +var _ adapter.Reshaper = GitLab{} // deepCopy copies a decoded YAML node, so two operations sharing a body don't // share one map in the document. @@ -271,3 +264,55 @@ func stringKeys(v any) any { return v } } + +// gitlabFirstSpec is the first release whose tag carries openapi_v3.yaml. +var gitlabFirstSpec = [3]int{18, 10, 0} + +// Versions are every stable GitLab release with the OpenAPI 3 spec +// (v18.10.0-ee on), oldest first by version: patch releases of an older +// minor (18.11.14) sit before the next minor's first release. The tags +// listing is read page by page, newest version first, until it passes +// v18.10.0-ee. +func (g GitLab) Versions(ctx context.Context) ([]plugin.Version, error) { + type tag struct { + Name string `json:"name"` + Commit struct { + Created time.Time `json:"created_at"` + } `json:"commit"` + } + var out []plugin.Version + for page := 1; page <= versions.MaxPages; page++ { + body, err := fetch.Get(ctx, fmt.Sprintf("%s&page=%d", cmp.Or(g.TagsURL, gitlabTagsURL), page), nil) + if err != nil { + return nil, fmt.Errorf("listing gitlab's tags: %w", err) + } + var tags []tag + if err := json.Unmarshal(body, &tags); err != nil { + return nil, fmt.Errorf("parsing gitlab tags response: %w", err) + } + older := false + for _, t := range tags { + m := gitlabRelease.FindStringSubmatch(t.Name) + if m == nil { + continue + } + v := [3]int{atoi(m[1]), atoi(m[2]), atoi(m[3])} + if slices.Compare(v[:], gitlabFirstSpec[:]) < 0 { + older = true + continue + } + out = append(out, plugin.Version{ID: gitlabVersion(t.Name), Released: t.Commit.Created.UTC(), Ref: t.Name, + URL: "https://gitlab.com/gitlab-org/gitlab/-/tags/" + t.Name}) + } + if older || len(tags) < 100 { + break + } + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) + return out, nil +} + +func atoi(s string) int { + n, _ := strconv.Atoi(s) + return n +} diff --git a/plugins/openapi/adapter/gitlab_test.go b/providers/gitlab/rest_api_fetch_test.go similarity index 82% rename from plugins/openapi/adapter/gitlab_test.go rename to providers/gitlab/rest_api_fetch_test.go index 2b67789..662bafa 100644 --- a/plugins/openapi/adapter/gitlab_test.go +++ b/providers/gitlab/rest_api_fetch_test.go @@ -1,12 +1,16 @@ -package adapter +package gitlab import ( "context" "encoding/json" "net/http" "net/http/httptest" + "slices" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // fakeGitLab serves a tags listing and specs by path, 404 for anything else. @@ -198,3 +202,31 @@ func TestGitLabFetchRejectsBadSpecs(t *testing.T) { } } } + +// Every stable release from v18.10.0-ee (the first with openapi_v3.yaml), in +// version order, release candidates left out; the listing is read a second +// page, and no further once it passes v18.10.0-ee. +func TestGitLabListsEveryReleaseWithTheSpec(t *testing.T) { + srv := openapitest.Recorded(t, map[string]string{ + "/tags?order_by=version&sort=desc&per_page=100&page=1": "gitlab-tags-1.json", + "/tags?order_by=version&sort=desc&per_page=100&page=2": "gitlab-tags-2.json", + }) + vs, err := GitLab{TagsURL: srv.URL + "/tags?order_by=version&sort=desc&per_page=100"}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if vs[0].ID != "18.10.0" || vs[0].Ref != "v18.10.0-ee" || vs[len(vs)-1].ID != "19.6.1" { + t.Errorf("first %v, last %v", vs[0], vs[len(vs)-1]) + } + seen := map[string]bool{} + for _, v := range vs { + if strings.Contains(v.Ref, "rc") || v.Released.IsZero() || seen[v.ID] { + t.Errorf("version %v", v) + } + seen[v.ID] = true + } + at := func(id string) int { return slices.IndexFunc(vs, func(v plugin.Version) bool { return v.ID == id }) } + if !(at("18.11.14") < at("19.0.0") && at("19.0.0") < at("19.6.0") && at("18.10.1") > at("18.10.0")) { + t.Errorf("not in version order: %s", openapitest.IDs(vs)) + } +} diff --git a/plugins/openapi/gitlab_test.go b/providers/gitlab/rest_api_test.go similarity index 74% rename from plugins/openapi/gitlab_test.go rename to providers/gitlab/rest_api_test.go index cafdd13..e59c6af 100644 --- a/plugins/openapi/gitlab_test.go +++ b/providers/gitlab/rest_api_test.go @@ -1,27 +1,25 @@ -package openapi +package gitlab import ( "context" - "encoding/json" "net/http" "net/http/httptest" - "os" - "strconv" "strings" "testing" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" - "gopkg.in/yaml.v3" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // gitlabPlugin is the plugin as registered for GitLab, its adapter reading the // saved copies under testdata/ from a local server instead of gitlab.com. -func gitlabPlugin(t *testing.T) (Plugin, string) { +func gitlabPlugin(t *testing.T) (openapi.Plugin, string) { t.Helper() srv := httptest.NewServer(http.FileServer(http.Dir("testdata"))) t.Cleanup(srv.Close) tmpl := srv.URL + "/gitlab-%s.yaml" - return Plugin{Adapter: adapter.GitLab{SpecURLTemplate: tmpl}, Keep: requestSide}, tmpl + return openapi.Plugin{Adapter: GitLab{SpecURLTemplate: tmpl}, Keep: openapi.RequestSide}, tmpl } // The golden test and the pair fixture in one: testdata/gitlab-v18.11.0-ee.yaml @@ -36,13 +34,13 @@ func gitlabPlugin(t *testing.T) (Plugin, string) { // // The excerpts also keep APIEntitiesBadge, whose id went from the generator's // default "string" to "integer" in the same release while the API kept -// returning the same JSON: the response-side noise requestSide drops. +// returning the same JSON: the response-side noise RequestSide drops. func TestGitLabPairRecreatesTheBitbucketAppPasswordRemoval(t *testing.T) { ctx := context.Background() - s := openStore(t) + s := kittest.NewMem() p, tmpl := gitlabPlugin(t) - rejected, err := pairWith(ctx, s, p, "v18.11.0-ee", "v19.0.0-ee") + rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "v18.11.0-ee", "v19.0.0-ee") if err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } @@ -105,13 +103,13 @@ func TestGitLabPairRecreatesTheBitbucketAppPasswordRemoval(t *testing.T) { if e.SourceURL == newURL { file = "testdata/gitlab-v19.0.0-ee.yaml" } - if got := yamlNodeJSON(t, file, e.SourcePointer); got != e.SourceExcerpt { + if got := openapitest.YAMLNodeJSON(t, file, e.SourcePointer); got != e.SourceExcerpt { t.Errorf("%s: excerpt %s, but %s#%s holds %s", e.Subject.Property, e.SourceExcerpt, file, e.SourcePointer, got) } } // Reading the same pair again must not duplicate the events. - if _, err := pairWith(ctx, s, p, "v18.11.0-ee", "v19.0.0-ee"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "v18.11.0-ee", "v19.0.0-ee"); err != nil { t.Fatalf("second read of the pair: %v", err) } if again, _ := s.All(); len(again) != len(events) { @@ -120,14 +118,14 @@ func TestGitLabPairRecreatesTheBitbucketAppPasswordRemoval(t *testing.T) { } // Without the filter, the same pair reports the response-side retyping too: -// the test above only passes because requestSide drops it. +// the test above only passes because RequestSide drops it. func TestGitLabResponseSideNoiseIsWhatTheFilterDrops(t *testing.T) { ctx := context.Background() - s := openStore(t) + s := kittest.NewMem() p, _ := gitlabPlugin(t) p.Keep = nil - if _, err := pairWith(ctx, s, p, "v18.11.0-ee", "v19.0.0-ee"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "v18.11.0-ee", "v19.0.0-ee"); err != nil { t.Fatalf("pair: %v", err) } events, _ := s.All() @@ -138,40 +136,6 @@ func TestGitLabResponseSideNoiseIsWhatTheFilterDrops(t *testing.T) { } } if !badge { - t.Error("unfiltered pair has no APIEntitiesBadge.id event; the fixture no longer shows what requestSide is for") + t.Error("unfiltered pair has no APIEntitiesBadge.id event; the fixture no longer shows what RequestSide is for") } } - -// yamlNodeJSON resolves an RFC 6901 pointer in a YAML file and serializes the -// node the way normalize serializes excerpts. -func yamlNodeJSON(t *testing.T, file, pointer string) string { - t.Helper() - data, err := os.ReadFile(file) - if err != nil { - t.Fatal(err) - } - var node any - if err := yaml.Unmarshal(data, &node); err != nil { - t.Fatal(err) - } - for _, tok := range strings.Split(strings.TrimPrefix(pointer, "/"), "/") { - tok = strings.NewReplacer("~1", "/", "~0", "~").Replace(tok) - switch n := node.(type) { - case map[string]any: - node = n[tok] - case []any: - i, err := strconv.Atoi(tok) - if err != nil || i >= len(n) { - return "" - } - node = n[i] - default: - return "" - } - } - b, err := json.Marshal(node) - if err != nil { - t.Fatal(err) - } - return string(b) -} diff --git a/providers/gitlab/testdata/README.md b/providers/gitlab/testdata/README.md new file mode 100644 index 0000000..54649ed --- /dev/null +++ b/providers/gitlab/testdata/README.md @@ -0,0 +1,20 @@ +# GitLab: saved copies and goldens + +Real copies of what GitLab publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/gitlab -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `gitlab-v18.11.0-ee.yaml`, `gitlab-v19.0.0-ee.yaml` | https://gitlab.com/gitlab-org/gitlab/-/raw/v18.11.0-ee/doc/api/openapi/openapi_v3.yaml (and `v19.0.0-ee`) | 2026-11-15 | CC BY-SA 4.0 (GitLab's `doc/` directory) | `bitbucket_app_password:` (in v18.11.0-ee, gone in v19.0.0-ee) | + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/gitlab-tags-1.json` | `https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/tags?order_by=version&sort=desc&per_page=100&page=1` | all 100 tags; `name` and `commit.created_at` | +| `versions/gitlab-tags-2.json` | the same, `page=2` | 14 tags (18.10.0, 18.10.1, 18.9.x, 18.1.4); same fields | diff --git a/plugins/openapi/testdata/gitlab-v18.11.0-ee.yaml b/providers/gitlab/testdata/gitlab-v18.11.0-ee.yaml similarity index 100% rename from plugins/openapi/testdata/gitlab-v18.11.0-ee.yaml rename to providers/gitlab/testdata/gitlab-v18.11.0-ee.yaml diff --git a/plugins/openapi/testdata/gitlab-v19.0.0-ee.yaml b/providers/gitlab/testdata/gitlab-v19.0.0-ee.yaml similarity index 100% rename from plugins/openapi/testdata/gitlab-v19.0.0-ee.yaml rename to providers/gitlab/testdata/gitlab-v19.0.0-ee.yaml diff --git a/plugins/openapi/adapter/testdata/versions/gitlab-tags-1.json b/providers/gitlab/testdata/versions/gitlab-tags-1.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/gitlab-tags-1.json rename to providers/gitlab/testdata/versions/gitlab-tags-1.json diff --git a/plugins/openapi/adapter/testdata/versions/gitlab-tags-2.json b/providers/gitlab/testdata/versions/gitlab-tags-2.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/gitlab-tags-2.json rename to providers/gitlab/testdata/versions/gitlab-tags-2.json diff --git a/providers/google-gemini-models.md b/providers/google-gemini-models.md deleted file mode 100644 index 4f002dd..0000000 --- a/providers/google-gemini-models.md +++ /dev/null @@ -1,33 +0,0 @@ -# Google Gemini API models (`google/gemini-models`) - -## What it watches - -Gemini API models Google shuts down: every model on Google's own Gemini API deprecations page with a shutdown date, one `model` event per model name, with the replacement Google recommends. Google gives each date as the earliest a model may be shut down; the event says so. - -Kind: `notices` (`plugins/notices`), with the deprecations-table reader (`plugins/notices/retire`, `retire.Gemini`), reading Markdoc tables. - -## Why this source - -- **Source:** [Gemini deprecations](https://ai.google.dev/gemini-api/docs/deprecations), which redirects to `https://aistudio.google.com/docs/deprecations`; that URL serves the page as Markdown (Markdoc `{% table %}` blocks), and the plugin reads it there. Checked on 2026-11-21. -- **Why this one:** it's Google's own table of every Gemini API model with its release date, its shutdown date and the recommended replacement, one table per model family, the shut-down ones kept under "Deprecated models". It's where Google says deprecation dates are tracked: "Deprecation announcements are made on the Release notes page, and the announced earliest shutdown dates are tracked on this page." -- **Alternatives considered:** - - **The Gemini API release notes** (`https://aistudio.google.com/docs/changelog`): the same deprecations, announced in prose, one entry per day. The table is the same facts, already structured. - - **Vertex AI's model versions page** (`google/vertex-model-retirements`): the same models on Google Cloud, with Google Cloud's own retirement dates, which differ from the Gemini API's (gemini-2.5-pro: 2026-10-20 on Vertex AI, 2026-12-01 here). A separate source: a repo reaches one or the other. - - **The Gemini API's models list** (`GET /v1beta/models`): what's served now, with no dates. -- **Quote:** "| `gemini-2.0-flash` | February 5, 2025 | June 1, 2026 | `gemini-3.6-flash` |" (Gemini 2.0 models, Deprecated models), and above the tables: "The shutdown dates listed in the table indicate the earliest possible dates on which a model might be retired". - -## How the provider announces changes - -- Models are named by version (`gemini-2.5-flash`, `gemini-2.5-flash-preview-09-2025`); a preview gets a shutdown date months after its stable model ships, a stable model about a year after its successor. -- A model is announced in the release notes, then its date appears here. Some shut-down models' requests are routed to a successor ("effective December 1, 2026, API requests to `gemini-2.5-pro` will automatically route to `gemini-3.8-flash`"); the replacement cell says so, and the hint quotes it. - -## What the plugin reads and ignores - -- Reads every Markdoc table with a "Shutdown date", a "Model" and a "Recommended replacement" column: one `breaking` `model` event per model name with a date, `version` the date. `replacement` is set when the cell names exactly one plain model; otherwise the hint quotes the cell. -- Ignores a row whose date isn't a date ("No shutdown date announced"), the managed agents' tables (an "Agent" column, not a model), and a cell that isn't a plain model id (a footnote mark). The pinned drop test: the Gemini 4 models and the agents, next to the two shut-down Gemini 3 previews, give only those two events. -- A read with far fewer models than the last one fails (the table changed shape), as do a page with no table and a block page. - -## Known gaps - -- Google's dates are the earliest possible; a later exact date only shows up when Google edits the row, which is then a new event. -- Models served only on Vertex AI are the other source's. diff --git a/providers/google-genai-js-surface.md b/providers/google-genai-js-surface.md deleted file mode 100644 index 93d06e0..0000000 --- a/providers/google-genai-js-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# Google Gen AI JavaScript SDK (`google/genai-js-surface`) - -## What it watches - -The public API of the `@google/genai` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @google/genai@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md (release-please, "⚠ BREAKING CHANGES"). -- **Quote:** `interface LiveMusicSetClientContentParameters` (`dist/genai.d.ts` line 3757) at 0.15.0, gone at 1.0.0. - -## How the provider announces changes - -- Ships every week or two as one bundled declaration file per platform (`dist/genai.d.ts`, `dist/node/node.d.ts`, `dist/web/web.d.ts`). -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@google/genai.GoogleGenAI`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- The node and web entry points are separate bundles: a removal there is one event per bundle. diff --git a/providers/google-genai-python-surface.md b/providers/google-genai-python-surface.md deleted file mode 100644 index c65c82d..0000000 --- a/providers/google-genai-python-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# Google Gen AI Python SDK (`google/genai-python-surface`) - -## What it watches - -The public API of the `google-genai` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install google-genai==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md (release-please, "⚠ BREAKING CHANGES"; for the `changelog` kind); the Gemini API Discovery document (the HTTP API). -- **Quote:** `class TuningJobOrOperation(_common.BaseModel)` (`google/genai/types.py` line 5924) at 0.8.0, gone at 1.0.0. - -## How the provider announces changes - -- The SDK ships every week or two; `google.genai.interactions` re-exports a generated client from a private package, so its names are read as still bound when they move. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `google/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. -- Symbols are named from the `google` namespace (`genai.types.Tool`), the import path code writes after `from google import genai`. diff --git a/providers/google-vertex-model-retirements.md b/providers/google-vertex-model-retirements.md deleted file mode 100644 index a9ab1f2..0000000 --- a/providers/google-vertex-model-retirements.md +++ /dev/null @@ -1,32 +0,0 @@ -# Google Vertex AI model retirements (`google/vertex-model-retirements`) - -## What it watches - -Generative AI models Google Cloud retires on Vertex AI (now called Gemini Enterprise Agent Platform): every model on Google Cloud's model versions page with a plain retirement date, one `model` event per model id, with the replacement Google names. - -Kind: `notices` (`plugins/notices`), with the deprecations-table reader (`plugins/notices/retire`, `retire.Vertex`), reading HTML tables. - -## Why this source - -- **Source:** [Model versions and lifecycle](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions) (the old `cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions` redirects there). Checked on 2026-11-21. -- **Why this one:** it's Google Cloud's own table of every model id with its release date, its retirement date and its replacement, including the "Retired models" table. The release-notes feed (`google/vertex-ai-models`) only announces some deprecations, in prose; this page is where the dates are kept. -- **Alternatives considered:** - - **The Vertex AI release notes feed**: already a source (`google/vertex-ai-models`), for announcements; not every retirement is announced there with a table of ids. - - **The deprecations page** (`docs.cloud.google.com/vertex-ai/generative-ai/docs/deprecations`): SDK modules and features, not model dates. - - **The Gemini API deprecations page** (`google/gemini-models`): the Gemini API's own dates, which differ. -- **Quote:** "| `veo-3.0-generate-001` | July 29, 2025 | June 30, 2026 | `veo-3.1-generate-001` |" (Retired models). - -## How the provider announces changes - -- A GA model is kept for at least a year, written as a minimum ("October 13, 2027 or later", "No sooner than May 20, 2028"); when Google decides to retire it, the cell becomes a plain date, and the model later moves to "Retired models". - -## What the plugin reads and ignores - -- Reads every table with a "Retirement date", a "Model ID" and a "Replacement model ID" (or "Recommended upgrade") column: one `breaking` `model` event per model id with a plain date, `version` the date. `replacement` is set when the cell names exactly one model. -- Ignores a minimum lifetime ("… or later", "No sooner than …", "No retirement date announced"): it isn't a retirement notice. The pinned drop test: the Gemini image models' table, four rows with such dates and one dated retirement, gives one event. -- Ignores a cell that isn't a plain model id ("textembedding-gecko@003 *", with a footnote mark). - -## Known gaps - -- The page is about 430 KB of HTML; only its headings and tables are read, so a date given only in prose beside a table is missed. -- Partner models (Claude, Llama…) on Vertex AI are on other pages. diff --git a/providers/google/README.md b/providers/google/README.md new file mode 100644 index 0000000..89e4353 --- /dev/null +++ b/providers/google/README.md @@ -0,0 +1,177 @@ +# Google + +Every source patch-it reads for Google, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Google Gemini API models (`google/gemini-models`) + +### What it watches + +Gemini API models Google shuts down: every model on Google's own Gemini API deprecations page with a shutdown date, one `model` event per model name, with the replacement Google recommends. Google gives each date as the earliest a model may be shut down; the event says so. + +Kind: `notices` (`kinds/notices`), with the deprecations-table reader (`kinds/notices/retire`, `GeminiModels` in [`models.go`](models.go)), reading Markdoc tables. + +### Why this source + +- **Source:** [Gemini deprecations](https://ai.google.dev/gemini-api/docs/deprecations), which redirects to `https://aistudio.google.com/docs/deprecations`; that URL serves the page as Markdown (Markdoc `{% table %}` blocks), and the plugin reads it there. Checked on 2026-11-21. +- **Why this one:** it's Google's own table of every Gemini API model with its release date, its shutdown date and the recommended replacement, one table per model family, the shut-down ones kept under "Deprecated models". It's where Google says deprecation dates are tracked: "Deprecation announcements are made on the Release notes page, and the announced earliest shutdown dates are tracked on this page." +- **Alternatives considered:** + - **The Gemini API release notes** (`https://aistudio.google.com/docs/changelog`): the same deprecations, announced in prose, one entry per day. The table is the same facts, already structured. + - **Vertex AI's model versions page** (`google/vertex-model-retirements`): the same models on Google Cloud, with Google Cloud's own retirement dates, which differ from the Gemini API's (gemini-2.5-pro: 2026-10-20 on Vertex AI, 2026-12-01 here). A separate source: a repo reaches one or the other. + - **The Gemini API's models list** (`GET /v1beta/models`): what's served now, with no dates. +- **Quote:** "| `gemini-2.0-flash` | February 5, 2025 | June 1, 2026 | `gemini-3.6-flash` |" (Gemini 2.0 models, Deprecated models), and above the tables: "The shutdown dates listed in the table indicate the earliest possible dates on which a model might be retired". + +### How the provider announces changes + +- Models are named by version (`gemini-2.5-flash`, `gemini-2.5-flash-preview-09-2025`); a preview gets a shutdown date months after its stable model ships, a stable model about a year after its successor. +- A model is announced in the release notes, then its date appears here. Some shut-down models' requests are routed to a successor ("effective December 1, 2026, API requests to `gemini-2.5-pro` will automatically route to `gemini-3.8-flash`"); the replacement cell says so, and the hint quotes it. + +### What the plugin reads and ignores + +- Reads every Markdoc table with a "Shutdown date", a "Model" and a "Recommended replacement" column: one `breaking` `model` event per model name with a date, `version` the date. `replacement` is set when the cell names exactly one plain model; otherwise the hint quotes the cell. +- Ignores a row whose date isn't a date ("No shutdown date announced"), the managed agents' tables (an "Agent" column, not a model), and a cell that isn't a plain model id (a footnote mark). The pinned drop test: the Gemini 4 models and the agents, next to the two shut-down Gemini 3 previews, give only those two events. +- A read with far fewer models than the last one fails (the table changed shape), as do a page with no table and a block page. + +### Known gaps + +- Google's dates are the earliest possible; a later exact date only shows up when Google edits the row, which is then a new event. +- Models served only on Vertex AI are the other source's. + +## Google Gen AI JavaScript SDK (`google/genai-js-surface`) + +### What it watches + +The public API of the `@google/genai` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @google/genai@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md (release-please, "⚠ BREAKING CHANGES"). +- **Quote:** `interface LiveMusicSetClientContentParameters` (`dist/genai.d.ts` line 3757) at 0.15.0, gone at 1.0.0. + +### How the provider announces changes + +- Ships every week or two as one bundled declaration file per platform (`dist/genai.d.ts`, `dist/node/node.d.ts`, `dist/web/web.d.ts`). +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@google/genai.GoogleGenAI`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- The node and web entry points are separate bundles: a removal there is one event per bundle. + +## Google Gen AI Python SDK (`google/genai-python-surface`) + +### What it watches + +The public API of the `google-genai` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install google-genai==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md (release-please, "⚠ BREAKING CHANGES"; for the `changelog` kind); the Gemini API Discovery document (the HTTP API). +- **Quote:** `class TuningJobOrOperation(_common.BaseModel)` (`google/genai/types.py` line 5924) at 0.8.0, gone at 1.0.0. + +### How the provider announces changes + +- The SDK ships every week or two; `google.genai.interactions` re-exports a generated client from a private package, so its names are read as still bound when they move. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `google/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. +- Symbols are named from the `google` namespace (`genai.types.Tool`), the import path code writes after `from google import genai`. + +## Google Vertex AI model retirements (`google/vertex-model-retirements`) + +### What it watches + +Generative AI models Google Cloud retires on Vertex AI (now called Gemini Enterprise Agent Platform): every model on Google Cloud's model versions page with a plain retirement date, one `model` event per model id, with the replacement Google names. + +Kind: `notices` (`kinds/notices`), with the deprecations-table reader (`kinds/notices/retire`, `VertexModelRetirements` in [`models.go`](models.go)), reading HTML tables. + +### Why this source + +- **Source:** [Model versions and lifecycle](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions) (the old `cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions` redirects there). Checked on 2026-11-21. +- **Why this one:** it's Google Cloud's own table of every model id with its release date, its retirement date and its replacement, including the "Retired models" table. The release-notes feed (`google/vertex-ai-models`) only announces some deprecations, in prose; this page is where the dates are kept. +- **Alternatives considered:** + - **The Vertex AI release notes feed**: already a source (`google/vertex-ai-models`), for announcements; not every retirement is announced there with a table of ids. + - **The deprecations page** (`docs.cloud.google.com/vertex-ai/generative-ai/docs/deprecations`): SDK modules and features, not model dates. + - **The Gemini API deprecations page** (`google/gemini-models`): the Gemini API's own dates, which differ. +- **Quote:** "| `veo-3.0-generate-001` | July 29, 2025 | June 30, 2026 | `veo-3.1-generate-001` |" (Retired models). + +### How the provider announces changes + +- A GA model is kept for at least a year, written as a minimum ("October 13, 2027 or later", "No sooner than May 20, 2028"); when Google decides to retire it, the cell becomes a plain date, and the model later moves to "Retired models". + +### What the plugin reads and ignores + +- Reads every table with a "Retirement date", a "Model ID" and a "Replacement model ID" (or "Recommended upgrade") column: one `breaking` `model` event per model id with a plain date, `version` the date. `replacement` is set when the cell names exactly one model. +- Ignores a minimum lifetime ("… or later", "No sooner than …", "No retirement date announced"): it isn't a retirement notice. The pinned drop test: the Gemini image models' table, four rows with such dates and one dated retirement, gives one event. +- Ignores a cell that isn't a plain model id ("textembedding-gecko@003 *", with a footnote mark). + +### Known gaps + +- The page is about 430 KB of HTML; only its headings and tables are read, so a date given only in prose beside a table is missed. +- Partner models (Claude, Llama…) on Vertex AI are on other pages. + +## Vertex AI generative models (`google/vertex-ai-models`) + +### What it watches + +Generative AI model endpoints on Google Cloud's Vertex AI that Google deprecates: one `model` event per model id in a "Discontinued endpoints" table, with the replacement when the row names exactly one. + +Kind: `notices` (`kinds/notices`), with the feed reader (`kinds/notices/feed`) and its `VertexAIModels` feed ([`vertex_ai_models.go`](vertex_ai_models.go)). + +### Why this source + +- **Source:** the [Generative AI on Vertex AI release notes](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/release-notes) Atom feed, `https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml` (the `cloud.google.com/feeds/…` URL redirects here). Checked on 2026-11-14. +- **Why this one:** it's Google's own release notes as a feed, one entry per day, each change under a heading naming its kind (`Deprecated`), and deprecations come with a table of discontinued endpoints and replacements. +- **Alternatives considered:** the model versions and lifecycle docs page (HTML, rewritten in place, no history); the Google Cloud deprecations page (all of Cloud, prose); the models list API (what exists now, not when it stops). +- **Quote:** "We recommend updating your model endpoints before June 30, 2026, to avoid service disruption." (Deprecated: Imagen generation GA endpoints deprecation). + +### How the provider announces changes + +- Deprecations are announced in the release notes with a date to move by; shutdown dates aren't always given. +- Content is licensed CC BY 4.0. + +### What the plugin reads and ignores + +- Only `Deprecated` sections with a "Discontinued endpoints" table; one event per model id, `provider: google`. `replacement` only when the row names one other plain id. +- The date the section says to move by is the event's `version`; a section saying it "is deprecated" with only a "before …" date is a deprecation, not breaking. +- Drops (and logs) product names in prose (third-party models mentioned in a sentence) and non-model deprecations (Vertex AI Extensions). 35 events from the saved feed. +- Every event cites a Wayback Machine snapshot of the feed and is read from it. + +### Known gaps + +- Whether an "update before " deprecation should wait for a stated shutdown date is open; today it's a deprecation with that date. +- Partner models (Claude, Llama on Vertex) are only named in prose, so they're dropped. diff --git a/providers/google/genai_js_surface_test.go b/providers/google/genai_js_surface_test.go new file mode 100644 index 0000000..f69a24e --- /dev/null +++ b/providers/google/genai_js_surface_test.go @@ -0,0 +1,16 @@ +package google + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// @google/genai 1.0.0 removed LiveMusicSetClientContentParameters. +func TestGenaiJSSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: GenaiJSSurface, Golden: [2]string{"0.15.0", "1.0.0"}, Want: []string{ + "removed_symbol @google/genai/node.LiveMusicSetClientContentParameters ", + "removed_symbol @google/genai/web.LiveMusicSetClientContentParameters ", + "removed_symbol LiveMusicSetClientContentParameters ", + }, Drop: [2]string{"1.0.0", "1.1.0"}}) +} diff --git a/providers/google/genai_python_surface_test.go b/providers/google/genai_python_surface_test.go new file mode 100644 index 0000000..fbfeaf4 --- /dev/null +++ b/providers/google/genai_python_surface_test.go @@ -0,0 +1,16 @@ +package google + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// google-genai 1.0.0 removed TuningJobOrOperation. 3.4.0 re-exports +// interactions' names from a private module: still importable. +func TestGenaiPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: GenaiPythonSurface, Golden: [2]string{"0.8.0", "1.0.0"}, Want: []string{ + "removed_symbol genai.types.TuningJobOrOperation ", + "removed_symbol genai.types.TuningJobOrOperationDict ", + }, Drop: [2]string{"3.3.0", "3.4.0"}}) +} diff --git a/providers/google/models.go b/providers/google/models.go new file mode 100644 index 0000000..65ca8f6 --- /dev/null +++ b/providers/google/models.go @@ -0,0 +1,44 @@ +package google + +import ( + "regexp" + + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" +) + +// googleModel is a model id as code sends it, nothing around it: a cell +// with a footnote mark ("textembedding-gecko@003 *") isn't read. +var googleModel = regexp.MustCompile(`^[a-z0-9][a-z0-9.@_-]*$`) + +// GeminiModels is the Gemini API's deprecations page (ai.google.dev, served by +// aistudio.google.com as markdown, checked 2026-11-21): one Markdoc table per +// model family, | Model | Release date | Shutdown date | Recommended +// replacement |, current models with "No shutdown date announced", shut-down +// ones under "Deprecated models". Every model there is one code names in a +// request (text, image, video, audio, embedding: all through the same SDK); +// the managed agents' tables name an agent, not a model, and are skipped. +// Google says its dates are the earliest a model may be shut down. +var GeminiModels = retire.Page{ + API: "google/gemini-models", + Provider: "google", + Vendor: "Google", + URL: "https://aistudio.google.com/docs/deprecations", + Format: retire.FormatMarkdoc, + Keep: googleModel.MatchString, + Earliest: true, +} + +// VertexModelRetirements is Google Cloud's Vertex AI model versions page (checked +// 2026-11-21): HTML tables of | Model ID | Release date | Retirement date | +// Replacement model ID | (or Recommended upgrade). A GA model's date is a +// minimum lifetime ("October 13, 2027 or later", "No sooner than May 20, +// 2028"), not a notice, and isn't read as a date; a retired or retiring +// model's is a plain date ("June 30, 2026"). +var VertexModelRetirements = retire.Page{ + API: "google/vertex-model-retirements", + Provider: "google", + Vendor: "Google", + URL: "https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions", + Format: retire.FormatHTML, + Keep: googleModel.MatchString, +} diff --git a/plugins/notices/google_test.go b/providers/google/models_test.go similarity index 65% rename from plugins/notices/google_test.go rename to providers/google/models_test.go index 7ea3e49..c2c1d97 100644 --- a/plugins/notices/google_test.go +++ b/providers/google/models_test.go @@ -1,4 +1,4 @@ -package notices +package google import ( "os" @@ -6,7 +6,9 @@ import ( "testing" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" ) // section is the saved page from start up to end (to the end of the page @@ -40,7 +42,7 @@ func readGoogle(t *testing.T, page retire.Page, content string) int { t.Fatal(err) } saved := kittest.Pages{page.URL: f} - return len(kittest.Page(t, kittest.Env(t, saved), Plugin{Page: page, Archiver: &kittest.Archive{T: t, Pages: saved}})) + return len(kittest.Page(t, kittest.Env(t, saved), notices.Plugin{Page: page, Archiver: &kittest.Archive{T: t, Pages: saved}})) } // The pinned drop test for the Gemini API page: the Gemini 4 models (no @@ -50,18 +52,18 @@ func readGoogle(t *testing.T, page retire.Page, content string) int { // renamed to "Model" would give two more, so the header is what keeps it // out. func TestGeminiDropsModelsWithNoDateAndAgents(t *testing.T) { - const file = "retire/testdata/gemini-deprecations.md" + const file = "testdata/gemini-deprecations.md" current := section(t, file, "## Gemini 4 models", "## Gemini 3 models") retired := section(t, file, "### Deprecated models {% id=\"gemini-3-deprecated-models\" %}", "## Gemini 2.5 Pro models") agents := section(t, file, "## Managed agents", "") - if n := readGoogle(t, retire.Gemini, current+retired+agents); n != 2 { + if n := readGoogle(t, GeminiModels, current+retired+agents); n != 2 { t.Errorf("%d events, want the 2 shut-down Gemini 3 models only", n) } - if _, err := retire.Parse(retire.Gemini.Format.Pipes([]byte(agents)), retire.Gemini.Keep); err == nil { + if _, err := retire.Parse(GeminiModels.Format.Pipes([]byte(agents)), GeminiModels.Keep); err == nil { t.Error("the agents' tables read as retirements") } asModels := strings.ReplaceAll(agents, " * Agent\n", " * Model\n") - if rs, err := retire.Parse(retire.Gemini.Format.Pipes([]byte(asModels)), retire.Gemini.Keep); err != nil || len(rs) != 2 { + if rs, err := retire.Parse(GeminiModels.Format.Pipes([]byte(asModels)), GeminiModels.Keep); err != nil || len(rs) != 2 { t.Errorf("the agents' table with a Model header: %d, %v; the drop proves nothing", len(rs), err) } } @@ -72,12 +74,12 @@ func TestGeminiDropsModelsWithNoDateAndAgents(t *testing.T) { // (gemini-2.5-flash-image, March 15, 2027): one event. The same table with // the dates plain would give five. func TestVertexDropsAMinimumLifetime(t *testing.T) { - ga := section(t, "retire/testdata/vertex-model-versions.html", `

    ). README.md +// says why each source and what it reads. +package google + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/kit" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "google", Name: "Google", Category: plugin.CategoryAI, Homepage: "https://cloud.google.com", + Sources: []plugin.Source{ + { + ID: "vertex-ai-models", Layer: plugin.LayerAIModels, + Watches: "Generative AI model deprecations on Vertex AI", + URLs: []string{"https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml"}, + Plugin: notices.Plugin{Page: VertexAIModels, Archiver: kit.Wayback{}}, + }, + { + ID: "gemini-models", Layer: plugin.LayerAIModels, + Watches: "Gemini API model shutdown dates (the earliest Google gives) and their replacements, from Google's own deprecations table", + URLs: []string{"https://ai.google.dev/gemini-api/docs/deprecations", "https://aistudio.google.com/docs/deprecations"}, + Packages: []string{"pypi:google-genai", "npm:@google/genai"}, + Plugin: notices.Plugin{Page: GeminiModels, Archiver: kit.Wayback{}}, + }, + { + ID: "vertex-model-retirements", Layer: plugin.LayerAIModels, + Watches: "Vertex AI (Gemini Enterprise Agent Platform) model retirement dates and replacements, from Google Cloud's model versions tables", + URLs: []string{"https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions"}, + Packages: []string{"pypi:google-genai", "pypi:google-cloud-aiplatform", "npm:@google/genai"}, + Plugin: notices.Plugin{Page: VertexModelRetirements, Archiver: kit.Wayback{}}, + }, + apisurface.PyPI(GenaiPythonSurface, plugin.LayerSDK, "https://github.com/googleapis/python-genai"), + apisurface.NPM(GenaiJSSurface, "https://github.com/googleapis/js-genai"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + GenaiJSSurface = apisurface.NPMPackage("google/genai-js-surface", "@google/genai") + GenaiPythonSurface = apisurface.Package{ID: "google/genai-python-surface", Name: "google-genai", Ecosystem: "pypi", Module: "google"} +) diff --git a/providers/google/testdata/README.md b/providers/google/testdata/README.md new file mode 100644 index 0000000..36d780e --- /dev/null +++ b/providers/google/testdata/README.md @@ -0,0 +1,33 @@ +# Google: saved copies and goldens + +Real copies of what Google publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/google -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved feed + +A real copy, saved once with `curl`; the golden test reads it through the whole `notices` plugin. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `vertex-ai-generative-ai.atom.xml` | https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml (Atom; `https://cloud.google.com/feeds/...` 301s here; `Last-Modified` sent) | 2026-11-14 08:27 UTC | CC BY 4.0 (Google Cloud documentation), kept whole | "Vertex AI Extensions is deprecated and will be shut down after November 26, 2026." | + +## Saved model deprecations pages + +The deprecations and model-versions pages, read by the golden tests through the whole `notices` plugin. + +**License:** © Google, CC BY 4.0 (Google's developer documentation). + +| File | URL | Fetched | Quote | +|---|---|---|---| +| `gemini-deprecations.md` | https://aistudio.google.com/docs/deprecations (where https://ai.google.dev/gemini-api/docs/deprecations redirects; served as Markdown). Kept whole, byte for byte | 2026-11-21 | "\| `gemini-2.0-flash` \| February 5, 2025 \| June 1, 2026 \| `gemini-3.6-flash` \|", as Markdoc `* cell` lines | +| `vertex-model-versions.html` | https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions. Excerpt: every `

    `/`

    ` line and every line of every `

    ` (982 of 10,074 lines), unchanged; scripts, navigation and prose left out. `retire.Parse` finds the same 39 retirements in the excerpt as in the full page | 2026-11-21 | "<td>June 30, 2026</td>" in the "Retired models" table | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/google-genai/`: `google_genai-0.8.0-py3-none-any.trimmed.whl`, `google_genai-1.0.0-py3-none-any.trimmed.whl`, `google_genai-3.3.0-py3-none-any.trimmed.whl`, `google_genai-3.4.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/74/6d/c5b1757ffe28fdfb38df3fda79c614ec840ebac0b72a3fcbe2ed969e254d/google_genai-0.8.0-py3-none-any.whl; https://files.pythonhosted.org/packages/24/9d/63dbd2b6c630f44cbbf09c4e04b4c9012da01f6e585d34ae53d07931bb67/google_genai-1.0.0-py3-none-any.whl; https://files.pythonhosted.org/packages/ae/e4/619de4d0f985cfafc7a420339796279716aba5c6cac362ab4f97b856279f/google_genai-3.3.0-py3-none-any.whl; https://files.pythonhosted.org/packages/2b/7a/daed011805af7b3ef07c18d4ea8e9534891c7dfeeac438b0d22361f65e0a/google_genai-3.4.0-py3-none-any.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `google/genai/__init__.py`, `google/genai/interactions.py`, `google/genai/types.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/google-genai/`: `pypi-google-genai-excerpt.json` and `pypi-google-genai-0.8.0.json`, `pypi-google-genai-1.0.0.json`, `pypi-google-genai-3.3.0.json`, `pypi-google-genai-3.4.0.json` | https://pypi.org/pypi/google-genai/json, https://pypi.org/pypi/google-genai/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/google-genai/`: `genai-0.15.0.trimmed.tgz`, `genai-1.0.0.trimmed.tgz`, `genai-1.1.0.trimmed.tgz` | https://registry.npmjs.org/@google/genai/-/genai-0.15.0.tgz; https://registry.npmjs.org/@google/genai/-/genai-1.0.0.tgz; https://registry.npmjs.org/@google/genai/-/genai-1.1.0.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/genai.d.ts`, `dist/node/node.d.ts`, `dist/web/web.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/google-genai/`: `npm-google-genai-excerpt.json` and `npm-google-genai-0.15.0.json`, `npm-google-genai-1.0.0.json`, `npm-google-genai-1.1.0.json` | https://registry.npmjs.org/@google%2Fgenai, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/notices/retire/testdata/gemini-deprecations.md b/providers/google/testdata/gemini-deprecations.md similarity index 100% rename from plugins/notices/retire/testdata/gemini-deprecations.md rename to providers/google/testdata/gemini-deprecations.md diff --git a/plugins/notices/testdata/golden/google-gemini-models.json b/providers/google/testdata/golden/google-gemini-models.json similarity index 100% rename from plugins/notices/testdata/golden/google-gemini-models.json rename to providers/google/testdata/golden/google-gemini-models.json diff --git a/plugins/apisurface/testdata/golden/google-genai-js-surface.json b/providers/google/testdata/golden/google-genai-js-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/google-genai-js-surface.json rename to providers/google/testdata/golden/google-genai-js-surface.json diff --git a/plugins/apisurface/testdata/golden/google-genai-python-surface.json b/providers/google/testdata/golden/google-genai-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/google-genai-python-surface.json rename to providers/google/testdata/golden/google-genai-python-surface.json diff --git a/plugins/notices/testdata/golden/google-vertex-ai-models.json b/providers/google/testdata/golden/google-vertex-ai-models.json similarity index 100% rename from plugins/notices/testdata/golden/google-vertex-ai-models.json rename to providers/google/testdata/golden/google-vertex-ai-models.json diff --git a/plugins/notices/testdata/golden/google-vertex-model-retirements.json b/providers/google/testdata/golden/google-vertex-model-retirements.json similarity index 100% rename from plugins/notices/testdata/golden/google-vertex-model-retirements.json rename to providers/google/testdata/golden/google-vertex-model-retirements.json diff --git a/plugins/apisurface/testdata/npm/google-genai/genai-0.15.0.trimmed.tgz b/providers/google/testdata/npm/google-genai/genai-0.15.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/genai-0.15.0.trimmed.tgz rename to providers/google/testdata/npm/google-genai/genai-0.15.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/google-genai/genai-1.0.0.trimmed.tgz b/providers/google/testdata/npm/google-genai/genai-1.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/genai-1.0.0.trimmed.tgz rename to providers/google/testdata/npm/google-genai/genai-1.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/google-genai/genai-1.1.0.trimmed.tgz b/providers/google/testdata/npm/google-genai/genai-1.1.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/genai-1.1.0.trimmed.tgz rename to providers/google/testdata/npm/google-genai/genai-1.1.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/google-genai/npm-google-genai-0.15.0.json b/providers/google/testdata/npm/google-genai/npm-google-genai-0.15.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/npm-google-genai-0.15.0.json rename to providers/google/testdata/npm/google-genai/npm-google-genai-0.15.0.json diff --git a/plugins/apisurface/testdata/npm/google-genai/npm-google-genai-1.0.0.json b/providers/google/testdata/npm/google-genai/npm-google-genai-1.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/npm-google-genai-1.0.0.json rename to providers/google/testdata/npm/google-genai/npm-google-genai-1.0.0.json diff --git a/plugins/apisurface/testdata/npm/google-genai/npm-google-genai-1.1.0.json b/providers/google/testdata/npm/google-genai/npm-google-genai-1.1.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/npm-google-genai-1.1.0.json rename to providers/google/testdata/npm/google-genai/npm-google-genai-1.1.0.json diff --git a/plugins/apisurface/testdata/npm/google-genai/npm-google-genai-excerpt.json b/providers/google/testdata/npm/google-genai/npm-google-genai-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/google-genai/npm-google-genai-excerpt.json rename to providers/google/testdata/npm/google-genai/npm-google-genai-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/google-genai/google_genai-0.8.0-py3-none-any.trimmed.whl b/providers/google/testdata/pypi/google-genai/google_genai-0.8.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/google_genai-0.8.0-py3-none-any.trimmed.whl rename to providers/google/testdata/pypi/google-genai/google_genai-0.8.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/google-genai/google_genai-1.0.0-py3-none-any.trimmed.whl b/providers/google/testdata/pypi/google-genai/google_genai-1.0.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/google_genai-1.0.0-py3-none-any.trimmed.whl rename to providers/google/testdata/pypi/google-genai/google_genai-1.0.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/google-genai/google_genai-3.3.0-py3-none-any.trimmed.whl b/providers/google/testdata/pypi/google-genai/google_genai-3.3.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/google_genai-3.3.0-py3-none-any.trimmed.whl rename to providers/google/testdata/pypi/google-genai/google_genai-3.3.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/google-genai/google_genai-3.4.0-py3-none-any.trimmed.whl b/providers/google/testdata/pypi/google-genai/google_genai-3.4.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/google_genai-3.4.0-py3-none-any.trimmed.whl rename to providers/google/testdata/pypi/google-genai/google_genai-3.4.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-0.8.0.json b/providers/google/testdata/pypi/google-genai/pypi-google-genai-0.8.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-0.8.0.json rename to providers/google/testdata/pypi/google-genai/pypi-google-genai-0.8.0.json diff --git a/plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-1.0.0.json b/providers/google/testdata/pypi/google-genai/pypi-google-genai-1.0.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-1.0.0.json rename to providers/google/testdata/pypi/google-genai/pypi-google-genai-1.0.0.json diff --git a/plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-3.3.0.json b/providers/google/testdata/pypi/google-genai/pypi-google-genai-3.3.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-3.3.0.json rename to providers/google/testdata/pypi/google-genai/pypi-google-genai-3.3.0.json diff --git a/plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-3.4.0.json b/providers/google/testdata/pypi/google-genai/pypi-google-genai-3.4.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-3.4.0.json rename to providers/google/testdata/pypi/google-genai/pypi-google-genai-3.4.0.json diff --git a/plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-excerpt.json b/providers/google/testdata/pypi/google-genai/pypi-google-genai-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/google-genai/pypi-google-genai-excerpt.json rename to providers/google/testdata/pypi/google-genai/pypi-google-genai-excerpt.json diff --git a/plugins/notices/feed/testdata/vertex-ai-generative-ai.atom.xml b/providers/google/testdata/vertex-ai-generative-ai.atom.xml similarity index 100% rename from plugins/notices/feed/testdata/vertex-ai-generative-ai.atom.xml rename to providers/google/testdata/vertex-ai-generative-ai.atom.xml diff --git a/plugins/notices/retire/testdata/vertex-model-versions.html b/providers/google/testdata/vertex-model-versions.html similarity index 100% rename from plugins/notices/retire/testdata/vertex-model-versions.html rename to providers/google/testdata/vertex-model-versions.html diff --git a/providers/google/vertex_ai_models.go b/providers/google/vertex_ai_models.go new file mode 100644 index 0000000..067186b --- /dev/null +++ b/providers/google/vertex_ai_models.go @@ -0,0 +1,102 @@ +package google + +import ( + "fmt" + "regexp" + "strings" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" +) + +// VertexAIModels is Google Cloud's "Generative AI on Vertex AI" release +// notes, Atom (checked 2026-11-14: one entry per day, each change under an +//

    naming its kind: Feature, Change, Announcement, Deprecated). A model +// deprecation is a "Deprecated" section with a table of model ids in +// (discontinued, recommended migration) and the date to move by. +var VertexAIModels = feed.Feed{ + API: "google/vertex-ai-models", + Vendor: "Google", + URL: "https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml", + Read: readVertexAI, +} + +var tableRow = regexp.MustCompile(`(?is)

    (.*?)`) + +var tableCell = regexp.MustCompile(`(?is)]*>(.*?)`) + +var plainModelID = regexp.MustCompile(`^[a-z0-9][a-z0-9.@_-]*$`) + +func readVertexAI(e feed.Entry) []feed.Finding { + var out []feed.Finding + for _, s := range feed.SplitBy(e.HTML, 3) { + if !feed.Marked([]string{s.Heading}, "Deprecated", "Breaking") { + continue + } + lines := feed.Lines(s.HTML) + drop := func(why string) { + title := "" + if len(lines) > 0 { + title = lines[0] + } + out = append(out, feed.Finding{Entry: e.Link, Dropped: fmt.Sprintf("%q: %s", title, why)}) + } + rows := tableRow.FindAllStringSubmatch(s.HTML, -1) + if len(rows) < 2 { + drop("names no model id in a table") + continue + } + header := cells(rows[0][1]) + if len(header) < 2 || !strings.Contains(strings.ToLower(header[0]), "discontinued") { + drop(fmt.Sprintf("a table that isn't discontinued models: %q", header)) + continue + } + line, date, ct := feed.Dated(lines) + if date == "" { + drop("no sentence giving the date to move by") + continue + } + for _, r := range rows[1:] { + raw := tableCell.FindAllStringSubmatch(r[1], -1) + if len(raw) < 2 { + continue + } + names := feed.Codes(raw[0][1]) + if len(names) != 1 || !plainModelID.MatchString(names[0]) || feed.Text(raw[0][1]) != names[0] { + drop(fmt.Sprintf("row %q doesn't name one model id", feed.Text(raw[0][1]))) + continue + } + name, migrate := names[0], feed.Text(raw[1][1]) + subject := event.Subject{Type: event.SubjectModel, Provider: "google", Name: name} + hint := fmt.Sprintf("Google recommends: %s.", migrate) + // Exactly one plain model, and not the model itself (the feed has a + // row whose migration is its own name): anything else stays a hint. + if repl := feed.Codes(raw[1][1]); len(repl) == 1 && feed.Text(raw[1][1]) == repl[0] && repl[0] != name { + subject.Replacement = repl[0] + hint = fmt.Sprintf("Use `%s` instead: Google's recommended migration.", repl[0]) + } + desc := fmt.Sprintf("Model %q is deprecated on Vertex AI: Google asks to move off it before %s to avoid service disruption.", name, date) + if ct == event.ChangeTypeBreaking { + desc = fmt.Sprintf("Model %q is shut down on Vertex AI on %s: requests naming it fail from that date.", name, date) + } + out = append(out, feed.Finding{ + ChangeType: ct, + Version: date, + Subject: subject, + Description: desc, + Hint: hint, + Excerpt: feed.Excerpt(s.Heading, lines[0], line, strings.Join(header, " | "), name+" | "+migrate), + Entry: e.Link, + }) + } + } + return out +} + +func cells(row string) []string { + var out []string + for _, c := range tableCell.FindAllStringSubmatch(row, -1) { + out = append(out, feed.Text(c[1])) + } + return out +} diff --git a/providers/google/vertex_ai_models_test.go b/providers/google/vertex_ai_models_test.go new file mode 100644 index 0000000..df57e76 --- /dev/null +++ b/providers/google/vertex_ai_models_test.go @@ -0,0 +1,52 @@ +package google + +import ( + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/feed" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest" +) + +// The feed as saved on 2026-11-14 (testdata/README.md) through the whole +// plugin. +func TestVertexAIModelsGolden(t *testing.T) { + noticestest.Golden(t, VertexAIModels, "testdata/vertex-ai-generative-ai.atom.xml") +} + +// What the feed's marked entries came to, kept and dropped: the golden files +// pin the events, this pins that the unsure ones were dropped, not guessed. +func TestVertexAIModelsUnsureEntriesAreDropped(t *testing.T) { + for _, c := range []struct { + feed feed.Feed + file string + dropped []string // a substring of each drop reason, in order + }{ + {VertexAIModels, "testdata/vertex-ai-generative-ai.atom.xml", []string{ + "Vertex AI Extensions deprecation", + "Anthropic's Claude 3 Haiku", // a product name in prose, not a model id + "Anthropic's Claude 3.5 Haiku", + }}, + } { + fs, err := c.feed.Findings(kittest.Read(t, c.file)) + if err != nil { + t.Fatal(err) + } + var drops []string + for _, f := range fs { + if f.Dropped != "" { + drops = append(drops, f.Entry+" "+f.Dropped) + } + } + if len(drops) != len(c.dropped) { + t.Errorf("%s: dropped %d, want %d:\n%s", c.feed.API, len(drops), len(c.dropped), strings.Join(drops, "\n")) + continue + } + for i, want := range c.dropped { + if !strings.Contains(drops[i], want) { + t.Errorf("%s: drop %d is %q, want %q", c.feed.API, i, drops[i], want) + } + } + } +} diff --git a/providers/mongodb-atlas-admin-spec.md b/providers/mongodb-atlas-admin-spec.md deleted file mode 100644 index 5a5ef5b..0000000 --- a/providers/mongodb-atlas-admin-spec.md +++ /dev/null @@ -1,42 +0,0 @@ -# MongoDB (`mongodb/atlas-admin-spec`) - -## What it watches - -The MongoDB Atlas Administration API v2 (`cloud.mongodb.com/api/atlas/v2`): operations MongoDB marks deprecated, and removals of operations it had marked deprecated, day by day in the OpenAPI spec MongoDB publishes for it. - -Kind: `openapi` (`plugins/openapi`), with `adapter.MongoDBAtlas`. The API's own changelog is a separate source, `mongodb/atlas-admin-api` (kind `changelog`). - -## Why this source - -- **Source:** `openapi/v2.json` in [mongodb/openapi](https://github.com/mongodb/openapi), pinned to a commit (`https://raw.githubusercontent.com/mongodb/openapi//openapi/v2.json`). The versions come from the GitHub commits API. Checked on 2026-11-21. -- **Why this one:** - - It's MongoDB's own spec of the whole API, committed by its release workflow ("ci(prod): Release OpenAPI Spec") a few times a week: 768 commits from 2024-07-25 to 2026-11-19. - - It marks deprecated operations with the `deprecated` flag. - - Every commit can be cited and replayed. -- **Alternatives considered:** - - **The repo's `v0.0.N` tags:** they mark the repo's tooling releases, not the spec. - - **The per-resource-version files in `openapi/v2/`:** one file per API resource version; `v2.json` holds every operation with all its versions, which is what a caller of any version sees removed. - - **`changelog/changelog.json`:** read by `mongodb/atlas-admin-api`; it reports changes per resource version, in prose, not removals of whole operations. -- **Quote:** `"deprecated": true` on `GET /api/atlas/v2/users/byName/{userName}` ("Returns the details for one MongoDB Cloud user account with the specified username."), new on 2025-02-20. - -## How the provider announces changes - -- **One version per day,** the day's last commit, its date the event's `version`: `info.version` is a fixed `2.0`, and the dated resource versions (`application/vnd.atlas.2025-03-12+json`) are per operation, several in one spec. -- **Deprecations use the flag** (53 operations on 2026-11-19). Fourteen descriptions mention "deprecated" without it, each about the deprecated invitation flow, not the operation. -- **Deprecated operations do leave:** the tenant backup operations were flagged, then removed between 2025-10 and 2026-11. -- **Operations also leave unmarked:** GET `/rest/unauth/version` on 2024-08-07. - -## What the plugin reads and ignores - -- **Reads** every day's spec, diffed against the day before. Two events come out of it: - - **Deprecations:** an operation that gains the `deprecated` flag, quoting the whole operation. - - **Removals (breaking):** an operation that leaves the spec after the previous day's spec had marked it deprecated. -- **Ignores everything else:** removals of operations never marked deprecated, schema and property changes (the changelog source reports those per resource version), new operations. -- **The golden test** replays 2025-02-18 → 2025-02-20, when 14 user-management operations were deprecated at once; three are saved, three events. **The drop test** replays 2024-07-25 → 2024-08-07: GET `/rest/unauth/version` gone unmarked, no event. - -## Known gaps - -- **Deprecated resource versions** (an operation's `2023-01-01` content type sunset while newer ones stay) aren't events: only whole operations are. The changelog source covers them. -- **Removals MongoDB didn't flag first aren't events.** -- **History starts on 2024-07-25,** when `openapi/v2.json` was first committed. -- **License:** the spec is CC BY-NC-SA 3.0 US; only small excerpts are saved for tests. diff --git a/providers/mongodb-atlas.md b/providers/mongodb-atlas.md deleted file mode 100644 index d47dc78..0000000 --- a/providers/mongodb-atlas.md +++ /dev/null @@ -1,44 +0,0 @@ -# MongoDB Atlas (`mongodb/atlas-admin-api`) - -## What it watches - -The MongoDB Atlas Administration API (`/api/atlas/v2`): an endpoint's API version deprecated (unless MongoDB reactivates it), and an endpoint's API version removed at its sunset date, as MongoDB lists them in its own machine-readable API changelog. - -Kind: `changelog` (`plugins/changelog`), with its JSON parser (`json.go`) and the `MongoDBAtlas` log. - -## Why this source - -- **Source:** `changelog/changelog.json` in [mongodb/openapi](https://github.com/mongodb/openapi), read at the commit that last changed it (`https://raw.githubusercontent.com/mongodb/openapi//changelog/changelog.json`). The commit comes from the GitHub commits API. Checked on 2026-11-19. -- **Why this one:** it's MongoDB's own record of what changed, released by MongoDB's CI ("Release API Changelog") a few times a month. It's also what the [API changelog docs page](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog/) shows. - - It covers 188 days from 2023-02-01 to 2026-11-18. Each day lists every endpoint that changed, per API version, with a change code from oasdiff, a sentence, and whether the change is backward compatible. - - The life-cycle entries say what happens and when: "Resource version 2023-01-01 deprecated and marked for removal on 2025-06-01", "endpoint with API Version '2023-01-01' was removed as it has reached its sunset date '2026-01-22'". -- **Alternatives considered:** - - **The per-version OpenAPI specs in the same repo** (`openapi/v2/openapi-.json`). The changelog is MongoDB's own diff of them, already classified, so diffing them again would only re-derive it. - - **The docs changelog page.** It's built from the same data, as HTML. - - **The drivers' changelogs** (PyMongo, the Node.js driver). They're a different surface, the database driver, not this API, and a separate plugin if added. -- **Quote:** "endpoint with API Version '2023-01-01' was removed as it has reached its sunset date '2026-01-22'" (the shared-tier backup endpoints, 2026-01-22) - -## How the provider announces changes - -- **Versioning by date, per resource.** A caller picks the version per request in the `Accept` header (`application/vnd.atlas.2023-01-01+json`). Each API version of an endpoint is deprecated when a newer one ships, and removed at a sunset date, usually a year or more later. -- **The changelog gets a release a few times a month.** It holds 22,273 changes, 481 of them marked not backward compatible. - -## What the plugin reads and ignores - -- **Reads** the change codes about a whole endpoint at one API version, replaying the days oldest first: - - `endpoint-deprecated` and `resource-version-deprecated` become **`deprecation`** events, unless a later `endpoint-reactivated` withdraws them. MongoDB has reactivated 13 times. For example, `GET /api/atlas/v2/groups/{groupId}/clusters` at `2024-05-30` was deprecated on 2024-06-25 and reactivated the next day. - - `endpoint-removed` becomes a **`breaking`** event, unless the same endpoint and version shows up again on a later day (none has): then the removal goes, and so does any deprecation before it. A removal announced twice counts from its first announcement. All 38 in the file say the version "has reached its sunset date". - - **`version`** is the API version the change is about (`2023-01-01`): the one a caller's `Accept` header names. - - A deprecation counts from its first announcement since the last reactivation: the changelog repeats some. -- **Cites** the file at its commit, with a JSON pointer to the change and the change itself as the excerpt: every field MongoDB wrote, in its order, whitespace aside. -- **Ignores** every other change code. Most are additions. The other "not backward compatible" ones are property-level, and the flag is broad: a response enum gaining a value counts (68 times). Removed or newly required request properties are probably real breaks, but they aren't read until measured. -- **Not read:** `api-path-removed-without-deprecation`. Its one entry (`GET …/streams/activeVpcPeeringConnections` at `2024-11-13`, 2025-01-10) comes with `endpoint-added` the same day, and the endpoint changes again later, so it wasn't removed. Also not read: `sunset-deleted`, whose one entry keeps the endpoint deprecated. -- On the changelog released 2026-11-18 this gives 81 events: 43 deprecations still standing and 38 removals. - -## Known gaps - -- **Property-level breaking changes aren't events.** Examples are a request property removed (4), made required (11) or added as required (3), or an enum value no longer accepted (36), even where MongoDB marks them not backward compatible. -- **The changelog doesn't always announce a deprecation before a removal.** None of the 38 removals had an `endpoint-deprecated` or `resource-version-deprecated` entry for the same endpoint and version in the changelog, so some removals arrive without an earlier deprecation event. The removal entries do say the sunset date was reached. -- **An event stored before it's withdrawn stays stored:** a deprecation before its reactivation, or a removal before its version comes back. The plugin doesn't emit it again, but nothing withdraws an event already in the feed. -- **The drivers aren't covered,** and they're what most application code uses. -- **The patch-it client can't place these events yet.** Their `version` is a dated API version (`2023-01-01`), chosen per request in an `Accept` header, a scheme the client's version check doesn't know. diff --git a/providers/mongodb-node-surface.md b/providers/mongodb-node-surface.md deleted file mode 100644 index c44b234..0000000 --- a/providers/mongodb-node-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# MongoDB Node.js driver (`mongodb/node-surface`) - -## What it watches - -The public API of the `mongodb` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install mongodb@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** HISTORY.md; the upgrade guides (majors only). -- **Quote:** `interface AsyncDisposable_2` (exported as `AsyncDisposable`, `mongodb.d.ts` line 613) at 6.22.0, gone at 7.0.0. - -## How the provider announces changes - -- The driver ships one declaration file (`mongodb.d.ts`, an API Extractor rollup); majors remove what the previous one deprecated. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `mongodb.MongoClient.connect`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). diff --git a/providers/mongodb-pymongo-surface.md b/providers/mongodb-pymongo-surface.md deleted file mode 100644 index 1ceb59a..0000000 --- a/providers/mongodb-pymongo-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# PyMongo (`mongodb/pymongo-surface`) - -## What it watches - -The public API of the `pymongo` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install pymongo==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** the changelog in the docs (`doc/changelog.rst`); the migration guides (majors only). -- **Quote:** `explicit_session: bool = False,` in `AsyncCommandCursor.__init__` (`pymongo/asynchronous/command_cursor.py`) at 4.15.5, gone at 4.16.0. - -## How the provider announces changes - -- The driver releases a minor every few months; constructors' parameters change in minors. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `pymongo/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. -- Wheels are per platform; the first by file name is read (the Python files are the same in each). diff --git a/providers/mongodb/README.md b/providers/mongodb/README.md new file mode 100644 index 0000000..fe07417 --- /dev/null +++ b/providers/mongodb/README.md @@ -0,0 +1,165 @@ +# MongoDB + +Every source patch-it reads for MongoDB, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## MongoDB (`mongodb/atlas-admin-spec`) + +### What it watches + +The MongoDB Atlas Administration API v2 (`cloud.mongodb.com/api/atlas/v2`): operations MongoDB marks deprecated, and removals of operations it had marked deprecated, day by day in the OpenAPI spec MongoDB publishes for it. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `MongoDBAtlas` ([`atlas_admin_spec.go`](atlas_admin_spec.go)). The API's own changelog is a separate source, `mongodb/atlas-admin-api` (kind `changelog`). + +### Why this source + +- **Source:** `openapi/v2.json` in [mongodb/openapi](https://github.com/mongodb/openapi), pinned to a commit (`https://raw.githubusercontent.com/mongodb/openapi//openapi/v2.json`). The versions come from the GitHub commits API. Checked on 2026-11-21. +- **Why this one:** + - It's MongoDB's own spec of the whole API, committed by its release workflow ("ci(prod): Release OpenAPI Spec") a few times a week: 768 commits from 2024-07-25 to 2026-11-19. + - It marks deprecated operations with the `deprecated` flag. + - Every commit can be cited and replayed. +- **Alternatives considered:** + - **The repo's `v0.0.N` tags:** they mark the repo's tooling releases, not the spec. + - **The per-resource-version files in `openapi/v2/`:** one file per API resource version; `v2.json` holds every operation with all its versions, which is what a caller of any version sees removed. + - **`changelog/changelog.json`:** read by `mongodb/atlas-admin-api`; it reports changes per resource version, in prose, not removals of whole operations. +- **Quote:** `"deprecated": true` on `GET /api/atlas/v2/users/byName/{userName}` ("Returns the details for one MongoDB Cloud user account with the specified username."), new on 2025-02-20. + +### How the provider announces changes + +- **One version per day,** the day's last commit, its date the event's `version`: `info.version` is a fixed `2.0`, and the dated resource versions (`application/vnd.atlas.2025-03-12+json`) are per operation, several in one spec. +- **Deprecations use the flag** (53 operations on 2026-11-19). Fourteen descriptions mention "deprecated" without it, each about the deprecated invitation flow, not the operation. +- **Deprecated operations do leave:** the tenant backup operations were flagged, then removed between 2025-10 and 2026-11. +- **Operations also leave unmarked:** GET `/rest/unauth/version` on 2024-08-07. + +### What the plugin reads and ignores + +- **Reads** every day's spec, diffed against the day before. Two events come out of it: + - **Deprecations:** an operation that gains the `deprecated` flag, quoting the whole operation. + - **Removals (breaking):** an operation that leaves the spec after the previous day's spec had marked it deprecated. +- **Ignores everything else:** removals of operations never marked deprecated, schema and property changes (the changelog source reports those per resource version), new operations. +- **The golden test** replays 2025-02-18 → 2025-02-20, when 14 user-management operations were deprecated at once; three are saved, three events. **The drop test** replays 2024-07-25 → 2024-08-07: GET `/rest/unauth/version` gone unmarked, no event. + +### Known gaps + +- **Deprecated resource versions** (an operation's `2023-01-01` content type sunset while newer ones stay) aren't events: only whole operations are. The changelog source covers them. +- **Removals MongoDB didn't flag first aren't events.** +- **History starts on 2024-07-25,** when `openapi/v2.json` was first committed. +- **License:** the spec is CC BY-NC-SA 3.0 US; only small excerpts are saved for tests. + +## MongoDB Atlas (`mongodb/atlas-admin-api`) + +### What it watches + +The MongoDB Atlas Administration API (`/api/atlas/v2`): an endpoint's API version deprecated (unless MongoDB reactivates it), and an endpoint's API version removed at its sunset date, as MongoDB lists them in its own machine-readable API changelog. + +Kind: `changelog` (`kinds/changelog`), with its JSON parser (`kinds/changelog/json.go`) and the `AtlasAdminAPI` log. + +### Why this source + +- **Source:** `changelog/changelog.json` in [mongodb/openapi](https://github.com/mongodb/openapi), read at the commit that last changed it (`https://raw.githubusercontent.com/mongodb/openapi//changelog/changelog.json`). The commit comes from the GitHub commits API. Checked on 2026-11-19. +- **Why this one:** it's MongoDB's own record of what changed, released by MongoDB's CI ("Release API Changelog") a few times a month. It's also what the [API changelog docs page](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog/) shows. + - It covers 188 days from 2023-02-01 to 2026-11-18. Each day lists every endpoint that changed, per API version, with a change code from oasdiff, a sentence, and whether the change is backward compatible. + - The life-cycle entries say what happens and when: "Resource version 2023-01-01 deprecated and marked for removal on 2025-06-01", "endpoint with API Version '2023-01-01' was removed as it has reached its sunset date '2026-01-22'". +- **Alternatives considered:** + - **The per-version OpenAPI specs in the same repo** (`openapi/v2/openapi-.json`). The changelog is MongoDB's own diff of them, already classified, so diffing them again would only re-derive it. + - **The docs changelog page.** It's built from the same data, as HTML. + - **The drivers' changelogs** (PyMongo, the Node.js driver). They're a different surface, the database driver, not this API, and a separate plugin if added. +- **Quote:** "endpoint with API Version '2023-01-01' was removed as it has reached its sunset date '2026-01-22'" (the shared-tier backup endpoints, 2026-01-22) + +### How the provider announces changes + +- **Versioning by date, per resource.** A caller picks the version per request in the `Accept` header (`application/vnd.atlas.2023-01-01+json`). Each API version of an endpoint is deprecated when a newer one ships, and removed at a sunset date, usually a year or more later. +- **The changelog gets a release a few times a month.** It holds 22,273 changes, 481 of them marked not backward compatible. + +### What the plugin reads and ignores + +- **Reads** the change codes about a whole endpoint at one API version, replaying the days oldest first: + - `endpoint-deprecated` and `resource-version-deprecated` become **`deprecation`** events, unless a later `endpoint-reactivated` withdraws them. MongoDB has reactivated 13 times. For example, `GET /api/atlas/v2/groups/{groupId}/clusters` at `2024-05-30` was deprecated on 2024-06-25 and reactivated the next day. + - `endpoint-removed` becomes a **`breaking`** event, unless the same endpoint and version shows up again on a later day (none has): then the removal goes, and so does any deprecation before it. A removal announced twice counts from its first announcement. All 38 in the file say the version "has reached its sunset date". + - **`version`** is the API version the change is about (`2023-01-01`): the one a caller's `Accept` header names. + - A deprecation counts from its first announcement since the last reactivation: the changelog repeats some. +- **Cites** the file at its commit, with a JSON pointer to the change and the change itself as the excerpt: every field MongoDB wrote, in its order, whitespace aside. +- **Ignores** every other change code. Most are additions. The other "not backward compatible" ones are property-level, and the flag is broad: a response enum gaining a value counts (68 times). Removed or newly required request properties are probably real breaks, but they aren't read until measured. +- **Not read:** `api-path-removed-without-deprecation`. Its one entry (`GET …/streams/activeVpcPeeringConnections` at `2024-11-13`, 2025-01-10) comes with `endpoint-added` the same day, and the endpoint changes again later, so it wasn't removed. Also not read: `sunset-deleted`, whose one entry keeps the endpoint deprecated. +- On the changelog released 2026-11-18 this gives 81 events: 43 deprecations still standing and 38 removals. + +### Known gaps + +- **Property-level breaking changes aren't events.** Examples are a request property removed (4), made required (11) or added as required (3), or an enum value no longer accepted (36), even where MongoDB marks them not backward compatible. +- **The changelog doesn't always announce a deprecation before a removal.** None of the 38 removals had an `endpoint-deprecated` or `resource-version-deprecated` entry for the same endpoint and version in the changelog, so some removals arrive without an earlier deprecation event. The removal entries do say the sunset date was reached. +- **An event stored before it's withdrawn stays stored:** a deprecation before its reactivation, or a removal before its version comes back. The plugin doesn't emit it again, but nothing withdraws an event already in the feed. +- **The drivers aren't covered,** and they're what most application code uses. +- **The patch-it client can't place these events yet.** Their `version` is a dated API version (`2023-01-01`), chosen per request in an `Accept` header, a scheme the client's version check doesn't know. + +## MongoDB Node.js driver (`mongodb/node-surface`) + +### What it watches + +The public API of the `mongodb` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install mongodb@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** HISTORY.md; the upgrade guides (majors only). +- **Quote:** `interface AsyncDisposable_2` (exported as `AsyncDisposable`, `mongodb.d.ts` line 613) at 6.22.0, gone at 7.0.0. + +### How the provider announces changes + +- The driver ships one declaration file (`mongodb.d.ts`, an API Extractor rollup); majors remove what the previous one deprecated. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `mongodb.MongoClient.connect`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). + +## PyMongo (`mongodb/pymongo-surface`) + +### What it watches + +The public API of the `pymongo` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install pymongo==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** the changelog in the docs (`doc/changelog.rst`); the migration guides (majors only). +- **Quote:** `explicit_session: bool = False,` in `AsyncCommandCursor.__init__` (`pymongo/asynchronous/command_cursor.py`) at 4.15.5, gone at 4.16.0. + +### How the provider announces changes + +- The driver releases a minor every few months; constructors' parameters change in minors. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `pymongo/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. +- Wheels are per platform; the first by file name is read (the Python files are the same in each). diff --git a/plugins/changelog/json_test.go b/providers/mongodb/atlas_admin_api_test.go similarity index 90% rename from plugins/changelog/json_test.go rename to providers/mongodb/atlas_admin_api_test.go index ba2a104..b97d893 100644 --- a/plugins/changelog/json_test.go +++ b/providers/mongodb/atlas_admin_api_test.go @@ -1,4 +1,4 @@ -package changelog +package mongodb import ( "context" @@ -12,6 +12,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" ) const ( @@ -28,8 +29,8 @@ var atlasBefore = plugin.Version{ID: "2026-11-09", Ref: "f49749a61f67254d63931bb // extracted, as if the file before had none. func logPair(t *testing.T, sha, file string) []event.Event { t.Helper() - env := kittest.Env(t, kittest.Pages{MongoDBAtlas.URL(sha): file}) - p := Plugin{Log: MongoDBAtlas} + env := kittest.Env(t, kittest.Pages{AtlasAdminAPI.URL(sha): file}) + p := changelog.Plugin{Log: AtlasAdminAPI} to, err := p.ReadAt(context.Background(), env, plugin.Version{ID: "2026-11-18", Ref: sha}) if err != nil { t.Fatal(err) @@ -47,7 +48,7 @@ func TestJSONGolden(t *testing.T) { // Every event cites the pinned file, and its excerpt is the change its // pointer names there. for _, e := range got { - if e.SourceURL != MongoDBAtlas.URL(atlasSHA) { + if e.SourceURL != AtlasAdminAPI.URL(atlasSHA) { t.Errorf("%s: source_url %s", e.Subject.Operation, e.SourceURL) } if node := nodeAt(t, atlasFixture, e.SourcePointer); !sameJSON(node, e.SourceExcerpt) { @@ -60,7 +61,7 @@ func TestJSONGolden(t *testing.T) { // 2023-01-01 of the shared-tier ("tenant") backup endpoints, "as it has // reached its sunset date '2026-01-22'". func TestTenantBackupSunset(t *testing.T) { - fs, err := MongoDBAtlas.Read(kittest.Read(t, atlasFixture)) + fs, err := AtlasAdminAPI.Read(kittest.Read(t, atlasFixture)) if err != nil { t.Fatal(err) } @@ -147,7 +148,7 @@ func TestReactivationWithdrawsTheDeprecation(t *testing.T) { if codes["endpoint-deprecated"] == 0 || codes["endpoint-reactivated"] == 0 { t.Fatalf("the atlasFixture's clusters 2024-05-30 entries are %v: they no longer show a reactivation", codes) } - fs, err := MongoDBAtlas.Read(kittest.Read(t, atlasFixture)) + fs, err := AtlasAdminAPI.Read(kittest.Read(t, atlasFixture)) if err != nil { t.Fatal(err) } @@ -176,7 +177,7 @@ func TestLifeCycleInOrder(t *testing.T) { day("2026-01-15", "/b", "resource-version-deprecated"), day("2026-01-01", "/a", "endpoint-deprecated"), }, ",") + "]") - fs, err := MongoDBAtlas.Read(b) + fs, err := AtlasAdminAPI.Read(b) if err != nil { t.Fatal(err) } @@ -199,7 +200,7 @@ func TestRemovalUndoneAndRawExcerpt(t *testing.T) { {"date":"2026-02-01","paths":[{"path":"/a","httpMethod":"GET","versions":[{"version":"2023-01-01","changes":[{"change":"removed","changeCode":"endpoint-removed","backwardCompatible":false}]}]}, {"path":"/b","httpMethod":"GET","versions":[{"version":"2023-01-01","changes":[{"change":"removed","changeCode":"endpoint-removed","backwardCompatible":false,"sunset":"2026-02-01"}]}]}]} ]`) - fs, err := MongoDBAtlas.Read(b) + fs, err := AtlasAdminAPI.Read(b) if err != nil { t.Fatal(err) } @@ -224,7 +225,7 @@ func TestRepeatedRemovalAndReturn(t *testing.T) { day("2026-02-01", "/a", "endpoint-removed"), day("2026-01-01", "/a", "endpoint-deprecated"), }, ",") + "]") - fs, err := MongoDBAtlas.Read(b) + fs, err := AtlasAdminAPI.Read(b) if err != nil { t.Fatal(err) } @@ -239,7 +240,7 @@ func TestRepeatsAreReadOnce(t *testing.T) { {"date":"2026-02-01","paths":[{"path":"/a","httpMethod":"GET","versions":[{"version":"2023-01-01","changes":[{"change":"endpoint deprecated","changeCode":"endpoint-deprecated","backwardCompatible":true}]}]}]}, {"date":"2026-01-01","paths":[{"path":"/a","httpMethod":"GET","versions":[{"version":"2023-01-01","changes":[{"change":"endpoint deprecated","changeCode":"endpoint-deprecated","backwardCompatible":true},{"change":"added the new optional request property","changeCode":"new-optional-request-property","backwardCompatible":true}]}]}]} ]`) - fs, err := MongoDBAtlas.Read(b) + fs, err := AtlasAdminAPI.Read(b) if err != nil { t.Fatal(err) } @@ -250,7 +251,7 @@ func TestRepeatsAreReadOnce(t *testing.T) { func TestReadRefusesWhatIsntAChangelog(t *testing.T) { for name, b := range map[string]string{"html": "moved", "empty": "[]", "object": `{"date":"x"}`} { - if _, err := MongoDBAtlas.Read([]byte(b)); err == nil { + if _, err := AtlasAdminAPI.Read([]byte(b)); err == nil { t.Errorf("%s: want an error, never zero events read as a quiet week", name) } } @@ -297,11 +298,11 @@ func TestJSONChangelogPairByPair(t *testing.T) { "https://api.github.com/repos/mongodb/openapi/commits?path=changelog%2Fchangelog.json&per_page=100&page=1": "testdata/log-history/commits.json", } for n := 1; n <= 3; n++ { - pages[MongoDBAtlas.URL(sha(n))] = fmt.Sprintf("testdata/log-history/changelog-%d.json", n) + pages[AtlasAdminAPI.URL(sha(n))] = fmt.Sprintf("testdata/log-history/changelog-%d.json", n) } env := kittest.Env(t, pages) ctx := context.Background() - p := Plugin{Log: MongoDBAtlas} + p := changelog.Plugin{Log: AtlasAdminAPI} vs, err := p.ListVersions(ctx, env) if err != nil { t.Fatal(err) @@ -334,3 +335,23 @@ func TestJSONChangelogPairByPair(t *testing.T) { t.Errorf("pairs gave %q, want %q", strings.Join(got, "; "), want) } } + +// day and change are the changelog file's shape, as kinds/changelog reads +// it, for the tests that check what a saved file holds. +type day struct { + Date string `json:"date"` + Paths []struct { + Path string `json:"path"` + Method string `json:"httpMethod"` + Versions []struct { + Version string `json:"version"` + Changes []json.RawMessage `json:"changes"` + } `json:"versions"` + } `json:"paths"` +} + +type change struct { + Change string `json:"change"` + ChangeCode string `json:"changeCode"` + BackwardCompatible bool `json:"backwardCompatible"` +} diff --git a/plugins/openapi/adapter/mongodb.go b/providers/mongodb/atlas_admin_spec.go similarity index 56% rename from plugins/openapi/adapter/mongodb.go rename to providers/mongodb/atlas_admin_spec.go index 586d261..9e2e9a8 100644 --- a/plugins/openapi/adapter/mongodb.go +++ b/providers/mongodb/atlas_admin_spec.go @@ -1,13 +1,16 @@ -package adapter +package mongodb import ( "context" "encoding/json" "fmt" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // Variables, not constants, only so tests can point them at a local server. @@ -32,7 +35,7 @@ var ( // for the openapi plugin. A tag here is a commit SHA. type MongoDBAtlas struct{} -var _ Adapter = MongoDBAtlas{} +var _ adapter.Adapter = MongoDBAtlas{} func (MongoDBAtlas) API() string { return "mongodb/atlas-admin-spec" } @@ -48,7 +51,7 @@ func (MongoDBAtlas) LatestTag(ctx context.Context) (string, error) { // Versions are the days the spec changed, each read at that day's last // commit (Daily). func (MongoDBAtlas) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, atlasRepo, atlasPath) + return adapter.Commits(ctx, atlasRepo, atlasPath) } // Fetch downloads the spec at commit sha. Version is the commit's date @@ -56,23 +59,44 @@ func (MongoDBAtlas) Versions(ctx context.Context) ([]plugin.Version, error) { // (application/vnd.atlas.2025-03-12+json) are per operation, several in one // spec. The server is https://cloud.mongodb.com with no path: the paths are // already what a caller sends (/api/atlas/v2/...). -func (MongoDBAtlas) Fetch(ctx context.Context, sha string) (Spec, error) { +func (MongoDBAtlas) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(atlasCommitURL, sha)) if err != nil { - return Spec{}, fmt.Errorf("looking up mongodb atlas spec commit %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("looking up mongodb atlas spec commit %s: %w", sha, err) } if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha", sha) + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha", sha) } url := fmt.Sprintf(atlasSpecURLTemplate, fullSHA) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching mongodb atlas spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("fetching mongodb atlas spec %s: %w", sha, err) } if !json.Valid(body) { - return Spec{}, fmt.Errorf("mongodb atlas spec %s is not valid json", sha) + return adapter.Spec{}, fmt.Errorf("mongodb atlas spec %s is not valid json", sha) } - return Spec{Content: body, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil + return adapter.Spec{Content: body, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil } -var _ Lister = MongoDBAtlas{} +var _ adapter.Lister = MongoDBAtlas{} + +// atlasDiff is how the Atlas Administration API's spec says what it says: +// +// - Deprecations use the `deprecated` flag (53 operations on 2026-11-19). +// Fourteen operations mention "deprecated" in their description without +// it, each about the deprecated invitation flow ("This resource cannot +// be used to view details about users invited via the deprecated +// Invite One MongoDB Cloud User to Join One Project endpoint"), not the +// operation itself, so the description isn't read. +// - Matching by path template keeps a renamed path parameter from reading +// as a removal. +var atlasDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// atlasKeep keeps operation deprecations, and removals of operations the old +// spec had marked deprecated (the tenant backup operations, deprecated and +// then gone between 2025-10 and 2026-11). Everything else is dropped: +// operations that leave the spec unmarked (GET /rest/unauth/version on +// 2024-08-07: the drop test), and schema and property changes, which the +// API's own changelog (mongodb/atlas-admin-api, kind changelog) reports per +// resource version. +var atlasKeep = openapi.DeprecationsOnly(atlasDiff) diff --git a/plugins/openapi/mongodb_test.go b/providers/mongodb/atlas_admin_spec_test.go similarity index 80% rename from plugins/openapi/mongodb_test.go rename to providers/mongodb/atlas_admin_spec_test.go index 3314cea..0ef7f5d 100644 --- a/plugins/openapi/mongodb_test.go +++ b/providers/mongodb/atlas_admin_spec_test.go @@ -1,4 +1,4 @@ -package openapi +package mongodb import ( "context" @@ -10,7 +10,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // atlasDays are the saved excerpts of mongodb/openapi's openapi/v2.json @@ -27,7 +29,7 @@ func atlasURL(day string) string { } // fakeAtlasAdapter serves the saved excerpts, cited by the real URL each was -// copied from, as adapter.MongoDBAtlas.Fetch does. +// copied from, as MongoDBAtlas.Fetch does. type fakeAtlasAdapter struct{} func (fakeAtlasAdapter) API() string { return "mongodb/atlas-admin-spec" } @@ -45,12 +47,12 @@ func (fakeAtlasAdapter) Fetch(_ context.Context, day string) (adapter.Spec, erro return adapter.Spec{Content: body, Version: day, SourceURL: atlasURL(day)}, nil } -func atlasPlugin() Plugin { - return Plugin{Adapter: fakeAtlasAdapter{}, Diff: atlasDiff, Keep: atlasKeep} +func atlasPlugin() openapi.Plugin { + return openapi.Plugin{Adapter: fakeAtlasAdapter{}, Diff: atlasDiff, Keep: atlasKeep} } func TestMongoDBAtlasRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Adapter: adapter.MongoDBAtlas{}}) + kittest.Registered(t, openapi.Plugin{Adapter: MongoDBAtlas{}}) } // The golden test: on 2025-02-20 Atlas deprecated 14 user-management @@ -59,8 +61,8 @@ func TestMongoDBAtlasRegistersItself(t *testing.T) { // /users/byName/{userName}), with GET /orgs/{orgId}/users, unchanged. func TestMongoDBAtlasGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, atlasPlugin(), "2025-02-18", "2025-02-20"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, atlasPlugin(), "2025-02-18", "2025-02-20"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) @@ -83,8 +85,8 @@ func TestMongoDBAtlasGolden(t *testing.T) { // without ever being marked deprecated. No event. func TestMongoDBAtlasDropsRemovalsThatWerentDeprecated(t *testing.T) { ctx := context.Background() - s := openStore(t) - if _, err := kittest.Pair(ctx, vercelEnv(s), s, atlasPlugin(), "2024-07-25", "2024-08-07"); err != nil { + s := kittest.NewMem() + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, atlasPlugin(), "2024-07-25", "2024-08-07"); err != nil { t.Fatal(err) } if events := kittest.Stored(t, s); len(events) != 0 { diff --git a/providers/mongodb/node_surface_test.go b/providers/mongodb/node_surface_test.go new file mode 100644 index 0000000..8c2dd25 --- /dev/null +++ b/providers/mongodb/node_surface_test.go @@ -0,0 +1,25 @@ +package mongodb + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// mongodb 7.0.0 removed CancellationToken, Transaction and more. +func TestNodeSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: NodeSurface, Golden: [2]string{"6.22.0", "7.0.0"}, Want: []string{ + "removed_symbol AsyncDisposable ", + "removed_symbol CancellationToken ", + "removed_symbol ChangeStream.streamOptions ", + "removed_symbol ClientMetadata ", + "removed_symbol ClientMetadataOptions ", + "removed_symbol ClientSession.transaction ", + "removed_symbol CloseOptions ", + "removed_symbol CursorStreamOptions ", + "removed_symbol ReadPreference.minWireVersion ", + "removed_symbol ResumeOptions ", + "removed_symbol ServerCapabilities ", + "removed_symbol Transaction ", + }, Drop: [2]string{"7.0.0", "7.1.0"}}) +} diff --git a/providers/mongodb/provider.go b/providers/mongodb/provider.go new file mode 100644 index 0000000..d021bef --- /dev/null +++ b/providers/mongodb/provider.go @@ -0,0 +1,54 @@ +// Package mongodb is what patch-it reads for MongoDB: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package mongodb + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "mongodb", Name: "MongoDB", Category: plugin.CategoryDatabases, Homepage: "https://www.mongodb.com", + Sources: []plugin.Source{ + // No Hints: the Atlas changelog is its own source (mongodb/atlas-admin-api, + // kind changelog). Only operation deprecations and removals: see + // atlas_admin_spec.go. + { + ID: "atlas-admin-spec", Layer: plugin.LayerAPI, + Watches: "Atlas Administration API v2 operations deprecated, and deprecated operations removed, day by day in MongoDB's published spec", + URLs: []string{"https://github.com/mongodb/openapi/blob/main/openapi/v2.json"}, + Plugin: openapi.Plugin{Adapter: MongoDBAtlas{}, Diff: atlasDiff, Keep: atlasKeep}, + }, + { + ID: "atlas-admin-api", Layer: plugin.LayerAPI, + Watches: "Atlas Administration API versions deprecated and removed at their sunset date, per endpoint, from MongoDB's own API changelog", + URLs: []string{"https://github.com/mongodb/openapi/blob/main/changelog/changelog.json"}, + Plugin: changelog.Plugin{Log: AtlasAdminAPI}, + }, + apisurface.PyPI(PymongoSurface, plugin.LayerSDK, "https://github.com/mongodb/mongo-python-driver"), + apisurface.NPM(NodeSurface, "https://github.com/mongodb/node-mongodb-native"), + }, + }) +} + +// AtlasAdminAPI is the Atlas Administration API's changelog, +// changelog/changelog.json in mongodb/openapi (checked 2026-11-19: 188 days +// from 2023-02-01 to 2026-11-18, released by MongoDB's CI, "Release API +// Changelog", a few times a month; the docs page +// https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog/ +// is built from it). Atlas versions each resource by date (`2023-01-01`), +// chosen per request in the Accept header. +var AtlasAdminAPI = changelog.Log{ + API: "mongodb/atlas-admin-api", Vendor: "MongoDB", Name: "Atlas Administration API", + Repo: "mongodb/openapi", Path: "changelog/changelog.json", +} + +// The packages whose public API the apisurface sources read. +var ( + NodeSurface = apisurface.NPMPackage("mongodb/node-surface", "mongodb") + PymongoSurface = apisurface.Package{ID: "mongodb/pymongo-surface", Name: "pymongo", Ecosystem: "pypi", Module: "pymongo"} +) diff --git a/providers/mongodb/pymongo_surface_test.go b/providers/mongodb/pymongo_surface_test.go new file mode 100644 index 0000000..343ba73 --- /dev/null +++ b/providers/mongodb/pymongo_surface_test.go @@ -0,0 +1,17 @@ +package mongodb + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// pymongo 4.16.0's command cursors no longer take explicit_session. +func TestPymongoSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PymongoSurface, Golden: [2]string{"4.15.5", "4.16.0"}, Want: []string{ + "removed_parameter asynchronous.command_cursor.AsyncCommandCursor explicit_session", + "removed_parameter asynchronous.command_cursor.AsyncRawBatchCommandCursor explicit_session", + "removed_parameter command_cursor.CommandCursor,synchronous.command_cursor.CommandCursor explicit_session", + "removed_parameter command_cursor.RawBatchCommandCursor,synchronous.command_cursor.RawBatchCommandCursor explicit_session", + }, Drop: [2]string{"4.15.4", "4.15.5"}}) +} diff --git a/providers/mongodb/testdata/README.md b/providers/mongodb/testdata/README.md new file mode 100644 index 0000000..eaa5c74 --- /dev/null +++ b/providers/mongodb/testdata/README.md @@ -0,0 +1,26 @@ +# MongoDB: saved copies and goldens + +Real copies of what MongoDB publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/mongodb -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/pymongo/`: `pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.trimmed.whl`, `pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.trimmed.whl`, `pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.trimmed.whl` | https://files.pythonhosted.org/packages/5c/9e/5d6bd240a8d32e088078b37dcfa1579028c51d91168c0e992827ec1e87e6/pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.whl; https://files.pythonhosted.org/packages/33/e4/d80061be4e53125597dd2916171c87986043b190e50c1834fff455e71d42/pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.whl; https://files.pythonhosted.org/packages/4d/93/c36c0998dd91ad8b5031d2e77a903d5cd705b5ba05ca92bcc8731a2c3a8d/pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.whl | 2026-11-21 | Apache-2.0 (the wheel's own license files are kept in it). Trimmed: only `pymongo/__init__.py`, `pymongo/asynchronous/__init__.py`, `pymongo/asynchronous/command_cursor.py`, `pymongo/command_cursor.py`, `pymongo/synchronous/__init__.py`, `pymongo/synchronous/command_cursor.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/pymongo/`: `pypi-pymongo-excerpt.json` and `pypi-pymongo-4.15.4.json`, `pypi-pymongo-4.15.5.json`, `pypi-pymongo-4.16.0.json` | https://pypi.org/pypi/pymongo/json, https://pypi.org/pypi/pymongo/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/mongodb/`: `mongodb-6.22.0.trimmed.tgz`, `mongodb-7.0.0.trimmed.tgz`, `mongodb-7.1.0.trimmed.tgz` | https://registry.npmjs.org/mongodb/-/mongodb-6.22.0.tgz; https://registry.npmjs.org/mongodb/-/mongodb-7.0.0.tgz; https://registry.npmjs.org/mongodb/-/mongodb-7.1.0.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `mongodb.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/mongodb/`: `npm-mongodb-excerpt.json` and `npm-mongodb-6.22.0.json`, `npm-mongodb-7.0.0.json`, `npm-mongodb-7.1.0.json` | https://registry.npmjs.org/mongodb, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | + +## JSON changelogs + +Read with `Plugin{Log: ...}` (`kinds/changelog/json.go`); `golden/mongodb-atlas.json` is what it stores from the first file. + +| File | URL | Saved | License | Use | +|---|---|---|---|---| +| `mongodb-atlas-changelog-c0f99ca9.json` | https://raw.githubusercontent.com/mongodb/openapi/c0f99ca9145e5aa74d08ae4451020857e93b5f28/changelog/changelog.json (the "Release API Changelog" commit of 2026-11-18 20:15 UTC; the same file as `main` on 2026-11-19) | 2026-11-19 | Apache-2.0 (mongodb/openapi) | "endpoint with API Version '2023-01-01' was removed as it has reached its sunset date '2026-01-22'" | +| `mongodb-atlas-changelog-2026-11-18-day.json` | The same file's newest day (`2026-11-18`), kept whole and unchanged: the drop test | 2026-11-19 | Apache-2.0 (mongodb/openapi) | `"changeCode": "request-property-one-of-removed"`, `"backwardCompatible": false` | +| `log-history/commits.json`, `log-history/changelog-{1,2,3}.json` | Stand-ins for the GitHub commits list of `changelog/changelog.json` and the file at three commits, in the real file's shape | written for the test, 2026-11-20 | n/a (test fixtures) | for the pair-by-pair test only (three versions, two pairs); no golden reads them | + +**Trimmed, positions kept:** the real file is 10 MB. `mongodb-atlas-changelog-c0f99ca9.json` keeps every day, endpoint, API version and change in place. Every change the plugin doesn't read is replaced by `{}`: all but the three life-cycle codes and `endpoint-reactivated`. So is every endpoint or version left with none. So every JSON pointer in `golden/mongodb-atlas.json` names the same change in the real file. The 105 kept changes are copied unchanged. The plugin reads exactly the same 81 findings from this copy as from the real file (checked when the copy was made). The copy is re-indented. diff --git a/plugins/openapi/testdata/golden/mongodb-atlas-admin-spec.json b/providers/mongodb/testdata/golden/mongodb-atlas-admin-spec.json similarity index 100% rename from plugins/openapi/testdata/golden/mongodb-atlas-admin-spec.json rename to providers/mongodb/testdata/golden/mongodb-atlas-admin-spec.json diff --git a/plugins/changelog/testdata/golden/mongodb-atlas.json b/providers/mongodb/testdata/golden/mongodb-atlas.json similarity index 100% rename from plugins/changelog/testdata/golden/mongodb-atlas.json rename to providers/mongodb/testdata/golden/mongodb-atlas.json diff --git a/plugins/apisurface/testdata/golden/mongodb-node-surface.json b/providers/mongodb/testdata/golden/mongodb-node-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/mongodb-node-surface.json rename to providers/mongodb/testdata/golden/mongodb-node-surface.json diff --git a/plugins/apisurface/testdata/golden/mongodb-pymongo-surface.json b/providers/mongodb/testdata/golden/mongodb-pymongo-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/mongodb-pymongo-surface.json rename to providers/mongodb/testdata/golden/mongodb-pymongo-surface.json diff --git a/plugins/changelog/testdata/log-history/changelog-1.json b/providers/mongodb/testdata/log-history/changelog-1.json similarity index 100% rename from plugins/changelog/testdata/log-history/changelog-1.json rename to providers/mongodb/testdata/log-history/changelog-1.json diff --git a/plugins/changelog/testdata/log-history/changelog-2.json b/providers/mongodb/testdata/log-history/changelog-2.json similarity index 100% rename from plugins/changelog/testdata/log-history/changelog-2.json rename to providers/mongodb/testdata/log-history/changelog-2.json diff --git a/plugins/changelog/testdata/log-history/changelog-3.json b/providers/mongodb/testdata/log-history/changelog-3.json similarity index 100% rename from plugins/changelog/testdata/log-history/changelog-3.json rename to providers/mongodb/testdata/log-history/changelog-3.json diff --git a/plugins/changelog/testdata/log-history/commits.json b/providers/mongodb/testdata/log-history/commits.json similarity index 100% rename from plugins/changelog/testdata/log-history/commits.json rename to providers/mongodb/testdata/log-history/commits.json diff --git a/plugins/openapi/testdata/mongodb-atlas-2024-07-25.json b/providers/mongodb/testdata/mongodb-atlas-2024-07-25.json similarity index 100% rename from plugins/openapi/testdata/mongodb-atlas-2024-07-25.json rename to providers/mongodb/testdata/mongodb-atlas-2024-07-25.json diff --git a/plugins/openapi/testdata/mongodb-atlas-2024-08-07.json b/providers/mongodb/testdata/mongodb-atlas-2024-08-07.json similarity index 100% rename from plugins/openapi/testdata/mongodb-atlas-2024-08-07.json rename to providers/mongodb/testdata/mongodb-atlas-2024-08-07.json diff --git a/plugins/openapi/testdata/mongodb-atlas-2025-02-18.json b/providers/mongodb/testdata/mongodb-atlas-2025-02-18.json similarity index 100% rename from plugins/openapi/testdata/mongodb-atlas-2025-02-18.json rename to providers/mongodb/testdata/mongodb-atlas-2025-02-18.json diff --git a/plugins/openapi/testdata/mongodb-atlas-2025-02-20.json b/providers/mongodb/testdata/mongodb-atlas-2025-02-20.json similarity index 100% rename from plugins/openapi/testdata/mongodb-atlas-2025-02-20.json rename to providers/mongodb/testdata/mongodb-atlas-2025-02-20.json diff --git a/plugins/changelog/testdata/mongodb-atlas-changelog-2026-11-18-day.json b/providers/mongodb/testdata/mongodb-atlas-changelog-2026-11-18-day.json similarity index 100% rename from plugins/changelog/testdata/mongodb-atlas-changelog-2026-11-18-day.json rename to providers/mongodb/testdata/mongodb-atlas-changelog-2026-11-18-day.json diff --git a/plugins/changelog/testdata/mongodb-atlas-changelog-c0f99ca9.json b/providers/mongodb/testdata/mongodb-atlas-changelog-c0f99ca9.json similarity index 100% rename from plugins/changelog/testdata/mongodb-atlas-changelog-c0f99ca9.json rename to providers/mongodb/testdata/mongodb-atlas-changelog-c0f99ca9.json diff --git a/plugins/apisurface/testdata/npm/mongodb/mongodb-6.22.0.trimmed.tgz b/providers/mongodb/testdata/npm/mongodb/mongodb-6.22.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/mongodb-6.22.0.trimmed.tgz rename to providers/mongodb/testdata/npm/mongodb/mongodb-6.22.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/mongodb/mongodb-7.0.0.trimmed.tgz b/providers/mongodb/testdata/npm/mongodb/mongodb-7.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/mongodb-7.0.0.trimmed.tgz rename to providers/mongodb/testdata/npm/mongodb/mongodb-7.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/mongodb/mongodb-7.1.0.trimmed.tgz b/providers/mongodb/testdata/npm/mongodb/mongodb-7.1.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/mongodb-7.1.0.trimmed.tgz rename to providers/mongodb/testdata/npm/mongodb/mongodb-7.1.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/mongodb/npm-mongodb-6.22.0.json b/providers/mongodb/testdata/npm/mongodb/npm-mongodb-6.22.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/npm-mongodb-6.22.0.json rename to providers/mongodb/testdata/npm/mongodb/npm-mongodb-6.22.0.json diff --git a/plugins/apisurface/testdata/npm/mongodb/npm-mongodb-7.0.0.json b/providers/mongodb/testdata/npm/mongodb/npm-mongodb-7.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/npm-mongodb-7.0.0.json rename to providers/mongodb/testdata/npm/mongodb/npm-mongodb-7.0.0.json diff --git a/plugins/apisurface/testdata/npm/mongodb/npm-mongodb-7.1.0.json b/providers/mongodb/testdata/npm/mongodb/npm-mongodb-7.1.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/npm-mongodb-7.1.0.json rename to providers/mongodb/testdata/npm/mongodb/npm-mongodb-7.1.0.json diff --git a/plugins/apisurface/testdata/npm/mongodb/npm-mongodb-excerpt.json b/providers/mongodb/testdata/npm/mongodb/npm-mongodb-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/mongodb/npm-mongodb-excerpt.json rename to providers/mongodb/testdata/npm/mongodb/npm-mongodb-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/pymongo/pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.trimmed.whl b/providers/mongodb/testdata/pypi/pymongo/pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.trimmed.whl rename to providers/mongodb/testdata/pypi/pymongo/pymongo-4.15.4-cp310-cp310-macosx_10_9_x86_64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/pymongo/pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.trimmed.whl b/providers/mongodb/testdata/pypi/pymongo/pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.trimmed.whl rename to providers/mongodb/testdata/pypi/pymongo/pymongo-4.15.5-cp310-cp310-macosx_10_9_x86_64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/pymongo/pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.trimmed.whl b/providers/mongodb/testdata/pypi/pymongo/pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.trimmed.whl rename to providers/mongodb/testdata/pypi/pymongo/pymongo-4.16.0-cp310-cp310-macosx_10_9_x86_64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-4.15.4.json b/providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-4.15.4.json similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-4.15.4.json rename to providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-4.15.4.json diff --git a/plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-4.15.5.json b/providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-4.15.5.json similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-4.15.5.json rename to providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-4.15.5.json diff --git a/plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-4.16.0.json b/providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-4.16.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-4.16.0.json rename to providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-4.16.0.json diff --git a/plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-excerpt.json b/providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/pymongo/pypi-pymongo-excerpt.json rename to providers/mongodb/testdata/pypi/pymongo/pypi-pymongo-excerpt.json diff --git a/providers/neon-serverless-surface.md b/providers/neon-serverless-surface.md deleted file mode 100644 index acccd1c..0000000 --- a/providers/neon-serverless-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# Neon serverless driver (`neon/serverless-surface`) - -## What it watches - -The public API of the `@neondatabase/serverless` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @neondatabase/serverless@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md. -- **Quote:** `export { native } from "pg"` (`index.d.mts` line 8) at 0.10.4, gone at 1.0.0. - -## How the provider announces changes - -- The driver is one declaration file per module format; its `Pool` and `Client` extend `pg`'s, whose members aren't read. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@neondatabase/serverless.neon`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- Members inherited from `pg` aren't read: a method gone from `Pool` is a note (pg may define it). diff --git a/providers/neon.md b/providers/neon/README.md similarity index 58% rename from providers/neon.md rename to providers/neon/README.md index e6e03b1..7905541 100644 --- a/providers/neon.md +++ b/providers/neon/README.md @@ -1,12 +1,16 @@ -# Neon (`neon/api`) +# Neon -## What it watches +Every source patch-it reads for Neon, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Neon (`neon/api`) + +### What it watches The Neon API (`console.neon.tech/api/v2`), the management API for Neon projects, branches, computes, databases and roles: operations Neon marks deprecated, and removals of operations it had marked deprecated, between two versions of the API's OpenAPI spec. -Kind: `openapi` (`plugins/openapi`), with `adapter.Neon`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `Neon` ([`api.go`](api.go)). -## Why this source +### Why this source - **Source:** `packages/sdk/spec/neon-openapi.json` in [neondatabase/neon-pkgs](https://github.com/neondatabase/neon-pkgs), pinned to the commit that last changed it (`https://raw.githubusercontent.com/neondatabase/neon-pkgs//packages/sdk/spec/neon-openapi.json`). The newest such commit comes from the GitHub commits API. Checked on 2026-11-19. - **Why this one:** @@ -20,7 +24,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Neon`. - **The SDKs** (`@neon/sdk`, `@neondatabase/serverless`, the `neon-api` Python package). Their changelogs don't list removed API operations in a form to read. - **Quote:** "Deprecated: to test a branch's already-saved configuration, use `sendNeonAuthEmailProviderTest`" (`POST /projects/{project_id}/branches/{branch_id}/auth/send_test_email`, deprecated in the spec on 2026-08-23) -## How the provider announces changes +### How the provider announces changes - **Operations are named by the path a caller sends,** `POST /api/v2/projects/…`: the spec's server is `https://console.neon.tech/api/v2` and its paths leave out `/api/v2`, so the adapter moves it into the paths (as Sentry's does with `/api/0`). Quotes cite the spec as published. If Neon ever moves `/api/v2` between the server and the paths, the operations stay the same, rather than every deprecated one reading as removed. - **No API version beyond `/api/v2`.** `info.version` is `v2` in all 23 commits, so the event's `version` is the date of the spec commit, the closest thing to the API version a change arrived in. @@ -29,7 +33,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Neon`. - **Sunset dates aren't removal dates.** On 2026-11-17, 14 operations say "Removal scheduled for March 1, 2026" (`x-sunset` 2026-03-01) and one "Removal scheduled for July 1, 2026", and all 15 are still in the spec, the live one included (checked 2026-11-19). - **The changelog announces API deprecations and removals in prose:** `GET /consumption_history/account` was "deprecated, with a planned sunset of June 1, 2026" (2026-04-03) and "has been removed" (2026-06-19). -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** the spec at the newest commit, diffed against the last one. Two events come out of it: - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so Neon's reason and its `x-sunset` date are in the excerpt. @@ -43,7 +47,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Neon`. - **Reads** a historical pair (a version pair, `5c57d009` → `93b93dc9`) and recreates that deprecation (the golden test). The drop test replays `4c6b3be4` to `4497de89`, the `recover` removal. - **A kept removal:** none happened in neon-pkgs's history, so a test replays the same spec from `@neondatabase/api-client` 2.7.2 to 2.7.3 (a different source, used only for this test): `GET /consumption_history/account`, deprecated and then removed, the removal Neon's changelog announced. That's one breaking event. -## Known gaps +### Known gaps - **Removals Neon didn't mark first aren't events,** even if the endpoint really went away. - **A sunset date that passes isn't an event.** The 15 operations past their "Removal scheduled" date are reported once, when they were deprecated, and again only if they leave the spec. @@ -52,3 +56,41 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Neon`. - **Only the management API is covered,** not the serverless driver (`@neondatabase/serverless`) or the Data API. - **Two spec commits on one day are one version,** read at the day's last commit: the event's `version` is a day. - **The patch-it client needs `neon` in its list of date-versioned APIs.** The events' `version` is a date (`2026-08-23`), because the API has no version; without the entry, the client reads it as a package version and can't place these events. That list is in the client used by patch-it's hosted ingestion service, not in this repo. + +## Neon serverless driver (`neon/serverless-surface`) + +### What it watches + +The public API of the `@neondatabase/serverless` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @neondatabase/serverless@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md. +- **Quote:** `export { native } from "pg"` (`index.d.mts` line 8) at 0.10.4, gone at 1.0.0. + +### How the provider announces changes + +- The driver is one declaration file per module format; its `Pool` and `Client` extend `pg`'s, whose members aren't read. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@neondatabase/serverless.neon`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- Members inherited from `pg` aren't read: a method gone from `Pool` is a note (pg may define it). diff --git a/providers/neon/api.go b/providers/neon/api.go new file mode 100644 index 0000000..4f914eb --- /dev/null +++ b/providers/neon/api.go @@ -0,0 +1,127 @@ +package neon + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/patch-it-dev/patch-it-plugins/core/diff" + "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" +) + +// Variables, not constants, only so tests can point them at a local server. +var ( + // neonCommitsURL lists the commits that changed the Neon API spec in + // neondatabase/neon-pkgs, newest first; with per_page=1, the newest. + neonCommitsURL = "https://api.github.com/repos/neondatabase/neon-pkgs/commits?path=packages/sdk/spec/neon-openapi.json&per_page=1" + // neonCommitURL is one commit, for its date. + neonCommitURL = "https://api.github.com/repos/neondatabase/neon-pkgs/commits/%s" + // neonSpecURLTemplate is the Neon API spec (console.neon.tech/api/v2) at + // one commit. Neon serves it live at + // https://neon.com/api_spec/release/v2.json, which has no versions; the + // copy in neondatabase/neon-pkgs is pulled from there and committed when + // a daily drift check sees it change (23 commits from 2026-06-24 to + // 2026-11-17), and a commit never changes. + neonSpecURLTemplate = "https://raw.githubusercontent.com/neondatabase/neon-pkgs/%s/packages/sdk/spec/neon-openapi.json" +) + +// Neon adapts the Neon API spec in neondatabase/neon-pkgs for the openapi +// plugin. The repo tags no spec releases, so a tag here is the commit that +// last changed the spec. +type Neon struct{} + +var _ adapter.Adapter = Neon{} + +func (Neon) API() string { return "neon/api" } + +// LatestTag is the SHA of the newest commit that changed the spec. +func (Neon) LatestTag(ctx context.Context) (string, error) { + sha, err := github.LatestCommit(ctx, github.Get, neonCommitsURL) + if err != nil { + return "", fmt.Errorf("looking up neon's latest spec commit: %w", err) + } + return sha, nil +} + +// Fetch downloads the spec at commit sha and moves the server URL's path into +// the paths: see ServerBasePath. +// +// Version is the commit's date (YYYY-MM-DD): the API's only version is the +// `/api/v2` in its URL (info.version a fixed "v2" in all 23 commits, checked +// 2026-11-19), so the date the spec changed is the closest thing to "the API +// version the change arrived in". +func (Neon) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { + fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(neonCommitURL, sha)) + if err != nil { + return adapter.Spec{}, fmt.Errorf("looking up neon spec commit %s: %w", sha, err) + } + if fullSHA == "" { + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) + } + // Pin to the full SHA even when given a short one: the citation must + // name exactly one document. + url := fmt.Sprintf(neonSpecURLTemplate, fullSHA) + body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth + if err != nil { + return adapter.Spec{}, fmt.Errorf("fetching neon spec %s: %w", sha, err) + } + if !json.Valid(body) { + return adapter.Spec{}, fmt.Errorf("neon spec %s is not valid json", sha) + } + // The server is "https://console.neon.tech/api/v2" and the paths don't + // repeat /api/v2 (all 23 commits, checked 2026-11-19). Moved into the + // paths, an operation is named by the path a caller sends, and a spec + // that ever moved it (as Sentry's did) can't read as every deprecated + // operation removed. + content, err := adapter.ServerBasePath(body) + if err != nil { + return adapter.Spec{}, fmt.Errorf("neon spec %s: %w", sha, err) + } + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil +} + +// SourcePointer: see BasePathPointer. +func (Neon) SourcePointer(content []byte) func(string) string { + return adapter.BasePathPointer(content) +} + +var _ adapter.Reshaper = Neon{} + +// Versions are the commits that changed Neon's spec. +func (Neon) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Commits(ctx, "neondatabase/neon-pkgs", "packages/sdk/spec/neon-openapi.json") +} + +// neonDiff is how the Neon API spec says what it says: +// +// - Deprecations use the `deprecated` flag, and only the flag: in the 23 +// commits of neondatabase/neon-pkgs's copy (2026-06-24 to 2026-11-17) no +// operation is described as deprecated without it. (Two unflagged +// operations deprecate a parameter in words; those aren't operation +// deprecations.) +// A flagged operation's description says why or when ("Deprecated: to +// test a branch's already-saved configuration, use +// `sendNeonAuthEmailProviderTest`", "Removal scheduled for March 1, +// 2026"), and every one carries an `x-sunset` date, so the event quotes +// the whole operation, not the bare `true`. +// - Path parameters could be renamed without the URL changing; none was in +// this history, but matching by path template costs nothing here and +// keeps a rename from reading as a removal. +var neonDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// neonKeep keeps operation deprecations, and removals of operations the old +// spec had marked deprecated. In the spec's history that's 1 event: POST +// /projects/{project_id}/branches/{branch_id}/auth/send_test_email, +// deprecated on 2026-08-23. Everything else is dropped: +// +// - One operation left the spec, not deprecated first: POST +// /projects/{project_id}/branches/{branch_id}/recover on 2026-08-09. +// neon-pkgs's own PR for it (#408) says it "was not removed from the API. +// It was removed from the published spec": it still routes. +// - Request and response property changes, new operations: not changes a +// caller has to fix, or not ones the spec's history shows reliably. +var neonKeep = openapi.DeprecationsOnly(neonDiff) diff --git a/plugins/openapi/adapter/neon_test.go b/providers/neon/api_fetch_test.go similarity index 99% rename from plugins/openapi/adapter/neon_test.go rename to providers/neon/api_fetch_test.go index 545b6d7..4068e86 100644 --- a/plugins/openapi/adapter/neon_test.go +++ b/providers/neon/api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package neon import ( "context" diff --git a/plugins/openapi/neon_test.go b/providers/neon/api_test.go similarity index 85% rename from plugins/openapi/neon_test.go rename to providers/neon/api_test.go index 09ed7e0..df877a7 100644 --- a/plugins/openapi/neon_test.go +++ b/providers/neon/api_test.go @@ -1,4 +1,4 @@ -package openapi +package neon import ( "context" @@ -12,7 +12,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // neonCommits are the spec commits saved under testdata/ (trimmed to the @@ -27,7 +29,7 @@ var neonCommits = map[string][2]string{ } // fakeNeonAdapter serves the saved copies, cited by the real URL each was -// copied from and reshaped, as adapter.Neon.Fetch cites and reshapes it. +// copied from and reshaped, as Neon.Fetch cites and reshapes it. type fakeNeonAdapter struct{ latest string } func (fakeNeonAdapter) API() string { return "neon/api" } @@ -43,7 +45,7 @@ func (fakeNeonAdapter) Fetch(_ context.Context, tag string) (adapter.Spec, error if err != nil { return adapter.Spec{}, err } - // As adapter.Neon.Fetch does: /api/v2 moved from the server URL into the + // As Neon.Fetch does: /api/v2 moved from the server URL into the // paths. content, err := adapter.ServerBasePath(body) if err != nil { @@ -63,8 +65,8 @@ func neonURL(tag string) string { } // neonPlugin is the plugin exactly as registered, over the given adapter. -func neonPlugin(a adapter.Adapter) Plugin { - return Plugin{Adapter: a, Diff: neonDiff, Keep: neonKeep} +func neonPlugin(a adapter.Adapter) openapi.Plugin { + return openapi.Plugin{Adapter: a, Diff: neonDiff, Keep: neonKeep} } // The golden test, the pair fixture: the one operation Neon deprecated in @@ -76,8 +78,8 @@ func neonPlugin(a adapter.Adapter) Plugin { // .../auth/email_server, deprecated in both, is no new event. func TestNeonGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, neonPlugin(fakeNeonAdapter{}), "5c57d009", "93b93dc9"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, neonPlugin(fakeNeonAdapter{}), "5c57d009", "93b93dc9"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) @@ -98,7 +100,7 @@ func TestNeonGolden(t *testing.T) { t.Errorf("source_url %s", e.SourceURL) } // The whole operation is quoted, so the reason and the sunset are in it. - if node := jsonNode(t, neonFile("93b93dc9"), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, neonFile("93b93dc9"), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("excerpt doesn't match 93b93dc9#%s", e.SourcePointer) } for _, want := range []string{`"deprecated":true`, "use `sendNeonAuthEmailProviderTest`", `"x-sunset":"2027-02-28"`} { @@ -116,18 +118,18 @@ func TestNeonGolden(t *testing.T) { // event. func TestNeonDropsRemovalsThatWerentDeprecated(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, neonPlugin(fakeNeonAdapter{}), "4c6b3be4", "4497de89"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, neonPlugin(fakeNeonAdapter{}), "4c6b3be4", "4497de89"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { t.Fatalf("stored %d events, want none", len(events)) } // Without the filter the same pair reports the removal. - s = openStore(t) + s = kittest.NewMem() p := neonPlugin(fakeNeonAdapter{}) p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "4c6b3be4", "4497de89"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "4c6b3be4", "4497de89"); err != nil { t.Fatal(err) } var removals []string @@ -169,7 +171,7 @@ func (neonAPIClient) Fetch(_ context.Context, version string) (adapter.Spec, err if err != nil { return adapter.Spec{}, err } - if content, err = adapter.ServerBasePath(content); err != nil { // as adapter.Neon.Fetch does + if content, err = adapter.ServerBasePath(content); err != nil { // as Neon.Fetch does return adapter.Spec{}, err } return adapter.Spec{Content: content, Version: version, SourceURL: "https://registry.npmjs.org/@neondatabase/api-client/-/api-client-" + version + ".tgz"}, nil @@ -177,8 +179,8 @@ func (neonAPIClient) Fetch(_ context.Context, version string) (adapter.Spec, err func TestNeonKeepsTheRemovalOfADeprecatedOperation(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, neonPlugin(neonAPIClient{}), "2.7.2", "2.7.3"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, neonPlugin(neonAPIClient{}), "2.7.2", "2.7.3"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) diff --git a/providers/neon/provider.go b/providers/neon/provider.go new file mode 100644 index 0000000..4f2353f --- /dev/null +++ b/providers/neon/provider.go @@ -0,0 +1,33 @@ +// Package neon is what patch-it reads for Neon: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package neon + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "neon", Name: "Neon", Category: plugin.CategoryDatabases, Homepage: "https://neon.com", + Sources: []plugin.Source{ + // No Hints: Neon's changelog is a weekly digest, not keyed by operation. + // Only operation deprecations and removals: see api.go. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "Neon API operations deprecated, and deprecated operations removed, between commits of the spec", + URLs: []string{"https://github.com/neondatabase/neon-pkgs"}, + Packages: []string{"npm:@neondatabase/api-client"}, + Plugin: openapi.Plugin{Adapter: Neon{}, Diff: neonDiff, Keep: neonKeep}, + }, + apisurface.NPM(ServerlessSurface, "https://github.com/neondatabase/serverless"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + ServerlessSurface = apisurface.NPMPackage("neon/serverless-surface", "@neondatabase/serverless") +) diff --git a/providers/neon/serverless_surface_test.go b/providers/neon/serverless_surface_test.go new file mode 100644 index 0000000..021f208 --- /dev/null +++ b/providers/neon/serverless_surface_test.go @@ -0,0 +1,15 @@ +package neon + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// @neondatabase/serverless 1.0.0 dropped ClientBase.neonConfig and the +// native export; Pool.connect, gone from Pool, is pg's base class's. +func TestServerlessSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: ServerlessSurface, Golden: [2]string{"0.10.4", "1.0.0"}, Want: []string{ + "removed_symbol native ", + }, Drop: [2]string{"1.0.0", "1.0.1"}}) +} diff --git a/providers/neon/testdata/README.md b/providers/neon/testdata/README.md new file mode 100644 index 0000000..f866dce --- /dev/null +++ b/providers/neon/testdata/README.md @@ -0,0 +1,24 @@ +# Neon: saved copies and goldens + +Real copies of what Neon publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/neon -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `neon-5c57d009.json`, `neon-93b93dc9.json` | https://raw.githubusercontent.com/neondatabase/neon-pkgs/5c57d0095a9a4594a3c8b09d499b132902e7c42e/packages/sdk/spec/neon-openapi.json (and `93b93dc9e4d1b4ab48dac6c8ccba76b35541b476`) | 2026-11-19 | Excerpt for testing; © Neon. neondatabase/neon-pkgs is Apache-2.0, but the spec's own `info.license` says "Proprietary" | "Deprecated: to test a branch's already-saved configuration, use `sendNeonAuthEmailProviderTest`" (`POST /projects/{project_id}/branches/{branch_id}/auth/send_test_email`, new in `93b93dc9`) | +| `neon-4c6b3be4.json`, `neon-4497de89.json` | https://raw.githubusercontent.com/neondatabase/neon-pkgs/4c6b3be46b1b333e7f910db51218ad144de27179/packages/sdk/spec/neon-openapi.json (and `4497de89a5e84b38956fde686d271f99317b8fdb`) | 2026-11-19 | Excerpt for testing; © Neon. neondatabase/neon-pkgs is Apache-2.0, but the spec's own `info.license` says "Proprietary" | `"/projects/{project_id}/branches/{branch_id}/recover": {` (in `4c6b3be4`, gone in `4497de89` without being deprecated): the drop test | +| `neon-api-client-2.7.2.yaml`, `neon-api-client-2.7.3.yaml` | `public-v2-for-users.gen.yaml` in https://registry.npmjs.org/@neondatabase/api-client/-/api-client-2.7.2.tgz (and `api-client-2.7.3.tgz`) | 2026-11-19 | Excerpt for testing; © Neon. The package is MIT, but the spec's own `info.license` says "Proprietary" | "**Deprecated.** Use `GET /consumption_history/projects` (`getConsumptionHistoryPerProject`)" (`GET /consumption_history/account`, in 2.7.2, gone in 2.7.3) | + +The Neon copies are excerpts, not whole files: the spec says its license is "Proprietary" whatever the license of the repo or package that ships it. The JSON copies keep `openapi`, `servers`, `info` (without its `contact`) and the path items involved, whole and in their original order, every line copied unchanged (bar the trailing comma after a member that's now last); `components` left out. The YAML copies keep, by lines, `openapi`, `servers`, `info`'s `title`, `version` and `license`, and the path items involved; they're a different source from the plugin's (the npm package @neondatabase/api-client, succeeded by @neon/sdk and not released since 2.7.3), used only to check that the removal of an operation marked deprecated is kept. + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `npm/neondatabase-serverless/`: `serverless-0.10.4.trimmed.tgz`, `serverless-1.0.0.trimmed.tgz`, `serverless-1.0.1.trimmed.tgz` | https://registry.npmjs.org/@neondatabase/serverless/-/serverless-0.10.4.tgz; https://registry.npmjs.org/@neondatabase/serverless/-/serverless-1.0.0.tgz; https://registry.npmjs.org/@neondatabase/serverless/-/serverless-1.0.1.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `index.d.mts`, `index.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/neondatabase-serverless/`: `npm-neondatabase-serverless-excerpt.json` and `npm-neondatabase-serverless-0.10.4.json`, `npm-neondatabase-serverless-1.0.0.json`, `npm-neondatabase-serverless-1.0.1.json` | https://registry.npmjs.org/@neondatabase%2Fserverless, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/apisurface/testdata/golden/neon-serverless-surface.json b/providers/neon/testdata/golden/neon-serverless-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/neon-serverless-surface.json rename to providers/neon/testdata/golden/neon-serverless-surface.json diff --git a/plugins/openapi/testdata/golden/neon.json b/providers/neon/testdata/golden/neon.json similarity index 100% rename from plugins/openapi/testdata/golden/neon.json rename to providers/neon/testdata/golden/neon.json diff --git a/plugins/openapi/testdata/neon-4497de89.json b/providers/neon/testdata/neon-4497de89.json similarity index 100% rename from plugins/openapi/testdata/neon-4497de89.json rename to providers/neon/testdata/neon-4497de89.json diff --git a/plugins/openapi/testdata/neon-4c6b3be4.json b/providers/neon/testdata/neon-4c6b3be4.json similarity index 100% rename from plugins/openapi/testdata/neon-4c6b3be4.json rename to providers/neon/testdata/neon-4c6b3be4.json diff --git a/plugins/openapi/testdata/neon-5c57d009.json b/providers/neon/testdata/neon-5c57d009.json similarity index 100% rename from plugins/openapi/testdata/neon-5c57d009.json rename to providers/neon/testdata/neon-5c57d009.json diff --git a/plugins/openapi/testdata/neon-93b93dc9.json b/providers/neon/testdata/neon-93b93dc9.json similarity index 100% rename from plugins/openapi/testdata/neon-93b93dc9.json rename to providers/neon/testdata/neon-93b93dc9.json diff --git a/plugins/openapi/testdata/neon-api-client-2.7.2.yaml b/providers/neon/testdata/neon-api-client-2.7.2.yaml similarity index 100% rename from plugins/openapi/testdata/neon-api-client-2.7.2.yaml rename to providers/neon/testdata/neon-api-client-2.7.2.yaml diff --git a/plugins/openapi/testdata/neon-api-client-2.7.3.yaml b/providers/neon/testdata/neon-api-client-2.7.3.yaml similarity index 100% rename from plugins/openapi/testdata/neon-api-client-2.7.3.yaml rename to providers/neon/testdata/neon-api-client-2.7.3.yaml diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-0.10.4.json b/providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-0.10.4.json similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-0.10.4.json rename to providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-0.10.4.json diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.0.json b/providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.0.json rename to providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.0.json diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.1.json b/providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.1.json similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.1.json rename to providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-1.0.1.json diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-excerpt.json b/providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-excerpt.json rename to providers/neon/testdata/npm/neondatabase-serverless/npm-neondatabase-serverless-excerpt.json diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/serverless-0.10.4.trimmed.tgz b/providers/neon/testdata/npm/neondatabase-serverless/serverless-0.10.4.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/serverless-0.10.4.trimmed.tgz rename to providers/neon/testdata/npm/neondatabase-serverless/serverless-0.10.4.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/serverless-1.0.0.trimmed.tgz b/providers/neon/testdata/npm/neondatabase-serverless/serverless-1.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/serverless-1.0.0.trimmed.tgz rename to providers/neon/testdata/npm/neondatabase-serverless/serverless-1.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/neondatabase-serverless/serverless-1.0.1.trimmed.tgz b/providers/neon/testdata/npm/neondatabase-serverless/serverless-1.0.1.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/neondatabase-serverless/serverless-1.0.1.trimmed.tgz rename to providers/neon/testdata/npm/neondatabase-serverless/serverless-1.0.1.trimmed.tgz diff --git a/providers/newrelic.md b/providers/newrelic/README.md similarity index 92% rename from providers/newrelic.md rename to providers/newrelic/README.md index a014f70..0efae68 100644 --- a/providers/newrelic.md +++ b/providers/newrelic/README.md @@ -1,12 +1,16 @@ -# New Relic (`newrelic/python-agent`) +# New Relic -## What it watches +Every source patch-it reads for New Relic, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## New Relic (`newrelic/python-agent`) + +### What it watches Functions and classes a new major of New Relic's Python agent (the `newrelic` package) removes, from the major's release notes: in 11.0.0, `newrelic.agent.record_exception`, `newrelic.agent.add_custom_parameter`, `newrelic.api.log.NewRelicLogHandler`, and others. Code that uses one breaks on the upgrade. One event per member, with the major's first release as `version` and the release before it on PyPI as `previous_version`. The releases are listed from PyPI (yanked ones included: 11.0.0 is yanked); nothing in the code names a release or a commit. -Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members reader (`plugins/migrationguide/members`), reading a Markdown table. +Kind: `migrationguide` (`kinds/migrationguide`), with the removed-members reader (`kinds/migrationguide/members`), reading a Markdown table. -## Why this source +### Why this source - **Source:** `python-agent-0000.mdx` in newrelic/docs-website (9.0.0 to 13.0.0 are there, checked 2026-11-20), for each major's first release. The repo has no tags, so the plugin asks GitHub for the newest commit that changed the note and reads the raw file at that commit. 11.0.0's, [`python-agent-110000.mdx`](https://github.com/newrelic/docs-website/blob/f0b4f817bf9a7b76a78e26609369a8a7ce764c8e/src/content/docs/release-notes/agent-release-notes/python-release-notes/python-agent-110000.mdx) at commit `f0b4f817` (2026-04-22), is the one checked on 2026-11-19. A note with no "Removed features" section, or no note, has nothing to read (the pair is skipped). © New Relic, CC BY-NC-SA 4.0. - **Why this one:** these are New Relic's own release notes for the agent's 11.0.0. Their "Removed features" section has a table of the APIs that 11.0.0 removed, with what to use instead. A commit never changes, so the URL is its own citation. 11.0.0 is a version a repo pins. @@ -20,13 +24,13 @@ Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members read - **The Node.js agent's release notes** (newrelic/node-newrelic `NEWS.md`): it removed only 1 public API method in its last 8 majors, from v6.0.0 to v14.0.0 (`setIgnoreTransaction`, in v7.0.0). That's not enough to justify a plugin. - **Quote:** "The following APIs have been removed:" (Removed features), with rows such as "| `add_custom_parameter` | [`add_custom_attribute`](/docs/apm/agents/python-agent/python-agent-api/addcustomattribute-python-agent-api) |". -## How the provider announces changes +### How the provider announces changes - Package versions (SemVer). The Python agent releases about monthly. 11.0.0 shipped on 2025-09-25 and was yanked from PyPI ("Issues with server-side configuration"). 11.0.1 (2025-10-06) has the same public API: `newrelic/agent.py` and `newrelic/api/log.py` are byte-identical at v11.0.0 and v11.0.1. The events say 11.0.0, the release that made the change. - **Forced on a fresh install** for an unpinned or open pin (`newrelic>=10`), otherwise when the team upgrades. - Removals are deprecated first. At v10.17.0 every removed function warns with a `DeprecationWarning`; for the two distributed-trace functions the warning is in the `Transaction` method, so it fires only inside a transaction. -## What the plugin reads and ignores +### What the plugin reads and ignores - It reads the first table under "Removed features", `| Legacy API | Replacement API |`. The table writes names bare. The plugin writes them as code reaches them after `import newrelic`: `agent.record_exception` (the functions were re-exported by `newrelic.agent`) and `api.log.NewRelicLogHandler` (never in `newrelic.agent`). - It emits `renamed_symbol` only for a drop-in replacement, because the patch-it client applies a rename as is. A drop-in has the same arguments and behavior and already existed in `newrelic.agent` at v10.17.0 (the `DropIns` field). Every other row is a `removed_symbol`, with the "Replacement API" cell in the hint. The plugin reads a replacement written as a Markdown link around a code span (`[`name`](url)`) as that name. The 8 rows, checked against the agent's code (newrelic/newrelic-python-agent, Apache-2.0) at v10.17.0 and v11.0.0: @@ -45,7 +49,7 @@ Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members read That gives 7 events. - It ignores the section's second table, `| Legacy Setting | Replacement Setting |`. It lists `newrelic.ini` settings, not package members, and it isn't the section's first table. It also ignores the rest of the note: the "Deprecated features" settings, Python 3.7 support, and the new instrumentation. -## Known gaps +### Known gaps - **`lambda_handler` and `LambdaHandlerWrapper`** were both in `newrelic.agent` at v10.17.0 and are gone at v11.0.0, along with `newrelic/api/lambda_handler.py`. They get no event (see above). - **The same functions reached another way** get no event: the `newrelic.api.transaction` and `newrelic.api.time_trace` definitions, and the methods of the same names on `Transaction` (`add_custom_parameter`, `record_exception`…). All were removed in 11.0.0 too. diff --git a/plugins/migrationguide/members/newrelic.go b/providers/newrelic/provider.go similarity index 82% rename from plugins/migrationguide/members/newrelic.go rename to providers/newrelic/provider.go index 13bfff3..38a693c 100644 --- a/plugins/migrationguide/members/newrelic.go +++ b/providers/newrelic/provider.go @@ -1,6 +1,30 @@ -package members +// Package newrelic is what patch-it reads for New Relic: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package newrelic -// NewRelic is New Relic's release note for each major of the Python agent +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "newrelic", Name: "New Relic", Category: plugin.CategoryMonitoring, Homepage: "https://newrelic.com", + Sources: []plugin.Source{ + { + ID: "python-agent", Layer: plugin.LayerSDK, + Watches: "Members a new major of the New Relic Python agent removes, from the major's release notes (Removed features)", + URLs: []string{"https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes/", "https://pypi.org/project/newrelic/"}, + Packages: []string{"pypi:newrelic"}, + Plugin: migrationguide.Plugin{Guide: PythonAgent}, + }, + }, + }) +} + +// PythonAgent is New Relic's release note for each major of the Python agent // (the `newrelic` package on PyPI), in newrelic/docs-website as // python-agent-0000.mdx (python-agent-110000.mdx for 11.0.0; 9.0.0 // to 13.0.0 are there, checked 2026-11-20). That repo has no tags, so the @@ -68,7 +92,7 @@ package members // Paths and DropIns were checked against 11.0.0's table. A later major's // rows with one replacement are removed_symbol unless listed in DropIns, so // a new note is read conservatively. -var NewRelic = Guide{ +var PythonAgent = members.Guide{ API: "newrelic/python-agent", Package: "newrelic", Module: "newrelic", @@ -76,7 +100,7 @@ var NewRelic = Guide{ Repo: "newrelic/docs-website", Path: "src/content/docs/release-notes/agent-release-notes/python-release-notes/python-agent-{major}0000.mdx", Section: "Removed features", - Format: FormatMarkdown, + Format: members.FormatMarkdown, Header: "Legacy API", Doc: "release notes", // The cells link to docs.newrelic.com by path ("/docs/agents/…"). diff --git a/plugins/migrationguide/members/newrelic_test.go b/providers/newrelic/python_agent_test.go similarity index 60% rename from plugins/migrationguide/members/newrelic_test.go rename to providers/newrelic/python_agent_test.go index 4be8e3e..2dcded9 100644 --- a/plugins/migrationguide/members/newrelic_test.go +++ b/providers/newrelic/python_agent_test.go @@ -1,17 +1,19 @@ -package members_test +package newrelic import ( - "os" - "path/filepath" + "context" + "errors" "slices" "strings" "testing" "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide" - . "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" // the reader under test + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/migrationguidetest" ) // An excerpt of the release note at commit f0b4f817 (fetched 2026-11-19): the @@ -19,12 +21,12 @@ import ( const newrelicSource = "testdata/python-agent-110000-f0b4f817.mdx" func TestNewRelicRegistersItself(t *testing.T) { - kittest.Registered(t, migrationguide.Plugin{Guide: NewRelic}) + kittest.Registered(t, migrationguide.Plugin{Guide: PythonAgent}) } // The golden test: the saved excerpt in, every event out. func TestNewRelicGolden(t *testing.T) { - kittest.Golden(t, "../testdata/golden/newrelic-11.0.0.json", newrelicIngest(t)) + kittest.Golden(t, "testdata/golden/newrelic-11.0.0.json", newrelicIngest(t)) } // Each of the "Legacy API" table's 8 rows, decided: a rename only for the two @@ -81,7 +83,7 @@ func TestNewRelicEachRowOfTheTable(t *testing.T) { } // Every DropIns entry is a member the table removes: a typo would quietly // turn its rename into a removal. - for _, d := range NewRelic.DropIns { + for _, d := range PythonAgent.DropIns { if got[d].change != event.PackageRenamedSymbol { t.Errorf("DropIns %q: not a rename (%+v)", d, got[d]) } @@ -101,7 +103,7 @@ func TestNewRelicDropsWhatIsNotARemovedMember(t *testing.T) { page := string(kittest.Read(t, newrelicSource)) // The lambda row: read, and dropped. - rs, err := Parse([]byte(page), NewRelic) + rs, err := members.Parse([]byte(page), PythonAgent) if err != nil { t.Fatal(err) } @@ -119,7 +121,7 @@ func TestNewRelicDropsWhatIsNotARemovedMember(t *testing.T) { if asList == page { t.Fatal("no lambda row in the saved release note") } - if names := readNames(t, asList, NewRelic); !slices.Contains(names, "lambda_handler") || !slices.Contains(names, "LambdaHandlerWrapper") { + if names := readNames(t, asList, PythonAgent); !slices.Contains(names, "lambda_handler") || !slices.Contains(names, "LambdaHandlerWrapper") { t.Errorf("with \"and\", the lambda row reads as %v: its drop proves nothing", names) } @@ -132,9 +134,9 @@ func TestNewRelicDropsWhatIsNotARemovedMember(t *testing.T) { if start < 0 || end < start { t.Fatal("the saved release note's shape changed") } - g := NewRelic + g := PythonAgent g.Header = "Legacy Setting" - settings, err := Parse([]byte(page[:start]+page[end:]), g) + settings, err := members.Parse([]byte(page[:start]+page[end:]), g) if err != nil { t.Fatal(err) } @@ -159,68 +161,9 @@ func TestNewRelicDropsWhatIsNotARemovedMember(t *testing.T) { } } -// A replacement cell that is a Markdown link around one code span is read as -// that name; a link inside prose, or around more than a code span, isn't. -func TestSoleNameReadsALinkedName(t *testing.T) { - for cell, want := range map[string]string{ - "`new_fn`": "new_fn", - "[`new_fn`](/docs/new-fn)": "new_fn", - " [`acme.new_fn()`](https://x.test/a) ": "new_fn", - "[`new_fn`](/docs/new-fn#anchor)": "new_fn", - "Use [`new_fn`](/docs/new-fn)": "", - "[`new_fn`](/docs/new-fn) instead": "", - "[the `new_fn` API](/docs/new-fn)": "", - "[`new_fn`]": "", - "[`x=1`](/docs/x)": "", - "[`a`](/a) and [`b`](/b)": "", - } { - if got := SoleName(cell, "acme"); got != want { - t.Errorf("SoleName(%q) = %q, want %q", cell, got, want) - } - } -} - -// Without DropIns every one-replacement row is a rename, as NumPy's are; with -// it, only the listed ones. Paths applies to the replacement as to the name. -func TestDropInsLimitsRenames(t *testing.T) { - page := strings.Join([]string{ - "## Removed", - "| Removed | Use instead |", - "| --- | --- |", - "| `old_a` | [`new_a`](/a) |", - "| `old_b` | `new_b` |", - }, "\n") - g := Guide{API: "acme/sdk", Package: "acme", Module: "acme", Repo: "acme/acme", Path: "MIGRATION.md", - Section: "Removed", Format: FormatMarkdown, Header: "Removed", - Paths: map[string]string{"old_a": "mod.old_a", "new_a": "mod.new_a"}} - run := func(g Guide) map[string]string { - out := map[string]string{} - for _, e := range release(t, g, writeTemp(t, page), "1.9.0", "2.0.0") { - out[e.Subject.Symbols[0]] = string(e.Subject.Change) + " " + e.Subject.Replacement - } - return out - } - if got := run(g); got["mod.old_a"] != "renamed_symbol mod.new_a" || got["old_b"] != "renamed_symbol new_b" { - t.Errorf("no DropIns: %v", got) - } - g.DropIns = []string{"mod.old_a"} - if got := run(g); got["mod.old_a"] != "renamed_symbol mod.new_a" || got["old_b"] != "removed_symbol " { - t.Errorf("DropIns mod.old_a: %v", got) - } -} - -func writeTemp(t *testing.T, page string) string { +func readNames(t *testing.T, page string, g members.Guide) []string { t.Helper() - f := filepath.Join(t.TempDir(), "guide.md") - if err := os.WriteFile(f, []byte(page), 0o644); err != nil { - t.Fatal(err) - } - return f -} - -func readNames(t *testing.T, page string, g Guide) []string { - t.Helper() - rs, err := Parse([]byte(page), g) + rs, err := members.Parse([]byte(page), g) if err != nil { t.Fatal(err) } @@ -237,19 +180,36 @@ func readNames(t *testing.T, page string, g Guide) []string { // the saved excerpt. func newrelicIngest(t *testing.T) []event.Event { t.Helper() - return release(t, NewRelic, newrelicSource, "10.17.0", "11.0.0") + return migrationguidetest.Release(t, migrationguidetest.UntaggedEnv(t, PythonAgent, newrelicSource, "11.0.0", newrelicCommits, newrelicCommit), PythonAgent, "10.17.0", "11.0.0") +} + +// newrelicCommit is the docs-website commit New Relic's saved release note +// was fetched at, and newrelicCommits GitHub's answer naming it as the +// newest commit that changed the note. +const ( + newrelicCommit = "f0b4f817bf9a7b76a78e26609369a8a7ce764c8e" + newrelicCommits = "testdata/github-commits-python-agent-110000.json" +) + +// The docs repo has no tags: a major's note is read at the newest commit +// that changed it. A release that isn't a major's first has none. +func TestPythonAgentNoteIsReadAtTheNewestCommit(t *testing.T) { + ctx := context.Background() + want := "https://raw.githubusercontent.com/newrelic/docs-website/" + newrelicCommit + "/src/content/docs/release-notes/agent-release-notes/python-release-notes/python-agent-110000.mdx" + env := migrationguidetest.UntaggedEnv(t, PythonAgent, "testdata/README.md", "11.0.0", newrelicCommits, newrelicCommit) + if got, err := PythonAgent.GuideURL(ctx, env, plugin.Version{ID: "11.0.0"}); err != nil || got != want { + t.Errorf("%q, %v; want %q", got, err, want) + } + if got, err := PythonAgent.GuideURL(ctx, plugin.Env{}, plugin.Version{ID: "11.0.1"}); got != "" || err != nil { + t.Errorf("a release that isn't a major's first has no guide: %q, %v", got, err) + } } -// The hint is shown in a pull request or an issue, where a site-relative link -// breaks: LinkBase makes the guide's links absolute, and leaves the rest. -func TestAbsoluteLinks(t *testing.T) { - g := Guide{LinkBase: "https://docs.newrelic.com/"} - in := "Replacement API: [`notice_error()`](/docs/x/notice_error), see [here](https://example.test/y)" - want := "Replacement API: [`notice_error()`](https://docs.newrelic.com/docs/x/notice_error), see [here](https://example.test/y)" - if got := g.AbsoluteLinks(in); got != want { - t.Errorf("got %q, want %q", got, want) - } - if got := (Guide{}).AbsoluteLinks(in); got != in { - t.Errorf("no LinkBase changed the hint: %q", got) +// A major whose note no commit ever changed has nothing to read: the pair is +// skipped, not failed, and not a release without changes. +func TestPythonAgentMajorWithNoNoteHasNothingToRead(t *testing.T) { + env := kittest.Env(t, kittest.Pages{PythonAgent.CommitsURL(14): "testdata/github-commits-none.json"}) + if _, err := (migrationguide.Plugin{Guide: PythonAgent}).ReadAt(context.Background(), env, plugin.Version{ID: "14.0.0"}); !errors.Is(err, plugin.ErrNothingToRead) { + t.Errorf("no commit for the note: %v, want plugin.ErrNothingToRead", err) } } diff --git a/plugins/migrationguide/members/testdata/README.md b/providers/newrelic/testdata/README.md similarity index 56% rename from plugins/migrationguide/members/testdata/README.md rename to providers/newrelic/testdata/README.md index f28767c..7fd0394 100644 --- a/plugins/migrationguide/members/testdata/README.md +++ b/providers/newrelic/testdata/README.md @@ -1,12 +1,13 @@ -# Saved removed-members guides +# New Relic: saved copies and goldens -The golden files, `../../testdata/golden/{numpy-2.0.0,posthog-8.0.0,newrelic-11.0.0}.json`, are what the migration-guide kind stores from them (`go test ./plugins/migrationguide/members -update`). +Real copies of what New Relic publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/newrelic -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved removed-members guide + +Read through the `migrationguide` kind's removed-members reader; the golden file is what it stores from the guide. | File | URL | Fetched | License | Quote | |---|---|---|---|---| -| `numpy_2_0_migration_guide-v2.0.0.rst` | https://github.com/numpy/numpy/blob/v2.0.0/doc/source/numpy_2_0_migration_guide.rst | 2026-11-04 | BSD-3-Clause (NumPy), kept whole | "The table below provides replacements for the removed members:" | -| `migration-7.x-to-8.0-posthog-v8.0.0.md` | https://github.com/PostHog/posthog-python/blob/posthog-v8.0.0/docs/migration-7.x-to-8.0.md (commit 6edff41425188056e48f6119457dc9bc0669ca99) | 2026-11-19 | MIT (the repo's LICENSE is the MIT text, with two copyright lines, so GitHub's detector says NOASSERTION; PyPI says MIT), kept whole, byte for byte | "8.x.x removes these options and APIs:" (Fix removed APIs), with rows such as "\| `CaptureV1Error` \| `CaptureError` \|" | | `python-agent-110000-f0b4f817.mdx` | https://github.com/newrelic/docs-website/blob/f0b4f817bf9a7b76a78e26609369a8a7ce764c8e/src/content/docs/release-notes/agent-release-notes/python-release-notes/python-agent-110000.mdx (the repo has no tags; the file's latest commit) | 2026-11-19 | Excerpt for testing; © New Relic, CC BY-NC-SA 4.0. Kept: the "## Removed features" heading, the bullets that introduce its two tables, the "Legacy API" table and the "Legacy Setting" table (lines 30-31 and 36-66 of 136), every line unchanged. Left out: the front matter, "Notes", the Python 3.7 bullet, and the "Deprecated features", "New features", "Bug fixes" and "Support statement" sections. The plugin finds the same 8 rows and 7 events in the excerpt as in the full file | "The following APIs have been removed:", with rows such as "\| `record_exception` \| [`notice_error()`](/docs/agents/python-agent/python-agent-api/notice_error) \|" | -| `pypi-numpy-excerpt.json` | https://pypi.org/pypi/numpy/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | | `github-commits-python-agent-110000.json` | https://api.github.com/repos/newrelic/docs-website/commits?path=src/content/docs/release-notes/agent-release-notes/python-release-notes/python-agent-110000.mdx&per_page=1 (shape only) | written for the test, 2026-11-20 | not a saved copy: GitHub's commit list cut to the one field read (`sha`), naming the commit the note above was fetched at | for the guide's ref: the newest commit that changed the note | | `github-commits-none.json` | the same request for a major with no note (shape only) | written for the test, 2026-11-20 | GitHub's answer for a path no commit changed: an empty list | for the "no guide, nothing to read" test | diff --git a/plugins/migrationguide/members/testdata/github-commits-none.json b/providers/newrelic/testdata/github-commits-none.json similarity index 100% rename from plugins/migrationguide/members/testdata/github-commits-none.json rename to providers/newrelic/testdata/github-commits-none.json diff --git a/plugins/migrationguide/members/testdata/github-commits-python-agent-110000.json b/providers/newrelic/testdata/github-commits-python-agent-110000.json similarity index 100% rename from plugins/migrationguide/members/testdata/github-commits-python-agent-110000.json rename to providers/newrelic/testdata/github-commits-python-agent-110000.json diff --git a/plugins/migrationguide/testdata/golden/newrelic-11.0.0.json b/providers/newrelic/testdata/golden/newrelic-11.0.0.json similarity index 100% rename from plugins/migrationguide/testdata/golden/newrelic-11.0.0.json rename to providers/newrelic/testdata/golden/newrelic-11.0.0.json diff --git a/plugins/migrationguide/members/testdata/python-agent-110000-f0b4f817.mdx b/providers/newrelic/testdata/python-agent-110000-f0b4f817.mdx similarity index 100% rename from plugins/migrationguide/members/testdata/python-agent-110000-f0b4f817.mdx rename to providers/newrelic/testdata/python-agent-110000-f0b4f817.mdx diff --git a/providers/numpy.md b/providers/numpy.md deleted file mode 100644 index b16e8d9..0000000 --- a/providers/numpy.md +++ /dev/null @@ -1,31 +0,0 @@ -# NumPy (`numpy/numpy`) - -## What it watches - -Members a new major removes from or renames in NumPy's main namespace, from that major's migration guide: in 2.0.0, `np.float_`, `np.NaN`, `np.product` and about fifty more (code using one raises `AttributeError`). One event per member, with the major's first release as `version` and the release before it on PyPI as `previous_version`. The releases are listed from PyPI; the guide is read at each major's first tag (`v.0.0`), so nothing in the code names a release. - -Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members reader (`plugins/migrationguide/members`). - -## Why this source - -- **Source:** `doc/source/numpy__0_migration_guide.rst` at tag `v.0.0`, read raw at the tag; the one so far is [2.0's](https://github.com/numpy/numpy/blob/v2.0.0/doc/source/numpy_2_0_migration_guide.rst). A major with no guide at its tag has nothing to read (the pair is skipped). Releases from [PyPI](https://pypi.org/project/numpy/). Checked on 2026-11-04 (2.0) and 2026-11-20 (no other guide yet). -- **Why this one:** it's NumPy's own migration guide, with a table of every removed member and its migration guideline. A tag never changes, so the URL is its own citation. -- **Alternatives considered:** the 2.0.0 release notes (list the removals in prose, spread over several sections); the rendered guide on numpy.org (the same text as HTML); NEP 52 (the plan, not what shipped). -- **Quote:** "The table below provides replacements for the removed members:" (Main namespace), with rows such as "NaN — Use ``np.nan`` instead." - -## How the provider announces changes - -- Package versions (PEP 440). 2.0.0 shipped on 2024-06-16. -- **Forced on a fresh install** for an unpinned or open pin (`>=1.24`), otherwise when the team upgrades. -- Every replacement the guide names exists in NumPy 1.x too, so a rename works on either side of the upgrade. - -## What the plugin reads and ignores - -- Reads the "Main namespace" section's table: removed member, migration guideline (a guideline may continue over several lines). -- `renamed_symbol` with the replacement when the guideline is exactly "Use ``np.`` instead." (`float_` → `float64`, `NaN` → `nan`, `product` → `prod`…); `removed_symbol` otherwise (a builtin, an expression such as `-np.inf`, or advice). 56 events. - -## Known gaps - -- The guide's other tables (`np.lib` members, changed behavior) aren't read. -- Removals in a minor release aren't watched: only a major gets a guide. -- A later major's guide is read with 2.0's rule: a guideline that is exactly "Use ``np.`` instead." is a rename. NumPy 2.0's guide says each such replacement works on 1.x; a later guide might name one that's new, which would make the rename fail on the release before. diff --git a/providers/numpy-python-surface.md b/providers/numpy/README.md similarity index 52% rename from providers/numpy-python-surface.md rename to providers/numpy/README.md index 1c9e594..6a0b810 100644 --- a/providers/numpy-python-surface.md +++ b/providers/numpy/README.md @@ -1,24 +1,60 @@ -# NumPy (`numpy/python-surface`) +# NumPy -## What it watches +Every source patch-it reads for NumPy, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## NumPy migration guides (`numpy/numpy`) + +### What it watches + +Members a new major removes from or renames in NumPy's main namespace, from that major's migration guide: in 2.0.0, `np.float_`, `np.NaN`, `np.product` and about fifty more (code using one raises `AttributeError`). One event per member, with the major's first release as `version` and the release before it on PyPI as `previous_version`. The releases are listed from PyPI; the guide is read at each major's first tag (`v.0.0`), so nothing in the code names a release. + +Kind: `migrationguide` (`kinds/migrationguide`), with the removed-members reader (`kinds/migrationguide/members`). + +### Why this source + +- **Source:** `doc/source/numpy__0_migration_guide.rst` at tag `v.0.0`, read raw at the tag; the one so far is [2.0's](https://github.com/numpy/numpy/blob/v2.0.0/doc/source/numpy_2_0_migration_guide.rst). A major with no guide at its tag has nothing to read (the pair is skipped). Releases from [PyPI](https://pypi.org/project/numpy/). Checked on 2026-11-04 (2.0) and 2026-11-20 (no other guide yet). +- **Why this one:** it's NumPy's own migration guide, with a table of every removed member and its migration guideline. A tag never changes, so the URL is its own citation. +- **Alternatives considered:** the 2.0.0 release notes (list the removals in prose, spread over several sections); the rendered guide on numpy.org (the same text as HTML); NEP 52 (the plan, not what shipped). +- **Quote:** "The table below provides replacements for the removed members:" (Main namespace), with rows such as "NaN — Use ``np.nan`` instead." + +### How the provider announces changes + +- Package versions (PEP 440). 2.0.0 shipped on 2024-06-16. +- **Forced on a fresh install** for an unpinned or open pin (`>=1.24`), otherwise when the team upgrades. +- Every replacement the guide names exists in NumPy 1.x too, so a rename works on either side of the upgrade. + +### What the plugin reads and ignores + +- Reads the "Main namespace" section's table: removed member, migration guideline (a guideline may continue over several lines). +- `renamed_symbol` with the replacement when the guideline is exactly "Use ``np.`` instead." (`float_` → `float64`, `NaN` → `nan`, `product` → `prod`…); `removed_symbol` otherwise (a builtin, an expression such as `-np.inf`, or advice). 56 events. + +### Known gaps + +- The guide's other tables (`np.lib` members, changed behavior) aren't read. +- Removals in a minor release aren't watched: only a major gets a guide. +- A later major's guide is read with 2.0's rule: a guideline that is exactly "Use ``np.`` instead." is a rename. NumPy 2.0's guide says each such replacement works on 1.x; a later guide might name one that's new, which would make the rename fail on the release before. + +## NumPy's public API (`numpy/python-surface`) + +### What it watches The public API of the `numpy` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). -## Why this source +### Why this source - **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. - **Why this one:** the wheel is exactly what `pip install numpy==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. - **Alternatives considered:** the release notes (one file per release; the `numpy/numpy` migration guide source covers 2.0); the deprecation warnings in the code. - **Quote:** `def row_stack( tup: Sequence[ArrayLike], *, dtype: DTypeLike | None = None, casting: _CastingKind = "same_kind", ) -> NDArray[Any]` (`numpy/lib/_shape_base_impl.pyi` line 129, re-exported as `numpy.row_stack`) at 2.4.6, gone at 2.5.0. -## How the provider announces changes +### How the provider announces changes - NumPy deprecates for two releases and then removes; the `.pyi` stubs, read in place of the `.py` files, carry every public signature. - **Forced on upgrade**, for a repo whose pin reaches the release. -## What the plugin reads and ignores +### What the plugin reads and ignores - Reads the `.py` and `.pyi` files under `numpy/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. - Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). @@ -26,7 +62,7 @@ Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apis - A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. - Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. -## Known gaps +### Known gaps - A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. - A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. diff --git a/providers/numpy/numpy_test.go b/providers/numpy/numpy_test.go new file mode 100644 index 0000000..9da72ea --- /dev/null +++ b/providers/numpy/numpy_test.go @@ -0,0 +1,165 @@ +package numpy + +import ( + "context" + "errors" + "fmt" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/migrationguidetest" +) + +// The guide as published at tag v2.0.0 (fetched 2026-11-04). +func guide(t *testing.T) []byte { + t.Helper() + return kittest.Read(t, "testdata/numpy_2_0_migration_guide-v2.0.0.rst") +} + +func byMember(t *testing.T) map[string]members.Removal { + t.Helper() + rs, err := members.Parse(guide(t), Numpy) + if err != nil { + t.Fatal(err) + } + out := map[string]members.Removal{} + for _, r := range rs { + out[r.Member] = r + } + return out +} + +func TestEveryRemovedMemberOfTheMainNamespaceIsRead(t *testing.T) { + got := byMember(t) + if len(got) != 56 { + t.Errorf("%d removed members, want the table's 56", len(got)) + } + // A guideline continued over several lines is read whole. + if r := got["find_common_type"]; !strings.Contains(r.Guideline, "``0.0``, or ``0j``") { + t.Errorf("find_common_type: %q", r.Guideline) + } + // The table's escaped underscore is the member's own. + if _, ok := got["float_"]; !ok { + t.Error(`no "float_": the \_ escape wasn't undone`) + } +} + +// Only a guideline naming exactly one member of np is a rename; anything else +// (a builtin, an expression, advice) is a removal the patch-it client +// opens as an issue. +func TestOnlyOnePlainReplacementInNpIsARename(t *testing.T) { + got := byMember(t) + for member, want := range map[string]string{ + "float_": "float64", + "NaN": "nan", + "product": "prod", + "cumproduct": "cumprod", + "string_": "bytes_", + "Inf": "inf", + "alltrue": "", // "Use ``all`` instead.": the builtin, or np.all? Not said + "NINF": "", // "Use ``-np.inf`` instead.": an expression + "asfarray": "", // "Use ``np.asarray`` with a float dtype instead." + "compat": "", // no replacement + "who": "", + } { + if r, ok := got[member]; !ok || r.Replacement != want { + t.Errorf("%s: replacement %q, want %q", member, r.Replacement, want) + } + } +} + +func TestTheGuideStoresOneEventPerMemberAndARerunNothing(t *testing.T) { + // The guide at the v2.0.0 tag, and nothing else; kittest extracts the + // pair again and fails on anything new. + events := migrationguidetest.Release(t, migrationguidetest.GuideEnv(t, Numpy, "testdata/numpy_2_0_migration_guide-v2.0.0.rst", "2.0.0"), Numpy, "1.26.4", "2.0.0") + if len(events) != 56 { + t.Fatalf("%d events, want 56", len(events)) + } + var float *event.Event + for i := range events { + if events[i].Subject.Symbols[0] == "float_" { + float = &events[i] + } + } + if float == nil || float.Subject.Change != event.PackageRenamedSymbol || float.Subject.Replacement != "float64" || + float.API != "numpy/numpy" || float.Version != "2.0.0" || !strings.Contains(float.SourceExcerpt, "float\\_") { + t.Errorf("float_: %+v", float) + } +} + +// The package's releases come from PyPI; only the pair into the release the +// guide documents has events (the golden's, with previous_version set). +func TestOnlyTheGuidesReleaseHasEvents(t *testing.T) { + env := kittest.Env(t, kittest.Pages{ + "https://pypi.org/pypi/numpy/json": "testdata/pypi-numpy-excerpt.json", + Numpy.RawURL("v2.0.0", 2): "testdata/numpy_2_0_migration_guide-v2.0.0.rst", + }) + p := migrationguide.Plugin{Guide: Numpy} + ctx := context.Background() + vs, err := p.ListVersions(ctx, env) + if err != nil { + t.Fatal(err) + } + pinned := migrationguidetest.Release(t, migrationguidetest.GuideEnv(t, Numpy, "testdata/numpy_2_0_migration_guide-v2.0.0.rst", "2.0.0"), Numpy, "1.26.4", "2.0.0") + var got []string + for _, pair := range versions.Pairs(vs) { + from, err := p.ReadAt(ctx, env, pair[0]) + if err != nil { + t.Fatal(err) + } + to, err := p.ReadAt(ctx, env, pair[1]) + if err != nil { + t.Fatal(err) + } + res, err := p.Extract(ctx, env, from, to) + if err != nil || len(res.Rejected) > 0 { + t.Fatalf("%v %v", err, res.Rejected) + } + for i, e := range res.Events { + if e.PreviousVersion != pair[0].ID || e.Fingerprint != pinned[i].Fingerprint { + t.Errorf("event %d: previous %q, fingerprint differs from the golden's: %v", i, e.PreviousVersion, e.Fingerprint != pinned[i].Fingerprint) + } + } + got = append(got, fmt.Sprintf("%s->%s:%d", pair[0].ID, pair[1].ID, len(res.Events))) + } + want := fmt.Sprintf("1.26.4->2.0.0:%d 2.0.0->2.0.1:0", len(pinned)) + if strings.Join(got, " ") != want || len(pinned) == 0 { + t.Errorf("got %s, want %s", strings.Join(got, " "), want) + } +} + +// The guide at tag v2.0.0 (saved 2026-11-04) in, every event out: the pair +// from 1.26.4, the release before on PyPI. +func TestNumpyGolden(t *testing.T) { + got := migrationguidetest.Release(t, migrationguidetest.GuideEnv(t, Numpy, "testdata/numpy_2_0_migration_guide-v2.0.0.rst", "2.0.0"), Numpy, "1.26.4", "2.0.0") + kittest.Golden(t, "testdata/golden/numpy-2.0.0.json", got) +} + +// The guide is read at the major's first tag; a release that isn't one has +// none. +func TestNumpyGuideIsReadAtTheMajorsTag(t *testing.T) { + ctx := context.Background() + want := "https://raw.githubusercontent.com/numpy/numpy/v2.0.0/doc/source/numpy_2_0_migration_guide.rst" + if got, err := Numpy.GuideURL(ctx, migrationguidetest.GuideEnv(t, Numpy, "testdata/README.md", "2.0.0"), plugin.Version{ID: "2.0.0"}); err != nil || got != want { + t.Errorf("%q, %v; want %q", got, err, want) + } + if got, err := Numpy.GuideURL(ctx, plugin.Env{}, plugin.Version{ID: "2.0.1"}); got != "" || err != nil { + t.Errorf("a release that isn't a major's first has no guide: %q, %v", got, err) + } +} + +// A major with no guide at its tag (a 404) has nothing to read: the pair is +// skipped, not failed, and not a release without changes. +func TestNumpyMajorWithNoGuideHasNothingToRead(t *testing.T) { + notFound := plugin.Env{Get: func(context.Context, string) ([]byte, error) { return nil, &fetch.StatusError{StatusCode: 404} }} + if _, err := (migrationguide.Plugin{Guide: Numpy}).ReadAt(context.Background(), notFound, plugin.Version{ID: "3.0.0"}); !errors.Is(err, plugin.ErrNothingToRead) { + t.Errorf("no guide at the tag: %v, want plugin.ErrNothingToRead", err) + } +} diff --git a/providers/numpy/provider.go b/providers/numpy/provider.go new file mode 100644 index 0000000..9f899e5 --- /dev/null +++ b/providers/numpy/provider.go @@ -0,0 +1,45 @@ +// Package numpy is what patch-it reads for NumPy: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package numpy + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "numpy", Name: "NumPy", Category: plugin.CategoryPackages, Homepage: "https://numpy.org", + Sources: []plugin.Source{ + { + ID: "numpy", Layer: plugin.LayerPackage, + Watches: "Members a new major removes or renames in the main namespace, from that major's migration guide at its first tag", + URLs: []string{"https://numpy.org/devdocs/numpy_2_0_migration_guide.html", "https://pypi.org/project/numpy/"}, + Packages: []string{"pypi:numpy"}, + Plugin: migrationguide.Plugin{Guide: Numpy}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerPackage, "https://github.com/numpy/numpy"), + }, + }) +} + +// Numpy is NumPy's migration guide to a major, "Main namespace" table +// (doc/source/numpy_2_0_migration_guide.rst at v2.0.0, checked 2026-11-04; +// no other major has one yet, checked 2026-11-20). +var Numpy = members.Guide{ + API: "numpy/numpy", + Package: "numpy", + Module: "np", + Repo: "numpy/numpy", + Path: "doc/source/numpy_{major}_0_migration_guide.rst", + Section: "Main namespace", + Effect: "code using it raises AttributeError", +} + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "numpy/python-surface", Name: "numpy", Ecosystem: "pypi", Module: "numpy"} +) diff --git a/providers/numpy/python_surface_test.go b/providers/numpy/python_surface_test.go new file mode 100644 index 0000000..aafb142 --- /dev/null +++ b/providers/numpy/python_surface_test.go @@ -0,0 +1,13 @@ +package numpy + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// numpy 2.5.0 removed row_stack, deprecated since 2.0 (read from the +// .pyi stubs). +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"2.4.6", "2.5.0"}, Want: []string{"removed_symbol row_stack "}, Drop: [2]string{"2.5.0", "2.5.1"}}) +} diff --git a/providers/numpy/testdata/README.md b/providers/numpy/testdata/README.md new file mode 100644 index 0000000..f38bf50 --- /dev/null +++ b/providers/numpy/testdata/README.md @@ -0,0 +1,21 @@ +# NumPy: saved copies and goldens + +Real copies of what NumPy publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/numpy -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved removed-members guide + +Read through the `migrationguide` kind's removed-members reader; the golden file is what it stores from the guide. + +| File | URL | Fetched | License | Quote | +|---|---|---|---|---| +| `numpy_2_0_migration_guide-v2.0.0.rst` | https://github.com/numpy/numpy/blob/v2.0.0/doc/source/numpy_2_0_migration_guide.rst | 2026-11-04 | BSD-3-Clause (NumPy), kept whole | "The table below provides replacements for the removed members:" | +| `pypi-numpy-excerpt.json` | https://pypi.org/pypi/numpy/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/numpy/`: `numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.trimmed.whl`, `numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.trimmed.whl`, `numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.trimmed.whl` | https://files.pythonhosted.org/packages/b3/49/ec46835a70be8fa6446c495126ac84fdb28cb2558e1620ffb87a10c8b64c/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.whl; https://files.pythonhosted.org/packages/fa/0a/11486d02add7b1384dff7374d124b1cfbb0ee864dcc9f6a2c0380638cf84/numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.whl; https://files.pythonhosted.org/packages/62/7b/14687aa674250e5e546f616f486b0d56d3631cd5b2415739141ce40bdcea/numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.whl | 2026-11-21 | BSD-3-Clause (and the licenses its wheel lists) (the wheel's own license files are kept in it). Trimmed: only `numpy/__init__.py`, `numpy/__init__.pyi`, `numpy/lib/_shape_base_impl.py`, `numpy/lib/_shape_base_impl.pyi` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/numpy/`: `pypi-numpy-excerpt.json` and `pypi-numpy-2.4.6.json`, `pypi-numpy-2.5.0.json`, `pypi-numpy-2.5.1.json` | https://pypi.org/pypi/numpy/json, https://pypi.org/pypi/numpy/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | diff --git a/plugins/migrationguide/testdata/golden/numpy-2.0.0.json b/providers/numpy/testdata/golden/numpy-2.0.0.json similarity index 100% rename from plugins/migrationguide/testdata/golden/numpy-2.0.0.json rename to providers/numpy/testdata/golden/numpy-2.0.0.json diff --git a/plugins/apisurface/testdata/golden/numpy-python-surface.json b/providers/numpy/testdata/golden/numpy-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/numpy-python-surface.json rename to providers/numpy/testdata/golden/numpy-python-surface.json diff --git a/plugins/migrationguide/members/testdata/numpy_2_0_migration_guide-v2.0.0.rst b/providers/numpy/testdata/numpy_2_0_migration_guide-v2.0.0.rst similarity index 100% rename from plugins/migrationguide/members/testdata/numpy_2_0_migration_guide-v2.0.0.rst rename to providers/numpy/testdata/numpy_2_0_migration_guide-v2.0.0.rst diff --git a/plugins/migrationguide/members/testdata/pypi-numpy-excerpt.json b/providers/numpy/testdata/pypi-numpy-excerpt.json similarity index 100% rename from plugins/migrationguide/members/testdata/pypi-numpy-excerpt.json rename to providers/numpy/testdata/pypi-numpy-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/numpy/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.trimmed.whl b/providers/numpy/testdata/pypi/numpy/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.trimmed.whl rename to providers/numpy/testdata/pypi/numpy/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/numpy/numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.trimmed.whl b/providers/numpy/testdata/pypi/numpy/numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.trimmed.whl rename to providers/numpy/testdata/pypi/numpy/numpy-2.5.0-cp312-cp312-macosx_10_13_x86_64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/numpy/numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.trimmed.whl b/providers/numpy/testdata/pypi/numpy/numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.trimmed.whl rename to providers/numpy/testdata/pypi/numpy/numpy-2.5.1-cp312-cp312-macosx_10_13_x86_64.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/numpy/pypi-numpy-2.4.6.json b/providers/numpy/testdata/pypi/numpy/pypi-numpy-2.4.6.json similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/pypi-numpy-2.4.6.json rename to providers/numpy/testdata/pypi/numpy/pypi-numpy-2.4.6.json diff --git a/plugins/apisurface/testdata/pypi/numpy/pypi-numpy-2.5.0.json b/providers/numpy/testdata/pypi/numpy/pypi-numpy-2.5.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/pypi-numpy-2.5.0.json rename to providers/numpy/testdata/pypi/numpy/pypi-numpy-2.5.0.json diff --git a/plugins/apisurface/testdata/pypi/numpy/pypi-numpy-2.5.1.json b/providers/numpy/testdata/pypi/numpy/pypi-numpy-2.5.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/pypi-numpy-2.5.1.json rename to providers/numpy/testdata/pypi/numpy/pypi-numpy-2.5.1.json diff --git a/plugins/apisurface/testdata/pypi/numpy/pypi-numpy-excerpt.json b/providers/numpy/testdata/pypi/numpy/pypi-numpy-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/numpy/pypi-numpy-excerpt.json rename to providers/numpy/testdata/pypi/numpy/pypi-numpy-excerpt.json diff --git a/providers/openai-api.md b/providers/openai-api.md deleted file mode 100644 index decae74..0000000 --- a/providers/openai-api.md +++ /dev/null @@ -1,44 +0,0 @@ -# OpenAI (`openai/api`) - -## What it watches - -The OpenAI REST API (`api.openai.com/v1`): operations OpenAI marks deprecated, and removals of operations it had marked deprecated, day by day in the OpenAPI spec its SDKs are generated from. - -Kind: `openapi` (`plugins/openapi`), with `adapter.OpenAI`. - -## Why this source - -- **Source:** `openapi.yaml` in [openai/openai-openapi](https://github.com/openai/openai-openapi) (MIT), pinned to a commit (`https://raw.githubusercontent.com/openai/openai-openapi//openapi.yaml`). The versions come from the GitHub commits API. Checked on 2026-11-21. -- **Why this one:** - - It's OpenAI's own description of the API, the one `openai-python` and `openai-node` are generated from, and it's kept current: 589 commits changed it from 2022-01-19 to 2026-11-21, several on most days. - - It marks deprecated operations with the `deprecated` flag, and the operation's description says until when. - - Every commit can be cited and replayed. -- **Alternatives considered:** - - **The repo's tags** (`1.3.0`, `2.0.0`): too sparse to follow the API. - - **`openapi.json` beside it:** the same spec, but only committed from 2026-07-16 on; the YAML has the whole history. - - **The [deprecations page](https://developers.openai.com/api/docs/deprecations):** read for model shutdowns by `openai/models` (kind `notices`). It announces endpoint shutdowns in prose and tables, not per operation. - - **The changelog:** product news, not keyed by operation. -- **Quote:** "The endpoint and model are deprecated and scheduled to shut down on February 26, 2027." (`POST /audio/translations`, flagged deprecated on 2026-10-28) - -## How the provider announces changes - -- **One version per day.** The spec is committed several times a day, and `info.version` (`2.3.0`) isn't bumped with each change, so a version is a day: the day's last commit, its date the event's `version`. -- **Operations are named by the path a caller sends** (`POST /v1/audio/translations`): the server is `https://api.openai.com/v1` and the paths leave out `/v1`, so the adapter moves it into the paths. -- **Deprecations use the flag.** On 2026-11-21, 17 operations carry it, and none is called deprecated only in words (one description mentions deprecated models, not the operation). Flagged descriptions give the shutdown date. -- **Much of the daily churn is the spec's own shape**: enum lists rewritten as `const`, schemas regenerated, work in progress added and pulled again. - -## What the plugin reads and ignores - -- **Reads** every day's spec, diffed against the day before. Two events come out of it: - - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so the shutdown date is in the excerpt. - - **Removals (breaking):** an operation that leaves the spec after the previous day's spec had marked it deprecated. -- **Matches operations by path template,** so a renamed path parameter isn't a removal. -- **Ignores everything else:** removals of operations that were never deprecated, schema and property changes, new operations. The drop test replays 2026-11-17 → 2026-11-18, when the session spending-limit schemas added the day before were pulled again: three schema removals, no event. -- **The golden test** replays 2026-10-27 → 2026-10-28: `POST /audio/translations` deprecated, one event; the two new `/organization/external_keys` operations of the same day are dropped. - -## Known gaps - -- **Deprecated parameters, fields and enum values** (`user` in favor of `safety_identifier`, a model in a `model` enum) aren't events: only whole operations are. -- **Removals OpenAI didn't flag first aren't events,** even if the endpoint really went away. -- **History:** the GitHub commits API lists at most 1,000 commits. The spec has 589 (back to 2022-01-19), so all are listed today; at its pace, the oldest will start dropping off in 2027. -- **The patch-it client needs `openai` in its list of date-versioned APIs** to place the events' date `version`; that list is outside this repo. diff --git a/providers/openai-models.md b/providers/openai-models.md deleted file mode 100644 index a021144..0000000 --- a/providers/openai-models.md +++ /dev/null @@ -1,33 +0,0 @@ -# OpenAI model retirements (`openai/models`) - -## What it watches - -OpenAI models that are being shut down: every text model name code sends to the Chat Completions or Responses API, with its shutdown date and the replacement OpenAI recommends. One breaking event per model name. - -Kind: `notices` (`plugins/notices`), reading with the deprecations-page reader, `plugins/notices/retire/`. - -## Why this source - -- **Source:** [developers.openai.com/api/docs/deprecations](https://developers.openai.com/api/docs/deprecations), read as markdown at `https://developers.openai.com/api/docs/deprecations.md`. Checked on 2026-10-13. -- **Why this one:** it's OpenAI's own list of every deprecation, each announcement a table of shutdown date, model and recommended replacement. The markdown version is machine-readable without scraping HTML. `robots.txt` allows it. -- **Alternatives considered:** the models list API (`GET /v1/models`: says what exists now, not when it stops); OpenAI's blog and email notices (announce only some changes, no table); the old `platform.openai.com/docs/deprecations` URL (redirects here). -- **Quote:** "| October 23, 2026 | `gpt-4-0613` \| `gpt-4`, … | `gpt-5.6-sol` |" (2026-04-22 announcement, "Legacy GPT model snapshots"). - -## How the provider announces changes - -- An announcement every few weeks, shutdowns a few months later (at least 6 months for generally available models, 3 for specialized variants, possibly 2 weeks for previews, per the page). -- **Forced, by date**: a request naming a retired model fails on every SDK version. So the event's `version` is the shutdown date. -- The page keeps past announcements, newest first. - -## What the plugin reads and ignores - -- Reads every table whose first column is a shutdown or retirement date and which has a model column and a replacement column. Each backticked name in the model cell is one model (aliases after an escaped pipe too). -- A model listed twice keeps its first (newest) row; a newer "To be announced" withdraws an older date. -- A replacement that is itself retired is followed to one that still works (`gpt-3.5-turbo-0613` → `gpt-3.5-turbo` → `gpt-5.6-terra`), and the hint says so. -- Ignores image, audio, realtime, transcription, embedding and moderation models, fine-tuned bases (`ft-gpt-4`; code sends `ft:gpt-4-0613:org::id`) and the legacy `-completions` aliases: the events are for the operations that take text models. -- Every event cites a Wayback Machine snapshot of the page, never the live page, and is read from that snapshot. No snapshot, or one that differs from the live page, stores nothing that run. A page that suddenly lists far fewer retirements fails the run (a renamed column probably hid a table). - -## Known gaps - -- Replacements that need a setting (`gpt-5.6-sol` with `reasoning.mode: pro`) or name no model are passed on as written; a fix can't be generated from the second kind. -- Image, audio and embedding model retirements aren't events. diff --git a/providers/openai-node-surface.md b/providers/openai-node-surface.md deleted file mode 100644 index 67e5aa1..0000000 --- a/providers/openai-node-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# OpenAI Node.js SDK (`openai/node-surface`) - -## What it watches - -The public API of the `openai` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install openai@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** the repo's CHANGELOG.md (commit titles); the API spec (`openai/api`: the HTTP API). -- **Quote:** `interface AgentSessionBudgetReachedEvent` (`resources/beta/agents/agents.d.mts` line 1188) at 7.59.0, gone at 7.60.0. - -## How the provider announces changes - -- Generated from the same spec as the Python SDK and released several times a week; types follow the API, so a pulled preview feature removes its types in a minor. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `openai/resources/chat/completions.Completions.create`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). diff --git a/providers/openai-python-surface.md b/providers/openai-python-surface.md deleted file mode 100644 index ec2ec28..0000000 --- a/providers/openai-python-surface.md +++ /dev/null @@ -1,35 +0,0 @@ -# OpenAI Python SDK (`openai/python-surface`) - -## What it watches - -The public API of the `openai` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-20. -- **Why this one:** the wheel is exactly what `pip install openai==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** the repo's CHANGELOG.md (generated from commit titles; it says "chore(types): rename" without the old and new names a fix needs); GitHub release notes (the same text); the API's OpenAPI spec (`openai/api`: the HTTP API, not the Python names code uses). -- **Quote:** `class AsssitantDeleted(BaseModel)`, `openai/types/beta/asssitant_deleted.py` line 10 at 1.1.1, gone at 1.1.2 (renamed `AssistantDeleted`). - -## How the provider announces changes - -- The SDK is generated from OpenAI's API spec and released several times a week; type names follow the spec, so a renamed schema renames a class without a deprecation step. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `openai/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/providers/openai/README.md b/providers/openai/README.md new file mode 100644 index 0000000..c299308 --- /dev/null +++ b/providers/openai/README.md @@ -0,0 +1,155 @@ +# OpenAI + +Every source patch-it reads for OpenAI, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## OpenAI (`openai/api`) + +### What it watches + +The OpenAI REST API (`api.openai.com/v1`): operations OpenAI marks deprecated, and removals of operations it had marked deprecated, day by day in the OpenAPI spec its SDKs are generated from. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `OpenAI` ([`api.go`](api.go)). + +### Why this source + +- **Source:** `openapi.yaml` in [openai/openai-openapi](https://github.com/openai/openai-openapi) (MIT), pinned to a commit (`https://raw.githubusercontent.com/openai/openai-openapi//openapi.yaml`). The versions come from the GitHub commits API. Checked on 2026-11-21. +- **Why this one:** + - It's OpenAI's own description of the API, the one `openai-python` and `openai-node` are generated from, and it's kept current: 589 commits changed it from 2022-01-19 to 2026-11-21, several on most days. + - It marks deprecated operations with the `deprecated` flag, and the operation's description says until when. + - Every commit can be cited and replayed. +- **Alternatives considered:** + - **The repo's tags** (`1.3.0`, `2.0.0`): too sparse to follow the API. + - **`openapi.json` beside it:** the same spec, but only committed from 2026-07-16 on; the YAML has the whole history. + - **The [deprecations page](https://developers.openai.com/api/docs/deprecations):** read for model shutdowns by `openai/models` (kind `notices`). It announces endpoint shutdowns in prose and tables, not per operation. + - **The changelog:** product news, not keyed by operation. +- **Quote:** "The endpoint and model are deprecated and scheduled to shut down on February 26, 2027." (`POST /audio/translations`, flagged deprecated on 2026-10-28) + +### How the provider announces changes + +- **One version per day.** The spec is committed several times a day, and `info.version` (`2.3.0`) isn't bumped with each change, so a version is a day: the day's last commit, its date the event's `version`. +- **Operations are named by the path a caller sends** (`POST /v1/audio/translations`): the server is `https://api.openai.com/v1` and the paths leave out `/v1`, so the adapter moves it into the paths. +- **Deprecations use the flag.** On 2026-11-21, 17 operations carry it, and none is called deprecated only in words (one description mentions deprecated models, not the operation). Flagged descriptions give the shutdown date. +- **Much of the daily churn is the spec's own shape**: enum lists rewritten as `const`, schemas regenerated, work in progress added and pulled again. + +### What the plugin reads and ignores + +- **Reads** every day's spec, diffed against the day before. Two events come out of it: + - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so the shutdown date is in the excerpt. + - **Removals (breaking):** an operation that leaves the spec after the previous day's spec had marked it deprecated. +- **Matches operations by path template,** so a renamed path parameter isn't a removal. +- **Ignores everything else:** removals of operations that were never deprecated, schema and property changes, new operations. The drop test replays 2026-11-17 → 2026-11-18, when the session spending-limit schemas added the day before were pulled again: three schema removals, no event. +- **The golden test** replays 2026-10-27 → 2026-10-28: `POST /audio/translations` deprecated, one event; the two new `/organization/external_keys` operations of the same day are dropped. + +### Known gaps + +- **Deprecated parameters, fields and enum values** (`user` in favor of `safety_identifier`, a model in a `model` enum) aren't events: only whole operations are. +- **Removals OpenAI didn't flag first aren't events,** even if the endpoint really went away. +- **History:** the GitHub commits API lists at most 1,000 commits. The spec has 589 (back to 2022-01-19), so all are listed today; at its pace, the oldest will start dropping off in 2027. +- **The patch-it client needs `openai` in its list of date-versioned APIs** to place the events' date `version`; that list is outside this repo. + +## OpenAI model retirements (`openai/models`) + +### What it watches + +OpenAI models that are being shut down: every text model name code sends to the Chat Completions or Responses API, with its shutdown date and the replacement OpenAI recommends. One breaking event per model name. + +Kind: `notices` (`kinds/notices`), reading with the deprecations-page reader, `kinds/notices/retire/`. + +### Why this source + +- **Source:** [developers.openai.com/api/docs/deprecations](https://developers.openai.com/api/docs/deprecations), read as markdown at `https://developers.openai.com/api/docs/deprecations.md`. Checked on 2026-10-13. +- **Why this one:** it's OpenAI's own list of every deprecation, each announcement a table of shutdown date, model and recommended replacement. The markdown version is machine-readable without scraping HTML. `robots.txt` allows it. +- **Alternatives considered:** the models list API (`GET /v1/models`: says what exists now, not when it stops); OpenAI's blog and email notices (announce only some changes, no table); the old `platform.openai.com/docs/deprecations` URL (redirects here). +- **Quote:** "| October 23, 2026 | `gpt-4-0613` \| `gpt-4`, … | `gpt-5.6-sol` |" (2026-04-22 announcement, "Legacy GPT model snapshots"). + +### How the provider announces changes + +- An announcement every few weeks, shutdowns a few months later (at least 6 months for generally available models, 3 for specialized variants, possibly 2 weeks for previews, per the page). +- **Forced, by date**: a request naming a retired model fails on every SDK version. So the event's `version` is the shutdown date. +- The page keeps past announcements, newest first. + +### What the plugin reads and ignores + +- Reads every table whose first column is a shutdown or retirement date and which has a model column and a replacement column. Each backticked name in the model cell is one model (aliases after an escaped pipe too). +- A model listed twice keeps its first (newest) row; a newer "To be announced" withdraws an older date. +- A replacement that is itself retired is followed to one that still works (`gpt-3.5-turbo-0613` → `gpt-3.5-turbo` → `gpt-5.6-terra`), and the hint says so. +- Ignores image, audio, realtime, transcription, embedding and moderation models, fine-tuned bases (`ft-gpt-4`; code sends `ft:gpt-4-0613:org::id`) and the legacy `-completions` aliases: the events are for the operations that take text models. +- Every event cites a Wayback Machine snapshot of the page, never the live page, and is read from that snapshot. No snapshot, or one that differs from the live page, stores nothing that run. A page that suddenly lists far fewer retirements fails the run (a renamed column probably hid a table). + +### Known gaps + +- Replacements that need a setting (`gpt-5.6-sol` with `reasoning.mode: pro`) or name no model are passed on as written; a fix can't be generated from the second kind. +- Image, audio and embedding model retirements aren't events. + +## OpenAI Node.js SDK (`openai/node-surface`) + +### What it watches + +The public API of the `openai` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install openai@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** the repo's CHANGELOG.md (commit titles); the API spec (`openai/api`: the HTTP API). +- **Quote:** `interface AgentSessionBudgetReachedEvent` (`resources/beta/agents/agents.d.mts` line 1188) at 7.59.0, gone at 7.60.0. + +### How the provider announces changes + +- Generated from the same spec as the Python SDK and released several times a week; types follow the API, so a pulled preview feature removes its types in a minor. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `openai/resources/chat/completions.Completions.create`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). + +## OpenAI Python SDK (`openai/python-surface`) + +### What it watches + +The public API of the `openai` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-20. +- **Why this one:** the wheel is exactly what `pip install openai==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** the repo's CHANGELOG.md (generated from commit titles; it says "chore(types): rename" without the old and new names a fix needs); GitHub release notes (the same text); the API's OpenAPI spec (`openai/api`: the HTTP API, not the Python names code uses). +- **Quote:** `class AsssitantDeleted(BaseModel)`, `openai/types/beta/asssitant_deleted.py` line 10 at 1.1.1, gone at 1.1.2 (renamed `AssistantDeleted`). + +### How the provider announces changes + +- The SDK is generated from OpenAI's API spec and released several times a week; type names follow the spec, so a renamed schema renames a class without a deprecation step. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `openai/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/plugins/openapi/adapter/openai.go b/providers/openai/api.go similarity index 56% rename from plugins/openapi/adapter/openai.go rename to providers/openai/api.go index 05e14c5..1b5bd51 100644 --- a/plugins/openapi/adapter/openai.go +++ b/providers/openai/api.go @@ -1,14 +1,15 @@ -package adapter +package openai import ( "context" - "encoding/json" "fmt" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "gopkg.in/yaml.v3" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // Variables, not constants, only so tests can point them at a local server. @@ -34,7 +35,7 @@ var ( // openapi plugin. A tag here is a commit SHA. type OpenAI struct{} -var _ Adapter = OpenAI{} +var _ adapter.Adapter = OpenAI{} func (OpenAI) API() string { return "openai/api" } @@ -51,7 +52,7 @@ func (OpenAI) LatestTag(ctx context.Context) (string, error) { // commit (Daily): several commits a day is the norm here, and a day is the // version a caller can name. func (OpenAI) Versions(ctx context.Context) ([]plugin.Version, error) { - return commits(ctx, openaiRepo, openaiPath) + return adapter.Commits(ctx, openaiRepo, openaiPath) } // Fetch downloads the spec at commit sha, converts it from YAML to JSON (what @@ -59,47 +60,59 @@ func (OpenAI) Versions(ctx context.Context) ([]plugin.Version, error) { // ServerBasePath. Version is the commit's date (YYYY-MM-DD): info.version // ("2.3.0") isn't bumped with each change, and the API has no dated versions // of its own. -func (OpenAI) Fetch(ctx context.Context, sha string) (Spec, error) { +func (OpenAI) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(openaiCommitURL, sha)) if err != nil { - return Spec{}, fmt.Errorf("looking up openai spec commit %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("looking up openai spec commit %s: %w", sha, err) } if fullSHA == "" { - return Spec{}, fmt.Errorf("github commit %s has no sha", sha) + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha", sha) } url := fmt.Sprintf(openaiSpecURLTemplate, fullSHA) body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth if err != nil { - return Spec{}, fmt.Errorf("fetching openai spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("fetching openai spec %s: %w", sha, err) } - content, err := YAMLToJSON(body) + content, err := adapter.YAMLToJSON(body) if err != nil { - return Spec{}, fmt.Errorf("openai spec %s: %w", sha, err) + return adapter.Spec{}, fmt.Errorf("openai spec %s: %w", sha, err) } // The server is "https://api.openai.com/v1" and the paths don't repeat // /v1 (checked 2026-11-21): moved, an operation is named by the path a // caller sends ("POST /v1/audio/translations"). - if content, err = ServerBasePath(content); err != nil { - return Spec{}, fmt.Errorf("openai spec %s: %w", sha, err) + if content, err = adapter.ServerBasePath(content); err != nil { + return adapter.Spec{}, fmt.Errorf("openai spec %s: %w", sha, err) } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil } // SourcePointer: see BasePathPointer. -func (OpenAI) SourcePointer(content []byte) func(string) string { return BasePathPointer(content) } +func (OpenAI) SourcePointer(content []byte) func(string) string { + return adapter.BasePathPointer(content) +} var ( - _ Reshaper = OpenAI{} - _ Lister = OpenAI{} + _ adapter.Reshaper = OpenAI{} + _ adapter.Lister = OpenAI{} ) -// YAMLToJSON converts a YAML spec to JSON: diff.Parse reads JSON only, and -// normalize quotes the node it cites re-serialized, never the original bytes, -// so nothing quoted changes. -func YAMLToJSON(body []byte) ([]byte, error) { - var doc any - if err := yaml.Unmarshal(body, &doc); err != nil { - return nil, fmt.Errorf("parsing yaml: %w", err) - } - return json.Marshal(doc) -} +// openaiDiff is how OpenAI's spec says what it says: +// +// - Deprecations use the `deprecated` flag: in the spec of 2026-11-21, 17 +// operations carry it and none is called deprecated only in its summary +// or description (one description mentions deprecated models, not the +// operation). A flagged operation's description says why and when ("The +// endpoint and model are deprecated and scheduled to shut down on +// February 26, 2027"), so the event quotes the whole operation. +// - Path parameters could be renamed without the URL changing; matching by +// path template keeps a rename from reading as a removal. +var openaiDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// openaiKeep keeps operation deprecations, and removals of operations the old +// spec had marked deprecated. Everything else is dropped: the spec is +// committed several times a day, and most of what changes is the spec's own +// shape, not the API (enum lists rewritten as const, schemas regenerated), +// or work in progress pulled the day after it was added (the session +// spending-limit schemas, added on 2026-11-17 and gone on 2026-11-18: the +// drop test). New operations aren't something to fix either. +var openaiKeep = openapi.DeprecationsOnly(openaiDiff) diff --git a/plugins/openapi/openai_test.go b/providers/openai/api_test.go similarity index 80% rename from plugins/openapi/openai_test.go rename to providers/openai/api_test.go index 0d307f9..ebb6ee1 100644 --- a/plugins/openapi/openai_test.go +++ b/providers/openai/api_test.go @@ -1,4 +1,4 @@ -package openapi +package openai import ( "context" @@ -9,7 +9,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // openaiDays are the saved excerpts of openai/openai-openapi's openapi.yaml @@ -26,7 +28,7 @@ func openaiURL(day string) string { } // fakeOpenAIAdapter serves the saved excerpts, cited by the real URL each was -// copied from and converted and reshaped as adapter.OpenAI.Fetch does. +// copied from and converted and reshaped as OpenAI.Fetch does. type fakeOpenAIAdapter struct{} func (fakeOpenAIAdapter) API() string { return "openai/api" } @@ -55,12 +57,12 @@ func (fakeOpenAIAdapter) SourcePointer(content []byte) func(string) string { return adapter.BasePathPointer(content) } -func openaiPlugin() Plugin { - return Plugin{Adapter: fakeOpenAIAdapter{}, Diff: openaiDiff, Keep: openaiKeep} +func openaiPlugin() openapi.Plugin { + return openapi.Plugin{Adapter: fakeOpenAIAdapter{}, Diff: openaiDiff, Keep: openaiKeep} } func TestOpenAIRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Adapter: adapter.OpenAI{}}) + kittest.Registered(t, openapi.Plugin{Adapter: OpenAI{}}) } // The golden test: on 2026-10-28 ("Mark /audio/translations endpoint as @@ -70,8 +72,8 @@ func TestOpenAIRegistersItself(t *testing.T) { // (dropped: new) and left /audio/transcriptions as it was. func TestOpenAIGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, openaiPlugin(), "2026-10-27", "2026-10-28"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, openaiPlugin(), "2026-10-27", "2026-10-28"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } events := kittest.Stored(t, s) @@ -97,17 +99,17 @@ func TestOpenAIGolden(t *testing.T) { // removals unfiltered, no event. func TestOpenAIDropsWorkInProgressPulledBack(t *testing.T) { ctx := context.Background() - s := openStore(t) - if _, err := kittest.Pair(ctx, vercelEnv(s), s, openaiPlugin(), "2026-11-17", "2026-11-18"); err != nil { + s := kittest.NewMem() + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, openaiPlugin(), "2026-11-17", "2026-11-18"); err != nil { t.Fatal(err) } if events := kittest.Stored(t, s); len(events) != 0 { t.Fatalf("stored %d events, want none", len(events)) } - s = openStore(t) + s = kittest.NewMem() p := openaiPlugin() p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "2026-11-17", "2026-11-18"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "2026-11-17", "2026-11-18"); err != nil { t.Fatal(err) } if n := len(kittest.Stored(t, s)); n != 3 { diff --git a/providers/openai/models.go b/providers/openai/models.go new file mode 100644 index 0000000..d23b261 --- /dev/null +++ b/providers/openai/models.go @@ -0,0 +1,42 @@ +package openai + +import ( + "strings" + + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" +) + +// Models is OpenAI's deprecations page (checked 2026-10-13). Its tables cover every +// kind of model; these events are for the text models the Chat Completions +// and Responses APIs take. Fine-tuned bases ("ft-gpt-4") aren't names code +// sends (a fine-tuned model is "ft:gpt-4-0613:org::id"), and the "-completions" +// aliases belong to the legacy Completions endpoint. +var Models = retire.Page{ + API: "openai/models", + Provider: "openai", + Vendor: "OpenAI", + URL: "https://developers.openai.com/api/docs/deprecations.md", + Keep: openAIText, +} + +var ( + openAIFamilies = []string{"gpt-3.5", "gpt-4", "gpt-5", "o1", "o3", "o4", "chatgpt-", "computer-use", "codex-"} + openAINotText = []string{"image", "dall-e", "tts", "whisper", "transcribe", "realtime", "audio", "sora", "embedding", "moderation"} +) + +func openAIText(name string) bool { + if strings.HasPrefix(name, "ft-") || strings.HasSuffix(name, "-completions") { + return false + } + for _, s := range openAINotText { + if strings.Contains(name, s) { + return false + } + } + for _, p := range openAIFamilies { + if strings.HasPrefix(name, p) { + return true + } + } + return false +} diff --git a/plugins/notices/living_test.go b/providers/openai/models_living_test.go similarity index 92% rename from plugins/notices/living_test.go rename to providers/openai/models_living_test.go index 754ef00..1adac31 100644 --- a/plugins/notices/living_test.go +++ b/providers/openai/models_living_test.go @@ -1,4 +1,4 @@ -package notices +package openai import ( "context" @@ -10,7 +10,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" ) // growing is a living page that changes between reads, and the archive @@ -32,7 +32,7 @@ func (g *growing) Snapshot(_ context.Context, url string) (string, []byte, error // snapshot of the day it first appeared; the unchanged read costs one GET // and keeps the snapshot. Nothing reaches the network. func TestReadsOfALivingPageStoreEachNoticeOnce(t *testing.T) { - full, err := os.ReadFile("retire/testdata/openai-deprecations.md") + full, err := os.ReadFile("testdata/openai-deprecations.md") if err != nil { t.Fatal(err) } @@ -44,7 +44,7 @@ func TestReadsOfALivingPageStoreEachNoticeOnce(t *testing.T) { string(full), // today's string(full), // today's, read again } - pg := retire.OpenAI + pg := Models archive := &growing{} env := plugin.Env{ Get: func(_ context.Context, u string) ([]byte, error) { @@ -56,7 +56,7 @@ func TestReadsOfALivingPageStoreEachNoticeOnce(t *testing.T) { }, Now: func() time.Time { return archive.at }, } - ctx, sink, p := context.Background(), kittest.NewMem(), Plugin{Page: pg, Archiver: archive} + ctx, sink, p := context.Background(), kittest.NewMem(), notices.Plugin{Page: pg, Archiver: archive} var kept plugin.Snapshot stored := 0 for i, page := range days { diff --git a/providers/openai/models_parse_test.go b/providers/openai/models_parse_test.go new file mode 100644 index 0000000..3a47b00 --- /dev/null +++ b/providers/openai/models_parse_test.go @@ -0,0 +1,122 @@ +package openai + +import ( + "os" + "strings" + "testing" + "time" + + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" +) + +// The batch OpenAI shuts down on 2026-10-23, every alias its own name, each +// with the replacement the page names (saved copy of the page, 2026-10-13). +func TestOpenAIsOctober23Batch(t *testing.T) { + got := byModel(t, Models, "openai-deprecations.md") + want := map[string]string{ + "gpt-3.5-turbo-0125": "gpt-5.6-terra", "gpt-3.5-turbo": "gpt-5.6-terra", + "gpt-4-0613": "gpt-5.6-sol", "gpt-4": "gpt-5.6-sol", + "gpt-4-1106-preview": "gpt-5.6-sol", + "gpt-4-turbo": "gpt-5.6-sol", "gpt-4-turbo-2024-04-09": "gpt-5.6-sol", + "gpt-4.1-nano": "gpt-5.6-luna", "gpt-4.1-nano-2025-04-14": "gpt-5.6-luna", + "gpt-4o-2024-05-13": "gpt-5.6-sol", + "o1-2024-12-17": "gpt-5.6-sol", "o1": "gpt-5.6-sol", + "o1-pro-2025-03-19": "gpt-5.6-sol", "o1-pro": "gpt-5.6-sol", + "o3-mini-2025-01-31": "gpt-5.6-sol", "o3-mini": "gpt-5.6-sol", + "o4-mini-2025-04-16": "gpt-5.6-terra", "o4-mini": "gpt-5.6-terra", + } + n := 0 + for _, r := range got { + if r.Date == "2026-10-23" { + n++ + if want[r.Model] == "" { + t.Errorf("unexpected in the batch: %s", r.Model) + } + } + } + if n != len(want) { + t.Errorf("%d models on 2026-10-23, want %d", n, len(want)) + } + for m, repl := range want { + r, ok := got[m] + if !ok || r.Date != "2026-10-23" || retire.First(r.Replacement) != repl { + t.Errorf("%s: got %+v, want 2026-10-23 -> %s", m, r, repl) + } + } + if !strings.Contains(got["o1-pro"].Replacement, "reasoning.mode: pro") { + t.Errorf("the replacement's note is lost: %q", got["o1-pro"].Replacement) + } + gpt4 := got["gpt-4"].Excerpt + if !strings.Contains(gpt4, "### 2026-04-22: Legacy GPT model snapshots") || !strings.Contains(gpt4, "| Shutdown date") || !strings.Contains(gpt4, "`gpt-4-0613` \\| `gpt-4`") { + t.Errorf("the excerpt should be the heading, the header and the row:\n%s", gpt4) + } +} + +// Not text models, or not names code sends: image, audio, embeddings, +// fine-tuned bases, the legacy "-completions" aliases, endpoints. +func TestOnlyTextModelsCodeSendsAreKept(t *testing.T) { + got := byModel(t, Models, "openai-deprecations.md") + for _, m := range []string{"gpt-image-1", "ft-gpt-4", "gpt-4-0613-completions", "gpt-3.5-turbo-completions", "tts-1-hd-1106", "dall-e-2", "/v1/fine-tunes", "babbage-002", "text-embedding-ada-002"} { + if _, ok := got[m]; ok { + t.Errorf("%s should not be an event", m) + } + } +} + +// A replacement that is itself retired is followed to one that works: +// gpt-3.5-turbo-0613 was told to move to gpt-3.5-turbo, which goes on 2026-10-23. +func TestARetiredReplacementIsFollowed(t *testing.T) { + got := byModel(t, Models, "openai-deprecations.md") + r := got["gpt-3.5-turbo-0613"] + if retire.First(r.Replacement) != "gpt-5.6-terra" || len(r.Via) != 1 || r.Via[0] != "gpt-3.5-turbo" { + t.Errorf("got %+v", r) + } + es, errs := retire.Events(Models, []retire.Retirement{r}, "https://web.archive.org/web/20261013115538/https://developers.openai.com/api/docs/deprecations.md", time.Now()) + if len(es) != 1 { + t.Fatalf("events %d, errs %v", len(es), errs) + } + if h := es[0].MigrationHint; !strings.Contains(h, "gpt-5.6-terra") || !strings.Contains(h, "first named gpt-3.5-turbo") { + t.Errorf("hint: %q", h) + } +} + +func TestEveryRealRetirementBecomesValidEvents(t *testing.T) { + for _, c := range []struct { + p retire.Page + file string + }{{Models, "openai-deprecations.md"}} { + rs, err := retire.Parse(read(t, c.file), c.p.Keep) + if err != nil { + t.Fatal(err) + } + events, errs := retire.Events(c.p, rs, "https://web.archive.org/web/1/x", time.Now()) + if len(errs) != 0 || len(events) != len(rs) { + t.Errorf("%s: %d events from %d retirements, errors %v", c.p.API, len(events), len(rs), errs) + } + } +} + +func read(t *testing.T, name string) []byte { + t.Helper() + b, err := os.ReadFile("testdata/" + name) + if err != nil { + t.Fatal(err) + } + return b +} + +func byModel(t *testing.T, p retire.Page, file string) map[string]retire.Retirement { + t.Helper() + rs, err := retire.Parse(read(t, file), p.Keep) + if err != nil { + t.Fatal(err) + } + out := map[string]retire.Retirement{} + for _, r := range rs { + if _, dup := out[r.Model]; dup { + t.Fatalf("%s listed twice", r.Model) + } + out[r.Model] = r + } + return out +} diff --git a/plugins/notices/retirements_retirements_test.go b/providers/openai/models_read_test.go similarity index 87% rename from plugins/notices/retirements_retirements_test.go rename to providers/openai/models_read_test.go index 2bc9907..36a3ad8 100644 --- a/plugins/notices/retirements_retirements_test.go +++ b/providers/openai/models_read_test.go @@ -1,4 +1,4 @@ -package notices +package openai import ( "context" @@ -9,7 +9,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire" ) const deprecations = `### 2026-04-22: Legacy GPT model snapshots @@ -64,7 +65,7 @@ func retirements(ctx context.Context, s *store, p retire.Page) (bool, error) { Get: func(context.Context, string) ([]byte, error) { return []byte(current.live), nil }, Now: time.Now, } - kept, rejected, err := kittest.ReadPage(ctx, env, s.Mem, Plugin{Page: p, Archiver: current.archive}, s.kept) + kept, rejected, err := kittest.ReadPage(ctx, env, s.Mem, notices.Plugin{Page: p, Archiver: current.archive}, s.kept) s.kept = kept return rejected, err } @@ -73,7 +74,7 @@ func TestRetirementsStoreOneEventPerModel(t *testing.T) { ctx, s, calls := context.Background(), openStore(t), 0 withPage(t, deprecations, fakeArchive{content: deprecations, calls: &calls}) - if rejected, err := retirements(ctx, s, retire.OpenAI); err != nil || rejected { + if rejected, err := retirements(ctx, s, Models); err != nil || rejected { t.Fatalf("rejected=%v err=%v", rejected, err) } events, err := s.All() @@ -92,7 +93,7 @@ func TestRetirementsStoreOneEventPerModel(t *testing.T) { } // Same page again: no snapshot, nothing new. - if _, err := retirements(ctx, s, retire.OpenAI); err != nil { + if _, err := retirements(ctx, s, Models); err != nil { t.Fatal(err) } if calls != 1 { @@ -111,7 +112,7 @@ func TestRetirementsStoreNothingWithoutASnapshotThatHoldsThem(t *testing.T) { ctx, s, calls := context.Background(), openStore(t), 0 archive.calls = &calls withPage(t, deprecations, archive) - if _, err := retirements(ctx, s, retire.OpenAI); err == nil { + if _, err := retirements(ctx, s, Models); err == nil { t.Errorf("%s: want an error", name) } if events, _ := s.All(); len(events) != 0 { @@ -127,12 +128,12 @@ func TestRetirementsStoreNothingWithoutASnapshotThatHoldsThem(t *testing.T) { func TestRetirementsRefuseAPageThatLostMostOfItsTables(t *testing.T) { ctx, s, calls := context.Background(), openStore(t), 0 withPage(t, deprecations, fakeArchive{content: deprecations, calls: &calls}) - if _, err := retirements(ctx, s, retire.OpenAI); err != nil { + if _, err := retirements(ctx, s, Models); err != nil { t.Fatal(err) } renamed := strings.Replace(deprecations, "Substitute model", "Successor", 1) + strings.Replace(strings.Replace(deprecations, "gpt-4-0613` \\| `gpt-4", "gpt-4o-old", 1), "Substitute model", "Recommended replacement", 1) withPage(t, renamed, fakeArchive{content: renamed, calls: &calls}) - if _, err := retirements(ctx, s, retire.OpenAI); err == nil || !strings.Contains(err.Error(), "shape may have changed") { + if _, err := retirements(ctx, s, Models); err == nil || !strings.Contains(err.Error(), "shape may have changed") { t.Fatalf("want the shape error, got %v", err) } if events, _ := s.All(); len(events) != 2 { diff --git a/providers/openai/models_test.go b/providers/openai/models_test.go new file mode 100644 index 0000000..3d74129 --- /dev/null +++ b/providers/openai/models_test.go @@ -0,0 +1,12 @@ +package openai + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest" +) + +// OpenAI's saved page (2026-10-13, testdata/README.md) in, every event out. +func TestModelsGolden(t *testing.T) { + noticestest.Golden(t, Models, "testdata/openai-deprecations.md") +} diff --git a/providers/openai/node_surface_test.go b/providers/openai/node_surface_test.go new file mode 100644 index 0000000..86129f0 --- /dev/null +++ b/providers/openai/node_surface_test.go @@ -0,0 +1,15 @@ +package openai + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// openai 7.60.0 dropped the agents' AgentSessionBudgetReachedEvent +// type (the session spending limits pulled from the API). +func TestNodeSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: NodeSurface, Golden: [2]string{"7.59.0", "7.60.0"}, Want: []string{ + "removed_symbol openai/resources/beta.AgentSessionBudgetReachedEvent,openai/resources/beta/agents.AgentSessionBudgetReachedEvent,openai/resources/beta/agents/agents.AgentSessionBudgetReachedEvent ", + }, Drop: [2]string{"7.60.0", "7.61.0"}}) +} diff --git a/providers/openai/provider.go b/providers/openai/provider.go new file mode 100644 index 0000000..92d6832 --- /dev/null +++ b/providers/openai/provider.go @@ -0,0 +1,44 @@ +// Package openai is what patch-it reads for OpenAI: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package openai + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/kit" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "openai", Name: "OpenAI", Category: plugin.CategoryAI, Homepage: "https://openai.com", + Sources: []plugin.Source{ + // No Hints: OpenAI's changelog is product news, not keyed by operation. + // Only operation deprecations and removals: see api.go. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API operations deprecated, and deprecated operations removed, day by day in the spec OpenAI's SDKs are generated from", + URLs: []string{"https://github.com/openai/openai-openapi/blob/main/openapi.yaml"}, + Packages: []string{"pypi:openai", "npm:openai"}, + Plugin: openapi.Plugin{Adapter: OpenAI{}, Diff: openaiDiff, Keep: openaiKeep}, + }, + { + ID: "models", Layer: plugin.LayerAIModels, + Watches: "Model deprecations and shutdown dates (Chat Completions and Responses text models)", + URLs: []string{"https://developers.openai.com/api/docs/deprecations"}, + Packages: []string{"pypi:openai", "npm:openai"}, + Plugin: notices.Plugin{Page: Models, Archiver: kit.Wayback{}}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/openai/openai-python"), + apisurface.NPM(NodeSurface, "https://github.com/openai/openai-node"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + NodeSurface = apisurface.NPMPackage("openai/node-surface", "openai") + PythonSurface = apisurface.Package{ID: "openai/python-surface", Name: "openai", Ecosystem: "pypi", Module: "openai"} +) diff --git a/providers/openai/python_surface_test.go b/providers/openai/python_surface_test.go new file mode 100644 index 0000000..6c0e163 --- /dev/null +++ b/providers/openai/python_surface_test.go @@ -0,0 +1,78 @@ +package openai + +import ( + "context" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/event" + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" +) + +const ( + wheel111 = "https://files.pythonhosted.org/packages/f7/86/ea99e3f966a639a3256e2f79d78cd63d45d5eb651a5457ccbdcfd9eed24a/openai-1.1.1-py3-none-any.whl" + wheel112 = "https://files.pythonhosted.org/packages/dd/82/b92f73453ea318c0d46f31aeb56e9d94a42606c010fb72a513f4a3cd4bac/openai-1.1.2-py3-none-any.whl" +) + +// The saved releases (testdata/README.md): PyPI's answers and the two +// wheels, trimmed to the openai.types.beta package. +var saved = kittest.Pages{ + "https://pypi.org/pypi/openai/json": "testdata/pypi-openai-excerpt.json", + "https://pypi.org/pypi/openai/1.1.1/json": "testdata/pypi-openai-1.1.1.json", + "https://pypi.org/pypi/openai/1.1.2/json": "testdata/pypi-openai-1.1.2.json", + wheel111: "testdata/openai-1.1.1-py3-none-any.trimmed.whl", + wheel112: "testdata/openai-1.1.2-py3-none-any.trimmed.whl", +} + +// pair lists the releases, reads 1.1.1 and 1.1.2 and extracts the pair, as +// patch-it's hosted ingestion service does, into the test kit's store. +func pair(t *testing.T) []event.Event { + t.Helper() + ctx, env := context.Background(), kittest.Env(t, saved) + p := apisurface.Plugin{Package: PythonSurface} + vs, err := p.ListVersions(ctx, env) + if err != nil { + t.Fatal(err) + } + var ids []string + for _, v := range vs { + ids = append(ids, v.ID) + } + if got := strings.Join(ids, " "); got != "1.1.0 1.1.1 1.1.2" { + t.Fatalf("versions %s", got) + } + last := versions.Pairs(vs)[1] + return kittest.Versions(t, env, p, last[0], last[1]) +} + +// openai 1.1.2 renamed the misspelled AsssitantDeleted to AssistantDeleted, +// module and all: the old name is gone from both places code could import +// it. (Not read as a rename: the class has no parameters to tell it's the +// same class.) +func TestPythonSurfaceGolden(t *testing.T) { + got := pair(t) + kittest.Golden(t, "testdata/golden/openai-python-surface.json", got) + for _, e := range got { + if e.PreviousVersion != "1.1.1" || e.Version != "1.1.2" || e.SourceURL != wheel112 || !strings.Contains(e.SourceExcerpt, "openai/types/beta/asssitant_deleted.py line ") { + t.Errorf("%v: %s<-%s, excerpt %q", e.Subject.Symbols, e.Version, e.PreviousVersion, e.SourceExcerpt) + } + } +} + +// The pinned drop test: 1.1.2 adds AssistantDeleted and its module. A name +// that appears is no breaking change: no event names it. +func TestPythonSurfaceAnAddedNameIsNoEvent(t *testing.T) { + for _, e := range pair(t) { + for _, s := range e.Subject.Symbols { + if strings.Contains(s, "AssistantDeleted") || strings.Contains(s, "assistant_deleted") { + t.Errorf("event for %s, which 1.1.2 added", s) + } + } + } +} + +func TestPythonSurfaceRegistersItself(t *testing.T) { + kittest.Registered(t, apisurface.Plugin{Package: PythonSurface}) +} diff --git a/providers/openai/testdata/README.md b/providers/openai/testdata/README.md new file mode 100644 index 0000000..7375b4a --- /dev/null +++ b/providers/openai/testdata/README.md @@ -0,0 +1,28 @@ +# OpenAI: saved copies and goldens + +Real copies of what OpenAI publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/openai -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved model deprecations pages + +The deprecations page, as markdown (the page's URL plus `.md`), read by the golden test through the whole `notices` plugin. + +**License:** excerpts for testing; © OpenAI. Not covered by this repo's license. + +**Trimmed.** Each file keeps the page title and, for every retirement table that names at least one model the plugin keeps (text models code sends), the section heading above it and the whole table, copied unchanged. Prose, notice-period policy, endpoint tables and tables of only image, audio or embedding models were left out. `retire.Parse` returns exactly the same retirements from the trimmed and the full pages, so the golden files didn't change. + +| File | URL | Fetched | Quote | +|---|---|---|---| +| `openai-deprecations.md` | https://developers.openai.com/api/docs/deprecations.md | 2026-10-13 | "\| October 23, 2026 \| `gpt-4-0613` \\\| `gpt-4`, … \| `gpt-5.6-sol` \|" | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//` (the Python package's own pair, 1.1.1 → 1.1.2, from the files at the top level of `testdata/`). + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `openai-1.1.1-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/f7/86/ea99e3f966a639a3256e2f79d78cd63d45d5eb651a5457ccbdcfd9eed24a/openai-1.1.1-py3-none-any.whl | 2026-11-20 | Apache-2.0 (openai-python; the wheel's `licenses/LICENSE` is kept in it). Trimmed: only `openai/__init__.py`, `openai/types/__init__.py`, every file under `openai/types/beta/`, and the dist-info `METADATA`, `WHEEL` and `LICENSE`, each copied byte for byte (46 of the wheel's files); the plugin reads the same symbols under `openai.types.beta` from it as from the whole wheel. | `class AsssitantDeleted(BaseModel):` (`openai/types/beta/asssitant_deleted.py`, line 10) | +| `openai-1.1.2-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/dd/82/b92f73453ea318c0d46f31aeb56e9d94a42606c010fb72a513f4a3cd4bac/openai-1.1.2-py3-none-any.whl | 2026-11-20 | The same, trimmed the same way. | `from .assistant_deleted import AssistantDeleted as AssistantDeleted` (`openai/types/beta/__init__.py`) | +| `pypi-openai-excerpt.json` | https://pypi.org/pypi/openai/json | 2026-11-20 | PyPI metadata. Trimmed: `releases` to 1.0.0rc1 (a pre-release, left out) and 1.1.0 to 1.1.2, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked` | | +| `pypi-openai-1.1.1.json`, `pypi-openai-1.1.2.json` | https://pypi.org/pypi/openai/1.1.1/json, …/1.1.2/json | 2026-11-20 | PyPI metadata. Trimmed: `info.name`, `info.version`, and `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/openai/`: `openai-7.59.0.trimmed.tgz`, `openai-7.60.0.trimmed.tgz`, `openai-7.61.0.trimmed.tgz` | https://registry.npmjs.org/openai/-/openai-7.59.0.tgz; https://registry.npmjs.org/openai/-/openai-7.60.0.tgz; https://registry.npmjs.org/openai/-/openai-7.61.0.tgz | 2026-11-21 | Apache-2.0 (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `resources/beta.d.mts`, `resources/beta/agents.d.mts`, `resources/beta/agents/agents.d.mts`, `resources/beta/agents/index.d.mts`, `resources/beta/index.d.mts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/openai/`: `npm-openai-excerpt.json` and `npm-openai-7.59.0.json`, `npm-openai-7.60.0.json`, `npm-openai-7.61.0.json` | https://registry.npmjs.org/openai, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/openapi/testdata/golden/openai-api.json b/providers/openai/testdata/golden/openai-api.json similarity index 100% rename from plugins/openapi/testdata/golden/openai-api.json rename to providers/openai/testdata/golden/openai-api.json diff --git a/plugins/notices/testdata/golden/openai-models.json b/providers/openai/testdata/golden/openai-models.json similarity index 100% rename from plugins/notices/testdata/golden/openai-models.json rename to providers/openai/testdata/golden/openai-models.json diff --git a/plugins/apisurface/testdata/golden/openai-node-surface.json b/providers/openai/testdata/golden/openai-node-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/openai-node-surface.json rename to providers/openai/testdata/golden/openai-node-surface.json diff --git a/plugins/apisurface/testdata/golden/openai-python-surface.json b/providers/openai/testdata/golden/openai-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/openai-python-surface.json rename to providers/openai/testdata/golden/openai-python-surface.json diff --git a/plugins/apisurface/testdata/npm/openai/npm-openai-7.59.0.json b/providers/openai/testdata/npm/openai/npm-openai-7.59.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/openai/npm-openai-7.59.0.json rename to providers/openai/testdata/npm/openai/npm-openai-7.59.0.json diff --git a/plugins/apisurface/testdata/npm/openai/npm-openai-7.60.0.json b/providers/openai/testdata/npm/openai/npm-openai-7.60.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/openai/npm-openai-7.60.0.json rename to providers/openai/testdata/npm/openai/npm-openai-7.60.0.json diff --git a/plugins/apisurface/testdata/npm/openai/npm-openai-7.61.0.json b/providers/openai/testdata/npm/openai/npm-openai-7.61.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/openai/npm-openai-7.61.0.json rename to providers/openai/testdata/npm/openai/npm-openai-7.61.0.json diff --git a/plugins/apisurface/testdata/npm/openai/npm-openai-excerpt.json b/providers/openai/testdata/npm/openai/npm-openai-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/openai/npm-openai-excerpt.json rename to providers/openai/testdata/npm/openai/npm-openai-excerpt.json diff --git a/plugins/apisurface/testdata/npm/openai/openai-7.59.0.trimmed.tgz b/providers/openai/testdata/npm/openai/openai-7.59.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/openai/openai-7.59.0.trimmed.tgz rename to providers/openai/testdata/npm/openai/openai-7.59.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/openai/openai-7.60.0.trimmed.tgz b/providers/openai/testdata/npm/openai/openai-7.60.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/openai/openai-7.60.0.trimmed.tgz rename to providers/openai/testdata/npm/openai/openai-7.60.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/openai/openai-7.61.0.trimmed.tgz b/providers/openai/testdata/npm/openai/openai-7.61.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/openai/openai-7.61.0.trimmed.tgz rename to providers/openai/testdata/npm/openai/openai-7.61.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/openai-1.1.1-py3-none-any.trimmed.whl b/providers/openai/testdata/openai-1.1.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/openai-1.1.1-py3-none-any.trimmed.whl rename to providers/openai/testdata/openai-1.1.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/openai-1.1.2-py3-none-any.trimmed.whl b/providers/openai/testdata/openai-1.1.2-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/openai-1.1.2-py3-none-any.trimmed.whl rename to providers/openai/testdata/openai-1.1.2-py3-none-any.trimmed.whl diff --git a/plugins/openapi/testdata/openai-2026-10-27.yaml b/providers/openai/testdata/openai-2026-10-27.yaml similarity index 100% rename from plugins/openapi/testdata/openai-2026-10-27.yaml rename to providers/openai/testdata/openai-2026-10-27.yaml diff --git a/plugins/openapi/testdata/openai-2026-10-28.yaml b/providers/openai/testdata/openai-2026-10-28.yaml similarity index 100% rename from plugins/openapi/testdata/openai-2026-10-28.yaml rename to providers/openai/testdata/openai-2026-10-28.yaml diff --git a/plugins/openapi/testdata/openai-2026-11-17.yaml b/providers/openai/testdata/openai-2026-11-17.yaml similarity index 100% rename from plugins/openapi/testdata/openai-2026-11-17.yaml rename to providers/openai/testdata/openai-2026-11-17.yaml diff --git a/plugins/openapi/testdata/openai-2026-11-18.yaml b/providers/openai/testdata/openai-2026-11-18.yaml similarity index 100% rename from plugins/openapi/testdata/openai-2026-11-18.yaml rename to providers/openai/testdata/openai-2026-11-18.yaml diff --git a/plugins/notices/retire/testdata/openai-deprecations.md b/providers/openai/testdata/openai-deprecations.md similarity index 100% rename from plugins/notices/retire/testdata/openai-deprecations.md rename to providers/openai/testdata/openai-deprecations.md diff --git a/plugins/apisurface/testdata/pypi-openai-1.1.1.json b/providers/openai/testdata/pypi-openai-1.1.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi-openai-1.1.1.json rename to providers/openai/testdata/pypi-openai-1.1.1.json diff --git a/plugins/apisurface/testdata/pypi-openai-1.1.2.json b/providers/openai/testdata/pypi-openai-1.1.2.json similarity index 100% rename from plugins/apisurface/testdata/pypi-openai-1.1.2.json rename to providers/openai/testdata/pypi-openai-1.1.2.json diff --git a/plugins/apisurface/testdata/pypi-openai-excerpt.json b/providers/openai/testdata/pypi-openai-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi-openai-excerpt.json rename to providers/openai/testdata/pypi-openai-excerpt.json diff --git a/providers/planetscale.md b/providers/planetscale/README.md similarity index 92% rename from providers/planetscale.md rename to providers/planetscale/README.md index e4aabd1..f7b404c 100644 --- a/providers/planetscale.md +++ b/providers/planetscale/README.md @@ -1,12 +1,16 @@ -# PlanetScale (`planetscale/api`) +# PlanetScale -## What it watches +Every source patch-it reads for PlanetScale, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## PlanetScale (`planetscale/api`) + +### What it watches The PlanetScale API (`api.planetscale.com/v1`): operations PlanetScale marks deprecated, and removals of operations it had marked deprecated, between two versions of the API's OpenAPI spec. PlanetScale says it in the operation's description, never with the `deprecated` flag. -Kind: `openapi` (`plugins/openapi`), with `adapter.PlanetScale`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `PlanetScale` ([`api.go`](api.go)). -## Why this source +### Why this source - **Source:** `schemas/openapi.yaml` in [planetscale/terraform-provider-planetscale](https://github.com/planetscale/terraform-provider-planetscale), pinned to the commit that last changed it (`https://raw.githubusercontent.com/planetscale/terraform-provider-planetscale//schemas/openapi.yaml`). The newest such commit comes from the GitHub commits API. Checked on 2026-11-19. - **Why this one:** @@ -21,14 +25,14 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.PlanetScale`. - **There's no deprecations page.** - **Quote:** "Deprecated. Use GET /organizations/:organization/databases/:database/branches/:branch/change-requests instead." (`GET .../branches/{branch}/neki-changes`, deprecated in the spec on 2026-11-09) -## How the provider announces changes +### How the provider announces changes - **No API version beyond `/v1`.** `info.version` is a fixed `v1`, so the event's `version` is the date of the spec commit, the closest thing to the API version a change arrived in. - **The spec grows fast:** from 116 operations (2025-11-11) to 291 (2026-11-09) in the repo, and 298 live on 2026-11-19. - **Deprecations are rare and said in words.** No version of the spec has ever set `deprecated: true`. The one deprecation in the history, five operations on 2026-11-09, put "Deprecated. Use ... instead." as the first line of each operation's description. - **Operations leave without being marked.** 41 operations left the spec, none of them deprecated first. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** the spec at the newest commit, converted from YAML to JSON with its values unchanged, and diffed against the last one. Two events come out of it: - **Deprecations:** an operation whose description now starts with "Deprecated." or "Deprecated:" (any case, after any leading whitespace). The event cites the description, so PlanetScale's replacement is in the excerpt. A description that mentions deprecation further on isn't a deprecation, nor is "Deprecated, storage shrinking is part of storage autoscaling.", which the spec writes on properties. If PlanetScale ever sets the flag, the event quotes the whole operation. @@ -42,7 +46,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.PlanetScale`. - Over the 31 consecutive pairs this keeps 5 events, all deprecations on 2026-11-09 (`fc13e09d`): `GET` and `DELETE .../bouncers/{bouncer}/resizes`, `GET .../neki-changes`, `GET` and `DELETE .../neki-changes/{id}`. A pattern matching "deprecat" anywhere in the description finds the same 5. - **Reads** a historical pair (a version pair, `e631095a` → `fc13e09d`) and recreates those 5. The drop test replays `b49c3540` to `f6d6ad4d` (the replica rename): no event, where the same pair unfiltered reports the 7 removals. -## Known gaps +### Known gaps - **Deprecations PlanetScale announces elsewhere aren't events.** The 12 `/organizations/{organization}/databases/{database}/workflows` operations left the spec on 2026-10-14 without ever being marked in it, and planetscale-go calls `read-only-replicas` deprecated while the spec never did. - **Removals PlanetScale didn't mark first aren't events,** even if the endpoint really went away. diff --git a/providers/planetscale/api.go b/providers/planetscale/api.go new file mode 100644 index 0000000..b1f4354 --- /dev/null +++ b/providers/planetscale/api.go @@ -0,0 +1,160 @@ +package planetscale + +import ( + "cmp" + "context" + "encoding/json" + "fmt" + "regexp" + + "github.com/patch-it-dev/patch-it-plugins/core/diff" + "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "gopkg.in/yaml.v3" +) + +const ( + // planetscaleRepo is PlanetScale's Terraform provider, which keeps a copy + // of the PlanetScale API spec at planetscaleSpecPath. + planetscaleRepo = "planetscale/terraform-provider-planetscale" + // planetscaleSpecPath is the spec in that repo: a copy of + // https://planetscale.com/docs/openapi.yaml, which has no versions, + // committed when it changes. + planetscaleSpecPath = "schemas/openapi.yaml" +) + +// PlanetScale adapts the PlanetScale API spec for the openapi plugin. The +// repo tags no spec releases, so a tag here is the commit that last changed +// the spec, as for Supabase. +// +// The zero value reads GitHub. The fields point it at another server, for +// tests. +type PlanetScale struct { + APIBase string // GitHub's REST API; "" is https://api.github.com + RawBase string // files at a commit; "" is https://raw.githubusercontent.com +} + +var _ adapter.Adapter = PlanetScale{} + +func (PlanetScale) API() string { return "planetscale/api" } + +func (p PlanetScale) api(path string) string { + return cmp.Or(p.APIBase, "https://api.github.com") + "/repos/" + planetscaleRepo + path +} + +// LatestTag is the SHA of the newest commit that changed the spec. +func (p PlanetScale) LatestTag(ctx context.Context) (string, error) { + sha, err := github.LatestCommit(ctx, github.Get, p.api("/commits?path="+planetscaleSpecPath+"&per_page=1")) + if err != nil { + return "", fmt.Errorf("looking up planetscale's latest spec commit: %w", err) + } + return sha, nil +} + +// Fetch downloads the spec at commit sha and converts it from YAML to JSON, +// which is what diff.Parse reads (as for Algolia). +// +// Version is the commit's date (YYYY-MM-DD): the API has no version of its +// own (`info.version` is a fixed "v1", checked 2026-11-19), so the date the +// spec changed is the closest thing to "the API version the change arrived +// in". +// +// A file that isn't a spec is an error, not an empty API: diffed against the +// last one, it would read as every operation removed. The commits that +// changed the file include one that deleted it (f33a0c3b35, 2025-12-04; +// it came back the same day), where the raw URL answers 404: fetch.Get's +// error. A file served 200 that has no paths (emptied, or a stub page like +// "404: Not Found", which YAML reads as a one-key mapping) is refused here. +func (p PlanetScale) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { + fullSHA, date, err := github.Commit(ctx, github.Get, p.api("/commits/"+sha)) + if err != nil { + return adapter.Spec{}, fmt.Errorf("looking up planetscale spec commit %s: %w", sha, err) + } + if fullSHA == "" { + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) + } + // Pin to the full SHA even when given a short one: the citation must + // name exactly one document. + url := cmp.Or(p.RawBase, "https://raw.githubusercontent.com") + "/" + planetscaleRepo + "/" + fullSHA + "/" + planetscaleSpecPath + body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth + if err != nil { + return adapter.Spec{}, fmt.Errorf("fetching planetscale spec %s: %w", sha, err) + } + var doc map[string]any + if err := yaml.Unmarshal(body, &doc); err != nil { + return adapter.Spec{}, fmt.Errorf("parsing planetscale spec %s as yaml: %w", sha, err) + } + if paths, _ := doc["paths"].(map[string]any); len(paths) == 0 { + return adapter.Spec{}, fmt.Errorf("planetscale spec %s has no paths: not a spec", sha) + } + content, err := json.Marshal(doc) + if err != nil { + return adapter.Spec{}, fmt.Errorf("converting planetscale spec %s to json: %w", sha, err) + } + // The server is "https://api.planetscale.com/v1" and the paths leave out + // /v1 (all 32 versions, checked 2026-11-19). Moved into the paths, an + // operation is named by the path a caller sends, and a spec that ever + // moved it (as Sentry's did) can't read as every deprecated operation + // removed. + if content, err = adapter.ServerBasePath(content); err != nil { + return adapter.Spec{}, fmt.Errorf("planetscale spec %s: %w", sha, err) + } + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil +} + +// SourcePointer: see BasePathPointer. +func (PlanetScale) SourcePointer(content []byte) func(string) string { + return adapter.BasePathPointer(content) +} + +var _ adapter.Reshaper = PlanetScale{} + +// Versions are the commits that changed PlanetScale's spec. +func (PlanetScale) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Commits(ctx, planetscaleRepo, planetscaleSpecPath) +} + +// planetscaleDiff is how the PlanetScale API spec says what it says: +// +// - Deprecations are only in the description's first words, "Deprecated. +// Use GET /organizations/:organization/databases/:database/branches/:branch/change-requests +// instead.": the spec has never set the `deprecated` flag (none in any +// of the 32 versions of schemas/openapi.yaml in +// planetscale/terraform-provider-planetscale, 2025-11-11 to 2026-11-09, +// nor in the live https://planetscale.com/docs/openapi.yaml on +// 2026-11-19). If it ever does, the operation is quoted whole, so the +// words come with it. +// - Path parameters get renamed, and that isn't a change for callers. +var planetscaleDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true, DeprecatedDescription: planetscaleDeprecatedDescription} + +// planetscaleDeprecatedWords is the way every deprecation in the history is +// written: the description starts "Deprecated." (the others start with what +// the operation does, or with an empty line, then "### Authorization"). Only +// at the start, +// so not a description that mentions deprecation further on; and with the +// period or a colon, so not "Deprecated, storage shrinking is part of +// storage autoscaling.", which the spec writes on properties. +var planetscaleDeprecatedWords = regexp.MustCompile(`(?i)^\s*deprecated[.:]`) + +func planetscaleDeprecatedDescription(description string) bool { + return planetscaleDeprecatedWords.MatchString(description) +} + +// planetscaleKeep keeps operation deprecations, and removals of operations +// the old spec had marked deprecated. Over the 31 consecutive pairs of the +// spec's history that's 5 events, all on 2026-11-09 (fc13e09d): GET and +// DELETE .../bouncers/{bouncer}/resizes, GET .../neki-changes, GET and +// DELETE .../neki-changes/{id}. Everything else is dropped: +// +// - 41 operations left the spec, none deprecated first. 6 of them, on +// 2026-10-03, were the read-only replica operations renamed to +// dedicated read replicas, and planetscale/planetscale-go still sends +// the old paths ("the deprecated read-only-replicas path", main on +// 2026-11-19): left the spec isn't stopped working. +// - Property changes and new operations, as for vercel: 226 type changes +// on 2025-12-06 alone, when the spec switched whole numbers to +// `integer`. +var planetscaleKeep = openapi.DeprecationsOnly(planetscaleDiff) diff --git a/plugins/openapi/adapter/planetscale_test.go b/providers/planetscale/api_fetch_test.go similarity index 99% rename from plugins/openapi/adapter/planetscale_test.go rename to providers/planetscale/api_fetch_test.go index 9750d8f..eaf84a8 100644 --- a/plugins/openapi/adapter/planetscale_test.go +++ b/providers/planetscale/api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package planetscale import ( "context" diff --git a/plugins/openapi/planetscale_test.go b/providers/planetscale/api_test.go similarity index 92% rename from plugins/openapi/planetscale_test.go rename to providers/planetscale/api_test.go index 0da3651..825ebe9 100644 --- a/plugins/openapi/planetscale_test.go +++ b/providers/planetscale/api_test.go @@ -1,4 +1,4 @@ -package openapi +package planetscale import ( "context" @@ -12,7 +12,8 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // planetscaleCommits are the planetscale/terraform-provider-planetscale @@ -33,7 +34,7 @@ func planetscaleFile(sha string) string { return "testdata/planetscale-" + sha[: // planetscalePlugin is the plugin as registered, its adapter reading GitHub's // answers and the saved copies from a local server. It returns the base the // spec URLs start with in place of planetscaleRaw. -func planetscalePlugin(t *testing.T) (Plugin, string) { +func planetscalePlugin(t *testing.T) (openapi.Plugin, string) { t.Helper() const repo = "/planetscale/terraform-provider-planetscale" srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -52,14 +53,14 @@ func planetscalePlugin(t *testing.T) (Plugin, string) { http.NotFound(w, r) })) t.Cleanup(srv.Close) - a := adapter.PlanetScale{APIBase: srv.URL + "/api", RawBase: srv.URL + "/raw"} - return Plugin{Adapter: a, Diff: planetscaleDiff, Keep: planetscaleKeep}, srv.URL + "/raw" + repo + a := PlanetScale{APIBase: srv.URL + "/api", RawBase: srv.URL + "/raw"} + return openapi.Plugin{Adapter: a, Diff: planetscaleDiff, Keep: planetscaleKeep}, srv.URL + "/raw" + repo } -func pairPlanetScale(t *testing.T, p Plugin, from, to string) []event.Event { +func pairPlanetScale(t *testing.T, p openapi.Plugin, from, to string) []event.Event { t.Helper() - s := openStore(t) - if rejected, err := kittest.Pair(context.Background(), vercelEnv(s), s, p, from, to); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(context.Background(), openapitest.Env(s), s, p, from, to); err != nil || rejected { t.Fatalf("pair %s -> %s: rejected=%v err=%v", from, to, rejected, err) } return kittest.Stored(t, s) @@ -99,7 +100,7 @@ func TestPlanetScaleGolden(t *testing.T) { if url := base + "/" + to + "/schemas/openapi.yaml"; e.SourceURL != url { t.Errorf("%s: source_url %s, want %s", e.Subject.Operation, e.SourceURL, url) } - if node := yamlNodeJSON(t, planetscaleFile(to), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.YAMLNodeJSON(t, planetscaleFile(to), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt doesn't match %s#%s", e.Subject.Operation, planetscaleFile(to), e.SourcePointer) } var description string diff --git a/providers/planetscale/provider.go b/providers/planetscale/provider.go new file mode 100644 index 0000000..9fefe99 --- /dev/null +++ b/providers/planetscale/provider.go @@ -0,0 +1,26 @@ +// Package planetscale is what patch-it reads for PlanetScale: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package planetscale + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "planetscale", Name: "PlanetScale", Category: plugin.CategoryDatabases, Homepage: "https://planetscale.com", + Sources: []plugin.Source{ + // No Hints: PlanetScale's changelog is product news, not keyed by + // operation. Operation deprecations only, said in the description: see + // api.go. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "API operations deprecated, and deprecated operations removed, between commits of the spec, said in the operation's description", + URLs: []string{"https://github.com/planetscale/terraform-provider-planetscale"}, + Plugin: openapi.Plugin{Adapter: PlanetScale{}, Diff: planetscaleDiff, Keep: planetscaleKeep}, + }, + }, + }) +} diff --git a/providers/planetscale/testdata/README.md b/providers/planetscale/testdata/README.md new file mode 100644 index 0000000..a8bd329 --- /dev/null +++ b/providers/planetscale/testdata/README.md @@ -0,0 +1,14 @@ +# PlanetScale: saved copies and goldens + +Real copies of what PlanetScale publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/planetscale -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `planetscale-e631095a.yaml`, `planetscale-fc13e09d.yaml` | https://raw.githubusercontent.com/planetscale/terraform-provider-planetscale/e631095aa649a6797578a1d51d861b91e0568aa1/schemas/openapi.yaml (and `fc13e09d0c18b893aabd3e02d175d13957bba677`) | 2026-11-19 | none stated for the file (its `info` says "© 2026 PlanetScale, Inc."); the repo, planetscale/terraform-provider-planetscale, is Apache-2.0. Excerpt for testing; © PlanetScale | "Deprecated. Use GET /organizations/:organization/databases/:database/branches/:branch/change-requests instead." (`GET .../neki-changes`, new in `fc13e09d`) | +| `planetscale-b49c3540.yaml`, `planetscale-f6d6ad4d.yaml` | https://raw.githubusercontent.com/planetscale/terraform-provider-planetscale/b49c354080667638b79781801f0517ae07bc55b8/schemas/openapi.yaml (and `f6d6ad4d3929f6c1ef021eb13c1541ba31f72107`) | 2026-11-19 | none stated for the file (its `info` says "© 2026 PlanetScale, Inc."); the repo, planetscale/terraform-provider-planetscale, is Apache-2.0. Excerpt for testing; © PlanetScale | `/organizations/{organization}/databases/{database}/branches/{branch}/read-only-replicas:` (in `b49c3540`, never deprecated, gone in `f6d6ad4d`, where `.../dedicated-read-replicas:` is): the drop test | + +The PlanetScale copies are trimmed by lines: everything before `paths:` (`openapi`, `info`), then the path items involved, whole, and the two-line `servers` block (`https://api.planetscale.com/v1`, the same in every version), every line copied unchanged; the other paths, `tags`, `security`, `x-readme` and `components` left out. The file states no license, so only what the tests need is kept. The golden pair gives the full files' 5 deprecations (their only ones), the drop-test pair their 7 removals (their only ones). The tests serve them as GitHub would, with each commit's date. diff --git a/plugins/openapi/testdata/golden/planetscale.json b/providers/planetscale/testdata/golden/planetscale.json similarity index 100% rename from plugins/openapi/testdata/golden/planetscale.json rename to providers/planetscale/testdata/golden/planetscale.json diff --git a/plugins/openapi/testdata/planetscale-b49c3540.yaml b/providers/planetscale/testdata/planetscale-b49c3540.yaml similarity index 100% rename from plugins/openapi/testdata/planetscale-b49c3540.yaml rename to providers/planetscale/testdata/planetscale-b49c3540.yaml diff --git a/plugins/openapi/testdata/planetscale-e631095a.yaml b/providers/planetscale/testdata/planetscale-e631095a.yaml similarity index 100% rename from plugins/openapi/testdata/planetscale-e631095a.yaml rename to providers/planetscale/testdata/planetscale-e631095a.yaml diff --git a/plugins/openapi/testdata/planetscale-f6d6ad4d.yaml b/providers/planetscale/testdata/planetscale-f6d6ad4d.yaml similarity index 100% rename from plugins/openapi/testdata/planetscale-f6d6ad4d.yaml rename to providers/planetscale/testdata/planetscale-f6d6ad4d.yaml diff --git a/plugins/openapi/testdata/planetscale-fc13e09d.yaml b/providers/planetscale/testdata/planetscale-fc13e09d.yaml similarity index 100% rename from plugins/openapi/testdata/planetscale-fc13e09d.yaml rename to providers/planetscale/testdata/planetscale-fc13e09d.yaml diff --git a/providers/posthog-go.md b/providers/posthog-go.md deleted file mode 100644 index 69a0fd8..0000000 --- a/providers/posthog-go.md +++ /dev/null @@ -1,27 +0,0 @@ -# PostHog Go SDK (`posthog/go`) - -## What it watches - -Names removed or renamed in each release of posthog-go, from that release's section of its `CHANGELOG.md` at its tag. Package `go:github.com/posthog/posthog-go` (events name the module at each release's major, `…/v2` from 2.0.0); releases listed from the repo's `vX.Y.Z` tags. The Python SDK's 8.0 migration guide is a separate source (`posthog/python-sdk`). - -Kind: `changelog` (`plugins/changelog`, `sdks.go`). - -## Why this source - -- **Source:** https://github.com/PostHog/posthog-go/blob/main/CHANGELOG.md, read raw at the release's tag; checked on 2026-11-20. -- **Why this one:** changesets writes each major's changes under "### Major Changes", one bullet per change starting with its commit (`fc05013: Remove …`). -- **Alternatives considered:** GitHub release notes (the same text); PostHog's SDK docs (one page, not versioned). -- **Quote:** "fc05013: Remove `Capture.Library` and `Exception.Library`." (2.0.0). - -## How the provider announces changes - -Majors are rare; v2 moved the module path to `github.com/posthog/posthog-go/v2`. - -## What the plugin reads and ignores - -- Reads "Major Changes" bullets (and any breaking heading); the commit prefix is read past. -- Drops (and logs) behavior changes and bullets that don't name what they remove plainly. - -## Known gaps - -- A release whose section is missing at its tag is skipped as nothing to read. diff --git a/providers/posthog.md b/providers/posthog/README.md similarity index 78% rename from providers/posthog.md rename to providers/posthog/README.md index 9e6fc84..7a38c8d 100644 --- a/providers/posthog.md +++ b/providers/posthog/README.md @@ -1,12 +1,16 @@ -# PostHog (`posthog/python-sdk`) +# PostHog -## What it watches +Every source patch-it reads for PostHog, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## PostHog (`posthog/python-sdk`) + +### What it watches Members a new major of the `posthog` Python SDK removes, from that major's migration guide: in 8.0.0, `CaptureMode`, `posthog.capture_v1`, `posthog.capture_v1.CaptureV1Error`, `posthog.request.batch_post`… (code using one breaks on the upgrade). One event per member, with the major's first release as `version` and the release before it on PyPI as `previous_version`. The releases are listed from PyPI; the guide is read at each major's first tag, so nothing in the code names a release. -Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members reader (`plugins/migrationguide/members`), reading a Markdown table. +Kind: `migrationguide` (`kinds/migrationguide`), with the removed-members reader (`kinds/migrationguide/members`), reading a Markdown table. -## Why this source +### Why this source - **Source:** `docs/migration-.x-to-.0.md` at tag `posthog-v.0.0`, read raw at the tag; the one so far is [`docs/migration-7.x-to-8.0.md` at posthog-v8.0.0](https://github.com/PostHog/posthog-python/blob/posthog-v8.0.0/docs/migration-7.x-to-8.0.md) (commit `6edff41425188056e48f6119457dc9bc0669ca99`). A major with no guide at its tag has nothing to read (the pair is skipped). Releases from [PyPI](https://pypi.org/project/posthog/). Checked on 2026-11-19. The guide isn't in the repo at posthog-v7.91.4, the release before, and is the same at posthog-v8.0.2. MIT. - **Why this one:** it's PostHog's own migration guide for the SDK's 8.0.0, and its "Fix removed APIs" section is a table of what 8.0.0 removed and what to use instead. A tag never changes, so the URL is its own citation, and 8.0.0 is a version a repo pins. @@ -22,13 +26,13 @@ Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members read - **The rendered docs** on posthog.com, and `references/posthog-python-migration.md` in the same repo: the same guide, as a live page and with posthog.com's front matter. - **Quote:** "8.x.x removes these options and APIs:" (Fix removed APIs), with rows such as "| `CaptureV1Error` | `CaptureError` |". -## How the provider announces changes +### How the provider announces changes - Package versions (SemVer). posthog-python releases often (7.89.0 to 8.0.0 in five days). 8.0.0 shipped on 2026-11-17. - **Forced on a fresh install** for an unpinned or open pin (`posthog>=7`), otherwise when the team upgrades. - A major release gets a migration guide in `docs/`; this is the first one there. -## What the plugin reads and ignores +### What the plugin reads and ignores - Reads the table under "Fix removed APIs", `| Removed | Use instead |`. A row becomes one event per name, but only when its first cell is nothing but code spans naming members. Names are written as code writes them after the import: `posthog.` is stripped, other prefixes kept. - `removed_symbol` for every name, with the "Use instead" cell in the migration hint. Not `renamed_symbol`, even when that cell is one name: every replacement is new in 8.0.0, so a renamed import would fail on 7.x, and `CaptureError` also moves module (below). The 7 rows, checked against the code at posthog-v7.91.4 and posthog-v8.0.0: @@ -47,7 +51,7 @@ Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members read - **`CaptureV1Error` → `CaptureError` moves module too:** from `posthog.capture_v1` to `posthog`, and `CaptureError` is new in 8.0.0. The row says only the names; the guide says the rest a few paragraphs below ("Replace `from posthog.capture_v1 import CaptureV1Error` with `from posthog import CaptureError`. There is no alias."). - Ignores the guide's eight other tables (endpoints, AI lane arguments, error fields, retries, SDK identity, dropped events, options, and "Rename deprecated settings", whose old names still work in 8.x.x) and its prose (behavior changes such as property precedence and retries). -## Known gaps +### Known gaps - PostHog's REST API itself (see above: no pinned spec, and nothing deprecated in its history). - **Importing the `posthog.capture_mode` module directly** (`from posthog.capture_mode import …`) breaks in 8.0.0 and gets no event of its own: the row's `capture_mode` is dropped because the guide says setting it still works. The usual use of that module, `CaptureMode`, is an event. @@ -55,3 +59,31 @@ Kind: `migrationguide` (`plugins/migrationguide`), with the removed-members read - Later majors of posthog-python: each is a new entry in this plugin. - Behavior changes in 8.0.0 that aren't removals (keyword-only arguments, property precedence, retries, routing of AI events). - The `posthoganalytics` package, which the guide says has the same changes. + +## PostHog Go SDK (`posthog/go`) + +### What it watches + +Names removed or renamed in each release of posthog-go, from that release's section of its `CHANGELOG.md` at its tag. Package `go:github.com/posthog/posthog-go` (events name the module at each release's major, `…/v2` from 2.0.0); releases listed from the repo's `vX.Y.Z` tags. The Python SDK's 8.0 migration guide is a separate source (`posthog/python-sdk`). + +Kind: `changelog` (`kinds/changelog`, `sdks.go`). + +### Why this source + +- **Source:** https://github.com/PostHog/posthog-go/blob/main/CHANGELOG.md, read raw at the release's tag; checked on 2026-11-20. +- **Why this one:** changesets writes each major's changes under "### Major Changes", one bullet per change starting with its commit (`fc05013: Remove …`). +- **Alternatives considered:** GitHub release notes (the same text); PostHog's SDK docs (one page, not versioned). +- **Quote:** "fc05013: Remove `Capture.Library` and `Exception.Library`." (2.0.0). + +### How the provider announces changes + +Majors are rare; v2 moved the module path to `github.com/posthog/posthog-go/v2`. + +### What the plugin reads and ignores + +- Reads "Major Changes" bullets (and any breaking heading); the commit prefix is read past. +- Drops (and logs) behavior changes and bullets that don't name what they remove plainly. + +### Known gaps + +- A release whose section is missing at its tag is skipped as nothing to read. diff --git a/providers/posthog/go_test.go b/providers/posthog/go_test.go new file mode 100644 index 0000000..982ff1c --- /dev/null +++ b/providers/posthog/go_test.go @@ -0,0 +1,13 @@ +package posthog + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +func TestPostHogGoSDKs(t *testing.T) { + changelogtest.CheckSDKs(t, []changelogtest.SDKCase{ + {File: Go, Release: "2.0.0", Prev: "1.44.1", Saved: "posthog-go-2.0.0-CHANGELOG.md", Dropped: "", Drop: "1.44.1"}, + }) +} diff --git a/plugins/migrationguide/members/posthog.go b/providers/posthog/provider.go similarity index 74% rename from plugins/migrationguide/members/posthog.go rename to providers/posthog/provider.go index 162271e..4cb9fa5 100644 --- a/plugins/migrationguide/members/posthog.go +++ b/providers/posthog/provider.go @@ -1,6 +1,37 @@ -package members +// Package posthog is what patch-it reads for PostHog: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package posthog -// PostHog is the posthog Python SDK's guide to a major, +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "posthog", Name: "PostHog", Category: plugin.CategoryAnalytics, Homepage: "https://posthog.com", + Sources: []plugin.Source{ + { + ID: "python-sdk", Layer: plugin.LayerSDK, + Watches: "Members a new major of the posthog Python SDK removes, from its migration guide in docs/ at the major's first tag", + URLs: []string{"https://github.com/PostHog/posthog-python/tree/main/docs", "https://pypi.org/project/posthog/"}, + Packages: []string{"pypi:posthog"}, + Plugin: migrationguide.Plugin{Guide: PythonSDK}, + }, + changelog.SDK("go", Go, "go:github.com/posthog/posthog-go"), + }, + }) +} + +// Go is posthog-go's changesets CHANGELOG.md: "## X.Y.Z" with "### +// Major Changes", each bullet starting with its commit; tagged vX.Y.Z. +var Go = changelog.File{API: "posthog/go", Package: "github.com/posthog/posthog-go", Ecosystem: "go", Module: "posthog", + Repo: "PostHog/posthog-go", TagPrefix: "v", Path: "CHANGELOG.md"} + +// PythonSDK is the posthog Python SDK's guide to a major, // docs/migration-{prev}.x-to-{major}.0.md at the major's first tag. The one // there is so far (checked 2026-11-20) is 8.0.0's, docs/migration-7.x-to-8.0.md // at tag posthog-v8.0.0 (commit @@ -62,7 +93,7 @@ package members // major's names that aren't in them are read as the table writes them, and // NewReplacements keeps every row with one replacement a removed_symbol (no // rename the client would apply), so a new guide is read conservatively. -var PostHog = Guide{ +var PythonSDK = members.Guide{ API: "posthog/python-sdk", Package: "posthog", Module: "posthog", @@ -70,7 +101,7 @@ var PostHog = Guide{ Repo: "PostHog/posthog-python", Path: "docs/migration-{prev}.x-to-{major}.0.md", Section: "Fix removed APIs", - Format: FormatMarkdown, + Format: members.FormatMarkdown, Header: "Removed", EnvVars: []string{"POSTHOG_CAPTURE_MODE"}, Paths: map[string]string{ diff --git a/plugins/migrationguide/members/posthog_test.go b/providers/posthog/python_sdk_test.go similarity index 60% rename from plugins/migrationguide/members/posthog_test.go rename to providers/posthog/python_sdk_test.go index 229ab76..2789037 100644 --- a/plugins/migrationguide/members/posthog_test.go +++ b/providers/posthog/python_sdk_test.go @@ -1,7 +1,7 @@ -package members_test +package posthog import ( - "errors" + "context" "slices" "strings" "testing" @@ -10,20 +10,21 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide" - . "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide/members" // the reader under test + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/members" + "github.com/patch-it-dev/patch-it-plugins/kinds/migrationguide/migrationguidetest" ) // The guide as published at tag posthog-v8.0.0 (fetched 2026-11-19), whole. const posthogSource = "testdata/migration-7.x-to-8.0-posthog-v8.0.0.md" func TestPostHogRegistersItself(t *testing.T) { - kittest.Registered(t, migrationguide.Plugin{Guide: PostHog}) + kittest.Registered(t, migrationguide.Plugin{Guide: PythonSDK}) } // The golden test: the saved guide in, every event out. func TestPostHogGolden(t *testing.T) { - kittest.Golden(t, "../testdata/golden/posthog-8.0.0.json", posthogIngest(t)) + kittest.Golden(t, "testdata/golden/posthog-8.0.0.json", posthogIngest(t)) } // Each of the "Fix removed APIs" table's 7 rows, decided: every name is a @@ -85,7 +86,7 @@ func TestPostHogDropsWhatIsNotARemovedMember(t *testing.T) { // The table's own rows: an environment variable, an argument value, and // two rows of prose (a parameter, a dependency). With the rules off, each // is a row of the table, with names in code spans. - rs, err := Parse(kittest.Read(t, posthogSource), PostHog) + rs, err := members.Parse(kittest.Read(t, posthogSource), PythonSDK) if err != nil { t.Fatal(err) } @@ -131,9 +132,9 @@ func TestPostHogDropsWhatIsNotARemovedMember(t *testing.T) { {"Update error handling", "Field", "drops"}, {"Move to event options", "Option", "cookieless_mode"}, } { - g := PostHog + g := PythonSDK g.Section, g.Header = other.section, other.header - rs, err := Parse(kittest.Read(t, posthogSource), g) + rs, err := members.Parse(kittest.Read(t, posthogSource), g) if err != nil { t.Fatal(err) } @@ -150,98 +151,22 @@ func TestPostHogDropsWhatIsNotARemovedMember(t *testing.T) { } } -func TestPipeCells(t *testing.T) { - for row, want := range map[string][]string{ - "| Removed | Use instead |": {"Removed", "Use instead"}, - "| --- | --- |": {"---", "---"}, - "| `a`, `b` | Nothing |": {"`a`, `b`", "Nothing"}, - "| `x | y` | a \\| b |": {"`x | y`", "a | b"}, - "|`a`|`b`|": {"`a`", "`b`"}, - "| `request.batch_post`, `EVENTS_ENDPOINT` |": {"`request.batch_post`, `EVENTS_ENDPOINT`"}, - "| one | two | three |": {"one", "two", "three"}, - } { - if got := PipeCells(row); !slices.Equal(got, want) { - t.Errorf("PipeCells(%q) = %q, want %q", row, got, want) - } - } -} - -func TestMarkdownTable(t *testing.T) { - g := Guide{Package: "acme", Module: "acme", Section: "Removed", Format: FormatMarkdown, Header: "Removed", EnvVars: []string{"ACME_MODE"}} - page := strings.Join([]string{ - "# Guide", - "## Removed", - "```python", - "# not a heading", - "```", - "Text before the table.", - "", - "| Removed | Use instead |", - "| :--- | ---: |", - "| `acme.old_fn()` | `acme.new_fn` |", - "| `A`, `B`, and `ACME_MODE` | Nothing |", - "| `C` | `D` and `E` |", - "| `F` | Use `G` instead |", - "| `same` | `same` |", - "| `x=1` | `y` |", - "| The `dep` dependency | Nothing |", - "| `short` |", - "", - "| Removed | Use instead |", - "| --- | --- |", - "| `not_read` | `the second table` |", - }, "\n") - rs, err := Parse([]byte(page), g) - if err != nil { - t.Fatal(err) - } - type row struct{ member, replacement, dropped string } - var got []row - for _, r := range rs { - d := "" - if r.Dropped != "" { - d = "dropped" - } - got = append(got, row{r.Member, r.Replacement, d}) - } - want := []row{ - {"old_fn", "new_fn", ""}, - {"A", "", ""}, - {"B", "", ""}, - {"ACME_MODE", "", "dropped"}, - {"C", "", ""}, - {"F", "", ""}, - {"same", "", ""}, - {"`x=1`", "", "dropped"}, - {"The `dep` dependency", "", "dropped"}, - {"| `short` |", "", "dropped"}, - } - if !slices.Equal(got, want) { - t.Errorf("got\n%v\nwant\n%v", got, want) - } - if rs[0].Guideline != "Use instead: `acme.new_fn`" || - rs[0].Excerpt != "Removed\n| Removed | Use instead |\n| :--- | ---: |\n| `acme.old_fn()` | `acme.new_fn` |" { - t.Errorf("%+v", rs[0]) - } - - for name, c := range map[string]struct { - page string - nothing bool // plugin.ErrNothingToRead: no part to read, not a guide that changed shape - }{ - "no section": {"## Other\n| Removed | Use instead |\n| --- | --- |\n| `a` | b |", true}, - "no table": {"## Removed\ntext\n## Next\n| Removed | Use instead |\n| --- | --- |\n| `a` | b |", true}, - "another table": {"## Removed\n| Method | Endpoint |\n| --- | --- |\n| `a` | b |", false}, - } { - _, err := Parse([]byte(c.page), g) - if err == nil || errors.Is(err, plugin.ErrNothingToRead) != c.nothing { - t.Errorf("%s: err %v, want an error that is plugin.ErrNothingToRead: %v", name, err, c.nothing) - } - } -} - // posthogIngest is the pair from 7.91.4, the release before on PyPI, over // the saved guide. func posthogIngest(t *testing.T) []event.Event { t.Helper() - return release(t, PostHog, posthogSource, "7.91.4", "8.0.0") + return migrationguidetest.Release(t, migrationguidetest.GuideEnv(t, PythonSDK, posthogSource, "8.0.0"), PythonSDK, "7.91.4", "8.0.0") +} + +// The guide is read at the major's first tag (posthog-v8.0.0); a release +// that isn't one has none. +func TestPythonSDKGuideIsReadAtTheMajorsTag(t *testing.T) { + ctx := context.Background() + want := "https://raw.githubusercontent.com/PostHog/posthog-python/posthog-v8.0.0/docs/migration-7.x-to-8.0.md" + if got, err := PythonSDK.GuideURL(ctx, migrationguidetest.GuideEnv(t, PythonSDK, "testdata/README.md", "8.0.0"), plugin.Version{ID: "8.0.0"}); err != nil || got != want { + t.Errorf("%q, %v; want %q", got, err, want) + } + if got, err := PythonSDK.GuideURL(ctx, plugin.Env{}, plugin.Version{ID: "8.0.1"}); got != "" || err != nil { + t.Errorf("a release that isn't a major's first has no guide: %q, %v", got, err) + } } diff --git a/providers/posthog/testdata/README.md b/providers/posthog/testdata/README.md new file mode 100644 index 0000000..0fba80c --- /dev/null +++ b/providers/posthog/testdata/README.md @@ -0,0 +1,19 @@ +# PostHog: saved copies and goldens + +Real copies of what PostHog publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/posthog -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved removed-members guide + +Read through the `migrationguide` kind's removed-members reader; the golden file is what it stores from the guide. + +| File | URL | Fetched | License | Quote | +|---|---|---|---|---| +| `migration-7.x-to-8.0-posthog-v8.0.0.md` | https://github.com/PostHog/posthog-python/blob/posthog-v8.0.0/docs/migration-7.x-to-8.0.md (commit 6edff41425188056e48f6119457dc9bc0669ca99) | 2026-11-19 | MIT (the repo's LICENSE is the MIT text, with two copyright lines, so GitHub's detector says NOASSERTION; PyPI says MIT), kept whole, byte for byte | "8.x.x removes these options and APIs:" (Fix removed APIs), with rows such as "\| `CaptureV1Error` \| `CaptureError` \|" | + +## SDK changelogs + +Read with `Plugin{File: ...}` (`kinds/changelog/sdks.go`); `golden/-.json` is what each stores from its release (`changelogtest.CheckSDKs`), the pair from the release before it on the registry (or among the repo's tags). Every file is the changelog at the release's tag, saved with `curl`, **trimmed** to two releases' sections, each kept whole and unchanged: the release the golden pins and one more release from the same file whose notes remove nothing the reader can name (the drop test). Only the pinned release's own section is read for the golden, so the trimmed copy gives the same events as the whole file (checked when each copy was made). + +| File | URL | Tag commit | Saved | License; trimming | Quote | +|---|---|---|---|---|---| +| `posthog-go-2.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/PostHog/posthog-go/v2.0.0/CHANGELOG.md | `ee5c496` | 2026-11-20 | MIT (posthog-go); trimmed to the sections of 2.0.0 (the golden) and 1.44.1 (the drop test), each unchanged | "fc05013: Remove `Capture.Library` and `Exception.Library`. Set `$lib` in the event's `Properties` instead, and set `$…" | diff --git a/plugins/migrationguide/testdata/golden/posthog-8.0.0.json b/providers/posthog/testdata/golden/posthog-8.0.0.json similarity index 100% rename from plugins/migrationguide/testdata/golden/posthog-8.0.0.json rename to providers/posthog/testdata/golden/posthog-8.0.0.json diff --git a/plugins/changelog/testdata/golden/posthog-go.json b/providers/posthog/testdata/golden/posthog-go.json similarity index 100% rename from plugins/changelog/testdata/golden/posthog-go.json rename to providers/posthog/testdata/golden/posthog-go.json diff --git a/plugins/migrationguide/members/testdata/migration-7.x-to-8.0-posthog-v8.0.0.md b/providers/posthog/testdata/migration-7.x-to-8.0-posthog-v8.0.0.md similarity index 100% rename from plugins/migrationguide/members/testdata/migration-7.x-to-8.0-posthog-v8.0.0.md rename to providers/posthog/testdata/migration-7.x-to-8.0-posthog-v8.0.0.md diff --git a/plugins/changelog/testdata/posthog-go-2.0.0-CHANGELOG.md b/providers/posthog/testdata/posthog-go-2.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/posthog-go-2.0.0-CHANGELOG.md rename to providers/posthog/testdata/posthog-go-2.0.0-CHANGELOG.md diff --git a/providers/redis-ioredis.md b/providers/redis-ioredis.md deleted file mode 100644 index 235686a..0000000 --- a/providers/redis-ioredis.md +++ /dev/null @@ -1,27 +0,0 @@ -# ioredis (`redis/ioredis`) - -## What it watches - -Names removed or renamed in each release of ioredis, the Node.js Redis client, from that release's section of its `CHANGELOG.md` at its tag. Package `npm:ioredis`; releases listed from npm, each read at `vX.Y.Z`. - -Kind: `changelog` (`plugins/changelog`, `sdks.go`). - -## Why this source - -- **Source:** https://github.com/redis/ioredis/blob/main/CHANGELOG.md, read raw at the release's tag; checked on 2026-11-20. -- **Why this one:** semantic-release writes every release's "BREAKING CHANGES" into this file; a major is headed `# [X.0.0](...)`, a minor or patch `## [X.Y.Z](...)`, and both are read. -- **Alternatives considered:** GitHub release notes (the same text); the README's upgrade notes (not versioned per release). -- **Quote:** "`Redis#serverInfo` is removed. This field is never documented so you very likely have never used it." (5.0.0). - -## How the provider announces changes - -A major every few years (v6.0.0 in 2026), with its breaking changes listed in the changelog. - -## What the plugin reads and ignores - -- `Class#member` is read as `Class.member`. Counts plain removals and renames. -- Drops (and logs): changed defaults, dropped Node.js versions, options removed (`allowUsernameInURI`), behavior changes. - -## Known gaps - -- Removed options aren't symbols: not events. diff --git a/providers/redis-node-redis-surface.md b/providers/redis-node-redis-surface.md deleted file mode 100644 index ce57289..0000000 --- a/providers/redis-node-redis-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# node-redis client (`redis/node-redis-surface`) - -## What it watches - -The public API of the `@redis/client` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @redis/client@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** GitHub release notes; `docs/v4-to-v5.md` (majors only). -- **Quote:** `enum RedisFlushModes` (`dist/lib/commands/FLUSHALL.d.ts` line 1) at 1.6.1, gone at 5.0.0 (the client went from 1.x to 5.0.0 with redis 5). - -## How the provider announces changes - -- `redis` on npm re-exports `@redis/client` (and the module packages) wholesale; the client's declarations are where its API is, so this source reads `@redis/client` and covers `npm:redis` too. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@redis/client.createClient`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- `@redis/client`'s versions follow its own numbering; a lockfile's `redis` version maps to the client version it depends on. diff --git a/providers/redis-redis-py-surface.md b/providers/redis-redis-py-surface.md deleted file mode 100644 index 9618ff4..0000000 --- a/providers/redis-redis-py-surface.md +++ /dev/null @@ -1,35 +0,0 @@ -# redis-py (`redis/redis-py-surface`) - -## What it watches - -The public API of the `redis` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install redis==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** GitHub release notes (the `CHANGES` file stops at 4.0). -- **Quote:** `def get_handler_for_connection(self)` (`OSSMaintNotificationsHandler`, `redis/maint_notifications.py` line 1073) at 8.0.1, gone at 8.1.0. - -## How the provider announces changes - -- The client releases minors every month or two; its newer subsystems (multi-database, maintenance notifications) change shape between minors. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `redis/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/providers/redis.md b/providers/redis.md deleted file mode 100644 index a954ff1..0000000 --- a/providers/redis.md +++ /dev/null @@ -1,37 +0,0 @@ -# Redis (`redis/commands`) - -## What it watches - -Redis's command surface: commands that disappear entirely between two Redis releases, read from the command definitions in the server's own source (`src/commands/`, one JSON file per command) at each release tag. - -Kind: `catalog` (`plugins/catalog`), the `Commands` reader (`plugins/catalog/redis.go`). - -## Why this source - -- **Source:** [`src/commands/`](https://github.com/redis/redis/tree/unstable/src/commands) in redis/redis, read at each final release's tag (`X.Y.Z`, listed from [GitHub releases](https://github.com/redis/redis/releases) and ordered by version). A release is one listing (`GET https://api.github.com/repos/redis/redis/contents/src/commands?ref=`); a file that is gone at the next release is fetched once, at the older tag (`https://raw.githubusercontent.com/redis/redis//src/commands/`), for the command's name and the entry quoted as evidence. Checked on 2026-11-20: 460 files at 8.10.0, the directory there from 7.0.0. -- **Why this one:** it is what the server is built from: `commands.def`, the server's command table, is generated from these files, and so is redis.io's command reference. A release tag maps an event to the server version a team runs, and a tag never changes, so the file's URL is its own citation. -- **Alternatives considered:** - - **`redis/redis-doc` `commands.json`** (what this source read before, until 2026-11-20): the repo is archived, the file last changed on 2023-10-24, 370 commands, so nothing from Redis 7.4 or 8.x was ever seen. - - **`redis/docs` `data/commands.json`** (redis.io's maintained docs repo, 678 commands on 2026-11-20): one file, but a docs artifact. Its history (5 commits since 2024-02) shows editorial churn that would read as removals: commit `2f513f2` (2024-06-06) dropped 126 module commands (`BF.*`, `CF.*`, `FT.*`…) that Redis never removed, and later commits put them back; commit `9740114` (2026-07-30) deleted the file outright. Its versions are commit dates, not server releases. Every one of those would be a false event, so it isn't read. - - **An OpenAPI spec.** Redis the database has none: it's a binary protocol, not a REST API. - - **The client libraries' changelogs** (`redis-py`'s `CHANGES`, `node-redis`'s `CHANGELOG.md`): both stopped being updated years ago, and their bullets name client arguments, not server commands. -- **Quote:** at tag `8.8-m03`, `src/commands/gcra.json` is `{"GCRA": {"summary": "Rate limit via GCRA (Generic Cell Rate Algorithm).", … "since": "8.8.0", …}}`; at `8.8-rc1` the file is gone, and so is `gcrasetvalue.json`. - -## How the provider announces changes - -- **No API version**: Redis is versioned by server release (`7.4.0`, `8.10.0`). Several lines are patched at once (7.2.10 shipped after 8.0.0), which is why versions are ordered by number, not by date: a pair across lines would read the older line's missing commands as removals. -- **Commands are deprecated, essentially never removed.** Between every final release from 7.0.0 to 8.10.3, no command file was removed (checked 2026-11-20 across the tags); about twenty commands carry `deprecated_since` and still work. The one removal in that span is between pre-release tags: GCRA and GCRASETVALUE, added in the 8.8 milestone builds, gone at 8.8-rc1. The golden test pins that pair. - -## What the plugin reads and ignores - -- Reads: the list of `*.json` files in `src/commands/` at each release. A file in the older release's list and not in the newer's becomes a `breaking` `package_release` event (`change: removed_symbol`), its symbol the command's name (a subcommand with its container: `CLIENT KILL`), its version the newer release and its `previous_version` the older. The excerpt quotes the file at the older tag. -- Ignores: what a command's file says (arguments, flags, complexity, ACL categories): only presence is compared. An added command is not an event. A file renamed with the same command in it would read as a removal; none was renamed in the span checked. -- A release from before 7.0.0 has no `src/commands/`: nothing to read (the pair is skipped). -- Pre-release tags (`-rc`, `-m`) aren't listed: they aren't releases a team runs. -- The pinned drop test: 8.8.0 → 8.10.0 adds 17 command files and removes none, so no event. - -## Known gaps - -- Commands gaining `deprecated_since` between two releases aren't turned into `deprecation` events yet: that needs the changed files' contents, not only the list. -- Module commands (`FT.*`, `JSON.*`, `TS.*`…) live in the modules' own repos, not in `src/commands/`. -- `node-redis` and `redis-py`'s own breaking changes aren't watched here: they're client SDKs, a separate source. diff --git a/providers/redis/README.md b/providers/redis/README.md new file mode 100644 index 0000000..939691c --- /dev/null +++ b/providers/redis/README.md @@ -0,0 +1,143 @@ +# Redis + +Every source patch-it reads for Redis, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Redis (`redis/commands`) + +### What it watches + +Redis's command surface: commands that disappear entirely between two Redis releases, read from the command definitions in the server's own source (`src/commands/`, one JSON file per command) at each release tag. + +Kind: `catalog` (`kinds/catalog`), the `Commands` reader (`kinds/catalog/commands.go`). + +### Why this source + +- **Source:** [`src/commands/`](https://github.com/redis/redis/tree/unstable/src/commands) in redis/redis, read at each final release's tag (`X.Y.Z`, listed from [GitHub releases](https://github.com/redis/redis/releases) and ordered by version). A release is one listing (`GET https://api.github.com/repos/redis/redis/contents/src/commands?ref=`); a file that is gone at the next release is fetched once, at the older tag (`https://raw.githubusercontent.com/redis/redis//src/commands/`), for the command's name and the entry quoted as evidence. Checked on 2026-11-20: 460 files at 8.10.0, the directory there from 7.0.0. +- **Why this one:** it is what the server is built from: `commands.def`, the server's command table, is generated from these files, and so is redis.io's command reference. A release tag maps an event to the server version a team runs, and a tag never changes, so the file's URL is its own citation. +- **Alternatives considered:** + - **`redis/redis-doc` `commands.json`** (what this source read before, until 2026-11-20): the repo is archived, the file last changed on 2023-10-24, 370 commands, so nothing from Redis 7.4 or 8.x was ever seen. + - **`redis/docs` `data/commands.json`** (redis.io's maintained docs repo, 678 commands on 2026-11-20): one file, but a docs artifact. Its history (5 commits since 2024-02) shows editorial churn that would read as removals: commit `2f513f2` (2024-06-06) dropped 126 module commands (`BF.*`, `CF.*`, `FT.*`…) that Redis never removed, and later commits put them back; commit `9740114` (2026-07-30) deleted the file outright. Its versions are commit dates, not server releases. Every one of those would be a false event, so it isn't read. + - **An OpenAPI spec.** Redis the database has none: it's a binary protocol, not a REST API. + - **The client libraries' changelogs** (`redis-py`'s `CHANGES`, `node-redis`'s `CHANGELOG.md`): both stopped being updated years ago, and their bullets name client arguments, not server commands. +- **Quote:** at tag `8.8-m03`, `src/commands/gcra.json` is `{"GCRA": {"summary": "Rate limit via GCRA (Generic Cell Rate Algorithm).", … "since": "8.8.0", …}}`; at `8.8-rc1` the file is gone, and so is `gcrasetvalue.json`. + +### How the provider announces changes + +- **No API version**: Redis is versioned by server release (`7.4.0`, `8.10.0`). Several lines are patched at once (7.2.10 shipped after 8.0.0), which is why versions are ordered by number, not by date: a pair across lines would read the older line's missing commands as removals. +- **Commands are deprecated, essentially never removed.** Between every final release from 7.0.0 to 8.10.3, no command file was removed (checked 2026-11-20 across the tags); about twenty commands carry `deprecated_since` and still work. The one removal in that span is between pre-release tags: GCRA and GCRASETVALUE, added in the 8.8 milestone builds, gone at 8.8-rc1. The golden test pins that pair. + +### What the plugin reads and ignores + +- Reads: the list of `*.json` files in `src/commands/` at each release. A file in the older release's list and not in the newer's becomes a `breaking` `package_release` event (`change: removed_symbol`), its symbol the command's name (a subcommand with its container: `CLIENT KILL`), its version the newer release and its `previous_version` the older. The excerpt quotes the file at the older tag. +- Ignores: what a command's file says (arguments, flags, complexity, ACL categories): only presence is compared. An added command is not an event. A file renamed with the same command in it would read as a removal; none was renamed in the span checked. +- A release from before 7.0.0 has no `src/commands/`: nothing to read (the pair is skipped). +- Pre-release tags (`-rc`, `-m`) aren't listed: they aren't releases a team runs. +- The pinned drop test: 8.8.0 → 8.10.0 adds 17 command files and removes none, so no event. + +### Known gaps + +- Commands gaining `deprecated_since` between two releases aren't turned into `deprecation` events yet: that needs the changed files' contents, not only the list. +- Module commands (`FT.*`, `JSON.*`, `TS.*`…) live in the modules' own repos, not in `src/commands/`. +- `node-redis` and `redis-py`'s own breaking changes aren't watched here: they're client SDKs, a separate source. + +## ioredis (`redis/ioredis`) + +### What it watches + +Names removed or renamed in each release of ioredis, the Node.js Redis client, from that release's section of its `CHANGELOG.md` at its tag. Package `npm:ioredis`; releases listed from npm, each read at `vX.Y.Z`. + +Kind: `changelog` (`kinds/changelog`, `sdks.go`). + +### Why this source + +- **Source:** https://github.com/redis/ioredis/blob/main/CHANGELOG.md, read raw at the release's tag; checked on 2026-11-20. +- **Why this one:** semantic-release writes every release's "BREAKING CHANGES" into this file; a major is headed `# [X.0.0](...)`, a minor or patch `## [X.Y.Z](...)`, and both are read. +- **Alternatives considered:** GitHub release notes (the same text); the README's upgrade notes (not versioned per release). +- **Quote:** "`Redis#serverInfo` is removed. This field is never documented so you very likely have never used it." (5.0.0). + +### How the provider announces changes + +A major every few years (v6.0.0 in 2026), with its breaking changes listed in the changelog. + +### What the plugin reads and ignores + +- `Class#member` is read as `Class.member`. Counts plain removals and renames. +- Drops (and logs): changed defaults, dropped Node.js versions, options removed (`allowUsernameInURI`), behavior changes. + +### Known gaps + +- Removed options aren't symbols: not events. + +## node-redis client (`redis/node-redis-surface`) + +### What it watches + +The public API of the `@redis/client` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @redis/client@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** GitHub release notes; `docs/v4-to-v5.md` (majors only). +- **Quote:** `enum RedisFlushModes` (`dist/lib/commands/FLUSHALL.d.ts` line 1) at 1.6.1, gone at 5.0.0 (the client went from 1.x to 5.0.0 with redis 5). + +### How the provider announces changes + +- `redis` on npm re-exports `@redis/client` (and the module packages) wholesale; the client's declarations are where its API is, so this source reads `@redis/client` and covers `npm:redis` too. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@redis/client.createClient`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- `@redis/client`'s versions follow its own numbering; a lockfile's `redis` version maps to the client version it depends on. + +## redis-py (`redis/redis-py-surface`) + +### What it watches + +The public API of the `redis` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install redis==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** GitHub release notes (the `CHANGES` file stops at 4.0). +- **Quote:** `def get_handler_for_connection(self)` (`OSSMaintNotificationsHandler`, `redis/maint_notifications.py` line 1073) at 8.0.1, gone at 8.1.0. + +### How the provider announces changes + +- The client releases minors every month or two; its newer subsystems (multi-database, maintenance notifications) change shape between minors. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `redis/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. diff --git a/plugins/catalog/catalog_test.go b/providers/redis/commands_test.go similarity index 69% rename from plugins/catalog/catalog_test.go rename to providers/redis/commands_test.go index 1e5ba88..6870ab6 100644 --- a/plugins/catalog/catalog_test.go +++ b/providers/redis/commands_test.go @@ -1,4 +1,4 @@ -package catalog +package redis import ( "context" @@ -18,13 +18,13 @@ import ( func redisPair(t *testing.T, from, to string, files ...string) []event.Event { t.Helper() pages := kittest.Pages{ - Redis.listingURL(from): "testdata/redis-contents-src-commands-" + from + ".json", - Redis.listingURL(to): "testdata/redis-contents-src-commands-" + to + ".json", + Commands.ListingURL(from): "testdata/redis-contents-src-commands-" + from + ".json", + Commands.ListingURL(to): "testdata/redis-contents-src-commands-" + to + ".json", } for _, f := range files { - pages[Redis.FileURL(from, f)] = "testdata/redis-" + from + "-" + f + pages[Commands.FileURL(from, f)] = "testdata/redis-" + from + "-" + f } - return kittest.Versions(t, kittest.Env(t, pages), Redis, plugin.Version{ID: from, Ref: from}, plugin.Version{ID: to, Ref: to}) + return kittest.Versions(t, kittest.Env(t, pages), Commands, plugin.Version{ID: from, Ref: from}, plugin.Version{ID: to, Ref: to}) } // The one removal in redis/redis's src/commands/ between any two tags from @@ -37,7 +37,7 @@ func TestGolden(t *testing.T) { var names []string for _, e := range got { names = append(names, e.Subject.Symbols[0]) - if e.SourceURL != Redis.FileURL("8.8-m03", strings.ToLower(e.Subject.Symbols[0])+".json") || !strings.Contains(e.SourceExcerpt, `"since":"8.8.0"`) { + if e.SourceURL != Commands.FileURL("8.8-m03", strings.ToLower(e.Subject.Symbols[0])+".json") || !strings.Contains(e.SourceExcerpt, `"since":"8.8.0"`) { t.Errorf("%s: cites %s, quoting %.80q", e.Subject.Symbols[0], e.SourceURL, e.SourceExcerpt) } } @@ -56,17 +56,6 @@ func TestReleasesThatOnlyAddCommandsHaveNoEvents(t *testing.T) { } } -// A subcommand is named with its container, as code sends it. -func TestASubcommandIsNamedWithItsContainer(t *testing.T) { - name, _, err := command([]byte(`{"KILL": {"summary": "x", "container": "CLIENT"}}`)) - if err != nil || name != "CLIENT KILL" { - t.Errorf("%q, %v", name, err) - } - if _, _, err := command([]byte(`{"A": {}, "B": {}}`)); err == nil { - t.Error("two commands in one file must be an error, not a guess") - } -} - // Versions are the final releases on GitHub, by version number (a patch to // an older line published later stays in its place), each read at its tag. // A release before src/commands/ existed has nothing to read. @@ -74,7 +63,7 @@ func TestVersionsAreFinalReleasesByVersion(t *testing.T) { env := kittest.Env(t, kittest.Pages{ "https://api.github.com/repos/redis/redis/releases?per_page=100&page=1": "testdata/redis-releases-excerpt.json", }) - vs, err := Redis.ListVersions(context.Background(), env) + vs, err := Commands.ListVersions(context.Background(), env) if err != nil { t.Fatal(err) } @@ -86,7 +75,7 @@ func TestVersionsAreFinalReleasesByVersion(t *testing.T) { t.Errorf("versions %s", got) } notFound := plugin.Env{Get: func(context.Context, string) ([]byte, error) { return nil, &fetch.StatusError{StatusCode: 404} }} - if _, err := Redis.ReadAt(context.Background(), notFound, plugin.Version{ID: "6.2.20", Ref: "6.2.20"}); !errors.Is(err, plugin.ErrNothingToRead) { + if _, err := Commands.ReadAt(context.Background(), notFound, plugin.Version{ID: "6.2.20", Ref: "6.2.20"}); !errors.Is(err, plugin.ErrNothingToRead) { t.Errorf("no src/commands/ at the tag: %v, want plugin.ErrNothingToRead", err) } } diff --git a/providers/redis/ioredis_test.go b/providers/redis/ioredis_test.go new file mode 100644 index 0000000..32c4f5a --- /dev/null +++ b/providers/redis/ioredis_test.go @@ -0,0 +1,13 @@ +package redis + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +func TestIoredisSDKs(t *testing.T) { + changelogtest.CheckSDKs(t, []changelogtest.SDKCase{ + {File: Ioredis, Release: "5.0.0", Prev: "4.31.0", Saved: "redis-ioredis-5.0.0-CHANGELOG.md", Dropped: "", Drop: "5.0.0-beta.4"}, + }) +} diff --git a/providers/redis/node_redis_surface_test.go b/providers/redis/node_redis_surface_test.go new file mode 100644 index 0000000..f4115ed --- /dev/null +++ b/providers/redis/node_redis_surface_test.go @@ -0,0 +1,15 @@ +package redis + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// @redis/client 5.0.0 removed commandOptions and RedisFlushModes. +func TestNodeRedisSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: NodeRedisSurface, Golden: [2]string{"1.6.1", "5.0.0"}, Want: []string{ + "removed_symbol RedisFlushModes ", + "removed_symbol commandOptions ", + }, Drop: [2]string{"6.3.0", "6.3.1"}}) +} diff --git a/providers/redis/provider.go b/providers/redis/provider.go new file mode 100644 index 0000000..e3a87a1 --- /dev/null +++ b/providers/redis/provider.go @@ -0,0 +1,52 @@ +// Package redis is what patch-it reads for Redis: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package redis + +import ( + "regexp" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/catalog" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "redis", Name: "Redis", Category: plugin.CategoryDatabases, Homepage: "https://redis.io", + Sources: []plugin.Source{ + { + ID: "commands", Layer: plugin.LayerRuntime, + Watches: "Commands removed entirely between two Redis releases, from the command definitions in the server's own source (src/commands/) at each release tag", + URLs: []string{"https://github.com/redis/redis/tree/unstable/src/commands", "https://github.com/redis/redis/releases"}, + Plugin: Commands, + }, + changelog.SDK("ioredis", Ioredis, "npm:ioredis"), + apisurface.PyPI(RedisPySurface, plugin.LayerSDK, "https://github.com/redis/redis-py"), + // redis on npm re-exports @redis/client and its siblings wholesale; the + // client's declarations are where its API is. + apisurface.NPM(NodeRedisSurface, "https://github.com/redis/node-redis", "npm:redis"), + }, + }) +} + +// Ioredis is ioredis' semantic-release CHANGELOG.md: "## [X.Y.Z](...)" +// with "### BREAKING CHANGES"; tagged vX.Y.Z. +var Ioredis = changelog.File{API: "redis/ioredis", Package: "ioredis", Ecosystem: "npm", + Repo: "redis/ioredis", TagPrefix: "v", Path: "CHANGELOG.md"} + +// Commands is redis/redis's src/commands/ (checked 2026-11-20: 460 files at +// 8.10.0, every final release a GitHub release tagged X.Y.Z). The directory +// exists from 7.0.0; an older release has nothing to read. +var Commands = catalog.Commands{ + API: "redis/commands", Ecosystem: "redis", Package: "redis", + Repo: "redis/redis", Dir: "src/commands", + Release: regexp.MustCompile(`^(\d+\.\d+\.\d+)$`), +} + +// The packages whose public API the apisurface sources read. +var ( + NodeRedisSurface = apisurface.NPMPackage("redis/node-redis-surface", "@redis/client") + RedisPySurface = apisurface.Package{ID: "redis/redis-py-surface", Name: "redis", Ecosystem: "pypi", Module: "redis"} +) diff --git a/providers/redis/redis_py_surface_test.go b/providers/redis/redis_py_surface_test.go new file mode 100644 index 0000000..7e9713a --- /dev/null +++ b/providers/redis/redis_py_surface_test.go @@ -0,0 +1,12 @@ +package redis + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// redis 8.1.0 removed OSSMaintNotificationsHandler.get_handler_for_connection. +func TestRedisPySurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: RedisPySurface, Golden: [2]string{"8.0.1", "8.1.0"}, Want: []string{"removed_symbol maint_notifications.OSSMaintNotificationsHandler.get_handler_for_connection "}, Drop: [2]string{"7.4.1", "8.0.0"}}) +} diff --git a/providers/redis/testdata/README.md b/providers/redis/testdata/README.md new file mode 100644 index 0000000..051ea7c --- /dev/null +++ b/providers/redis/testdata/README.md @@ -0,0 +1,35 @@ +# Redis: saved copies and goldens + +Real copies of what Redis publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/redis -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved catalog snapshots + +Read through the `catalog` kind; the golden file is what it stores from them. + +| File | URL | Fetched | License | Quote | +|---|---|---|---|---| +| `redis-contents-src-commands-8.8-m03.json` | https://api.github.com/repos/redis/redis/contents/src/commands?ref=8.8-m03 | 2026-11-20 | BSD-3-Clause / RSALv2 / SSPLv1 / AGPLv3 (redis/redis); the listing cut to the two fields read, `name` and `type`, every entry kept | `{"name": "gcra.json", "type": "file"}` | +| `redis-contents-src-commands-8.8-rc1.json` | https://api.github.com/repos/redis/redis/contents/src/commands?ref=8.8-rc1 | 2026-11-20 | as above | no `gcra.json`, no `gcrasetvalue.json` | +| `redis-contents-src-commands-8.8.0.json`, `redis-contents-src-commands-8.10.0.json` | https://api.github.com/repos/redis/redis/contents/src/commands?ref=8.8.0 and `?ref=8.10.0` | 2026-11-20 | as above | the drop test: 17 files added, none removed | +| `redis-8.8-m03-gcra.json` | https://raw.githubusercontent.com/redis/redis/8.8-m03/src/commands/gcra.json | 2026-11-20 | as above, kept whole, byte for byte | `"GCRA": {"summary": "Rate limit via GCRA (Generic Cell Rate Algorithm).", … "since": "8.8.0"` | +| `redis-8.8-m03-gcrasetvalue.json` | https://raw.githubusercontent.com/redis/redis/8.8-m03/src/commands/gcrasetvalue.json | 2026-11-20 | as above, kept whole, byte for byte | `"GCRASETVALUE": {"summary": "An internal command for recording a GCRA TAT value during AOF rewrite and replication."` | +| `redis-releases-excerpt.json` | https://api.github.com/repos/redis/redis/releases (shape only) | written for the test, 2026-11-20 | not a saved copy: five entries in the shape of GitHub's releases API (`tag_name`, `draft`, `prerelease`, `published_at`, `html_url`), dates approximate, a pre-release and a patch to an older line published later among them | for the version-listing test only | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/redis/`: `redis-7.4.1-py3-none-any.trimmed.whl`, `redis-8.0.0-py3-none-any.trimmed.whl`, `redis-8.0.1-py3-none-any.trimmed.whl`, `redis-8.1.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/4a/2e/2677f3f93dae0497e7e33b6637302e7f3744efc553f34231183e32584885/redis-7.4.1-py3-none-any.whl; https://files.pythonhosted.org/packages/27/e3/b519734372d305bd547534a9f32e4ce9f98552af753dce72cf3483a0ff0b/redis-8.0.0-py3-none-any.whl; https://files.pythonhosted.org/packages/fd/0a/c2345ebf1ebe70840ce3f6c6ee612f8fa749cfbd1b03069c53bf0c62aaad/redis-8.0.1-py3-none-any.whl; https://files.pythonhosted.org/packages/66/9d/c5731f6e3608663d4d3656fd8d3aecee8b509c3082818f5a13eae925baea/redis-8.1.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `redis/__init__.py`, `redis/maint_notifications.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/redis/`: `pypi-redis-excerpt.json` and `pypi-redis-7.4.1.json`, `pypi-redis-8.0.0.json`, `pypi-redis-8.0.1.json`, `pypi-redis-8.1.0.json` | https://pypi.org/pypi/redis/json, https://pypi.org/pypi/redis/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/redis-client/`: `client-1.6.1.trimmed.tgz`, `client-5.0.0.trimmed.tgz`, `client-6.3.0.trimmed.tgz`, `client-6.3.1.trimmed.tgz` | https://registry.npmjs.org/@redis/client/-/client-1.6.1.tgz; https://registry.npmjs.org/@redis/client/-/client-5.0.0.tgz; https://registry.npmjs.org/@redis/client/-/client-6.3.0.tgz; https://registry.npmjs.org/@redis/client/-/client-6.3.1.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/index.d.ts`, `dist/lib/client/index.d.ts`, `dist/lib/command-options.d.ts`, `dist/lib/commands/FLUSHALL.d.ts`, `dist/lib/errors.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/redis-client/`: `npm-redis-client-excerpt.json` and `npm-redis-client-1.6.1.json`, `npm-redis-client-5.0.0.json`, `npm-redis-client-6.3.0.json`, `npm-redis-client-6.3.1.json` | https://registry.npmjs.org/@redis%2Fclient, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | + +## SDK changelogs + +Read with `Plugin{File: ...}` (`kinds/changelog/sdks.go`); `golden/-.json` is what each stores from its release (`changelogtest.CheckSDKs`), the pair from the release before it on the registry (or among the repo's tags). Every file is the changelog at the release's tag, saved with `curl`, **trimmed** to two releases' sections, each kept whole and unchanged: the release the golden pins and one more release from the same file whose notes remove nothing the reader can name (the drop test). Only the pinned release's own section is read for the golden, so the trimmed copy gives the same events as the whole file (checked when each copy was made). + +| File | URL | Tag commit | Saved | License; trimming | Quote | +|---|---|---|---|---|---| +| `redis-ioredis-5.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/redis/ioredis/v5.0.0/CHANGELOG.md | `b8e99b4` | 2026-11-20 | MIT (ioredis); trimmed to the sections of 5.0.0 (the golden) and 5.0.0-beta.4 (the drop test), each unchanged | "you very likely have never used it." | diff --git a/plugins/catalog/testdata/golden/redis-commands.json b/providers/redis/testdata/golden/redis-commands.json similarity index 100% rename from plugins/catalog/testdata/golden/redis-commands.json rename to providers/redis/testdata/golden/redis-commands.json diff --git a/plugins/changelog/testdata/golden/redis-ioredis.json b/providers/redis/testdata/golden/redis-ioredis.json similarity index 100% rename from plugins/changelog/testdata/golden/redis-ioredis.json rename to providers/redis/testdata/golden/redis-ioredis.json diff --git a/plugins/apisurface/testdata/golden/redis-node-redis-surface.json b/providers/redis/testdata/golden/redis-node-redis-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/redis-node-redis-surface.json rename to providers/redis/testdata/golden/redis-node-redis-surface.json diff --git a/plugins/apisurface/testdata/golden/redis-redis-py-surface.json b/providers/redis/testdata/golden/redis-redis-py-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/redis-redis-py-surface.json rename to providers/redis/testdata/golden/redis-redis-py-surface.json diff --git a/plugins/apisurface/testdata/npm/redis-client/client-1.6.1.trimmed.tgz b/providers/redis/testdata/npm/redis-client/client-1.6.1.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/client-1.6.1.trimmed.tgz rename to providers/redis/testdata/npm/redis-client/client-1.6.1.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/redis-client/client-5.0.0.trimmed.tgz b/providers/redis/testdata/npm/redis-client/client-5.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/client-5.0.0.trimmed.tgz rename to providers/redis/testdata/npm/redis-client/client-5.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/redis-client/client-6.3.0.trimmed.tgz b/providers/redis/testdata/npm/redis-client/client-6.3.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/client-6.3.0.trimmed.tgz rename to providers/redis/testdata/npm/redis-client/client-6.3.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/redis-client/client-6.3.1.trimmed.tgz b/providers/redis/testdata/npm/redis-client/client-6.3.1.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/client-6.3.1.trimmed.tgz rename to providers/redis/testdata/npm/redis-client/client-6.3.1.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/redis-client/npm-redis-client-1.6.1.json b/providers/redis/testdata/npm/redis-client/npm-redis-client-1.6.1.json similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/npm-redis-client-1.6.1.json rename to providers/redis/testdata/npm/redis-client/npm-redis-client-1.6.1.json diff --git a/plugins/apisurface/testdata/npm/redis-client/npm-redis-client-5.0.0.json b/providers/redis/testdata/npm/redis-client/npm-redis-client-5.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/npm-redis-client-5.0.0.json rename to providers/redis/testdata/npm/redis-client/npm-redis-client-5.0.0.json diff --git a/plugins/apisurface/testdata/npm/redis-client/npm-redis-client-6.3.0.json b/providers/redis/testdata/npm/redis-client/npm-redis-client-6.3.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/npm-redis-client-6.3.0.json rename to providers/redis/testdata/npm/redis-client/npm-redis-client-6.3.0.json diff --git a/plugins/apisurface/testdata/npm/redis-client/npm-redis-client-6.3.1.json b/providers/redis/testdata/npm/redis-client/npm-redis-client-6.3.1.json similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/npm-redis-client-6.3.1.json rename to providers/redis/testdata/npm/redis-client/npm-redis-client-6.3.1.json diff --git a/plugins/apisurface/testdata/npm/redis-client/npm-redis-client-excerpt.json b/providers/redis/testdata/npm/redis-client/npm-redis-client-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/redis-client/npm-redis-client-excerpt.json rename to providers/redis/testdata/npm/redis-client/npm-redis-client-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/redis/pypi-redis-7.4.1.json b/providers/redis/testdata/pypi/redis/pypi-redis-7.4.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/pypi-redis-7.4.1.json rename to providers/redis/testdata/pypi/redis/pypi-redis-7.4.1.json diff --git a/plugins/apisurface/testdata/pypi/redis/pypi-redis-8.0.0.json b/providers/redis/testdata/pypi/redis/pypi-redis-8.0.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/pypi-redis-8.0.0.json rename to providers/redis/testdata/pypi/redis/pypi-redis-8.0.0.json diff --git a/plugins/apisurface/testdata/pypi/redis/pypi-redis-8.0.1.json b/providers/redis/testdata/pypi/redis/pypi-redis-8.0.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/pypi-redis-8.0.1.json rename to providers/redis/testdata/pypi/redis/pypi-redis-8.0.1.json diff --git a/plugins/apisurface/testdata/pypi/redis/pypi-redis-8.1.0.json b/providers/redis/testdata/pypi/redis/pypi-redis-8.1.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/pypi-redis-8.1.0.json rename to providers/redis/testdata/pypi/redis/pypi-redis-8.1.0.json diff --git a/plugins/apisurface/testdata/pypi/redis/pypi-redis-excerpt.json b/providers/redis/testdata/pypi/redis/pypi-redis-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/pypi-redis-excerpt.json rename to providers/redis/testdata/pypi/redis/pypi-redis-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/redis/redis-7.4.1-py3-none-any.trimmed.whl b/providers/redis/testdata/pypi/redis/redis-7.4.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/redis-7.4.1-py3-none-any.trimmed.whl rename to providers/redis/testdata/pypi/redis/redis-7.4.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/redis/redis-8.0.0-py3-none-any.trimmed.whl b/providers/redis/testdata/pypi/redis/redis-8.0.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/redis-8.0.0-py3-none-any.trimmed.whl rename to providers/redis/testdata/pypi/redis/redis-8.0.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/redis/redis-8.0.1-py3-none-any.trimmed.whl b/providers/redis/testdata/pypi/redis/redis-8.0.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/redis-8.0.1-py3-none-any.trimmed.whl rename to providers/redis/testdata/pypi/redis/redis-8.0.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/redis/redis-8.1.0-py3-none-any.trimmed.whl b/providers/redis/testdata/pypi/redis/redis-8.1.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/redis/redis-8.1.0-py3-none-any.trimmed.whl rename to providers/redis/testdata/pypi/redis/redis-8.1.0-py3-none-any.trimmed.whl diff --git a/plugins/catalog/testdata/redis-8.8-m03-gcra.json b/providers/redis/testdata/redis-8.8-m03-gcra.json similarity index 100% rename from plugins/catalog/testdata/redis-8.8-m03-gcra.json rename to providers/redis/testdata/redis-8.8-m03-gcra.json diff --git a/plugins/catalog/testdata/redis-8.8-m03-gcrasetvalue.json b/providers/redis/testdata/redis-8.8-m03-gcrasetvalue.json similarity index 100% rename from plugins/catalog/testdata/redis-8.8-m03-gcrasetvalue.json rename to providers/redis/testdata/redis-8.8-m03-gcrasetvalue.json diff --git a/plugins/catalog/testdata/redis-contents-src-commands-8.10.0.json b/providers/redis/testdata/redis-contents-src-commands-8.10.0.json similarity index 100% rename from plugins/catalog/testdata/redis-contents-src-commands-8.10.0.json rename to providers/redis/testdata/redis-contents-src-commands-8.10.0.json diff --git a/plugins/catalog/testdata/redis-contents-src-commands-8.8-m03.json b/providers/redis/testdata/redis-contents-src-commands-8.8-m03.json similarity index 100% rename from plugins/catalog/testdata/redis-contents-src-commands-8.8-m03.json rename to providers/redis/testdata/redis-contents-src-commands-8.8-m03.json diff --git a/plugins/catalog/testdata/redis-contents-src-commands-8.8-rc1.json b/providers/redis/testdata/redis-contents-src-commands-8.8-rc1.json similarity index 100% rename from plugins/catalog/testdata/redis-contents-src-commands-8.8-rc1.json rename to providers/redis/testdata/redis-contents-src-commands-8.8-rc1.json diff --git a/plugins/catalog/testdata/redis-contents-src-commands-8.8.0.json b/providers/redis/testdata/redis-contents-src-commands-8.8.0.json similarity index 100% rename from plugins/catalog/testdata/redis-contents-src-commands-8.8.0.json rename to providers/redis/testdata/redis-contents-src-commands-8.8.0.json diff --git a/plugins/changelog/testdata/redis-ioredis-5.0.0-CHANGELOG.md b/providers/redis/testdata/redis-ioredis-5.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/redis-ioredis-5.0.0-CHANGELOG.md rename to providers/redis/testdata/redis-ioredis-5.0.0-CHANGELOG.md diff --git a/plugins/catalog/testdata/redis-releases-excerpt.json b/providers/redis/testdata/redis-releases-excerpt.json similarity index 100% rename from plugins/catalog/testdata/redis-releases-excerpt.json rename to providers/redis/testdata/redis-releases-excerpt.json diff --git a/providers/salesforce.md b/providers/salesforce/README.md similarity index 93% rename from providers/salesforce.md rename to providers/salesforce/README.md index 7103ea0..717c955 100644 --- a/providers/salesforce.md +++ b/providers/salesforce/README.md @@ -1,12 +1,16 @@ -# Salesforce (`salesforce/rest-api`) +# Salesforce -## What it watches +Every source patch-it reads for Salesforce, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Salesforce (`salesforce/rest-api`) + +### What it watches Salesforce's REST API version policy: whole numbered API version ranges (`/services/data/vNN.N/`) that Salesforce's own end-of-life page says are already retired (every resource under that version returns `410:GONE`) or scheduled to be. -Kind: `notices` (`plugins/notices`), with the end-of-life reader (`plugins/notices/eol`) and its `Salesforce` page. +Kind: `notices` (`kinds/notices`), with the end-of-life reader (`kinds/notices/eol`) and its `RESTAPI` page. -## Why this source +### Why this source - **Source:** [API End-of-Life Policy](https://developer.salesforce.com/docs/platform/api-rest/guide/api-rest-eol.html), Salesforce's own table of REST API version ranges and their support status. Checked 2026-11-20: a plain GET of the live page gets a 403 every time, including with a browser `User-Agent`; on 2026-11-21 its CDN (`server: AkamaiNetStorage`) answered 503 instead, after the fetch layer's retries. So `env.Get` always fails here. The Wayback Machine's own crawler reads the same URL anyway (its capture of 2026-11-20 parses to the same findings), so this plugin falls back to a fresh snapshot when the direct read is blocked (401, 403, or 503), and reads and cites that snapshot directly: unlike `retirements` and `feed`, which read the live page first and only snapshot it afterward to cite, there's no live read here to cite alongside. **A read that can't be made is a failed run, never "nothing changed":** any other status (404, 429, 500…), a snapshot the archive can't take, or a snapshot with no table in it (a block page saved in its place) fails the read, and patch-it's hosted ingestion service records the error. - **Why this one:** it's the only place Salesforce states, in one page, which whole version ranges still work, which are scheduled to stop, and which already have. Salesforce's own policy text above the table: "Salesforce is committed to supporting each API version for a minimum of 3 years from the date of first release... Salesforce notifies customers who use an API version scheduled for deprecation at least 1 year before support for the version ends." @@ -18,20 +22,20 @@ Kind: `notices` (`plugins/notices`), with the end-of-life reader (`plugins/notic - **The retirement-detail sub-pages** the main table links to (e.g. "Salesforce Platform API Versions 31.0 through 40.0 Retirement"), each its own Salesforce Help article. The main page already states the same range, status and season; reading only it keeps one source of truth and one snapshot per run. - **Quote:** "As of Summer ’25, these versions are retired and unavailable." (versions 21.0 through 30.0, a real, already-happened retirement) -## How the provider announces changes +### How the provider announces changes - **Versioned by path, numbered, incrementing:** `/services/data/vNN.N/...` (currently up to v67.0; a new major number roughly every release, three times a year). `GET /services/data/vNN.N/` ("List Available REST Resources") is the one resource that exists at every version and nothing else, so it's this plugin's one honest, documented `operation` to cite for "this whole version is gone." - **No exact date, only a named release:** "Summer '27", not a calendar date. Salesforce's exact production rollout for a named release is staggered across weekends per instance (confirmed by cross-checking Salesforce's own admin blog against three others, which disagree on the exact weekend), so there is no single verifiable day to convert "Summer '27" into; the event's `version` is the API version number, and the season name is quoted, not guessed into a date. - **Three years minimum per version, one year's notice before deprecation,** per the policy text above the table. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads** every row of the end-of-life table: a version range, and its status cell. A range already described as retired ("As of Summer 'XX, these versions are retired and unavailable.") becomes a `breaking` event per version number in the range; a range with both a deprecation and a retirement sentence ("Deprecated and unsupported from Summer 'XX. Retired from Summer 'YY.") becomes a `deprecation` event per version number. One event per version number, not one per range, so a repo pinned to one specific version is matched directly. - **Ignores** a row that only says "Supported." (on the live page, 2026-11-20: versions 41.0 through 67.0) — nothing to report, and the pinned drop test. - **Cites** the Wayback snapshot, with the row's version-range label and its full status text as the excerpt. - On the page saved 2026-10-31 this gives 34 events: 10 deprecations (versions 31.0–40.0) and 24 already-breaking (versions 7.0–30.0, both past retirement bands). -## Known gaps +### Known gaps - **No per-operation or per-field changes.** This plugin only sees whole-version retirement; a field or resource removed within a still-supported version (the kind GitHub's or GitLab's `openapi` plugin would catch, if Salesforce had a stable spec to diff) isn't watched. - **Critical Updates aren't watched.** These are Salesforce's other real mechanism for staged breaking changes (an org-level toggle that eventually activates by default, then becomes mandatory), but there's no single, official, publicly dated list of them across releases to read; only the per-org Setup page and third-party trackers exist. diff --git a/providers/salesforce/provider.go b/providers/salesforce/provider.go new file mode 100644 index 0000000..4b7b7ab --- /dev/null +++ b/providers/salesforce/provider.go @@ -0,0 +1,39 @@ +// Package salesforce is what patch-it reads for Salesforce: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package salesforce + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/kit" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/eol" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "salesforce", Name: "Salesforce", Category: plugin.CategoryCRM, Homepage: "https://www.salesforce.com", + Sources: []plugin.Source{ + { + ID: "rest-api", Layer: plugin.LayerAPI, + Watches: "REST API version ranges deprecated and retired, from Salesforce's own API end-of-life policy page", + URLs: []string{"https://developer.salesforce.com/docs/platform/api-rest/guide/api-rest-eol.html"}, + Plugin: notices.Plugin{Page: RESTAPI, Archiver: kit.Wayback{}}, + }, + }, + }) +} + +// RESTAPI is Salesforce's REST API end-of-life policy page (checked +// 2026-11-20): +// a table of version ranges, each "Supported.", already retired ("As of +// Summer '25, these versions are retired and unavailable."), or scheduled +// ("Deprecated and unsupported from Summer '27. Retired from Summer '28."). +// Salesforce gives no exact date, only the named release ("Summer '27"); the +// policy text above the table says the notice is at least a year ahead of +// retirement. +var RESTAPI = eol.Page{ + API: "salesforce/rest-api", Vendor: "Salesforce", + URL: "https://developer.salesforce.com/docs/platform/api-rest/guide/api-rest-eol.html", + Operation: func(v string) string { return "GET /services/data/v" + v + "/" }, +} diff --git a/plugins/notices/eol_test.go b/providers/salesforce/rest_api_test.go similarity index 79% rename from plugins/notices/eol_test.go rename to providers/salesforce/rest_api_test.go index f0135a4..45a634c 100644 --- a/plugins/notices/eol_test.go +++ b/providers/salesforce/rest_api_test.go @@ -1,4 +1,4 @@ -package notices +package salesforce import ( "context" @@ -11,14 +11,15 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/notices/eol" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices" + "github.com/patch-it-dev/patch-it-plugins/kinds/notices/eol" ) func TestEOLRegistersItself(t *testing.T) { - kittest.Registered(t, Plugin{Page: eol.Salesforce}) + kittest.Registered(t, notices.Plugin{Page: RESTAPI}) } -// The golden test: eol.Salesforce's own end-of-life policy page (checked +// The golden test: RESTAPI's own end-of-life policy page (checked // 2026-11-20, saved 2026-10-31), real and unedited but for dropping the // surrounding navigation chrome. It already holds two real, past retirements // (versions 7.0 through 20.0, retired as of Summer '22; versions 21.0 @@ -27,9 +28,9 @@ func TestEOLRegistersItself(t *testing.T) { // Summer '28): 34 events, and the still-"Supported." 41.0 through 67.0 band // names none, the pinned drop test. func TestEOLGolden(t *testing.T) { - saved := kittest.Pages{eol.Salesforce.URL: "eol/testdata/salesforce-api-rest-eol-2026-10-31.html"} + saved := kittest.Pages{RESTAPI.URL: "testdata/salesforce-api-rest-eol-2026-10-31.html"} archive := &kittest.Archive{T: t, Pages: saved} - got := kittest.Page(t, kittest.Env(t, saved), Plugin{Page: eol.Salesforce, Archiver: archive}) + got := kittest.Page(t, kittest.Env(t, saved), notices.Plugin{Page: RESTAPI, Archiver: archive}) if archive.Calls != 1 { t.Errorf("%d snapshots, want 1: the second read's page is unchanged", archive.Calls) } @@ -39,7 +40,7 @@ func TestEOLGolden(t *testing.T) { // The pinned drop test: "Versions 41.0 through 67.0: Supported." is a real // row on the page, and it must name no version. func TestDropsAStillSupportedBand(t *testing.T) { - page := kittest.Read(t, "eol/testdata/salesforce-api-rest-eol-2026-10-31.html") + page := kittest.Read(t, "testdata/salesforce-api-rest-eol-2026-10-31.html") found, err := eol.Findings(page) if err != nil { t.Fatal(err) @@ -62,22 +63,22 @@ func TestDropsAStillSupportedBand(t *testing.T) { } } -// eol.Salesforce's docs site answers 403 to a plain GET, or 503 from its CDN; +// RESTAPI's docs site answers 403 to a plain GET, or 503 from its CDN; // the live page is never reachable through env.Get. Read must fall back to // the Wayback Machine's own fetch and use its snapshot directly, not fail // outright. 401 falls back the same way. func TestFallsBackToTheArchiveWhenTheLiveFetchIsBlocked(t *testing.T) { for _, code := range []int{401, 403, 503} { t.Run(fmt.Sprint(code), func(t *testing.T) { - saved := kittest.Pages{eol.Salesforce.URL: "eol/testdata/salesforce-api-rest-eol-2026-10-31.html"} + saved := kittest.Pages{RESTAPI.URL: "testdata/salesforce-api-rest-eol-2026-10-31.html"} archive := &kittest.Archive{T: t, Pages: saved} env := plugin.Env{ Get: func(context.Context, string) ([]byte, error) { - return nil, &fetch.StatusError{URL: eol.Salesforce.URL, StatusCode: code} + return nil, &fetch.StatusError{URL: RESTAPI.URL, StatusCode: code} }, Now: func() time.Time { return kittest.Clock }, } - got := kittest.Page(t, env, Plugin{Page: eol.Salesforce, Archiver: archive}) + got := kittest.Page(t, env, notices.Plugin{Page: RESTAPI, Archiver: archive}) if len(got) == 0 { t.Fatal("no events: the archive fallback didn't run") } @@ -90,7 +91,7 @@ func TestFallsBackToTheArchiveWhenTheLiveFetchIsBlocked(t *testing.T) { t.Errorf("%d snapshots, want 2: the live page is blocked every read", archive.Calls) } for _, e := range got { - if e.SourceURL == eol.Salesforce.URL { + if e.SourceURL == RESTAPI.URL { t.Errorf("%s: source_url is the blocked live page, want the archive's snapshot", e.Fingerprint) } } @@ -106,13 +107,13 @@ func TestDoesNotFallBackOnATransientError(t *testing.T) { t.Run(fmt.Sprint(code), func(t *testing.T) { env := plugin.Env{ Get: func(context.Context, string) ([]byte, error) { - return nil, &fetch.StatusError{URL: eol.Salesforce.URL, StatusCode: code} + return nil, &fetch.StatusError{URL: RESTAPI.URL, StatusCode: code} }, Now: func() time.Time { return kittest.Clock }, } // No Pages: a fallback here would fail the test by asking the // archive for a snapshot it was never given. - _, err := Plugin{Page: eol.Salesforce, Archiver: &kittest.Archive{T: t}}.Read(context.Background(), env, plugin.Snapshot{}) + _, err := notices.Plugin{Page: RESTAPI, Archiver: &kittest.Archive{T: t}}.Read(context.Background(), env, plugin.Snapshot{}) if err == nil { t.Fatalf("want an error for a %d, got none", code) } @@ -126,7 +127,7 @@ func TestDoesNotFallBackOnATransientError(t *testing.T) { func TestABlockedPageTheArchiveCantReadIsAFailedRun(t *testing.T) { blocked := plugin.Env{ Get: func(context.Context, string) ([]byte, error) { - return nil, &fetch.StatusError{URL: eol.Salesforce.URL, StatusCode: 403} + return nil, &fetch.StatusError{URL: RESTAPI.URL, StatusCode: 403} }, Now: func() time.Time { return kittest.Clock }, } @@ -135,7 +136,7 @@ func TestABlockedPageTheArchiveCantReadIsAFailedRun(t *testing.T) { "no snapshot": failingArchive{}, "a block page": blockPage{}, } { - _, err := Plugin{Page: eol.Salesforce, Archiver: archive}.Read(context.Background(), blocked, last) + _, err := notices.Plugin{Page: RESTAPI, Archiver: archive}.Read(context.Background(), blocked, last) if err == nil || errors.Is(err, plugin.ErrNothingToRead) { t.Errorf("%s: %v, want a failure that isn't plugin.ErrNothingToRead", name, err) } diff --git a/plugins/notices/eol/testdata/README.md b/providers/salesforce/testdata/README.md similarity index 58% rename from plugins/notices/eol/testdata/README.md rename to providers/salesforce/testdata/README.md index 9b956a7..0ea7c2e 100644 --- a/plugins/notices/eol/testdata/README.md +++ b/providers/salesforce/testdata/README.md @@ -1,4 +1,10 @@ -# Saved end-of-life pages +# Salesforce: saved copies and goldens + +Real copies of what Salesforce publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/salesforce -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved end-of-life page + +A real copy; the golden test reads it through the whole `notices` plugin. | File | URL | Fetched | License | Quote | |---|---|---|---|---| diff --git a/plugins/notices/testdata/golden/salesforce.json b/providers/salesforce/testdata/golden/salesforce.json similarity index 100% rename from plugins/notices/testdata/golden/salesforce.json rename to providers/salesforce/testdata/golden/salesforce.json diff --git a/plugins/notices/eol/testdata/salesforce-api-rest-eol-2026-10-31.html b/providers/salesforce/testdata/salesforce-api-rest-eol-2026-10-31.html similarity index 100% rename from plugins/notices/eol/testdata/salesforce-api-rest-eol-2026-10-31.html rename to providers/salesforce/testdata/salesforce-api-rest-eol-2026-10-31.html diff --git a/providers/sentry-node-surface.md b/providers/sentry-node-surface.md deleted file mode 100644 index b9e6e8b..0000000 --- a/providers/sentry-node-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# Sentry Node.js SDK (`sentry/node-surface`) - -## What it watches - -The public API of the `@sentry/node` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @sentry/node@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md; MIGRATION.md (majors only). -- **Quote:** `export { systemErrorIntegration } from "@sentry/node-core"` (`build/types/index.d.ts` line 35) at 9.47.2, gone at 10.0.0. - -## How the provider announces changes - -- Releases every week or two; most of what it exports is re-exported from `@sentry/core` and `@sentry/node-core`, read here by name. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@sentry/node.init`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- Names re-exported from `@sentry/core` are read by name: their signatures are that package's. diff --git a/providers/sentry-python-surface.md b/providers/sentry-python-surface.md deleted file mode 100644 index 712f97a..0000000 --- a/providers/sentry-python-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# Sentry Python SDK (`sentry/python-surface`) - -## What it watches - -The public API of the `sentry-sdk` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install sentry-sdk==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md; MIGRATION_GUIDE.md (majors only, for the `migrationguide` kind). -- **Quote:** `def to_timestamp(value: "datetime") -> float` (`sentry_sdk/utils.py` line 251) at 2.73.0, gone at 2.74.0. - -## How the provider announces changes - -- The SDK releases every week or two; helpers in public-looking modules (`sentry_sdk.utils`) are removed in minors. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `sentry_sdk/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. -- `sentry_sdk.utils` and similar modules have no leading underscore but are mostly the SDK's own helpers: their removals are events, though few customers call them. diff --git a/providers/sentry-sdks.md b/providers/sentry-sdks.md deleted file mode 100644 index 842041d..0000000 --- a/providers/sentry-sdks.md +++ /dev/null @@ -1,35 +0,0 @@ -# Sentry SDKs (`sentry/python-changelog`, `sentry/javascript-changelog`, `sentry/go`, `sentry/dotnet`) - -## What it watches - -Names removed, renamed or deprecated in each release of Sentry's Python, JavaScript, Go and .NET SDKs, from that release's section of the SDK's `CHANGELOG.md` at its tag. One `package_release` event per bullet that names what it changes plainly. Sentry's API is a separate source (`sentry/api`). - -Kind: `changelog` (`plugins/changelog`, `sdks.go`). - -| Source | Package | Releases listed from | Tag | -|---|---|---|---| -| `sentry/python-changelog` | `pypi:sentry-sdk` | PyPI | `X.Y.Z` | -| `sentry/javascript-changelog` | `npm:@sentry/node`, `npm:@sentry/browser` (released together) | npm (`@sentry/node`) | `X.Y.Z` | -| `sentry/go` | `go:github.com/getsentry/sentry-go` | the repo's `vX.Y.Z` tags | `vX.Y.Z` | -| `sentry/dotnet` | `nuget:Sentry` | the repo's `X.Y.Z` tags | `X.Y.Z` | - -## Why this source - -- **Source:** https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md, https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md, https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md, https://github.com/getsentry/sentry-dotnet/blob/main/CHANGELOG.md, each read raw at the release's tag; checked on 2026-11-20. -- **Why this one:** Sentry writes every major's removals into the changelog itself, under "Removed" / "Breaking Changes" / "Deprecations" headings or as conventional-commit bullets (`feat(core)!: Remove \`BaseClient\``). The Python 2.0 changelog section carries the same "Removed" and "Deprecated" lists as its `MIGRATION_GUIDE.md`, so the guide isn't a second source (it would repeat the same events under another id). -- **Alternatives considered:** the migration guides (`MIGRATION_GUIDE.md`, `MIGRATION.md`: prose sections per major, mostly behavior and options; the JavaScript one's headings aren't plain enough to read without false positives); GitHub release notes (the same text). -- **Quote:** "Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead." (sentry-python 2.0.0). - -## How the provider announces changes - -A major a year or so per SDK, announced with a migration guide and a changelog section; deprecations land in minors before. sentry-python has a 3.0.0rc1 tagged: its 3.0.0 section will be read when 3.0.0 is on PyPI. - -## What the plugin reads and ignores - -- Reads the release's section only; a bullet counts under a breaking, removal or deprecation heading, or marked `!` (conventional commits), when its first sentence names what it removes plainly. -- Drops (and logs): removed options and integrations' settings, dropped runtime and framework versions, behavior changes, and bullets that list names in prose. - -## Known gaps - -- Options passed to `init()` (`with_locals`, `enableLogs`) aren't symbols: their removal isn't an event. -- A release whose section is missing at its tag is skipped as nothing to read. diff --git a/providers/sentry.md b/providers/sentry.md deleted file mode 100644 index 06914d5..0000000 --- a/providers/sentry.md +++ /dev/null @@ -1,58 +0,0 @@ -# Sentry (`sentry/api`) - -## What it watches - -Sentry's public REST API (`https://{region}.sentry.io/api/0/...`): operations Sentry deprecates, between releases of its OpenAPI spec. Most of them it deprecates in the operation's description, not with the `deprecated` flag. - -Kind: `openapi` (`plugins/openapi`), with `adapter.Sentry`. - -## Why this source - -- **Source:** `openapi-derefed.json`, an asset of each `api@X.Y.Z` release of [getsentry/sentry](https://github.com/getsentry/sentry/releases), e.g. `https://github.com/getsentry/sentry/releases/download/api%402.16.0/openapi-derefed.json`. - - The plugin reads the release with the highest `api@` version, not the newest by date (GitHub lists releases in an order that isn't version order), leaving out drafts, prereleases and releases without the spec. - - A release asset is pinned by its release tag: the URL names the tag, and the tag names one release. GitHub does let a maintainer replace an asset in place, which a commit SHA would rule out; there's no SHA-pinned copy of the spec since it moved here. - - Checked on 2026-11-19: 19 `api@` releases, `api@2.5.0` (2026-11-14) to `api@2.16.0` (2026-11-18). -- **History:** until 2026-11-14 the spec was published in [getsentry/sentry-api-schema](https://github.com/getsentry/sentry-api-schema), committed as `openapi-derefed.json` (1,130 commits that changed it since 2020-08-25) and tagged `0.1.0` to `2.4.0` from 2026-02-10. That repo is archived ("@sentry/api has moved"); its `2.4.0` is byte for byte `api@2.5.0`. The adapter reads a tag or a commit of it too (`https://raw.githubusercontent.com/getsentry/sentry-api-schema//openapi-derefed.json`), so that history can be replayed. -- **Why this one:** it's Sentry's own OpenAPI spec of its public REST API, with every `$ref` resolved, published with `@sentry/api` ("The official, auto-generated TypeScript client for Sentry's public REST API"). It's the one machine-readable record of which endpoints Sentry documents and deprecates, and it carries the deprecation notices. -- **Alternatives considered:** - - **The [changelog](https://sentry.io/changelog/)** (RSS). It's product news. Its items around the alert-rule deprecation ("Monitors & Alerts are in Early Access", 2026-04-20; "Monitors & Alerts — Now Generally Available", 2026-05-07) don't name an endpoint, and the feed carries titles only. - - **The SDKs' changelogs** (`sentry-python`, `sentry-javascript`). They're about the event-ingestion SDKs, not the REST API. - - **`src/sentry/api/urls.py` in getsentry/sentry.** It lists the routes, but not which are public, documented or deprecated. -- **Quote:** "## Deprecated 🚧 Use [Fetch an Organization's Monitors](/api/monitors/fetch-an-organizations-monitors) and [Fetch Alerts](/api/monitors/fetch-alerts) instead." (the description of `GET /api/0/organizations/{organization_id_or_slug}/alert-rules/` from sentry-api-schema `1da1f31f`, 2026-01-22; a line break after the heading) - -## How the provider announces changes - -- **No API versions.** Every path is under `/api/0/`, and `info.version` is `v0`. The spec's own versions (`api@2.16.0`, `0.224.0`) are the `@sentry/api` package's, released several times a day lately, not the API's. -- **The event's `version` is a date:** the spec release's publication date (`2026-11-18` for `api@2.16.0`), or a commit's date when replaying the history before tags. Several releases a day share one. The patch-it client keeps a date-versioned API's events only if it's in its list of date-versioned APIs, so `sentry` needs to be in it. -- **Deprecations are in words.** Over the whole history (1,130 commits, then the 19 `api@` releases) the `deprecated` flag is set on 3 operations, and the description deprecates 13, always no later than the flag: - - **2022-03-01:** `GET .../stats/`, words and flag together: "This endpoint is deprecated in favor of [Organization Stats V2]". - - **2024-07-31:** `POST .../user-feedback/`: "*This endpoint is DEPRECATED. We document it here for older SDKs ...". Flagged on 2026-06-16. - - **2025-07-25:** `GET /api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/issues/`: "**Deprecated**: This endpoint has been replaced with the [Organization Issues endpoint]". Flagged on 2026-06-16. - - **2026-01-22:** the 10 issue and metric alert-rule operations (`.../alert-rules/`, `.../alert-rules/{alert_rule_id}/`, `.../rules/`, `.../rules/{rule_id}/`): "## Deprecated 🚧 Use [...] instead." Never flagged. -- **Endpoints leave the spec without a word.** See the removals below. - -## What the plugin reads and ignores - -- **Reads:** the spec of the newest `api@` release, diffed against the last one read. -- **One event comes out of it: a deprecation,** when an operation is newly deprecated, by the flag or by its description. Matched by path template. - - **A description deprecates an operation** when it has a `## Deprecated` heading, a line starting `**Deprecated**:`, or says "This endpoint is deprecated" (any case). Those are the three ways the history says it. The event cites the description. - - **Not "deprecat" anywhere.** That also matches three descriptions that only mention deprecation: `GET .../events/`'s "**Eventsv2 Deprecation Note**" (about the old `eventsv2` endpoint; 2022-06-16, and again under the 2024-05-10 parameter rename) and `GET .../trace-items/attributes/`'s "examples, and deprecation details" (2026-10-15). - - **A flagged operation is quoted whole,** `"deprecated":true` first and the description after it. - - **The flag after the words is no new event:** user-feedback and issues were deprecated when their descriptions said so, not on 2026-06-16. -- **Reads every path as a caller sends it, `/api/0/...`.** Until sentry-api-schema 2.0.1 the server was `https://{region}.sentry.io` and every path started `/api/0/`. From 2.1.0 (2026-11-13) the server is `https://{region}.sentry.io/api/0` and the paths don't. Same URLs, but compared as published all 289 operations would read as removed and added again. So the adapter moves the server URL's path back into every path, and maps each event's `source_pointer` back to the path as published. -- **Ignores everything else:** - - **Removals, even of deprecated operations.** An operation leaving the spec means Sentry stopped documenting it, and the history doesn't show when, or whether, it stopped working. With `/api/0` in every path, 157 operations left the spec (by path template), 11 of them deprecated first: - - `GET /api/0/organizations/{organization_slug}/stats/`, gone on 2024-01-22, is still routed in getsentry/sentry's `src/sentry/api/urls.py` (checked 2026-11-19). - - The 10 alert-rule operations left on 2026-05-08, the day after "Monitors & Alerts — Now Generally Available". Their routes aren't in `urls.py` today, but nothing from Sentry says they stopped answering on 2026-05-08. - - Compared as published, 446 operations left the spec: the 289 more are the 2026-11-13 move of `/api/0`, `GET .../issues/` and `POST .../user-feedback/` among them, both flagged deprecated. A rule keeping removals of deprecated operations would report those two shut down. - - **Property changes, and new operations.** -- **History:** 13 events over the whole history, all deprecations: the 13 above, none withdrawn. By the flag alone it would be 3, two of them dated 2026-06-16 instead of 2024 and 2025. -- **Reads** the three description deprecations in the golden test (sentry-api-schema commits `ead7f0cf` → `4650a66a`, `d64149d6` → `c2f638f6`, `47231e61` → `1da1f31f`). The drop test replays `2.0.1` → `2.1.0`, the `/api/0` move. Other tests replay `0.223.0` → `0.224.0` (the flag after the words) and the two commits that added the "deprecation" wording that isn't a deprecation. - -## Known gaps - -- **No removals.** When Sentry turns an endpoint off, the plugin has already reported its deprecation, if Sentry said so in the spec, and reports nothing else. -- **The same deprecation can be reported twice** if Sentry removes the words from a description and puts them back on a later day: the diff keeps no memory, and each event is dated by its release. It hasn't happened in the history, and the two operations still deprecated today also carry the flag, which keeps them from it. -- **A deprecation said another way isn't seen,** like "has been replaced" with no "deprecated", or a parameter deprecated in prose. -- **Undocumented endpoints aren't watched.** The spec covers what Sentry documents publicly: 199 path items in `api@2.16.0`. -- **Request and response property changes aren't events,** including deprecated parameters and fields. diff --git a/providers/sentry/README.md b/providers/sentry/README.md new file mode 100644 index 0000000..2e1b19b --- /dev/null +++ b/providers/sentry/README.md @@ -0,0 +1,173 @@ +# Sentry + +Every source patch-it reads for Sentry, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Sentry (`sentry/api`) + +### What it watches + +Sentry's public REST API (`https://{region}.sentry.io/api/0/...`): operations Sentry deprecates, between releases of its OpenAPI spec. Most of them it deprecates in the operation's description, not with the `deprecated` flag. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `Sentry` ([`api.go`](api.go)). + +### Why this source + +- **Source:** `openapi-derefed.json`, an asset of each `api@X.Y.Z` release of [getsentry/sentry](https://github.com/getsentry/sentry/releases), e.g. `https://github.com/getsentry/sentry/releases/download/api%402.16.0/openapi-derefed.json`. + - The plugin reads the release with the highest `api@` version, not the newest by date (GitHub lists releases in an order that isn't version order), leaving out drafts, prereleases and releases without the spec. + - A release asset is pinned by its release tag: the URL names the tag, and the tag names one release. GitHub does let a maintainer replace an asset in place, which a commit SHA would rule out; there's no SHA-pinned copy of the spec since it moved here. + - Checked on 2026-11-19: 19 `api@` releases, `api@2.5.0` (2026-11-14) to `api@2.16.0` (2026-11-18). +- **History:** until 2026-11-14 the spec was published in [getsentry/sentry-api-schema](https://github.com/getsentry/sentry-api-schema), committed as `openapi-derefed.json` (1,130 commits that changed it since 2020-08-25) and tagged `0.1.0` to `2.4.0` from 2026-02-10. That repo is archived ("@sentry/api has moved"); its `2.4.0` is byte for byte `api@2.5.0`. The adapter reads a tag or a commit of it too (`https://raw.githubusercontent.com/getsentry/sentry-api-schema//openapi-derefed.json`), so that history can be replayed. +- **Why this one:** it's Sentry's own OpenAPI spec of its public REST API, with every `$ref` resolved, published with `@sentry/api` ("The official, auto-generated TypeScript client for Sentry's public REST API"). It's the one machine-readable record of which endpoints Sentry documents and deprecates, and it carries the deprecation notices. +- **Alternatives considered:** + - **The [changelog](https://sentry.io/changelog/)** (RSS). It's product news. Its items around the alert-rule deprecation ("Monitors & Alerts are in Early Access", 2026-04-20; "Monitors & Alerts — Now Generally Available", 2026-05-07) don't name an endpoint, and the feed carries titles only. + - **The SDKs' changelogs** (`sentry-python`, `sentry-javascript`). They're about the event-ingestion SDKs, not the REST API. + - **`src/sentry/api/urls.py` in getsentry/sentry.** It lists the routes, but not which are public, documented or deprecated. +- **Quote:** "## Deprecated 🚧 Use [Fetch an Organization's Monitors](/api/monitors/fetch-an-organizations-monitors) and [Fetch Alerts](/api/monitors/fetch-alerts) instead." (the description of `GET /api/0/organizations/{organization_id_or_slug}/alert-rules/` from sentry-api-schema `1da1f31f`, 2026-01-22; a line break after the heading) + +### How the provider announces changes + +- **No API versions.** Every path is under `/api/0/`, and `info.version` is `v0`. The spec's own versions (`api@2.16.0`, `0.224.0`) are the `@sentry/api` package's, released several times a day lately, not the API's. +- **The event's `version` is a date:** the spec release's publication date (`2026-11-18` for `api@2.16.0`), or a commit's date when replaying the history before tags. Several releases a day share one. The patch-it client keeps a date-versioned API's events only if it's in its list of date-versioned APIs, so `sentry` needs to be in it. +- **Deprecations are in words.** Over the whole history (1,130 commits, then the 19 `api@` releases) the `deprecated` flag is set on 3 operations, and the description deprecates 13, always no later than the flag: + - **2022-03-01:** `GET .../stats/`, words and flag together: "This endpoint is deprecated in favor of [Organization Stats V2]". + - **2024-07-31:** `POST .../user-feedback/`: "*This endpoint is DEPRECATED. We document it here for older SDKs ...". Flagged on 2026-06-16. + - **2025-07-25:** `GET /api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/issues/`: "**Deprecated**: This endpoint has been replaced with the [Organization Issues endpoint]". Flagged on 2026-06-16. + - **2026-01-22:** the 10 issue and metric alert-rule operations (`.../alert-rules/`, `.../alert-rules/{alert_rule_id}/`, `.../rules/`, `.../rules/{rule_id}/`): "## Deprecated 🚧 Use [...] instead." Never flagged. +- **Endpoints leave the spec without a word.** See the removals below. + +### What the plugin reads and ignores + +- **Reads:** the spec of the newest `api@` release, diffed against the last one read. +- **One event comes out of it: a deprecation,** when an operation is newly deprecated, by the flag or by its description. Matched by path template. + - **A description deprecates an operation** when it has a `## Deprecated` heading, a line starting `**Deprecated**:`, or says "This endpoint is deprecated" (any case). Those are the three ways the history says it. The event cites the description. + - **Not "deprecat" anywhere.** That also matches three descriptions that only mention deprecation: `GET .../events/`'s "**Eventsv2 Deprecation Note**" (about the old `eventsv2` endpoint; 2022-06-16, and again under the 2024-05-10 parameter rename) and `GET .../trace-items/attributes/`'s "examples, and deprecation details" (2026-10-15). + - **A flagged operation is quoted whole,** `"deprecated":true` first and the description after it. + - **The flag after the words is no new event:** user-feedback and issues were deprecated when their descriptions said so, not on 2026-06-16. +- **Reads every path as a caller sends it, `/api/0/...`.** Until sentry-api-schema 2.0.1 the server was `https://{region}.sentry.io` and every path started `/api/0/`. From 2.1.0 (2026-11-13) the server is `https://{region}.sentry.io/api/0` and the paths don't. Same URLs, but compared as published all 289 operations would read as removed and added again. So the adapter moves the server URL's path back into every path, and maps each event's `source_pointer` back to the path as published. +- **Ignores everything else:** + - **Removals, even of deprecated operations.** An operation leaving the spec means Sentry stopped documenting it, and the history doesn't show when, or whether, it stopped working. With `/api/0` in every path, 157 operations left the spec (by path template), 11 of them deprecated first: + - `GET /api/0/organizations/{organization_slug}/stats/`, gone on 2024-01-22, is still routed in getsentry/sentry's `src/sentry/api/urls.py` (checked 2026-11-19). + - The 10 alert-rule operations left on 2026-05-08, the day after "Monitors & Alerts — Now Generally Available". Their routes aren't in `urls.py` today, but nothing from Sentry says they stopped answering on 2026-05-08. + - Compared as published, 446 operations left the spec: the 289 more are the 2026-11-13 move of `/api/0`, `GET .../issues/` and `POST .../user-feedback/` among them, both flagged deprecated. A rule keeping removals of deprecated operations would report those two shut down. + - **Property changes, and new operations.** +- **History:** 13 events over the whole history, all deprecations: the 13 above, none withdrawn. By the flag alone it would be 3, two of them dated 2026-06-16 instead of 2024 and 2025. +- **Reads** the three description deprecations in the golden test (sentry-api-schema commits `ead7f0cf` → `4650a66a`, `d64149d6` → `c2f638f6`, `47231e61` → `1da1f31f`). The drop test replays `2.0.1` → `2.1.0`, the `/api/0` move. Other tests replay `0.223.0` → `0.224.0` (the flag after the words) and the two commits that added the "deprecation" wording that isn't a deprecation. + +### Known gaps + +- **No removals.** When Sentry turns an endpoint off, the plugin has already reported its deprecation, if Sentry said so in the spec, and reports nothing else. +- **The same deprecation can be reported twice** if Sentry removes the words from a description and puts them back on a later day: the diff keeps no memory, and each event is dated by its release. It hasn't happened in the history, and the two operations still deprecated today also carry the flag, which keeps them from it. +- **A deprecation said another way isn't seen,** like "has been replaced" with no "deprecated", or a parameter deprecated in prose. +- **Undocumented endpoints aren't watched.** The spec covers what Sentry documents publicly: 199 path items in `api@2.16.0`. +- **Request and response property changes aren't events,** including deprecated parameters and fields. + +## Sentry Node.js SDK (`sentry/node-surface`) + +### What it watches + +The public API of the `@sentry/node` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @sentry/node@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md; MIGRATION.md (majors only). +- **Quote:** `export { systemErrorIntegration } from "@sentry/node-core"` (`build/types/index.d.ts` line 35) at 9.47.2, gone at 10.0.0. + +### How the provider announces changes + +- Releases every week or two; most of what it exports is re-exported from `@sentry/core` and `@sentry/node-core`, read here by name. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@sentry/node.init`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- Names re-exported from `@sentry/core` are read by name: their signatures are that package's. + +## Sentry Python SDK (`sentry/python-surface`) + +### What it watches + +The public API of the `sentry-sdk` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install sentry-sdk==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md; MIGRATION_GUIDE.md (majors only, for the `migrationguide` kind). +- **Quote:** `def to_timestamp(value: "datetime") -> float` (`sentry_sdk/utils.py` line 251) at 2.73.0, gone at 2.74.0. + +### How the provider announces changes + +- The SDK releases every week or two; helpers in public-looking modules (`sentry_sdk.utils`) are removed in minors. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `sentry_sdk/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. +- `sentry_sdk.utils` and similar modules have no leading underscore but are mostly the SDK's own helpers: their removals are events, though few customers call them. + +## Sentry SDKs (`sentry/python-changelog`, `sentry/javascript-changelog`, `sentry/go`, `sentry/dotnet`) + +### What it watches + +Names removed, renamed or deprecated in each release of Sentry's Python, JavaScript, Go and .NET SDKs, from that release's section of the SDK's `CHANGELOG.md` at its tag. One `package_release` event per bullet that names what it changes plainly. Sentry's API is a separate source (`sentry/api`). + +Kind: `changelog` (`kinds/changelog`, `sdks.go`). + +| Source | Package | Releases listed from | Tag | +|---|---|---|---| +| `sentry/python-changelog` | `pypi:sentry-sdk` | PyPI | `X.Y.Z` | +| `sentry/javascript-changelog` | `npm:@sentry/node`, `npm:@sentry/browser` (released together) | npm (`@sentry/node`) | `X.Y.Z` | +| `sentry/go` | `go:github.com/getsentry/sentry-go` | the repo's `vX.Y.Z` tags | `vX.Y.Z` | +| `sentry/dotnet` | `nuget:Sentry` | the repo's `X.Y.Z` tags | `X.Y.Z` | + +### Why this source + +- **Source:** https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md, https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md, https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md, https://github.com/getsentry/sentry-dotnet/blob/main/CHANGELOG.md, each read raw at the release's tag; checked on 2026-11-20. +- **Why this one:** Sentry writes every major's removals into the changelog itself, under "Removed" / "Breaking Changes" / "Deprecations" headings or as conventional-commit bullets (`feat(core)!: Remove \`BaseClient\``). The Python 2.0 changelog section carries the same "Removed" and "Deprecated" lists as its `MIGRATION_GUIDE.md`, so the guide isn't a second source (it would repeat the same events under another id). +- **Alternatives considered:** the migration guides (`MIGRATION_GUIDE.md`, `MIGRATION.md`: prose sections per major, mostly behavior and options; the JavaScript one's headings aren't plain enough to read without false positives); GitHub release notes (the same text). +- **Quote:** "Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead." (sentry-python 2.0.0). + +### How the provider announces changes + +A major a year or so per SDK, announced with a migration guide and a changelog section; deprecations land in minors before. sentry-python has a 3.0.0rc1 tagged: its 3.0.0 section will be read when 3.0.0 is on PyPI. + +### What the plugin reads and ignores + +- Reads the release's section only; a bullet counts under a breaking, removal or deprecation heading, or marked `!` (conventional commits), when its first sentence names what it removes plainly. +- Drops (and logs): removed options and integrations' settings, dropped runtime and framework versions, behavior changes, and bullets that list names in prose. + +### Known gaps + +- Options passed to `init()` (`with_locals`, `enableLogs`) aren't symbols: their removal isn't an event. +- A release whose section is missing at its tag is skipped as nothing to read. diff --git a/plugins/openapi/adapter/sentry.go b/providers/sentry/api.go similarity index 51% rename from plugins/openapi/adapter/sentry.go rename to providers/sentry/api.go index 9db5510..de484ff 100644 --- a/plugins/openapi/adapter/sentry.go +++ b/providers/sentry/api.go @@ -1,7 +1,6 @@ -package adapter +package sentry import ( - "bytes" "cmp" "context" "encoding/json" @@ -12,8 +11,12 @@ import ( "strings" "time" + "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" ) // sentryAsset is the spec's file name in both places it's published: @@ -49,7 +52,7 @@ type Sentry struct { RawBase string // files at a tag or commit; "" is https://raw.githubusercontent.com } -var _ Adapter = Sentry{} +var _ adapter.Adapter = Sentry{} func (Sentry) API() string { return "sentry/api" } @@ -125,7 +128,7 @@ func (r sentryReleaseInfo) hasSpec() bool { // (YYYY-MM-DD): the API has no version of its own (`/api/0`, info.version // "v0"), and the spec's own version numbers are a package's (@sentry/api), // not the API's. -func (s Sentry) Fetch(ctx context.Context, tag string) (Spec, error) { +func (s Sentry) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { raw := cmp.Or(s.RawBase, "https://raw.githubusercontent.com") + "/getsentry/sentry-api-schema/" + tag + "/" + sentryAsset var url string var date time.Time @@ -133,10 +136,10 @@ func (s Sentry) Fetch(ctx context.Context, tag string) (Spec, error) { case sentryRelease.MatchString(tag): r, err := sentryReleaseMeta(ctx, s.api("/repos/getsentry/sentry/releases/tags/"+tag), tag) if err != nil { - return Spec{}, err + return adapter.Spec{}, err } if !r.hasSpec() { - return Spec{}, fmt.Errorf("sentry release %s has no %s", tag, sentryAsset) + return adapter.Spec{}, fmt.Errorf("sentry release %s has no %s", tag, sentryAsset) } // Spelled as GitHub's own links spell it: the tag's @ as %40. url = cmp.Or(s.DownloadBase, "https://github.com") + "/getsentry/sentry/releases/download/" + @@ -145,13 +148,13 @@ func (s Sentry) Fetch(ctx context.Context, tag string) (Spec, error) { case sentrySchemaTag.MatchString(tag): r, err := sentryReleaseMeta(ctx, s.api("/repos/getsentry/sentry-api-schema/releases/tags/"+tag), tag) if err != nil { - return Spec{}, err + return adapter.Spec{}, err } url, date = raw, r.PublishedAt case sentrySchemaCommit.MatchString(tag): meta, err := fetch.Get(ctx, s.api("/repos/getsentry/sentry-api-schema/commits/"+tag), github.Headers()) if err != nil { - return Spec{}, fmt.Errorf("looking up sentry-api-schema commit %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("looking up sentry-api-schema commit %s: %w", tag, err) } var c struct { Commit struct { @@ -161,24 +164,24 @@ func (s Sentry) Fetch(ctx context.Context, tag string) (Spec, error) { } `json:"commit"` } if err := json.Unmarshal(meta, &c); err != nil { - return Spec{}, fmt.Errorf("parsing github commit %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("parsing github commit %s: %w", tag, err) } url, date = raw, c.Commit.Committer.Date default: - return Spec{}, fmt.Errorf("%q is neither a sentry api@X.Y.Z release, a sentry-api-schema tag nor a full commit sha", tag) + return adapter.Spec{}, fmt.Errorf("%q is neither a sentry api@X.Y.Z release, a sentry-api-schema tag nor a full commit sha", tag) } if date.IsZero() { - return Spec{}, fmt.Errorf("sentry %s: github gives no date", tag) + return adapter.Spec{}, fmt.Errorf("sentry %s: github gives no date", tag) } body, err := fetch.Get(ctx, url, nil) // public downloads need no auth if err != nil { - return Spec{}, fmt.Errorf("fetching the sentry %s spec: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("fetching the sentry %s spec: %w", tag, err) } - content, err := ServerBasePath(body) + content, err := adapter.ServerBasePath(body) if err != nil { - return Spec{}, fmt.Errorf("sentry %s: %w", tag, err) + return adapter.Spec{}, fmt.Errorf("sentry %s: %w", tag, err) } - return Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil + return adapter.Spec{Content: content, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil } func sentryReleaseMeta(ctx context.Context, url, tag string) (sentryReleaseInfo, error) { @@ -196,113 +199,96 @@ func sentryReleaseMeta(ctx context.Context, url, tag string) (sentryReleaseInfo, return r, nil } -// basePathKey is the root key ServerBasePath records the server path it moved -// into the paths under. The differ reads only paths and components, so the -// key is never diffed. -const basePathKey = "x-patch-it-base-path" +// SourcePointer: see BasePathPointer. +func (Sentry) SourcePointer(content []byte) func(string) string { + return adapter.BasePathPointer(content) +} -// ServerBasePath puts the server URL's path back at the front of every path, -// so an operation is named by the path a caller sends ("GET /api/0/…"), and -// a spec that moves the server's path into its paths (or out of them) reads -// as the same operations, not as every operation removed and added again. -// Used by every adapter whose API has a path in its server URL. -// -// Sentry did move it: -// Until sentry-api-schema 2.0.1 the server was "https://{region}.sentry.io" -// and the paths started "/api/0/"; from 2.1.0 (2026-11-13) the server is -// "https://{region}.sentry.io/api/0" and the paths don't. The URLs a caller -// sends are the same, but compared as published, every operation (289 of -// them) reads as removed and added again. With the server's path moved into -// the paths, every spec names an operation by the path a caller sends, -// "GET /api/0/organizations/", as Sentry's API reference does. -// -// A spec whose server has no path is returned byte for byte. The values are -// otherwise unchanged (numbers kept as written); the path moved is recorded -// for SourcePointer. -func ServerBasePath(body []byte) ([]byte, error) { - dec := json.NewDecoder(bytes.NewReader(body)) - dec.UseNumber() - var doc map[string]any - if err := dec.Decode(&doc); err != nil { - return nil, fmt.Errorf("parsing the spec: %w", err) - } - base := "" - for i, s := range asSlice(doc["servers"]) { - u, _ := asMap(s)["url"].(string) - p := serverPath(u) - if i > 0 && p != base { - return nil, fmt.Errorf("servers with different paths (%q, %q)", base, p) +var _ adapter.Reshaper = Sentry{} + +// Versions are every release of the spec, oldest first by date: the +// getsentry/sentry-api-schema release tags (0.1.0 to 2.4.0, the archived +// repo) and then getsentry/sentry's api@X.Y.Z releases with the spec +// attached. The ID is the release's date, as Fetch's Version. The schema +// repo's commits before its first tag aren't listed; Fetch still reads one +// by its SHA. +func (s Sentry) Versions(ctx context.Context) ([]plugin.Version, error) { + var out []plugin.Version + for _, src := range []struct { + repo string + keep func(sentryReleaseInfo) bool + }{ + {"getsentry/sentry-api-schema", func(r sentryReleaseInfo) bool { return sentrySchemaTag.MatchString(r.Tag) }}, + {"getsentry/sentry", func(r sentryReleaseInfo) bool { return sentryRelease.MatchString(r.Tag) && r.hasSpec() }}, + } { + rs, err := versions.GitHubPages[sentryReleaseInfo](ctx, github.Get, s.api("/repos/"+src.repo+"/releases")) + if err != nil { + return nil, fmt.Errorf("listing %s's releases: %w", src.repo, err) } - base = p - } - if base == "" { - return body, nil - } - paths := asMap(doc["paths"]) - moved := make(map[string]any, len(paths)) - for p, item := range paths { - if !strings.HasPrefix(p, "/") { - return nil, fmt.Errorf("path %q doesn't start with /", p) + for _, r := range rs { + if r.Draft || r.Prerelease || !src.keep(r) { + continue + } + at := r.PublishedAt.UTC() + out = append(out, plugin.Version{ID: at.Format(time.DateOnly), Released: at, Ref: r.Tag, + URL: "https://github.com/" + src.repo + "/releases/tag/" + strings.ReplaceAll(r.Tag, "@", "%40")}) } - moved[base+p] = item } - doc["paths"] = moved - doc[basePathKey] = base - return json.Marshal(doc) + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return out, nil } -// serverPath is the path of a server URL ("/api/0" for -// "https://{region}.sentry.io/api/0", "/api/v1" for Convex's -// "{deployment-url}/api/v1", whose whole origin is a variable), without a -// trailing slash; "" for none. Read by hand: url.Parse refuses a variable in -// the host. -func serverPath(u string) string { - _, rest, ok := strings.Cut(u, "://") - if !ok { - if !strings.HasPrefix(u, "{") || !strings.Contains(u, "}") { - return "" - } - _, rest, _ = strings.Cut(u, "}") - return strings.TrimRight(rest, "/") - } - i := strings.Index(rest, "/") - if i < 0 { - return "" - } - return strings.TrimRight(rest[i:], "/") -} +// sentryDiff is how Sentry's spec says what it says: +// +// - Deprecations are mostly in the operation's description, not the flag. +// Over the spec's history (the 1,130 commits that changed it in +// getsentry/sentry-api-schema, 2020-08-25 to 2026-11-14, then the 19 +// api@ releases to api@2.16.0) the flag deprecates 3 operations and the +// description 13, those 3 included, never later than the flag: the 10 +// issue and metric alert-rule operations on 2026-01-22, never flagged; +// POST .../user-feedback/ on 2024-07-31 and GET .../issues/ on +// 2025-07-25, both flagged on 2026-06-16; GET .../stats/, words and flag +// together on 2022-03-01. +// - The flag, when it's set, comes with the reason in the description, so +// a flagged operation is quoted whole. +// - Path parameters get renamed ({organization_slug} became +// {organization_id_or_slug} on 2024-05-10), and that isn't a change for +// callers. +var sentryDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true, DeprecatedDescription: sentryDeprecatedDescription} -// SourcePointer: see BasePathPointer. -func (Sentry) SourcePointer(content []byte) func(string) string { return BasePathPointer(content) } +// sentryDeprecatedWords are the three ways the descriptions say it, over the +// whole history: a "## Deprecated" heading with nothing else on its line, a +// line starting "**Deprecated**:", and "This endpoint is deprecated" in any +// case ("*This endpoint is DEPRECATED."). Also "**Deprecated:**", the colon +// inside the bold: never used for a deprecation yet, but how Sentry writes +// its other notes ("**Experimental:**", 45 times in api@2.16.0). Not a heading +// with more words ("## Deprecated fields"), which would be about part of the +// operation. Not "deprecat" anywhere: that also matches +// three descriptions that aren't deprecations, GET .../events/'s "**Eventsv2 +// Deprecation Note**" (about another endpoint; 2022-06-16, and again under +// the 2024-05-10 rename) and GET .../trace-items/attributes/'s "examples, and +// deprecation details" (2026-10-15). +var sentryDeprecatedWords = regexp.MustCompile(`(?im)^\s*#+\s*deprecated[^\p{L}\p{N}\n]*$|^\s*\*\*deprecated(\*\*:|:\*\*)|\bthis endpoint is deprecated\b`) -// BasePathPointer turns a pointer into a path ServerBasePath prefixed with -// the server's path back into one into the path as published. Every other -// pointer, and every pointer into a spec ServerBasePath didn't change, is -// already right. -func BasePathPointer(content []byte) func(string) string { - var doc struct { - Base string `json:"x-patch-it-base-path"` - } - _ = json.Unmarshal(content, &doc) // unreadable content: pointers stay as they are - if doc.Base == "" { - return func(ptr string) string { return ptr } - } - prefix := "/paths/" + pointerToken(doc.Base) - return func(ptr string) string { - rest, ok := strings.CutPrefix(ptr, prefix) - // Every path starts with /, so what follows is "~1..."; anything - // else is a pointer into a path that wasn't moved. - if !ok || !strings.HasPrefix(rest, "~1") { - return ptr - } - return "/paths/" + rest - } +func sentryDeprecatedDescription(description string) bool { + return sentryDeprecatedWords.MatchString(description) } -var _ Reshaper = Sentry{} - -// asSlice is v as an array, or nil. -func asSlice(v any) []any { - s, _ := v.([]any) - return s -} +// sentryKeep keeps operation deprecations only: not even a deprecated +// operation's removal. An operation leaving Sentry's spec means Sentry +// stopped documenting it, and the history doesn't show when, or whether, it +// stopped working. +// +// - 157 operations left the spec (by path template, with /api/0 in every +// path: see Sentry). 11 had been deprecated first: GET +// /api/0/organizations/{organization_slug}/stats/, gone on 2024-01-22 +// and still routed in getsentry/sentry's src/sentry/api/urls.py on +// 2026-11-19, and the 10 alert-rule operations, gone on 2026-05-08 (the +// day after Sentry's "Monitors & Alerts — Now Generally Available"), +// with nothing from Sentry saying they stopped answering then. +// - Compared as published, 289 more left on 2026-11-13, when /api/0 +// moved into the server URL, GET .../issues/ and POST .../user-feedback/ +// among them, both flagged deprecated. +// +// Property changes and new operations are dropped too, as for vercel. +func sentryKeep(c diff.Change) bool { return c.Kind == diff.OperationDeprecated } diff --git a/plugins/openapi/adapter/sentry_test.go b/providers/sentry/api_fetch_test.go similarity index 87% rename from plugins/openapi/adapter/sentry_test.go rename to providers/sentry/api_fetch_test.go index acb179f..f1e4e82 100644 --- a/plugins/openapi/adapter/sentry_test.go +++ b/providers/sentry/api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package sentry import ( "context" @@ -7,6 +7,8 @@ import ( "net/http/httptest" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // fakeSentryGitHub serves GitHub's API, release downloads and raw files from @@ -161,30 +163,23 @@ func TestSentryFetchSchemaTagOrCommit(t *testing.T) { } } -func TestSentryBasePathRefusesWhatItCantMove(t *testing.T) { - if _, err := ServerBasePath([]byte(`{"servers":[{"url":"https://x/api"}],"paths":{"/a":{},"a":{}}}`)); err == nil { - t.Error("a path without a leading /: want an error") +// The archived schema repo's tags, then getsentry/sentry's api@ releases, +// by date; the IDs are dates, as Fetch's Version. +func TestSentryListsBothRepos(t *testing.T) { + srv := openapitest.Recorded(t, map[string]string{ + "/repos/getsentry/sentry-api-schema/releases?per_page=100&page=1": "sentry-schema-releases.json", + "/repos/getsentry/sentry/releases?per_page=100&page=1": "sentry-api-releases.json", + }) + vs, err := Sentry{APIBase: srv.URL}.Versions(context.Background()) + if err != nil { + t.Fatal(err) } - if _, err := ServerBasePath([]byte(`{"servers":[{"url":"https://x/api/0"},{"url":"https://y"}],"paths":{}}`)); err == nil { - t.Error("servers with different paths: want an error") + if len(vs) != 21 || vs[0].Ref != "2.3.2" || vs[1].Ref != "2.4.0" || vs[2].Ref != "api@2.5.0" || vs[len(vs)-1].Ref != "api@2.16.0" { + t.Fatalf("versions %s", openapitest.IDs(vs)) } -} - -// A server whose whole origin is a variable (Convex's "{deployment-url}/api/v1") -// still has a path to move. -func TestServerPath(t *testing.T) { - for in, want := range map[string]string{ - "{deployment-url}/api/v1": "/api/v1", - "{deployment-url}/api/v1/": "/api/v1", - "{deployment-url}": "", - "https://{region}.sentry.io/api/0": "/api/0", - "https://{region}.sentry.io/api/0/": "/api/0", - "https://{region}.sentry.io": "", - "https://sentry.io/": "", - "/api/0": "", - } { - if got := serverPath(in); got != want { - t.Errorf("serverPath(%q) = %q, want %q", in, got, want) + for i := 1; i < len(vs); i++ { + if vs[i].Released.Before(vs[i-1].Released) || vs[i].ID != vs[i].Released.Format("2006-01-02") { + t.Errorf("%v after %v", vs[i], vs[i-1]) } } } diff --git a/plugins/openapi/sentry_test.go b/providers/sentry/api_test.go similarity index 92% rename from plugins/openapi/sentry_test.go rename to providers/sentry/api_test.go index 80b8b0c..cd3610b 100644 --- a/plugins/openapi/sentry_test.go +++ b/providers/sentry/api_test.go @@ -1,4 +1,4 @@ -package openapi +package sentry import ( "context" @@ -14,7 +14,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/diff" "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // The getsentry/sentry-api-schema commits and release tags saved under @@ -53,7 +55,7 @@ func sentryFile(ref string) string { // sentryPlugin is the plugin as registered for Sentry, its adapter reading // GitHub's answers and the saved copies from a local server. It returns the // base of the spec URLs: //openapi-derefed.json. -func sentryPlugin(t *testing.T) (Plugin, string) { +func sentryPlugin(t *testing.T) (openapi.Plugin, string) { t.Helper() const schema = "/api/repos/getsentry/sentry-api-schema" srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -76,15 +78,15 @@ func sentryPlugin(t *testing.T) (Plugin, string) { http.NotFound(w, r) })) t.Cleanup(srv.Close) - a := adapter.Sentry{APIBase: srv.URL + "/api", RawBase: srv.URL + "/raw"} - return Plugin{Adapter: a, Diff: sentryDiff, Keep: sentryKeep}, srv.URL + "/raw/getsentry/sentry-api-schema" + a := Sentry{APIBase: srv.URL + "/api", RawBase: srv.URL + "/raw"} + return openapi.Plugin{Adapter: a, Diff: sentryDiff, Keep: sentryKeep}, srv.URL + "/raw/getsentry/sentry-api-schema" } -func pairSentry(t *testing.T, p Plugin, pairs ...[2]string) []event.Event { +func pairSentry(t *testing.T, p openapi.Plugin, pairs ...[2]string) []event.Event { t.Helper() - s := openStore(t) + s := kittest.NewMem() for _, pair := range pairs { - if rejected, err := kittest.Pair(context.Background(), vercelEnv(s), s, p, pair[0], pair[1]); err != nil || rejected { + if rejected, err := kittest.Pair(context.Background(), openapitest.Env(s), s, p, pair[0], pair[1]); err != nil || rejected { t.Fatalf("pair %s -> %s: rejected=%v err=%v", pair[0], pair[1], rejected, err) } } @@ -123,7 +125,7 @@ func TestSentryGolden(t *testing.T) { if _, ok := sentryCommits[ref]; !ok { t.Fatalf("%s: cited %s", e.Subject.Operation, e.SourceURL) } - if node := jsonNode(t, sentryFile(ref), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, sentryFile(ref), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt doesn't match %s#%s", e.Subject.Operation, sentryFile(ref), e.SourcePointer) } // The excerpt is the description, JSON-encoded and maybe cut at 2,000 @@ -199,13 +201,13 @@ func TestSentryBasePathMoveIsNoChange(t *testing.T) { t.Errorf("unfiltered: %s %s", e.ChangeType, e.Subject.Operation) } ref := strings.TrimSuffix(strings.TrimPrefix(e.SourceURL, base+"/"), "/openapi-derefed.json") - if node := jsonNode(t, sentryFile(ref), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, sentryFile(ref), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: %s doesn't name the excerpt in %s", e.Subject.Operation, e.SourcePointer, sentryFile(ref)) } } // As published: every operation of 2.0.1 removed. - raw := Plugin{Adapter: rawSentry{}, Diff: sentryDiff} + raw := openapi.Plugin{Adapter: rawSentry{}, Diff: sentryDiff} var removed []string for _, e := range pairSentry(t, raw, [2]string{"2.0.1", "2.1.0"}) { if e.ChangeType == event.ChangeTypeBreaking && e.Subject.Kind == event.KindOperation { @@ -215,7 +217,7 @@ func TestSentryBasePathMoveIsNoChange(t *testing.T) { if len(removed) != 5 { t.Errorf("as published: removed %v, want the 5 operations of the saved 2.0.1", removed) } - raw.Keep = deprecationsOnly(sentryDiff) + raw.Keep = openapi.DeprecationsOnly(sentryDiff) events := pairSentry(t, raw, [2]string{"2.0.1", "2.1.0"}) if len(events) != 1 || events[0].Subject.Operation != "GET /api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/issues/" || !events[0].Breaking { t.Errorf("as published, removals of deprecated operations: %d events, want GET .../issues/ removed", len(events)) diff --git a/providers/sentry/node_surface_test.go b/providers/sentry/node_surface_test.go new file mode 100644 index 0000000..6d8fb66 --- /dev/null +++ b/providers/sentry/node_surface_test.go @@ -0,0 +1,16 @@ +package sentry + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// @sentry/node 10.0.0 stopped exporting systemErrorIntegration. 11.13.0 +// made the logger namespace a const object: its functions are still +// there, as members the reader doesn't follow. +func TestNodeSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: NodeSurface, Golden: [2]string{"9.47.2", "10.0.0"}, Want: []string{ + "removed_symbol systemErrorIntegration ", + }, Drop: [2]string{"11.12.0", "11.13.0"}}) +} diff --git a/providers/sentry/provider.go b/providers/sentry/provider.go new file mode 100644 index 0000000..485a90f --- /dev/null +++ b/providers/sentry/provider.go @@ -0,0 +1,54 @@ +// Package sentry is what patch-it reads for Sentry: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package sentry + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "sentry", Name: "Sentry", Category: plugin.CategoryMonitoring, Homepage: "https://sentry.io", + Sources: []plugin.Source{ + // No Hints: Sentry's changelog is product news, not keyed by operation. + // Operation deprecations only, most said in the description: see + // api.go. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API operations deprecated between releases of the spec, most of them in the operation's description", + URLs: []string{"https://github.com/getsentry/sentry/releases"}, + Plugin: openapi.Plugin{Adapter: Sentry{}, Diff: sentryDiff, Keep: sentryKeep}, + }, + changelog.SDK("python-changelog", PythonChangelog, "pypi:sentry-sdk"), + changelog.SDK("javascript-changelog", JavascriptChangelog, "npm:@sentry/node", "npm:@sentry/browser"), + changelog.SDK("go", Go, "go:github.com/getsentry/sentry-go"), + changelog.SDK("dotnet", Dotnet, "nuget:Sentry"), + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/getsentry/sentry-python"), + apisurface.NPM(NodeSurface, "https://github.com/getsentry/sentry-javascript"), + }, + }) +} + +// Sentry's SDKs: CHANGELOG.md, "## X.Y.Z", with "### Breaking Changes" / +// "### Removed" / "### Deprecations" sections or conventional-commit bullets +// ("feat(core)!: Remove `x`"); tagged X.Y.Z, except sentry-go's vX.Y.Z. +var ( + PythonChangelog = changelog.File{API: "sentry/python-changelog", Package: "sentry-sdk", Ecosystem: "pypi", Module: "sentry_sdk", + Repo: "getsentry/sentry-python", Path: "CHANGELOG.md"} + JavascriptChangelog = changelog.File{API: "sentry/javascript-changelog", Package: "@sentry/node", Ecosystem: "npm", + Repo: "getsentry/sentry-javascript", Path: "CHANGELOG.md"} + Go = changelog.File{API: "sentry/go", Package: "github.com/getsentry/sentry-go", Ecosystem: "go", Module: "sentry", + Repo: "getsentry/sentry-go", TagPrefix: "v", Path: "CHANGELOG.md"} + Dotnet = changelog.File{API: "sentry/dotnet", Package: "Sentry", Ecosystem: "nuget", + Repo: "getsentry/sentry-dotnet", Path: "CHANGELOG.md"} +) + +// The packages whose public API the apisurface sources read. +var ( + NodeSurface = apisurface.NPMPackage("sentry/node-surface", "@sentry/node") + PythonSurface = apisurface.Package{ID: "sentry/python-surface", Name: "sentry-sdk", Ecosystem: "pypi", Module: "sentry_sdk"} +) diff --git a/providers/sentry/python_surface_test.go b/providers/sentry/python_surface_test.go new file mode 100644 index 0000000..2c0e733 --- /dev/null +++ b/providers/sentry/python_surface_test.go @@ -0,0 +1,13 @@ +package sentry + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// sentry-sdk 2.74.0 removed utils.to_timestamp. 2.68.0 renamed a +// property setter's parameter: callers never pass it. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"2.73.0", "2.74.0"}, Want: []string{"removed_symbol utils.to_timestamp "}, Drop: [2]string{"2.67.1", "2.68.0"}}) +} diff --git a/providers/sentry/sdks_test.go b/providers/sentry/sdks_test.go new file mode 100644 index 0000000..201123b --- /dev/null +++ b/providers/sentry/sdks_test.go @@ -0,0 +1,16 @@ +package sentry + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +func TestSentrySDKs(t *testing.T) { + changelogtest.CheckSDKs(t, []changelogtest.SDKCase{ + {File: PythonChangelog, Release: "2.0.0", Prev: "1.45.1", Saved: "sentry-python-changelog-2.0.0-CHANGELOG.md", Dropped: "", Drop: "1.45.0"}, + {File: JavascriptChangelog, Release: "10.0.0", Prev: "9.47.2", Saved: "sentry-javascript-changelog-10.0.0-CHANGELOG.md", Dropped: "", Drop: "9.40.0"}, + {File: Go, Release: "0.31.0", Prev: "0.30.0", Saved: "sentry-go-0.31.0-CHANGELOG.md", Dropped: "", Drop: "0.30.0"}, + {File: Dotnet, Release: "4.0.0", Prev: "3.41.4", Saved: "sentry-dotnet-4.0.0-CHANGELOG.md", Dropped: "", Drop: "3.41.4"}, + }) +} diff --git a/providers/sentry/testdata/README.md b/providers/sentry/testdata/README.md new file mode 100644 index 0000000..8fb8f34 --- /dev/null +++ b/providers/sentry/testdata/README.md @@ -0,0 +1,50 @@ +# Sentry: saved copies and goldens + +Real copies of what Sentry publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/sentry -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `sentry-ead7f0cf.json`, `sentry-4650a66a.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/ead7f0cf9ccb8ac817105ac11bb94fe316fcb337/openapi-derefed.json (and `4650a66a859e015cccef2c171b115633321768e9`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "*This endpoint is DEPRECATED. We document it here for older SDKs" (`POST .../user-feedback/`, new in `4650a66a`) | +| `sentry-d64149d6.json`, `sentry-c2f638f6.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/d64149d65723484ca4d34c956ad017a66e1a4e07/openapi-derefed.json (and `c2f638f601baadcb055aec4ca3c2ba9f2654c087`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "**Deprecated**: This endpoint has been replaced with the [Organization Issues endpoint]" (`GET .../issues/`, new in `c2f638f6`) | +| `sentry-47231e61.json`, `sentry-1da1f31f.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/47231e6180b34f222ed462b1d0cb3cdb951cc4e7/openapi-derefed.json (and `1da1f31fac696201b1a7d20046fc199c8b1324b6`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "## Deprecated" then "🚧 Use [Fetch an Organization's Monitors](/api/monitors/fetch-an-organizations-monitors)" (`GET .../alert-rules/` and 9 more alert-rule operations, new in `1da1f31f`) | +| `sentry-0.223.0.json`, `sentry-0.224.0.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/0.223.0/openapi-derefed.json (and `0.224.0`) | 2026-11-19 | FSL-1.1-Apache-2.0 (getsentry/sentry-api-schema; the spec's own `info.license` says Apache 2.0) | `"deprecated": true` on `POST .../user-feedback/` and `GET .../issues/` (new in `0.224.0`, long after their descriptions said so) | +| `sentry-2.0.1.json`, `sentry-2.1.0.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/2.0.1/openapi-derefed.json (and `2.1.0`) | 2026-11-19 | FSL-1.1-Apache-2.0 (getsentry/sentry-api-schema; the spec's own `info.license` says Apache 2.0) | `"url": "https://{region}.sentry.io"` and `"/api/0/organizations/": {` (in `2.0.1`), `"url": "https://{region}.sentry.io/api/0"` and `"/organizations/": {` (in `2.1.0`): the drop test | +| `sentry-94bc6e59.json`, `sentry-d15557ff.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/94bc6e593eaf8a3800341abd429d2949895926fd/openapi-derefed.json (and `d15557ff7472748887043ab8a72687b20214a9bd`) | 2026-11-19 | Apache 2.0 (the spec's own `info.license`; getsentry/sentry-api-schema had no license file before 2026-02-10) | "**Eventsv2 Deprecation Note**: Users who may be using the `eventsv2` endpoint should update their requests to the `events` endpoint" (`GET .../events/`, new in `d15557ff`; not a deprecation of it) | +| `sentry-e8ec23b4.json`, `sentry-1ef7f21a.json` | https://raw.githubusercontent.com/getsentry/sentry-api-schema/e8ec23b4c9601dea2d51205983ec1d7b89550b85/openapi-derefed.json (and `1ef7f21a0501fae9490d69e3ae29f0d5acbfb61c`) | 2026-11-19 | FSL-1.1-Apache-2.0 (getsentry/sentry-api-schema; the spec's own `info.license` says Apache 2.0) | "a brief description, examples, and deprecation details." (`GET .../trace-items/attributes/`, new in `1ef7f21a`; not a deprecation) | + +The Sentry copies keep `openapi`, `info`, `servers` and the path items involved, whole, in their original order except that `servers` comes before `paths`, every line copied unchanged (bar the trailing comma after a path item that's now last); `components` and `tags` left out. Each pair gives the same events as the full files, with the filter and with the variants the tests use (flag only, "deprecat" anywhere). The tests serve them as GitHub would, with each commit's date and each tag's release date. + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/sentry-api-releases.json` | `https://api.github.com/repos/getsentry/sentry/releases?per_page=100&page=1` | the 19 `api@` releases; `tag_name`, `draft`, `prerelease`, `published_at`, asset names | +| `versions/sentry-schema-releases.json` | `https://api.github.com/repos/getsentry/sentry-api-schema/releases` (pages 1-4) | 2.3.2 and 2.4.0; same fields | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/sentry-sdk/`: `sentry_sdk-2.67.1-py3-none-any.trimmed.whl`, `sentry_sdk-2.68.0-py3-none-any.trimmed.whl`, `sentry_sdk-2.73.0-py3-none-any.trimmed.whl`, `sentry_sdk-2.74.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/34/e2/70692eba662037cddf93391cbbf98297159f3038612e9b9a8129e16feb7a/sentry_sdk-2.67.1-py3-none-any.whl; https://files.pythonhosted.org/packages/7d/9b/e2421d08956d0bc4691d995393d835e563886bff499d8fb10fdefae85a8d/sentry_sdk-2.68.0-py3-none-any.whl; https://files.pythonhosted.org/packages/b2/88/cabf98d017d7b940720e514e5f8ee02e3e6f7495caf93c30735a38387ec4/sentry_sdk-2.73.0-py3-none-any.whl; https://files.pythonhosted.org/packages/55/b1/736d4b4b308694b0071844a533522ac06669ad61751687b94edfbf863f17/sentry_sdk-2.74.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `sentry_sdk/__init__.py`, `sentry_sdk/traces.py`, `sentry_sdk/utils.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/sentry-sdk/`: `pypi-sentry-sdk-excerpt.json` and `pypi-sentry-sdk-2.67.1.json`, `pypi-sentry-sdk-2.68.0.json`, `pypi-sentry-sdk-2.73.0.json`, `pypi-sentry-sdk-2.74.0.json` | https://pypi.org/pypi/sentry-sdk/json, https://pypi.org/pypi/sentry-sdk/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/sentry-node/`: `node-10.0.0.trimmed.tgz`, `node-11.12.0.trimmed.tgz`, `node-11.13.0.trimmed.tgz`, `node-9.47.2.trimmed.tgz` | https://registry.npmjs.org/@sentry/node/-/node-10.0.0.tgz; https://registry.npmjs.org/@sentry/node/-/node-11.12.0.tgz; https://registry.npmjs.org/@sentry/node/-/node-11.13.0.tgz; https://registry.npmjs.org/@sentry/node/-/node-9.47.2.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `build/types/index.d.ts`, `build/types/logs/exports.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/sentry-node/`: `npm-sentry-node-excerpt.json` and `npm-sentry-node-10.0.0.json`, `npm-sentry-node-11.12.0.json`, `npm-sentry-node-11.13.0.json`, `npm-sentry-node-9.47.2.json` | https://registry.npmjs.org/@sentry%2Fnode, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | + +## SDK changelogs + +Read with `Plugin{File: ...}` (`kinds/changelog/sdks.go`); `golden/-.json` is what each stores from its release (`changelogtest.CheckSDKs`), the pair from the release before it on the registry (or among the repo's tags). Every file is the changelog at the release's tag, saved with `curl`, **trimmed** to two releases' sections, each kept whole and unchanged: the release the golden pins and one more release from the same file whose notes remove nothing the reader can name (the drop test). Only the pinned release's own section is read for the golden, so the trimmed copy gives the same events as the whole file (checked when each copy was made). + +| File | URL | Tag commit | Saved | License; trimming | Quote | +|---|---|---|---|---|---| +| `sentry-python-changelog-2.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-python/2.0.0/CHANGELOG.md | `38bbb8d` | 2026-11-20 | MIT (sentry-python); trimmed to the sections of 2.0.0 (the golden) and 1.45.0 (the drop test), each unchanged | "Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead." | +| `sentry-javascript-changelog-10.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-javascript/10.0.0/CHANGELOG.md | `19f754a` | 2026-11-20 | MIT (sentry-javascript); trimmed to the sections of 10.0.0 (the golden) and 9.40.0 (the drop test), each unchanged | "feat(core)!: Remove `BaseClient` ([#17071](https://github.com/getsentry/sentry-javascript/pull/17071))" | +| `sentry-go-0.31.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-go/v0.31.0/CHANGELOG.md | `17ceb6c` | 2026-11-20 | MIT (sentry-go); trimmed to the sections of 0.31.0 (the golden) and 0.30.0 (the drop test), each unchanged | "Remove `Segment` field from the `User` struct. This field is no longer used in the Sentry product. ([#928](https://gi…" | +| `sentry-dotnet-4.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/getsentry/sentry-dotnet/4.0.0/CHANGELOG.md | `d4d8af5` | 2026-11-20 | MIT (sentry-dotnet); trimmed to the sections of 4.0.0 (the golden) and 3.41.4 (the drop test), each unchanged | "`ITransaction` has been renamed to `ITransactionTracer`. You will need to update any references to these interfaces i…" | diff --git a/plugins/changelog/testdata/golden/sentry-dotnet.json b/providers/sentry/testdata/golden/sentry-dotnet.json similarity index 100% rename from plugins/changelog/testdata/golden/sentry-dotnet.json rename to providers/sentry/testdata/golden/sentry-dotnet.json diff --git a/plugins/changelog/testdata/golden/sentry-go.json b/providers/sentry/testdata/golden/sentry-go.json similarity index 100% rename from plugins/changelog/testdata/golden/sentry-go.json rename to providers/sentry/testdata/golden/sentry-go.json diff --git a/plugins/changelog/testdata/golden/sentry-javascript-changelog.json b/providers/sentry/testdata/golden/sentry-javascript-changelog.json similarity index 100% rename from plugins/changelog/testdata/golden/sentry-javascript-changelog.json rename to providers/sentry/testdata/golden/sentry-javascript-changelog.json diff --git a/plugins/apisurface/testdata/golden/sentry-node-surface.json b/providers/sentry/testdata/golden/sentry-node-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/sentry-node-surface.json rename to providers/sentry/testdata/golden/sentry-node-surface.json diff --git a/plugins/changelog/testdata/golden/sentry-python-changelog.json b/providers/sentry/testdata/golden/sentry-python-changelog.json similarity index 100% rename from plugins/changelog/testdata/golden/sentry-python-changelog.json rename to providers/sentry/testdata/golden/sentry-python-changelog.json diff --git a/plugins/apisurface/testdata/golden/sentry-python-surface.json b/providers/sentry/testdata/golden/sentry-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/sentry-python-surface.json rename to providers/sentry/testdata/golden/sentry-python-surface.json diff --git a/plugins/openapi/testdata/golden/sentry.json b/providers/sentry/testdata/golden/sentry.json similarity index 100% rename from plugins/openapi/testdata/golden/sentry.json rename to providers/sentry/testdata/golden/sentry.json diff --git a/plugins/apisurface/testdata/npm/sentry-node/node-10.0.0.trimmed.tgz b/providers/sentry/testdata/npm/sentry-node/node-10.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/node-10.0.0.trimmed.tgz rename to providers/sentry/testdata/npm/sentry-node/node-10.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/sentry-node/node-11.12.0.trimmed.tgz b/providers/sentry/testdata/npm/sentry-node/node-11.12.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/node-11.12.0.trimmed.tgz rename to providers/sentry/testdata/npm/sentry-node/node-11.12.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/sentry-node/node-11.13.0.trimmed.tgz b/providers/sentry/testdata/npm/sentry-node/node-11.13.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/node-11.13.0.trimmed.tgz rename to providers/sentry/testdata/npm/sentry-node/node-11.13.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/sentry-node/node-9.47.2.trimmed.tgz b/providers/sentry/testdata/npm/sentry-node/node-9.47.2.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/node-9.47.2.trimmed.tgz rename to providers/sentry/testdata/npm/sentry-node/node-9.47.2.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-10.0.0.json b/providers/sentry/testdata/npm/sentry-node/npm-sentry-node-10.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-10.0.0.json rename to providers/sentry/testdata/npm/sentry-node/npm-sentry-node-10.0.0.json diff --git a/plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-11.12.0.json b/providers/sentry/testdata/npm/sentry-node/npm-sentry-node-11.12.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-11.12.0.json rename to providers/sentry/testdata/npm/sentry-node/npm-sentry-node-11.12.0.json diff --git a/plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-11.13.0.json b/providers/sentry/testdata/npm/sentry-node/npm-sentry-node-11.13.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-11.13.0.json rename to providers/sentry/testdata/npm/sentry-node/npm-sentry-node-11.13.0.json diff --git a/plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-9.47.2.json b/providers/sentry/testdata/npm/sentry-node/npm-sentry-node-9.47.2.json similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-9.47.2.json rename to providers/sentry/testdata/npm/sentry-node/npm-sentry-node-9.47.2.json diff --git a/plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-excerpt.json b/providers/sentry/testdata/npm/sentry-node/npm-sentry-node-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/sentry-node/npm-sentry-node-excerpt.json rename to providers/sentry/testdata/npm/sentry-node/npm-sentry-node-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.67.1.json b/providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.67.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.67.1.json rename to providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.67.1.json diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.68.0.json b/providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.68.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.68.0.json rename to providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.68.0.json diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.73.0.json b/providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.73.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.73.0.json rename to providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.73.0.json diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.74.0.json b/providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.74.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.74.0.json rename to providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-2.74.0.json diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-excerpt.json b/providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/pypi-sentry-sdk-excerpt.json rename to providers/sentry/testdata/pypi/sentry-sdk/pypi-sentry-sdk-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.67.1-py3-none-any.trimmed.whl b/providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.67.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.67.1-py3-none-any.trimmed.whl rename to providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.67.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.68.0-py3-none-any.trimmed.whl b/providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.68.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.68.0-py3-none-any.trimmed.whl rename to providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.68.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.73.0-py3-none-any.trimmed.whl b/providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.73.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.73.0-py3-none-any.trimmed.whl rename to providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.73.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.74.0-py3-none-any.trimmed.whl b/providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.74.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/sentry-sdk/sentry_sdk-2.74.0-py3-none-any.trimmed.whl rename to providers/sentry/testdata/pypi/sentry-sdk/sentry_sdk-2.74.0-py3-none-any.trimmed.whl diff --git a/plugins/openapi/testdata/sentry-0.223.0.json b/providers/sentry/testdata/sentry-0.223.0.json similarity index 100% rename from plugins/openapi/testdata/sentry-0.223.0.json rename to providers/sentry/testdata/sentry-0.223.0.json diff --git a/plugins/openapi/testdata/sentry-0.224.0.json b/providers/sentry/testdata/sentry-0.224.0.json similarity index 100% rename from plugins/openapi/testdata/sentry-0.224.0.json rename to providers/sentry/testdata/sentry-0.224.0.json diff --git a/plugins/openapi/testdata/sentry-1da1f31f.json b/providers/sentry/testdata/sentry-1da1f31f.json similarity index 100% rename from plugins/openapi/testdata/sentry-1da1f31f.json rename to providers/sentry/testdata/sentry-1da1f31f.json diff --git a/plugins/openapi/testdata/sentry-1ef7f21a.json b/providers/sentry/testdata/sentry-1ef7f21a.json similarity index 100% rename from plugins/openapi/testdata/sentry-1ef7f21a.json rename to providers/sentry/testdata/sentry-1ef7f21a.json diff --git a/plugins/openapi/testdata/sentry-2.0.1.json b/providers/sentry/testdata/sentry-2.0.1.json similarity index 100% rename from plugins/openapi/testdata/sentry-2.0.1.json rename to providers/sentry/testdata/sentry-2.0.1.json diff --git a/plugins/openapi/testdata/sentry-2.1.0.json b/providers/sentry/testdata/sentry-2.1.0.json similarity index 100% rename from plugins/openapi/testdata/sentry-2.1.0.json rename to providers/sentry/testdata/sentry-2.1.0.json diff --git a/plugins/openapi/testdata/sentry-4650a66a.json b/providers/sentry/testdata/sentry-4650a66a.json similarity index 100% rename from plugins/openapi/testdata/sentry-4650a66a.json rename to providers/sentry/testdata/sentry-4650a66a.json diff --git a/plugins/openapi/testdata/sentry-47231e61.json b/providers/sentry/testdata/sentry-47231e61.json similarity index 100% rename from plugins/openapi/testdata/sentry-47231e61.json rename to providers/sentry/testdata/sentry-47231e61.json diff --git a/plugins/openapi/testdata/sentry-94bc6e59.json b/providers/sentry/testdata/sentry-94bc6e59.json similarity index 100% rename from plugins/openapi/testdata/sentry-94bc6e59.json rename to providers/sentry/testdata/sentry-94bc6e59.json diff --git a/plugins/openapi/testdata/sentry-c2f638f6.json b/providers/sentry/testdata/sentry-c2f638f6.json similarity index 100% rename from plugins/openapi/testdata/sentry-c2f638f6.json rename to providers/sentry/testdata/sentry-c2f638f6.json diff --git a/plugins/openapi/testdata/sentry-d15557ff.json b/providers/sentry/testdata/sentry-d15557ff.json similarity index 100% rename from plugins/openapi/testdata/sentry-d15557ff.json rename to providers/sentry/testdata/sentry-d15557ff.json diff --git a/plugins/openapi/testdata/sentry-d64149d6.json b/providers/sentry/testdata/sentry-d64149d6.json similarity index 100% rename from plugins/openapi/testdata/sentry-d64149d6.json rename to providers/sentry/testdata/sentry-d64149d6.json diff --git a/plugins/changelog/testdata/sentry-dotnet-4.0.0-CHANGELOG.md b/providers/sentry/testdata/sentry-dotnet-4.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/sentry-dotnet-4.0.0-CHANGELOG.md rename to providers/sentry/testdata/sentry-dotnet-4.0.0-CHANGELOG.md diff --git a/plugins/openapi/testdata/sentry-e8ec23b4.json b/providers/sentry/testdata/sentry-e8ec23b4.json similarity index 100% rename from plugins/openapi/testdata/sentry-e8ec23b4.json rename to providers/sentry/testdata/sentry-e8ec23b4.json diff --git a/plugins/openapi/testdata/sentry-ead7f0cf.json b/providers/sentry/testdata/sentry-ead7f0cf.json similarity index 100% rename from plugins/openapi/testdata/sentry-ead7f0cf.json rename to providers/sentry/testdata/sentry-ead7f0cf.json diff --git a/plugins/changelog/testdata/sentry-go-0.31.0-CHANGELOG.md b/providers/sentry/testdata/sentry-go-0.31.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/sentry-go-0.31.0-CHANGELOG.md rename to providers/sentry/testdata/sentry-go-0.31.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/sentry-javascript-changelog-10.0.0-CHANGELOG.md b/providers/sentry/testdata/sentry-javascript-changelog-10.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/sentry-javascript-changelog-10.0.0-CHANGELOG.md rename to providers/sentry/testdata/sentry-javascript-changelog-10.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/sentry-python-changelog-2.0.0-CHANGELOG.md b/providers/sentry/testdata/sentry-python-changelog-2.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/sentry-python-changelog-2.0.0-CHANGELOG.md rename to providers/sentry/testdata/sentry-python-changelog-2.0.0-CHANGELOG.md diff --git a/plugins/openapi/adapter/testdata/versions/sentry-api-releases.json b/providers/sentry/testdata/versions/sentry-api-releases.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/sentry-api-releases.json rename to providers/sentry/testdata/versions/sentry-api-releases.json diff --git a/plugins/openapi/adapter/testdata/versions/sentry-schema-releases.json b/providers/sentry/testdata/versions/sentry-schema-releases.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/sentry-schema-releases.json rename to providers/sentry/testdata/versions/sentry-schema-releases.json diff --git a/providers/stripe-node-surface.md b/providers/stripe-node-surface.md deleted file mode 100644 index e231f2d..0000000 --- a/providers/stripe-node-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# Stripe Node.js SDK (`stripe/node-surface`) - -## What it watches - -The public API of the `stripe` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install stripe@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md ("⚠️" on breaking bullets); the API spec (`stripe/api`). -- **Quote:** `namespace ErrorType` (`esm/stripe.esm.node.d.ts` line 482) at 22.6.2, gone at 23.0.0. - -## How the provider announces changes - -- Each major pins a new Stripe API version and removes what that version removed. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `stripe.Stripe.constructEventWithoutVerification`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- The `Stripe` namespace's thousands of resource types are types inside a namespace: not read (the API spec covers the fields). diff --git a/providers/stripe-python-surface.md b/providers/stripe-python-surface.md deleted file mode 100644 index 7d0af3e..0000000 --- a/providers/stripe-python-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# Stripe Python SDK (`stripe/python-surface`) - -## What it watches - -The public API of the `stripe` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install stripe==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md (prose per release, "⚠️" on breaking bullets); the API spec (`stripe/api`: the HTTP API, not Python names). -- **Quote:** `def request( self, method: Literal["get", "post", "delete"], url: str, params: Optional[Dict[str, Any]] = None, *, base_address: BaseAddress = "api", ) -> "StripeObject"` (`StripeObject`, `stripe/_stripe_object.py` line 452) at 15.6.2, gone at 16.0.0. - -## How the provider announces changes - -- Each major pins a new Stripe API version and removes what that version removed; minors add. `stripe/__init__.py` hands out most names lazily (`__getattr__`), so removals from the top-level namespace are notes, not events. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `stripe/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. -- Most top-level names are lazy (`__getattr__`): a class removed from `stripe` itself is only a note. diff --git a/providers/stripe-sdks.md b/providers/stripe-sdks.md deleted file mode 100644 index 68fb78c..0000000 --- a/providers/stripe-sdks.md +++ /dev/null @@ -1,42 +0,0 @@ -# Stripe SDKs (`stripe/python`, `stripe/node`, `stripe/go`, `stripe/java`, `stripe/ruby`, `stripe/dotnet`, `stripe/php`) - -## What it watches - -Classes, methods, properties, constants and resources removed or renamed in each release of Stripe's seven official server SDKs, read from that release's section of the SDK's own `CHANGELOG.md`. One `package_release` event per bullet that names what it removes plainly. Stripe's API itself is a separate source (`stripe/api`, kind `openapi`). - -Kind: `changelog` (`plugins/changelog`, `sdks.go`). - -| Source | Package | Releases listed from | Tag | -|---|---|---|---| -| `stripe/python` | `pypi:stripe` | PyPI | `vX.Y.Z` | -| `stripe/node` | `npm:stripe` | npm | `vX.Y.Z` | -| `stripe/go` | `go:github.com/stripe/stripe-go/v87` (events name the module at each release's major: `…/v73`) | the repo's `vX.Y.Z` tags | `vX.Y.Z` | -| `stripe/java` | `maven:com.stripe:stripe-java` | the repo's tags | `vX.Y.Z` | -| `stripe/ruby` | `rubygems:stripe` | the repo's tags | `vX.Y.Z` | -| `stripe/dotnet` | `nuget:Stripe.net` | the repo's tags | `vX.Y.Z` | -| `stripe/php` | `packagist:stripe/stripe-php` | the repo's tags | `vX.Y.Z` | - -## Why this source - -- **Source:** each SDK's `CHANGELOG.md`, read raw at the release's tag, e.g. https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md (checked on 2026-11-20; `https://raw.githubusercontent.com/stripe/stripe-python/v4.0.0/CHANGELOG.md` for the golden). -- **Why this one:** it's Stripe's own record of each release, and every breaking bullet is marked `⚠️`, in all seven SDKs. At a tag it never changes, so the URL is its own citation. -- **Alternatives considered:** GitHub release notes (the same text, release by release, editable afterwards); the SDKs' wiki migration guides (one page per major, prose); Stripe's API changelog (about the API, not the SDK's names); diffing the published packages (the `apisurface` kind, a separate source when it's built). -- **Quote:** "⚠️ Removed the deprecated `Charge.refund` method. Prefer [Refund.create](https://stripe.com/docs/api/refunds/create)" (stripe-python 4.0.0). - -## How the provider announces changes - -Stripe ships a new major of every SDK when it pins a new API version (twice a year or so), and marks each breaking bullet `⚠️`. Older changelogs head releases `## X.Y.Z - date`, newer ones `## X.Y.Z - date`; both are read. - -A release that changes the API version the SDK pins says so in its section, in the same words in all seven SDKs (checked 2026-11-20): "This release changes the pinned API version to `2026-11-18.endive`." A few say they keep it: "This release **doesn't** change the pinned API version; it still uses `2026-05-27.dahlia`." (Go, Java, .NET), "…**does not** change the pinned API version. It's still `2026-06-24.dahlia`." (PHP), "This release uses the same pinned API version to `2026-03-25.dahlia` as the last major release." (Node). - -## What the plugin reads and ignores - -- Reads the release's section only. A bullet counts when it's marked `⚠️` or sits under a breaking or deprecation heading, and its first sentence is a plain template over code spans: `Remove X`, `Remove X from Y`, `Rename X to Y`, `X has been removed`, `Deprecated X in favor of Y`. The pull-request link it starts with is read past. -- Drops (and logs) everything else: type changes ("Change type of …"), nullable fields, pinned API versions, dropped language versions, bullets that list names inside prose or parentheses, and "Generated changes from …" roll-ups. -- **What a release pins** (`MapsTo`, `pins.go`): while listing the releases, it reads the changelog at the newest release's tag (or the one before, when that tag isn't pushed yet) and sets each release's `MapsTo` to `stripe/api` at the API version its own section states (the same id `stripe/api` lists its versions by, `providers/stripe.md`), in one of the sentences above, exactly as written (`2026-11-18.endive`). A release whose section doesn't say pins nothing here, even though it keeps the release before's; two different versions in one section are none. Older wordings without "pinned" ("Major version release for API version 2022-08-01", "Move to API version …") aren't read. - -## Known gaps - -- Stripe's big generated roll-ups ("⚠️ Generated changes from #…") list their removals in nested bullets the reader doesn't open: those releases give no event. -- A release whose tag or section is missing is skipped as nothing to read, never guessed. -- Only releases that state their pin have one: most minors and patches don't say, so a release between two pin changes has none. diff --git a/providers/stripe.md b/providers/stripe.md deleted file mode 100644 index 6004544..0000000 --- a/providers/stripe.md +++ /dev/null @@ -1,36 +0,0 @@ -# Stripe (`stripe/api`) - -## What it watches - -Stripe's REST API, API version by API version (`2026-10-28.endive` → `2026-11-18.endive`): endpoints, parameters, fields, schemas and enum values that are removed, renamed, retyped or added between two versions of Stripe's own OpenAPI spec. Breaking events carry Stripe's own explanation from its API changelog as the migration hint when the changelog has one. - -Kind: `openapi` (`plugins/openapi`), with `adapter.Stripe` and the changelog hint source in `hint/`. - -## Why this source - -- **Source:** [github.com/stripe/openapi](https://github.com/stripe/openapi), the file `latest/openapi.spec3.json` pinned to a release tag (`https://raw.githubusercontent.com/stripe/openapi//latest/openapi.spec3.json`); the API versions from the releases' notes, `GET https://api.github.com/repos/stripe/openapi/releases` (checked 2026-11-20). Migration hints from [docs.stripe.com/changelog](https://docs.stripe.com/changelog), read as markdown (each page's URL plus `.md`). Checked on 2026-10-13. -- **Why this one:** it's Stripe's own machine-readable description of the API, maintained by Stripe and published on every release. Two specs can be diffed exactly, with no guessing: a removed field is a removed field. Stripe recommends `latest/openapi.spec3.json` (v1 and v2 endpoints). -- **Alternatives considered:** the API changelog alone (human-written, one entry per change; precise about *why* but not exhaustive at the field level, so it supplies hints, not events); `openapi/spec3.json` (legacy, v1 only); the `*.sdk.*` variants (include internal annotations and pre-release features); `preview/` (public-preview endpoints, not stable). -- **Quote:** "Removes the `charges` attribute from the `PaymentIntent` object" ([changelog, 2022-11-15](https://docs.stripe.com/changelog/2022-11-15), listed as Breaking). - -## How the provider announces changes - -- Versions are named `YYYY-MM-DD.` (`2026-09-30.endive`). Major releases include backward-incompatible changes; monthly releases only backward-compatible ones. -- **Breaking changes are opt-in.** An account has a default API version, and a request can override it with the `Stripe-Version` header; old versions keep working. A breaking change reaches code when someone upgrades the account version or the SDK. Modern SDKs pin the API version they were released with (stripe-node 12+, stripe-python 6+, stripe-ruby 9+, stripe-php 11+; Java, Go and .NET always did). -- The spec repo tags releases (`vNNNN`) several times a day, many per API version. Since v2191 (2026-03-11) each release's notes name the API version its SDK spec carries, in a table: `| openapi/spec3.sdk.{json,yaml} | 2026-11-18.endive |`. That is the version Stripe's SDKs pin ("This release changes the pinned API version to `2026-11-18.endive`"). -- **Versions are API versions.** The listed versions are those named in the notes, oldest first, each read at the newest release that names it and dated by the first one. The SDK changelog sources' `MapsTo` pins (`providers/stripe-sdks.md`) name the same ids, so a feed query on an SDK's versions finds this source's changes between the two API versions. A pair is one API version to the next. The event's `version` and `previous_version` are those ids, which are also the spec's `info.version`. - -## What the plugin reads and ignores - -- Reads: the whole spec at each API version's newest release, diffed against the version before's (`core/diff/`, `core/normalize/`). `$ref`s are never followed: a change inside a shared schema is reported once, on that schema, not once per endpoint that uses it. -- Hints: for each breaking event, the changelog entry for that version whose "REST API" table names the same parameter and operation; the entry's "What's new" text and link become `migration_hint`. An entry describing an addition never explains a removal, and the reverse. -- `latest/openapi.spec3.json` can lag a version bump by several releases (at v2602 the notes name `2026-11-18.endive` while the file still declares `2026-10-28.endive`). A spec that doesn't declare the listed version is an error, never read as that version. When a later release's file catches up, it also names the version in its notes, so the version is read there on a later run. - -## Known gaps - -- Releases before v2191 (2026-03-11) don't name their API version, so versions older than `2026-02-25.clover` aren't listed: naming them would mean reading every old spec or guessing. -- While a version is the newest, the release it's read at moves as Stripe publishes more of it. The pair into it is compared once, at the release current then. -- If Stripe ever moved its SDK spec on to the next version before `latest/openapi.spec3.json` had declared the current one, that version's release would stop moving and it would fail to read on every run, loudly. It hasn't happened: at each listed version's release (v2203 … v2600) the file declares that version (checked 2026-11-21); v2602 is the lag described above. -- Changes the spec doesn't express (behavior changes, webhook payload semantics) are only in the changelog, which isn't read for events. -- Enum value removals and some tax-related changes have no parameter row in the changelog, so those events keep the normalizer's one-line hint. -- Webhooks use the version set when the endpoint was created; the events don't say which webhook endpoints are affected. diff --git a/providers/stripe/README.md b/providers/stripe/README.md new file mode 100644 index 0000000..2e2b9d4 --- /dev/null +++ b/providers/stripe/README.md @@ -0,0 +1,158 @@ +# Stripe + +Every source patch-it reads for Stripe, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Stripe (`stripe/api`) + +### What it watches + +Stripe's REST API, API version by API version (`2026-10-28.endive` → `2026-11-18.endive`): endpoints, parameters, fields, schemas and enum values that are removed, renamed, retyped or added between two versions of Stripe's own OpenAPI spec. Breaking events carry Stripe's own explanation from its API changelog as the migration hint when the changelog has one. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `Stripe` ([`api.go`](api.go)) and the changelog hint source in `core/hint`. + +### Why this source + +- **Source:** [github.com/stripe/openapi](https://github.com/stripe/openapi), the file `latest/openapi.spec3.json` pinned to a release tag (`https://raw.githubusercontent.com/stripe/openapi//latest/openapi.spec3.json`); the API versions from the releases' notes, `GET https://api.github.com/repos/stripe/openapi/releases` (checked 2026-11-20). Migration hints from [docs.stripe.com/changelog](https://docs.stripe.com/changelog), read as markdown (each page's URL plus `.md`). Checked on 2026-10-13. +- **Why this one:** it's Stripe's own machine-readable description of the API, maintained by Stripe and published on every release. Two specs can be diffed exactly, with no guessing: a removed field is a removed field. Stripe recommends `latest/openapi.spec3.json` (v1 and v2 endpoints). +- **Alternatives considered:** the API changelog alone (human-written, one entry per change; precise about *why* but not exhaustive at the field level, so it supplies hints, not events); `openapi/spec3.json` (legacy, v1 only); the `*.sdk.*` variants (include internal annotations and pre-release features); `preview/` (public-preview endpoints, not stable). +- **Quote:** "Removes the `charges` attribute from the `PaymentIntent` object" ([changelog, 2022-11-15](https://docs.stripe.com/changelog/2022-11-15), listed as Breaking). + +### How the provider announces changes + +- Versions are named `YYYY-MM-DD.` (`2026-09-30.endive`). Major releases include backward-incompatible changes; monthly releases only backward-compatible ones. +- **Breaking changes are opt-in.** An account has a default API version, and a request can override it with the `Stripe-Version` header; old versions keep working. A breaking change reaches code when someone upgrades the account version or the SDK. Modern SDKs pin the API version they were released with (stripe-node 12+, stripe-python 6+, stripe-ruby 9+, stripe-php 11+; Java, Go and .NET always did). +- The spec repo tags releases (`vNNNN`) several times a day, many per API version. Since v2191 (2026-03-11) each release's notes name the API version its SDK spec carries, in a table: `| openapi/spec3.sdk.{json,yaml} | 2026-11-18.endive |`. That is the version Stripe's SDKs pin ("This release changes the pinned API version to `2026-11-18.endive`"). +- **Versions are API versions.** The listed versions are those named in the notes, oldest first, each read at the newest release that names it and dated by the first one. The SDK changelog sources' `MapsTo` pins (below) name the same ids, so a feed query on an SDK's versions finds this source's changes between the two API versions. A pair is one API version to the next. The event's `version` and `previous_version` are those ids, which are also the spec's `info.version`. + +### What the plugin reads and ignores + +- Reads: the whole spec at each API version's newest release, diffed against the version before's (`core/diff/`, `core/normalize/`). `$ref`s are never followed: a change inside a shared schema is reported once, on that schema, not once per endpoint that uses it. +- Hints: for each breaking event, the changelog entry for that version whose "REST API" table names the same parameter and operation; the entry's "What's new" text and link become `migration_hint`. An entry describing an addition never explains a removal, and the reverse. +- `latest/openapi.spec3.json` can lag a version bump by several releases (at v2602 the notes name `2026-11-18.endive` while the file still declares `2026-10-28.endive`). A spec that doesn't declare the listed version is an error, never read as that version. When a later release's file catches up, it also names the version in its notes, so the version is read there on a later run. + +### Known gaps + +- Releases before v2191 (2026-03-11) don't name their API version, so versions older than `2026-02-25.clover` aren't listed: naming them would mean reading every old spec or guessing. +- While a version is the newest, the release it's read at moves as Stripe publishes more of it. The pair into it is compared once, at the release current then. +- If Stripe ever moved its SDK spec on to the next version before `latest/openapi.spec3.json` had declared the current one, that version's release would stop moving and it would fail to read on every run, loudly. It hasn't happened: at each listed version's release (v2203 … v2600) the file declares that version (checked 2026-11-21); v2602 is the lag described above. +- Changes the spec doesn't express (behavior changes, webhook payload semantics) are only in the changelog, which isn't read for events. +- Enum value removals and some tax-related changes have no parameter row in the changelog, so those events keep the normalizer's one-line hint. +- Webhooks use the version set when the endpoint was created; the events don't say which webhook endpoints are affected. + +## Stripe Node.js SDK (`stripe/node-surface`) + +### What it watches + +The public API of the `stripe` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install stripe@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md ("⚠️" on breaking bullets); the API spec (`stripe/api`). +- **Quote:** `namespace ErrorType` (`esm/stripe.esm.node.d.ts` line 482) at 22.6.2, gone at 23.0.0. + +### How the provider announces changes + +- Each major pins a new Stripe API version and removes what that version removed. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `stripe.Stripe.constructEventWithoutVerification`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- The `Stripe` namespace's thousands of resource types are types inside a namespace: not read (the API spec covers the fields). + +## Stripe Python SDK (`stripe/python-surface`) + +### What it watches + +The public API of the `stripe` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install stripe==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md (prose per release, "⚠️" on breaking bullets); the API spec (`stripe/api`: the HTTP API, not Python names). +- **Quote:** `def request( self, method: Literal["get", "post", "delete"], url: str, params: Optional[Dict[str, Any]] = None, *, base_address: BaseAddress = "api", ) -> "StripeObject"` (`StripeObject`, `stripe/_stripe_object.py` line 452) at 15.6.2, gone at 16.0.0. + +### How the provider announces changes + +- Each major pins a new Stripe API version and removes what that version removed; minors add. `stripe/__init__.py` hands out most names lazily (`__getattr__`), so removals from the top-level namespace are notes, not events. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `stripe/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. +- Most top-level names are lazy (`__getattr__`): a class removed from `stripe` itself is only a note. + +## Stripe SDKs (`stripe/python`, `stripe/node`, `stripe/go`, `stripe/java`, `stripe/ruby`, `stripe/dotnet`, `stripe/php`) + +### What it watches + +Classes, methods, properties, constants and resources removed or renamed in each release of Stripe's seven official server SDKs, read from that release's section of the SDK's own `CHANGELOG.md`. One `package_release` event per bullet that names what it removes plainly. Stripe's API itself is a separate source (`stripe/api`, kind `openapi`). + +Kind: `changelog` (`kinds/changelog`, `sdks.go`). + +| Source | Package | Releases listed from | Tag | +|---|---|---|---| +| `stripe/python` | `pypi:stripe` | PyPI | `vX.Y.Z` | +| `stripe/node` | `npm:stripe` | npm | `vX.Y.Z` | +| `stripe/go` | `go:github.com/stripe/stripe-go/v87` (events name the module at each release's major: `…/v73`) | the repo's `vX.Y.Z` tags | `vX.Y.Z` | +| `stripe/java` | `maven:com.stripe:stripe-java` | the repo's tags | `vX.Y.Z` | +| `stripe/ruby` | `rubygems:stripe` | the repo's tags | `vX.Y.Z` | +| `stripe/dotnet` | `nuget:Stripe.net` | the repo's tags | `vX.Y.Z` | +| `stripe/php` | `packagist:stripe/stripe-php` | the repo's tags | `vX.Y.Z` | + +### Why this source + +- **Source:** each SDK's `CHANGELOG.md`, read raw at the release's tag, e.g. https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md (checked on 2026-11-20; `https://raw.githubusercontent.com/stripe/stripe-python/v4.0.0/CHANGELOG.md` for the golden). +- **Why this one:** it's Stripe's own record of each release, and every breaking bullet is marked `⚠️`, in all seven SDKs. At a tag it never changes, so the URL is its own citation. +- **Alternatives considered:** GitHub release notes (the same text, release by release, editable afterwards); the SDKs' wiki migration guides (one page per major, prose); Stripe's API changelog (about the API, not the SDK's names); diffing the published packages (the `apisurface` kind, a separate source when it's built). +- **Quote:** "⚠️ Removed the deprecated `Charge.refund` method. Prefer [Refund.create](https://stripe.com/docs/api/refunds/create)" (stripe-python 4.0.0). + +### How the provider announces changes + +Stripe ships a new major of every SDK when it pins a new API version (twice a year or so), and marks each breaking bullet `⚠️`. Older changelogs head releases `## X.Y.Z - date`, newer ones `## X.Y.Z - date`; both are read. + +A release that changes the API version the SDK pins says so in its section, in the same words in all seven SDKs (checked 2026-11-20): "This release changes the pinned API version to `2026-11-18.endive`." A few say they keep it: "This release **doesn't** change the pinned API version; it still uses `2026-05-27.dahlia`." (Go, Java, .NET), "…**does not** change the pinned API version. It's still `2026-06-24.dahlia`." (PHP), "This release uses the same pinned API version to `2026-03-25.dahlia` as the last major release." (Node). + +### What the plugin reads and ignores + +- Reads the release's section only. A bullet counts when it's marked `⚠️` or sits under a breaking or deprecation heading, and its first sentence is a plain template over code spans: `Remove X`, `Remove X from Y`, `Rename X to Y`, `X has been removed`, `Deprecated X in favor of Y`. The pull-request link it starts with is read past. +- Drops (and logs) everything else: type changes ("Change type of …"), nullable fields, pinned API versions, dropped language versions, bullets that list names inside prose or parentheses, and "Generated changes from …" roll-ups. +- **What a release pins** (`MapsTo`, `pins.go`): while listing the releases, it reads the changelog at the newest release's tag (or the one before, when that tag isn't pushed yet) and sets each release's `MapsTo` to `stripe/api` at the API version its own section states (the same id `stripe/api` lists its versions by, above), in one of the sentences above, exactly as written (`2026-11-18.endive`). A release whose section doesn't say pins nothing here, even though it keeps the release before's; two different versions in one section are none. Older wordings without "pinned" ("Major version release for API version 2022-08-01", "Move to API version …") aren't read. + +### Known gaps + +- Stripe's big generated roll-ups ("⚠️ Generated changes from #…") list their removals in nested bullets the reader doesn't open: those releases give no event. +- A release whose tag or section is missing is skipped as nothing to read, never guessed. +- Only releases that state their pin have one: most minors and patches don't say, so a release between two pin changes has none. diff --git a/providers/stripe/api.go b/providers/stripe/api.go new file mode 100644 index 0000000..743888a --- /dev/null +++ b/providers/stripe/api.go @@ -0,0 +1,123 @@ +package stripe + +import ( + "context" + "encoding/json" + "fmt" + "regexp" + "slices" + "time" + + "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" +) + +// Variables, not constants, only so tests can point them at a local server. +var ( + stripeReleasesURL = "https://api.github.com/repos/stripe/openapi/releases/latest" + // stripeSpecURLTemplate is Stripe's recommended file: v1 + v2 endpoints. + // Every release that names its API version (Versions) has it. + stripeSpecURLTemplate = "https://raw.githubusercontent.com/stripe/openapi/%s/latest/openapi.spec3.json" +) + +// Stripe is the reference adapter: the pattern every future adapter follows. +// It has no state, so its zero value is ready to use. +type Stripe struct{} + +// Compile-time check that Stripe actually satisfies Adapter. +var _ adapter.Adapter = Stripe{} + +func (Stripe) API() string { return "stripe/api" } + +// LatestTag asks GitHub for Stripe's newest openapi release tag, e.g. "v2468". +func (Stripe) LatestTag(ctx context.Context) (string, error) { + tag, err := github.LatestRelease(ctx, github.Get, stripeReleasesURL) + if err != nil { + return "", fmt.Errorf("looking up stripe's latest release: %w", err) + } + return tag, nil +} + +// Fetch downloads the spec pinned to tag and reads its declared API version +// out of info.version — the only version field the spec has. +func (Stripe) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { + url := fmt.Sprintf(stripeSpecURLTemplate, tag) + body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth + if err != nil { + return adapter.Spec{}, fmt.Errorf("fetching stripe spec %s: %w", tag, err) + } + + var parsed struct { + Info struct { + Version string `json:"version"` + } `json:"info"` + } + if err := json.Unmarshal(body, &parsed); err != nil { + return adapter.Spec{}, fmt.Errorf("parsing stripe spec %s: %w", tag, err) + } + if parsed.Info.Version == "" { + return adapter.Spec{}, fmt.Errorf("stripe spec %s has no info.version", tag) + } + + return adapter.Spec{ + Content: body, + Version: parsed.Info.Version, + SourceURL: url, + }, nil +} + +// stripeSDKSpecVersion is the API version a stripe/openapi release's notes +// say its SDK spec carries, the version Stripe's SDKs pin (every release +// since v2191, 2026-03-11, checked 2026-11-20): +// +// | openapi/spec3.sdk.{json,yaml} | 2026-11-18.endive | +var stripeSDKSpecVersion = regexp.MustCompile(`(?m)^\|\s*openapi/spec3\.sdk\.\{json,yaml\}\s*\|\s*(\d{4}-\d{2}-\d{2}(?:\.[a-z]+)?)\s*\|`) + +// Versions are Stripe's API versions ("2026-11-18.endive"), oldest first, as +// stripe/openapi's releases name them in their notes: each is read at the +// newest release that carries it (Ref, URL) and dated by the first +// (Released). A release whose notes name no version (every one before v2191) +// is left out: its version would have to be guessed. +func (Stripe) Versions(ctx context.Context) ([]plugin.Version, error) { + rs, err := versions.GitHubPages[stripeRelease](ctx, github.Get, versions.GitHubAPI+"/repos/stripe/openapi/releases") + if err != nil { + return nil, fmt.Errorf("listing stripe/openapi's releases: %w", err) + } + slices.SortStableFunc(rs, func(a, b stripeRelease) int { return a.Published.Compare(b.Published) }) + byID := map[string]*plugin.Version{} + var out []*plugin.Version + for _, r := range rs { + m := stripeSDKSpecVersion.FindStringSubmatch(r.Body) + if r.Draft || r.Prerelease || r.Tag == "" || m == nil { + continue + } + v, ok := byID[m[1]] + if !ok { + v = &plugin.Version{ID: m[1], Released: r.Published} + byID[m[1]], out = v, append(out, v) + } + v.Ref, v.URL = r.Tag, r.URL + } + vs := make([]plugin.Version, len(out)) + for i, v := range out { + vs[i] = *v + } + slices.SortStableFunc(vs, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) + return vs, nil +} + +// stripeRelease is a stripe/openapi release as GitHub's API lists it. +type stripeRelease struct { + Tag string `json:"tag_name"` + Draft bool `json:"draft"` + Prerelease bool `json:"prerelease"` + Published time.Time `json:"published_at"` + URL string `json:"html_url"` + Body string `json:"body"` +} + +// ListsSpecVersions: Stripe's version ids are the specs' info.version. +func (Stripe) ListsSpecVersions() {} diff --git a/providers/stripe/api_fetch_test.go b/providers/stripe/api_fetch_test.go new file mode 100644 index 0000000..3db583b --- /dev/null +++ b/providers/stripe/api_fetch_test.go @@ -0,0 +1,135 @@ +package stripe + +import ( + "context" + "fmt" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" +) + +// fakeGitHub serves a latest-release endpoint and specs by path. Paths missing +// from specs return 404, like raw.githubusercontent.com does. +func fakeGitHub(t *testing.T, releaseJSON string, specs map[string]string) *httptest.Server { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/releases/latest" { + w.Write([]byte(releaseJSON)) + return + } + body, ok := specs[r.URL.Path] + if !ok { + http.NotFound(w, r) + return + } + w.Write([]byte(body)) + })) + t.Cleanup(srv.Close) + + oldRel, oldSpec := stripeReleasesURL, stripeSpecURLTemplate + stripeReleasesURL = srv.URL + "/releases/latest" + stripeSpecURLTemplate = srv.URL + "/%s/latest/openapi.spec3.json" + t.Cleanup(func() { stripeReleasesURL, stripeSpecURLTemplate = oldRel, oldSpec }) + return srv +} + +func TestLatestTagReadsTheReleaseTag(t *testing.T) { + fakeGitHub(t, `{"tag_name":"v2484"}`, nil) + tag, err := Stripe{}.LatestTag(context.Background()) + if err != nil || tag != "v2484" { + t.Errorf("got %q, %v; want v2484", tag, err) + } +} + +func TestLatestTagRejectsAReleaseWithoutATag(t *testing.T) { + fakeGitHub(t, `{"name":"something"}`, nil) + if _, err := (Stripe{}).LatestTag(context.Background()); err == nil { + t.Error("release without tag_name: want an error") + } +} + +func TestFetchUsesTheRecommendedSpec(t *testing.T) { + srv := fakeGitHub(t, "", map[string]string{ + "/v2468/latest/openapi.spec3.json": `{"info":{"version":"2026-08-26.dahlia"}}`, + }) + spec, err := Stripe{}.Fetch(context.Background(), "v2468") + if err != nil { + t.Fatal(err) + } + if spec.Version != "2026-08-26.dahlia" || spec.SourceURL != srv.URL+"/v2468/latest/openapi.spec3.json" { + t.Errorf("got version %q from %s; want the latest/ file", spec.Version, spec.SourceURL) + } +} + +func TestFetchRejectsASpecWithoutAVersion(t *testing.T) { + fakeGitHub(t, "", map[string]string{"/v1/latest/openapi.spec3.json": `{"info":{}}`}) + _, err := Stripe{}.Fetch(context.Background(), "v1") + if err == nil || !strings.Contains(err.Error(), "info.version") { + t.Errorf("got %v, want an info.version error", err) + } +} + +func TestFetchFailsWhenNeitherSpecExists(t *testing.T) { + fakeGitHub(t, "", nil) + if _, err := (Stripe{}).Fetch(context.Background(), "v999999"); err == nil { + t.Error("missing tag: want an error") + } +} + +// Stripe's versions are its API versions, as each release's notes name +// them: one per version, oldest first, read at the newest release carrying +// it and dated by the first; v2190, whose notes name none, is left out. +func TestStripeListsAPIVersions(t *testing.T) { + srv := openapitest.Recorded(t, map[string]string{"/repos/stripe/openapi/releases?per_page=100&page=1": "stripe-openapi-releases.json"}) + old := versions.GitHubAPI + versions.GitHubAPI = srv.URL + t.Cleanup(func() { versions.GitHubAPI = old }) + vs, err := Stripe{}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + want := "2026-02-25.clover@v2203 2026-03-25.dahlia@v2248 2026-04-22.dahlia@v2275 2026-05-27.dahlia@v2323 2026-06-24.dahlia@v2348 " + + "2026-07-29.dahlia@v2441 2026-08-26.dahlia@v2516 2026-09-30.endive@v2592 2026-10-28.endive@v2600 2026-11-18.endive@v2602" + if got := openapitest.IDs(vs); got != want { + t.Fatalf("got %s\nwant %s", got, want) + } + last := vs[len(vs)-1] + if !last.Released.Equal(time.Date(2026, 11, 17, 22, 34, 17, 0, time.UTC)) || last.URL != "https://github.com/stripe/openapi/releases/tag/v2602" { + t.Errorf("newest: released %s (want v2601's date), url %s", last.Released, last.URL) + } +} + +// The plugin lists the API versions the releases' notes name, through +// core/versions. +func TestThePluginListsStripesAPIVersions(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/repos/stripe/openapi/releases" { + fmt.Fprint(w, `[{"tag_name":"v2","published_at":"2026-02-01T00:00:00Z","body":"| openapi/spec3.sdk.{json,yaml} | 2026-02-01.b |"},`+ + `{"tag_name":"v1","published_at":"2026-01-01T00:00:00Z","body":"| openapi/spec3.sdk.{json,yaml} | 2026-01-01.a |"}]`) + return + } + http.NotFound(w, r) + })) + defer srv.Close() + old := versions.GitHubAPI + versions.GitHubAPI = srv.URL + defer func() { versions.GitHubAPI = old }() + vs, err := openapi.Plugin{Adapter: Stripe{}}.ListVersions(context.Background(), plugin.Env{}) + if err != nil { + t.Fatal(err) + } + var refs []string + for _, v := range vs { + refs = append(refs, v.Ref) + } + if strings.Join(refs, " ") != "v1 v2" { + t.Errorf("refs %v, want v1 v2", refs) + } +} diff --git a/providers/stripe/node_surface_test.go b/providers/stripe/node_surface_test.go new file mode 100644 index 0000000..31a52f7 --- /dev/null +++ b/providers/stripe/node_surface_test.go @@ -0,0 +1,16 @@ +package stripe + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// stripe 23.0.0 removed constructEventWithoutVerification and the +// ErrorType namespace. +func TestNodeSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: NodeSurface, Golden: [2]string{"22.6.2", "23.0.0"}, Want: []string{ + "removed_symbol Stripe.ErrorType ", + "removed_symbol Stripe.constructEventWithoutVerification ", + }, Drop: [2]string{"23.0.0", "23.0.1"}}) +} diff --git a/plugins/changelog/pins_stripe_test.go b/providers/stripe/pins_api_test.go similarity index 72% rename from plugins/changelog/pins_stripe_test.go rename to providers/stripe/pins_api_test.go index 8a38ff9..9ab618d 100644 --- a/plugins/changelog/pins_stripe_test.go +++ b/providers/stripe/pins_api_test.go @@ -1,4 +1,4 @@ -package changelog +package stripe import ( "context" @@ -11,15 +11,16 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" - _ "github.com/patch-it-dev/patch-it-plugins/plugins/openapi" // registers stripe/api + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + _ "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" // registers stripe/api ) // Every pin the seven Stripe SDK sources read from their saved changelogs is // a version stripe/api lists, from its saved release listing -// (../openapi/adapter/testdata/versions/): the pin and the listing name an API +// (testdata/versions/): the pin and the listing name an API // version the same way, so a feed query on an SDK's versions finds the API's. func TestStripePinsAreVersionsStripeAPILists(t *testing.T) { - listing, err := os.ReadFile("../openapi/adapter/testdata/versions/stripe-openapi-releases.json") + listing, err := os.ReadFile("testdata/versions/stripe-openapi-releases.json") if err != nil { t.Fatal(err) } @@ -51,13 +52,13 @@ func TestStripePinsAreVersionsStripeAPILists(t *testing.T) { n := 0 for _, c := range []struct { - file File + file changelog.File tag string }{ - {StripePython, "17.1.0"}, {StripeNode, "23.2.0"}, {StripeGo, "87.2.0"}, {StripeJava, "34.1.0"}, - {StripeRuby, "21.1.0"}, {StripeDotnet, "53.2.0"}, {StripePHP, "23.1.0"}, + {Python, "17.1.0"}, {Node, "23.2.0"}, {Go, "87.2.0"}, {Java, "34.1.0"}, + {Ruby, "21.1.0"}, {Dotnet, "53.2.0"}, {PHP, "23.1.0"}, } { - for release, pin := range pins(kittest.Read(t, "testdata/pins/"+strings.ReplaceAll(c.file.API, "/", "-")+"-"+c.tag+"-CHANGELOG.md")) { + for release, pin := range changelog.Pins(kittest.Read(t, "testdata/pins/"+strings.ReplaceAll(c.file.API, "/", "-")+"-"+c.tag+"-CHANGELOG.md")) { n++ if c.file.Pins != "stripe/api" || !listed[pin] { t.Errorf("%s %s pins %s %s, which stripe/api doesn't list", c.file.API, release, c.file.Pins, pin) diff --git a/plugins/changelog/pins_test.go b/providers/stripe/pins_test.go similarity index 56% rename from plugins/changelog/pins_test.go rename to providers/stripe/pins_test.go index 4977086..904bc1a 100644 --- a/plugins/changelog/pins_test.go +++ b/providers/stripe/pins_test.go @@ -1,4 +1,4 @@ -package changelog +package stripe import ( "context" @@ -9,6 +9,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" ) // Each Stripe SDK's changelog at its newest tag, trimmed to the releases @@ -17,23 +18,23 @@ import ( // stated, and nothing for the release that doesn't say. func TestStripeReleasesStateWhatTheyPin(t *testing.T) { for _, c := range []struct { - file File + file changelog.File tag string want map[string]string }{ - {StripePython, "17.1.0", map[string]string{"17.1.0": "2026-11-18.endive"}}, // 17.0.0 says nothing - {StripeNode, "23.2.0", map[string]string{"23.2.0": "2026-11-18.endive", "22.0.0": "2026-03-25.dahlia"}}, - {StripeGo, "87.2.0", map[string]string{"87.2.0": "2026-11-18.endive", "86.0.0": "2026-05-27.dahlia"}}, - {StripeJava, "34.1.0", map[string]string{"34.1.0": "2026-10-28.endive", "33.0.0": "2026-05-27.dahlia"}}, - {StripeRuby, "21.1.0", map[string]string{"21.1.0": "2026-11-18.endive"}}, - {StripeDotnet, "53.2.0", map[string]string{"53.2.0": "2026-11-18.endive", "52.0.0": "2026-05-27.dahlia"}}, - {StripePHP, "23.1.0", map[string]string{"23.1.0": "2026-11-18.endive", "21.0.0": "2026-06-24.dahlia"}}, + {Python, "17.1.0", map[string]string{"17.1.0": "2026-11-18.endive"}}, // 17.0.0 says nothing + {Node, "23.2.0", map[string]string{"23.2.0": "2026-11-18.endive", "22.0.0": "2026-03-25.dahlia"}}, + {Go, "87.2.0", map[string]string{"87.2.0": "2026-11-18.endive", "86.0.0": "2026-05-27.dahlia"}}, + {Java, "34.1.0", map[string]string{"34.1.0": "2026-10-28.endive", "33.0.0": "2026-05-27.dahlia"}}, + {Ruby, "21.1.0", map[string]string{"21.1.0": "2026-11-18.endive"}}, + {Dotnet, "53.2.0", map[string]string{"53.2.0": "2026-11-18.endive", "52.0.0": "2026-05-27.dahlia"}}, + {PHP, "23.1.0", map[string]string{"23.1.0": "2026-11-18.endive", "21.0.0": "2026-06-24.dahlia"}}, } { t.Run(c.file.API, func(t *testing.T) { if c.file.Pins != "stripe/api" { t.Errorf("Pins %q, want stripe/api", c.file.Pins) } - got := pins(kittest.Read(t, "testdata/pins/"+strings.ReplaceAll(c.file.API, "/", "-")+"-"+c.tag+"-CHANGELOG.md")) + got := changelog.Pins(kittest.Read(t, "testdata/pins/"+strings.ReplaceAll(c.file.API, "/", "-")+"-"+c.tag+"-CHANGELOG.md")) if !maps.Equal(got, c.want) { t.Errorf("got %v, want %v", got, c.want) } @@ -47,9 +48,9 @@ func TestStripeReleasesStateWhatTheyPin(t *testing.T) { func TestListedVersionsCarryWhatTheyPin(t *testing.T) { env := kittest.Env(t, kittest.Pages{ "https://api.github.com/repos/stripe/stripe-go/tags?per_page=100&page=1": "testdata/versions/stripe-go-tags-pins.json", - StripeGo.At("87.2.0").URL(): "testdata/pins/stripe-go-87.2.0-CHANGELOG.md", + Go.At("87.2.0").URL(): "testdata/pins/stripe-go-87.2.0-CHANGELOG.md", }) - vs, err := Plugin{File: StripeGo}.ListVersions(context.Background(), env) + vs, err := changelog.Plugin{File: Go}.ListVersions(context.Background(), env) if err != nil { t.Fatal(err) } @@ -75,7 +76,7 @@ func TestPinsAreReadOnlyWhenTheyCanBe(t *testing.T) { } return nil, errors.New("503") }} - vs, err := Plugin{File: StripeGo}.ListVersions(context.Background(), env) + vs, err := changelog.Plugin{File: Go}.ListVersions(context.Background(), env) if err != nil || len(vs) != 3 { t.Fatalf("%v, %d versions", err, len(vs)) } @@ -87,31 +88,14 @@ func TestPinsAreReadOnlyWhenTheyCanBe(t *testing.T) { t.Errorf("%s pins %v with no changelog read", v.ID, v.MapsTo) } } - unpinned := StripeGo + unpinned := Go unpinned.Pins = "" fetched = nil - if _, err := (Plugin{File: unpinned}).ListVersions(context.Background(), env); err != nil || len(fetched) != 1 { + if _, err := (changelog.Plugin{File: unpinned}).ListVersions(context.Background(), env); err != nil || len(fetched) != 1 { t.Errorf("without Pins: %v, fetched %v", err, fetched) } } -// Two different versions in one release's section are none; a statement in -// a code block, or before the first release, is nobody's. -func TestAnUnsurePinIsNone(t *testing.T) { - got := pins([]byte("# Changelog\nThis release changes the pinned API version to `2020-01-01`.\n" + - "## 2.0.0 - 2026-01-02\nThis release changes the pinned API version to `2026-01-01.a`.\nThis release changes the pinned API version to `2026-01-02.b`.\n" + - "## 1.1.0 - 2026-01-01\n```\nThis release changes the pinned API version to `2025-12-01.a`.\n```\n" + - "## 1.0.0 - 2025-12-01\n* This release changes the pinned API version to `2025-11-01.a`.\n")) - if want := map[string]string{"1.0.0": "2025-11-01.a"}; !maps.Equal(got, want) { - t.Errorf("got %v, want %v", got, want) - } - // A "# comment" in a code example doesn't end the release's section. - got = pins([]byte("## 3.0.0 - 2026-02-01\n```sh\n# upgrade\n```\nThis release changes the pinned API version to `2026-02-01.c`.\n")) - if want := map[string]string{"3.0.0": "2026-02-01.c"}; !maps.Equal(got, want) { - t.Errorf("after a code block: got %v, want %v", got, want) - } -} - // When the newest release's tag can't be read yet, the one before's // changelog says what the earlier releases pin. func TestPinsFallBackToTheTagBefore(t *testing.T) { @@ -121,12 +105,12 @@ func TestPinsFallBackToTheTagBefore(t *testing.T) { switch { case strings.Contains(url, "/tags?"): return tags, nil - case url == StripeGo.At("86.4.2").URL(): + case url == Go.At("86.4.2").URL(): return file, nil } return nil, errors.New("404") }} - vs, err := Plugin{File: StripeGo}.ListVersions(context.Background(), env) + vs, err := changelog.Plugin{File: Go}.ListVersions(context.Background(), env) if err != nil || len(vs) != 3 || vs[0].MapsTo.Version != "2026-05-27.dahlia" { t.Errorf("%v %+v", err, vs) } diff --git a/providers/stripe/provider.go b/providers/stripe/provider.go new file mode 100644 index 0000000..9faadb8 --- /dev/null +++ b/providers/stripe/provider.go @@ -0,0 +1,65 @@ +// Package stripe is what patch-it reads for Stripe: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package stripe + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/hint" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "stripe", Name: "Stripe", Category: plugin.CategoryPayments, Homepage: "https://stripe.com", + Sources: []plugin.Source{ + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API changes between OpenAPI spec releases (removed and renamed endpoints, parameters and fields), with migration hints from Stripe's API changelog", + URLs: []string{"https://github.com/stripe/openapi"}, + Packages: []string{"pypi:stripe", "npm:stripe"}, + Plugin: openapi.Plugin{Adapter: Stripe{}, Hints: hint.Stripe{}}, + }, + changelog.SDK("python", Python, "pypi:stripe"), + changelog.SDK("node", Node, "npm:stripe"), + changelog.SDK("go", Go, "go:github.com/stripe/stripe-go/v87"), + changelog.SDK("java", Java, "maven:com.stripe:stripe-java"), + changelog.SDK("ruby", Ruby, "rubygems:stripe"), + changelog.SDK("dotnet", Dotnet, "nuget:Stripe.net"), + changelog.SDK("php", PHP, "packagist:stripe/stripe-php"), + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/stripe/stripe-python"), + apisurface.NPM(NodeSurface, "https://github.com/stripe/stripe-node"), + }, + }) +} + +// Stripe's SDKs: one CHANGELOG.md each, "## X.Y.Z - date" +// (older ones "## X.Y.Z - date"), every breaking bullet marked "⚠️"; each +// release tagged vX.Y.Z. A release that changes the API version the SDK +// pins says so in its section, "This release changes the pinned API version +// to `2026-11-18.endive`." (kinds/changelog/pins.go): its MapsTo is that +// stripe/api version. +var ( + Python = changelog.File{API: "stripe/python", Package: "stripe", Ecosystem: "pypi", Module: "stripe", + Repo: "stripe/stripe-python", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} + Node = changelog.File{API: "stripe/node", Package: "stripe", Ecosystem: "npm", + Repo: "stripe/stripe-node", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} + Go = changelog.File{API: "stripe/go", Package: "github.com/stripe/stripe-go", Ecosystem: "go", + Repo: "stripe/stripe-go", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} + Java = changelog.File{API: "stripe/java", Package: "com.stripe:stripe-java", Ecosystem: "maven", + Repo: "stripe/stripe-java", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} + Ruby = changelog.File{API: "stripe/ruby", Package: "stripe", Ecosystem: "rubygems", + Repo: "stripe/stripe-ruby", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} + Dotnet = changelog.File{API: "stripe/dotnet", Package: "Stripe.net", Ecosystem: "nuget", + Repo: "stripe/stripe-dotnet", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} + PHP = changelog.File{API: "stripe/php", Package: "stripe/stripe-php", Ecosystem: "packagist", + Repo: "stripe/stripe-php", TagPrefix: "v", Path: "CHANGELOG.md", Pins: "stripe/api"} +) + +// The packages whose public API the apisurface sources read. +var ( + NodeSurface = apisurface.NPMPackage("stripe/node-surface", "stripe") + PythonSurface = apisurface.Package{ID: "stripe/python-surface", Name: "stripe", Ecosystem: "pypi", Module: "stripe"} +) diff --git a/providers/stripe/python_surface_test.go b/providers/stripe/python_surface_test.go new file mode 100644 index 0000000..7b4e096 --- /dev/null +++ b/providers/stripe/python_surface_test.go @@ -0,0 +1,12 @@ +package stripe + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// stripe 16.0.0 removed StripeObject.request. 15.5.0 only added. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"15.6.2", "16.0.0"}, Want: []string{"removed_symbol StripeObject.request "}, Drop: [2]string{"15.4.0", "15.5.0"}}) +} diff --git a/providers/stripe/sdks_test.go b/providers/stripe/sdks_test.go new file mode 100644 index 0000000..8459d52 --- /dev/null +++ b/providers/stripe/sdks_test.go @@ -0,0 +1,19 @@ +package stripe + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +func TestStripeSDKs(t *testing.T) { + changelogtest.CheckSDKs(t, []changelogtest.SDKCase{ + {File: Python, Release: "4.0.0", Prev: "3.5.0", Saved: "stripe-python-4.0.0-CHANGELOG.md", Dropped: "", Drop: "3.5.0"}, + {File: Node, Release: "10.0.0", Prev: "9.16.0", Saved: "stripe-node-10.0.0-CHANGELOG.md", Dropped: "", Drop: "9.16.0"}, + {File: Go, Release: "73.0.0", Prev: "72.122.0", Saved: "stripe-go-73.0.0-CHANGELOG.md", Dropped: "", Drop: "72.122.0"}, + {File: Java, Release: "21.0.0", Prev: "20.136.0", Saved: "stripe-java-21.0.0-CHANGELOG.md", Dropped: "", Drop: "20.136.0"}, + {File: Ruby, Release: "7.0.0", Prev: "6.5.0", Saved: "stripe-ruby-7.0.0-CHANGELOG.md", Dropped: "", Drop: "6.5.0"}, + {File: Dotnet, Release: "40.0.0", Prev: "39.126.0", Saved: "stripe-dotnet-40.0.0-CHANGELOG.md", Dropped: "", Drop: "39.126.0"}, + {File: PHP, Release: "9.0.0", Prev: "8.12.1", Saved: "stripe-php-9.0.0-CHANGELOG.md", Dropped: "", Drop: "8.12.0"}, + }) +} diff --git a/providers/stripe/testdata/README.md b/providers/stripe/testdata/README.md new file mode 100644 index 0000000..a288fb9 --- /dev/null +++ b/providers/stripe/testdata/README.md @@ -0,0 +1,62 @@ +# Stripe: saved copies and goldens + +Real copies of what Stripe publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/stripe -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +Stripe's spec isn't saved: the `openapi` kind's own tests use small specs written inline, and `stripe/api`'s listing is tested on the recorded responses below. + +## Recorded API responses + +The version-listing tests read these, under `versions/`, instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/stripe-openapi-releases.json` | `https://api.github.com/repos/stripe/openapi/releases/tags/`, one per release, in the order `releases?per_page=100` lists them | 21 of 2,591: the first and the last release of each of the 10 API versions their notes name (v2191 to v2602), and v2190, the newest whose notes name none; `tag_name`, `name`, `draft`, `prerelease`, `published_at`, `html_url`, `body` | + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/stripe/`: `stripe-15.4.0-py3-none-any.trimmed.whl`, `stripe-15.5.0-py3-none-any.trimmed.whl`, `stripe-15.6.2-py3-none-any.trimmed.whl`, `stripe-16.0.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/00/e1/3047b4e244cc78bb598b0d5fcab6632b8bf8a4d526f2e840c4f4de02c989/stripe-15.4.0-py3-none-any.whl; https://files.pythonhosted.org/packages/d5/20/4c8377c570697ebe105ad5e073538e498d58e4985ca6e2944bdc917a5034/stripe-15.5.0-py3-none-any.whl; https://files.pythonhosted.org/packages/25/e9/251eb26d9ceae6c44adb3a54cb81ec717dc469452c09756b53a117726277/stripe-15.6.2-py3-none-any.whl; https://files.pythonhosted.org/packages/b5/de/5141ae3990862cc3d61a1cdd4acff72bcb587afb7b4d31c52eaddbb6bc8f/stripe-16.0.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `stripe/__init__.py`, `stripe/_stripe_object.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/stripe/`: `pypi-stripe-excerpt.json` and `pypi-stripe-15.4.0.json`, `pypi-stripe-15.5.0.json`, `pypi-stripe-15.6.2.json`, `pypi-stripe-16.0.0.json` | https://pypi.org/pypi/stripe/json, https://pypi.org/pypi/stripe/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/stripe/`: `stripe-22.6.2.trimmed.tgz`, `stripe-23.0.0.trimmed.tgz`, `stripe-23.0.1.trimmed.tgz` | https://registry.npmjs.org/stripe/-/stripe-22.6.2.tgz; https://registry.npmjs.org/stripe/-/stripe-23.0.0.tgz; https://registry.npmjs.org/stripe/-/stripe-23.0.1.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `esm/stripe.esm.node.d.ts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/stripe/`: `npm-stripe-excerpt.json` and `npm-stripe-22.6.2.json`, `npm-stripe-23.0.0.json`, `npm-stripe-23.0.1.json` | https://registry.npmjs.org/stripe, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | + +## SDK changelogs + +Read with `Plugin{File: ...}` (`kinds/changelog/sdks.go`); `golden/-.json` is what each stores from its release (`changelogtest.CheckSDKs`), the pair from the release before it on the registry (or among the repo's tags). Every file is the changelog at the release's tag, saved with `curl`, **trimmed** to two releases' sections, each kept whole and unchanged: the release the golden pins and one more release from the same file whose notes remove nothing the reader can name (the drop test). Only the pinned release's own section is read for the golden, so the trimmed copy gives the same events as the whole file (checked when each copy was made). + +| File | URL | Tag commit | Saved | License; trimming | Quote | +|---|---|---|---|---|---| +| `stripe-python-4.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-python/v4.0.0/CHANGELOG.md | `e65630a` | 2026-11-20 | MIT (stripe-python); trimmed to the sections of 4.0.0 (the golden) and 3.5.0 (the drop test), each unchanged | "Removed deprecated `AlipayAccount`, `BitcoinReceiver`, `BitcoinTransaction`, `IssuerFraudRecord`, `Recipient`, `Recip…" | +| `stripe-node-10.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-node/v10.0.0/CHANGELOG.md | `321d2fd` | 2026-11-20 | MIT (stripe-node); trimmed to the sections of 10.0.0 (the golden) and 9.16.0 (the drop test), each unchanged | "Remove `AlipayAccount` and `BitcoinReceiver` from `CustomerSource`." | +| `stripe-go-73.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-go/v73.0.0/CHANGELOG.md | `234502c` | 2026-11-20 | MIT (stripe-go); trimmed to the sections of 73.0.0 (the golden) and 72.122.0 (the drop test), each unchanged | "Remove `BalanceTransactionStatus`. It was meant to be an enum, but none of the enum values were defined, so it was ju…" | +| `stripe-java-21.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-java/v21.0.0/CHANGELOG.md | `cd2b023` | 2026-11-20 | MIT (stripe-java); trimmed to the sections of 21.0.0 (the golden) and 20.136.0 (the drop test), each unchanged | "Removed `CashBalance.retrieveCashBalance` method. Prefer `CashBalance.retrieve`." | +| `stripe-ruby-7.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-ruby/v7.0.0/CHANGELOG.md | `6081371` | 2026-11-20 | MIT (stripe-ruby); trimmed to the sections of 7.0.0 (the golden) and 6.5.0 (the drop test), each unchanged | "Remove `details` method from `Issuing.Card` resource. The method was not supported." | +| `stripe-dotnet-40.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-dotnet/v40.0.0/CHANGELOG.md | `e07ebe7` | 2026-11-20 | Apache-2.0 (stripe-dotnet); trimmed to the sections of 40.0.0 (the golden) and 39.126.0 (the drop test), each unchanged | "Remove `CustomerPaymentSettingsOptions`, `CustomerPaymentSettingsPaymentMethodOptionsBancontactOptions`, `CustomerPay…" | +| `stripe-php-9.0.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-php/v9.0.0/CHANGELOG.md | `e405c17` | 2026-11-20 | MIT (stripe-php); trimmed to the sections of 9.0.0 (the golden) and 8.12.0 (the drop test), each unchanged | "Remove deprecated `AlipayAccount`, `BitcoinReceiver`, `BitcoinTransaction`, `Recipient`, `RecipientTransfer`, and `Th…" | + +## What a release pins + +Read by `kinds/changelog/pins.go`; `pins_api_test.go` and `pins_test.go` check each release's stated pin. Every file is the SDK's `CHANGELOG.md` at its newest release tag, saved with `curl` on 2026-11-20, **trimmed** to the sections listed, each kept whole and unchanged. + +| File | URL | Tag commit | Sections kept | License | Quote | +|---|---|---|---|---|---| +| `pins/stripe-python-17.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-python/v17.1.0/CHANGELOG.md | `2bbff43` | 17.1.0 (changes the pin), 17.0.0 (says nothing) | MIT (stripe-python) | "This release changes the pinned API version to `2026-11-18.endive`." | +| `pins/stripe-node-23.2.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-node/v23.2.0/CHANGELOG.md | `dd92429` | 23.2.0, 23.0.1 (says nothing), 22.0.0 ("uses the same pinned API version to") | MIT (stripe-node) | "This release uses the same pinned API version to `2026-03-25.dahlia` as the last major release." | +| `pins/stripe-go-87.2.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-go/v87.2.0/CHANGELOG.md | `c97713a` | 87.2.0, 86.4.2 (says nothing), 86.0.0 ("doesn't change") | MIT (stripe-go) | "This release **doesn't** change the pinned API version; it still uses `2026-05-27.dahlia`." | +| `pins/stripe-java-34.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-java/v34.1.0/CHANGELOG.md | `d1dcf1a` | 34.1.0, 33.4.2 (says nothing), 33.0.0 ("doesn't change") | MIT (stripe-java) | "This release changes the pinned API version to `2026-10-28.endive`." | +| `pins/stripe-ruby-21.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-ruby/v21.1.0/CHANGELOG.md | `6605e66` | 21.1.0, 21.0.0 (says nothing) | MIT (stripe-ruby) | "This release changes the pinned API version to `2026-11-18.endive`." | +| `pins/stripe-dotnet-53.2.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-dotnet/v53.2.0/CHANGELOG.md | `a32d3eb` | 53.2.0, 52.4.2 (says nothing), 52.0.0 ("doesn't change") | Apache-2.0 (stripe-dotnet) | "This release changes the pinned API version to `2026-11-18.endive`." | +| `pins/stripe-php-23.1.0-CHANGELOG.md` | https://raw.githubusercontent.com/stripe/stripe-php/v23.1.0/CHANGELOG.md | `6694b4d` | 23.1.0, 23.0.0 (says nothing), 21.0.0 ("does not change") | MIT (stripe-php) | "This release **does not** change the pinned API version. It's still `2026-06-24.dahlia`." | + +## Version lists + +| File | URL | Saved | License | Use | +|---|---|---|---|---| +| `versions/stripe-go-tags-pins.json` | https://api.github.com/repos/stripe/stripe-go/tags (shape only) | written for the test, 2026-11-20 | not a saved copy: a few real tag names in the shape of GitHub's API | for the pins tests only; no golden reads it | diff --git a/plugins/changelog/testdata/golden/stripe-dotnet.json b/providers/stripe/testdata/golden/stripe-dotnet.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-dotnet.json rename to providers/stripe/testdata/golden/stripe-dotnet.json diff --git a/plugins/changelog/testdata/golden/stripe-go.json b/providers/stripe/testdata/golden/stripe-go.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-go.json rename to providers/stripe/testdata/golden/stripe-go.json diff --git a/plugins/changelog/testdata/golden/stripe-java.json b/providers/stripe/testdata/golden/stripe-java.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-java.json rename to providers/stripe/testdata/golden/stripe-java.json diff --git a/plugins/apisurface/testdata/golden/stripe-node-surface.json b/providers/stripe/testdata/golden/stripe-node-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/stripe-node-surface.json rename to providers/stripe/testdata/golden/stripe-node-surface.json diff --git a/plugins/changelog/testdata/golden/stripe-node.json b/providers/stripe/testdata/golden/stripe-node.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-node.json rename to providers/stripe/testdata/golden/stripe-node.json diff --git a/plugins/changelog/testdata/golden/stripe-php.json b/providers/stripe/testdata/golden/stripe-php.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-php.json rename to providers/stripe/testdata/golden/stripe-php.json diff --git a/plugins/apisurface/testdata/golden/stripe-python-surface.json b/providers/stripe/testdata/golden/stripe-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/stripe-python-surface.json rename to providers/stripe/testdata/golden/stripe-python-surface.json diff --git a/plugins/changelog/testdata/golden/stripe-python.json b/providers/stripe/testdata/golden/stripe-python.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-python.json rename to providers/stripe/testdata/golden/stripe-python.json diff --git a/plugins/changelog/testdata/golden/stripe-ruby.json b/providers/stripe/testdata/golden/stripe-ruby.json similarity index 100% rename from plugins/changelog/testdata/golden/stripe-ruby.json rename to providers/stripe/testdata/golden/stripe-ruby.json diff --git a/plugins/apisurface/testdata/npm/stripe/npm-stripe-22.6.2.json b/providers/stripe/testdata/npm/stripe/npm-stripe-22.6.2.json similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/npm-stripe-22.6.2.json rename to providers/stripe/testdata/npm/stripe/npm-stripe-22.6.2.json diff --git a/plugins/apisurface/testdata/npm/stripe/npm-stripe-23.0.0.json b/providers/stripe/testdata/npm/stripe/npm-stripe-23.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/npm-stripe-23.0.0.json rename to providers/stripe/testdata/npm/stripe/npm-stripe-23.0.0.json diff --git a/plugins/apisurface/testdata/npm/stripe/npm-stripe-23.0.1.json b/providers/stripe/testdata/npm/stripe/npm-stripe-23.0.1.json similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/npm-stripe-23.0.1.json rename to providers/stripe/testdata/npm/stripe/npm-stripe-23.0.1.json diff --git a/plugins/apisurface/testdata/npm/stripe/npm-stripe-excerpt.json b/providers/stripe/testdata/npm/stripe/npm-stripe-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/npm-stripe-excerpt.json rename to providers/stripe/testdata/npm/stripe/npm-stripe-excerpt.json diff --git a/plugins/apisurface/testdata/npm/stripe/stripe-22.6.2.trimmed.tgz b/providers/stripe/testdata/npm/stripe/stripe-22.6.2.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/stripe-22.6.2.trimmed.tgz rename to providers/stripe/testdata/npm/stripe/stripe-22.6.2.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/stripe/stripe-23.0.0.trimmed.tgz b/providers/stripe/testdata/npm/stripe/stripe-23.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/stripe-23.0.0.trimmed.tgz rename to providers/stripe/testdata/npm/stripe/stripe-23.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/stripe/stripe-23.0.1.trimmed.tgz b/providers/stripe/testdata/npm/stripe/stripe-23.0.1.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/stripe/stripe-23.0.1.trimmed.tgz rename to providers/stripe/testdata/npm/stripe/stripe-23.0.1.trimmed.tgz diff --git a/plugins/changelog/testdata/pins/stripe-dotnet-53.2.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-dotnet-53.2.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-dotnet-53.2.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-dotnet-53.2.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/pins/stripe-go-87.2.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-go-87.2.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-go-87.2.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-go-87.2.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/pins/stripe-java-34.1.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-java-34.1.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-java-34.1.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-java-34.1.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/pins/stripe-node-23.2.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-node-23.2.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-node-23.2.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-node-23.2.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/pins/stripe-php-23.1.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-php-23.1.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-php-23.1.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-php-23.1.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/pins/stripe-python-17.1.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-python-17.1.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-python-17.1.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-python-17.1.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/pins/stripe-ruby-21.1.0-CHANGELOG.md b/providers/stripe/testdata/pins/stripe-ruby-21.1.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/pins/stripe-ruby-21.1.0-CHANGELOG.md rename to providers/stripe/testdata/pins/stripe-ruby-21.1.0-CHANGELOG.md diff --git a/plugins/apisurface/testdata/pypi/stripe/pypi-stripe-15.4.0.json b/providers/stripe/testdata/pypi/stripe/pypi-stripe-15.4.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/pypi-stripe-15.4.0.json rename to providers/stripe/testdata/pypi/stripe/pypi-stripe-15.4.0.json diff --git a/plugins/apisurface/testdata/pypi/stripe/pypi-stripe-15.5.0.json b/providers/stripe/testdata/pypi/stripe/pypi-stripe-15.5.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/pypi-stripe-15.5.0.json rename to providers/stripe/testdata/pypi/stripe/pypi-stripe-15.5.0.json diff --git a/plugins/apisurface/testdata/pypi/stripe/pypi-stripe-15.6.2.json b/providers/stripe/testdata/pypi/stripe/pypi-stripe-15.6.2.json similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/pypi-stripe-15.6.2.json rename to providers/stripe/testdata/pypi/stripe/pypi-stripe-15.6.2.json diff --git a/plugins/apisurface/testdata/pypi/stripe/pypi-stripe-16.0.0.json b/providers/stripe/testdata/pypi/stripe/pypi-stripe-16.0.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/pypi-stripe-16.0.0.json rename to providers/stripe/testdata/pypi/stripe/pypi-stripe-16.0.0.json diff --git a/plugins/apisurface/testdata/pypi/stripe/pypi-stripe-excerpt.json b/providers/stripe/testdata/pypi/stripe/pypi-stripe-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/pypi-stripe-excerpt.json rename to providers/stripe/testdata/pypi/stripe/pypi-stripe-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/stripe/stripe-15.4.0-py3-none-any.trimmed.whl b/providers/stripe/testdata/pypi/stripe/stripe-15.4.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/stripe-15.4.0-py3-none-any.trimmed.whl rename to providers/stripe/testdata/pypi/stripe/stripe-15.4.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/stripe/stripe-15.5.0-py3-none-any.trimmed.whl b/providers/stripe/testdata/pypi/stripe/stripe-15.5.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/stripe-15.5.0-py3-none-any.trimmed.whl rename to providers/stripe/testdata/pypi/stripe/stripe-15.5.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/stripe/stripe-15.6.2-py3-none-any.trimmed.whl b/providers/stripe/testdata/pypi/stripe/stripe-15.6.2-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/stripe-15.6.2-py3-none-any.trimmed.whl rename to providers/stripe/testdata/pypi/stripe/stripe-15.6.2-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/stripe/stripe-16.0.0-py3-none-any.trimmed.whl b/providers/stripe/testdata/pypi/stripe/stripe-16.0.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/stripe/stripe-16.0.0-py3-none-any.trimmed.whl rename to providers/stripe/testdata/pypi/stripe/stripe-16.0.0-py3-none-any.trimmed.whl diff --git a/plugins/changelog/testdata/stripe-dotnet-40.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-dotnet-40.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-dotnet-40.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-dotnet-40.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/stripe-go-73.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-go-73.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-go-73.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-go-73.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/stripe-java-21.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-java-21.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-java-21.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-java-21.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/stripe-node-10.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-node-10.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-node-10.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-node-10.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/stripe-php-9.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-php-9.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-php-9.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-php-9.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/stripe-python-4.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-python-4.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-python-4.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-python-4.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/stripe-ruby-7.0.0-CHANGELOG.md b/providers/stripe/testdata/stripe-ruby-7.0.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/stripe-ruby-7.0.0-CHANGELOG.md rename to providers/stripe/testdata/stripe-ruby-7.0.0-CHANGELOG.md diff --git a/plugins/changelog/testdata/versions/stripe-go-tags-pins.json b/providers/stripe/testdata/versions/stripe-go-tags-pins.json similarity index 100% rename from plugins/changelog/testdata/versions/stripe-go-tags-pins.json rename to providers/stripe/testdata/versions/stripe-go-tags-pins.json diff --git a/plugins/openapi/adapter/testdata/versions/stripe-openapi-releases.json b/providers/stripe/testdata/versions/stripe-openapi-releases.json similarity index 100% rename from plugins/openapi/adapter/testdata/versions/stripe-openapi-releases.json rename to providers/stripe/testdata/versions/stripe-openapi-releases.json diff --git a/providers/supabase-js-surface.md b/providers/supabase-js-surface.md deleted file mode 100644 index 7cbc99a..0000000 --- a/providers/supabase-js-surface.md +++ /dev/null @@ -1,37 +0,0 @@ -# Supabase JavaScript client (`supabase/js-surface`) - -## What it watches - -The public API of the `@supabase/supabase-js` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the TypeScript declaration reader (`plugins/apisurface/dtsurface`). - -## Why this source - -- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @supabase/supabase-js@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md; the v2 migration guide. -- **Quote:** `getSubscriptions(): RealtimeSubscription[]` (`SupabaseClient`, `dist/module/SupabaseClient.d.ts` line 100) at 1.35.7, gone at 2.0.0. - -## How the provider announces changes - -- The client is small and wraps separate packages (`@supabase/auth-js`, `@supabase/postgrest-js`, …) whose APIs it re-exports wholesale. -- **Forced on upgrade**, for a repo whose lockfile reaches the release. - -## What the plugin reads and ignores - -- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`plugins/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. -- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@supabase/supabase-js.SupabaseClient.from`. -- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. -- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). -- One declaration reachable at several import paths is one event, every path in its `symbols`. -- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). - -## Known gaps - -- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. -- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. -- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. -- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. -- A parameter added without being optional is a note (the change-event contract has no subject for it yet). -- The packages it wraps are separate packages, not read by this source. diff --git a/providers/supabase-python-surface.md b/providers/supabase-python-surface.md deleted file mode 100644 index a44d6f0..0000000 --- a/providers/supabase-python-surface.md +++ /dev/null @@ -1,36 +0,0 @@ -# Supabase Python client (`supabase/python-surface`) - -## What it watches - -The public API of the `supabase` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. - -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). - -## Why this source - -- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. -- **Why this one:** the wheel is exactly what `pip install supabase==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. -- **Alternatives considered:** CHANGELOG.md (release-please). -- **Quote:** `api: Optional[SyncGoTrueAPI] = None, replace_default_headers: bool = False,` in `SupabaseAuthClient.__init__` (`supabase/lib/auth_client.py`) at 0.7.1, gone at 1.0.0. - -## How the provider announces changes - -- The client is small (about a hundred public names) and wraps separate packages (postgrest, realtime, storage3, supabase_auth) whose own APIs aren't read here. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the `.py` and `.pyi` files under `supabase/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. -- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). -- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). -- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. -- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. - -## Known gaps - -- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. -- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. -- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. -- Type changes (an annotation narrowed, a return type changed) aren't events. -- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. -- The packages it wraps (`postgrest`, `supabase_auth`, …) are separate packages, not read by this source. diff --git a/providers/supabase.md b/providers/supabase.md deleted file mode 100644 index 34d7169..0000000 --- a/providers/supabase.md +++ /dev/null @@ -1,46 +0,0 @@ -# Supabase (`supabase/management-api`) - -## What it watches - -The Supabase Management API (`api.supabase.com/v1`): operations Supabase marks deprecated, and removals of operations it had marked deprecated, between two versions of the API's OpenAPI spec. - -Kind: `openapi` (`plugins/openapi`), with `adapter.Supabase`. - -## Why this source - -- **Source:** `apps/docs/spec/api_v1_openapi.json` in [supabase/supabase](https://github.com/supabase/supabase), pinned to the commit that last changed it (`https://raw.githubusercontent.com/supabase/supabase//apps/docs/spec/api_v1_openapi.json`). The newest such commit comes from the GitHub commits API. Checked on 2026-11-19. -- **Why this one:** - - It's Supabase's own description of the API: the spec its API reference is built from. - - It marks deprecations with the `deprecated` flag, sometimes with the reason ("This endpoint is deprecated - use the deploy endpoint."). - - There are 90 versions from 2024-05-31 to 2026-11-18, and a commit can be cited and replayed. -- **Alternatives considered:** - - **`https://api.supabase.com/api/v1-json`.** The same spec served live, but it has no versions to pin, cite or replay. - - **The [changelog](https://supabase.com/changelog)** (RSS at `https://supabase.com/changelog-rss.xml`, 238 posts since 2022). It has about 30 breaking or deprecation posts. Almost all are about the platform rather than an API operation: Postgres versions, pooler ports, OAuth providers, the CLI, self-hosting. Or they're behavior changes ("OAuth token endpoint will return HTTP 200 instead of 201") with no field or operation to name. - - **There's no deprecations page** (`/docs/guides/deprecated` is a 404). - - **The SDKs.** `supabase-js` (2.119) and `supabase-py` (2.34) haven't had a major release in years, and their changelogs have no breaking sections to read. -- **Quote:** "This endpoint is deprecated - use the deploy endpoint." (`POST /v1/projects/{ref}/functions`, deprecated in the spec on 2025-02-19) - -## How the provider announces changes - -- **No API version beyond `/v1`.** `info.version` is a fixed `1.0.0`, so the event's `version` is the date of the spec commit, the closest thing to the API version a change arrived in. -- **The spec changes a few times a month.** Deprecations are rare: two in two and a half years. Three more operations were added already marked deprecated and later un-deprecated, so they never became deprecated. - -## What the plugin reads and ignores - -- **Reads:** the spec at the newest commit, diffed against the last one. Two events come out of it: - - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so Supabase's reason, when there is one, is in the excerpt. - - **Removals (breaking):** an operation that leaves the spec after the previous spec had marked it deprecated. -- **Matches operations by path template:** `/v1/branches/{branch_id}/merge` and `/v1/branches/{branch_id_or_ref}/merge` are one operation (renamed 2025-09-11). -- **Ignores everything else:** - - **Removals of operations that were never deprecated.** 22 operations left the spec in its history, none deprecated first: 14 analytics warehouse operations on 2024-07-15, 7 path-parameter renames, and one that came back 12 days later. Without credentials every route answers `401`, made-up ones included, so whether a removed one still works can't be checked from outside. - - **Request and response property changes, and new operations.** -- Over the 90 commits this keeps 2 events, both deprecations: `POST /v1/projects/{ref}/functions` (2025-02-19) and `GET /v1/projects/{ref}/analytics/endpoints/logs.all` (2026-06-29). -- **Reads** a historical pair (a version pair, `693bdc38` → `eb21ae25`) and recreates the `logs.all` deprecation. The golden test also reads the `functions` deprecation as a pair (`57d668c6` → `bf04ff66`). The drop tests replay the warehouse removal and the branch path-parameter rename. - -## Known gaps - -- **A shutdown said only in words isn't an event.** On 2026-09-30 the `logs.all` description became "This endpoint has been removed and always responds with `410 Gone`", but the operation stayed in the spec. The diff sees no structural change. -- **Removals Supabase didn't mark first aren't events,** even if the endpoint really went away. -- **Only the Management API is covered.** The APIs most apps call (the Data API through PostgREST, Auth, Storage, Realtime) and the SDKs are not. -- **Two spec commits on one day are one version** (four days in the history), read at the day's last commit: a change made and undone the same day isn't seen. -- **The patch-it client can't place these events yet.** Their `version` is a date (`2026-06-29`), because the API has no version. The client's version check reads an `api_operation` version as a package version, so it needs the same rule for date-versioned API events that `cloudflare`'s need. diff --git a/providers/supabase/README.md b/providers/supabase/README.md new file mode 100644 index 0000000..39cd1d6 --- /dev/null +++ b/providers/supabase/README.md @@ -0,0 +1,125 @@ +# Supabase + +Every source patch-it reads for Supabase, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Supabase (`supabase/management-api`) + +### What it watches + +The Supabase Management API (`api.supabase.com/v1`): operations Supabase marks deprecated, and removals of operations it had marked deprecated, between two versions of the API's OpenAPI spec. + +Kind: `openapi` (`kinds/openapi`), with its adapter, `Supabase` ([`management_api.go`](management_api.go)). + +### Why this source + +- **Source:** `apps/docs/spec/api_v1_openapi.json` in [supabase/supabase](https://github.com/supabase/supabase), pinned to the commit that last changed it (`https://raw.githubusercontent.com/supabase/supabase//apps/docs/spec/api_v1_openapi.json`). The newest such commit comes from the GitHub commits API. Checked on 2026-11-19. +- **Why this one:** + - It's Supabase's own description of the API: the spec its API reference is built from. + - It marks deprecations with the `deprecated` flag, sometimes with the reason ("This endpoint is deprecated - use the deploy endpoint."). + - There are 90 versions from 2024-05-31 to 2026-11-18, and a commit can be cited and replayed. +- **Alternatives considered:** + - **`https://api.supabase.com/api/v1-json`.** The same spec served live, but it has no versions to pin, cite or replay. + - **The [changelog](https://supabase.com/changelog)** (RSS at `https://supabase.com/changelog-rss.xml`, 238 posts since 2022). It has about 30 breaking or deprecation posts. Almost all are about the platform rather than an API operation: Postgres versions, pooler ports, OAuth providers, the CLI, self-hosting. Or they're behavior changes ("OAuth token endpoint will return HTTP 200 instead of 201") with no field or operation to name. + - **There's no deprecations page** (`/docs/guides/deprecated` is a 404). + - **The SDKs.** `supabase-js` (2.119) and `supabase-py` (2.34) haven't had a major release in years, and their changelogs have no breaking sections to read. +- **Quote:** "This endpoint is deprecated - use the deploy endpoint." (`POST /v1/projects/{ref}/functions`, deprecated in the spec on 2025-02-19) + +### How the provider announces changes + +- **No API version beyond `/v1`.** `info.version` is a fixed `1.0.0`, so the event's `version` is the date of the spec commit, the closest thing to the API version a change arrived in. +- **The spec changes a few times a month.** Deprecations are rare: two in two and a half years. Three more operations were added already marked deprecated and later un-deprecated, so they never became deprecated. + +### What the plugin reads and ignores + +- **Reads:** the spec at the newest commit, diffed against the last one. Two events come out of it: + - **Deprecations:** an operation that gains the `deprecated` flag. The event quotes the whole operation, so Supabase's reason, when there is one, is in the excerpt. + - **Removals (breaking):** an operation that leaves the spec after the previous spec had marked it deprecated. +- **Matches operations by path template:** `/v1/branches/{branch_id}/merge` and `/v1/branches/{branch_id_or_ref}/merge` are one operation (renamed 2025-09-11). +- **Ignores everything else:** + - **Removals of operations that were never deprecated.** 22 operations left the spec in its history, none deprecated first: 14 analytics warehouse operations on 2024-07-15, 7 path-parameter renames, and one that came back 12 days later. Without credentials every route answers `401`, made-up ones included, so whether a removed one still works can't be checked from outside. + - **Request and response property changes, and new operations.** +- Over the 90 commits this keeps 2 events, both deprecations: `POST /v1/projects/{ref}/functions` (2025-02-19) and `GET /v1/projects/{ref}/analytics/endpoints/logs.all` (2026-06-29). +- **Reads** a historical pair (a version pair, `693bdc38` → `eb21ae25`) and recreates the `logs.all` deprecation. The golden test also reads the `functions` deprecation as a pair (`57d668c6` → `bf04ff66`). The drop tests replay the warehouse removal and the branch path-parameter rename. + +### Known gaps + +- **A shutdown said only in words isn't an event.** On 2026-09-30 the `logs.all` description became "This endpoint has been removed and always responds with `410 Gone`", but the operation stayed in the spec. The diff sees no structural change. +- **Removals Supabase didn't mark first aren't events,** even if the endpoint really went away. +- **Only the Management API is covered.** The APIs most apps call (the Data API through PostgREST, Auth, Storage, Realtime) and the SDKs are not. +- **Two spec commits on one day are one version** (four days in the history), read at the day's last commit: a change made and undone the same day isn't seen. +- **The patch-it client can't place these events yet.** Their `version` is a date (`2026-06-29`), because the API has no version. The client's version check reads an `api_operation` version as a package version, so it needs the same rule for date-versioned API events that `cloudflare`'s need. + +## Supabase JavaScript client (`supabase/js-surface`) + +### What it watches + +The public API of the `@supabase/supabase-js` package on npm, release by release, read from its TypeScript declarations: exported names removed, class members removed, parameters removed, and parameters that are no longer optional. One `package_release` event per change. Every final release is listed from the npm registry (pre-releases and deprecated versions left out), and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the TypeScript declaration reader (`kinds/apisurface/dtsurface`). + +### Why this source + +- **Source:** the release tarballs on the npm registry (), each version's `dist.tarball`, read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the declarations in the tarball are exactly what TypeScript checks a customer's code against after `npm install @supabase/supabase-js@`, and what editors show JavaScript users. A published tarball never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md; the v2 migration guide. +- **Quote:** `getSubscriptions(): RealtimeSubscription[]` (`SupabaseClient`, `dist/module/SupabaseClient.d.ts` line 100) at 1.35.7, gone at 2.0.0. + +### How the provider announces changes + +- The client is small and wraps separate packages (`@supabase/auth-js`, `@supabase/postgrest-js`, …) whose APIs it re-exports wholesale. +- **Forced on upgrade**, for a repo whose lockfile reaches the release. + +### What the plugin reads and ignores + +- Reads `package.json` and the `.d.ts`, `.d.mts` and `.d.cts` files of each release's tarball from the npm registry, in memory, as text (`kinds/apisurface/dtsurface`): nothing in the package is run, no install script, no TypeScript compiler. The entry points are `package.json`'s `exports` (each subpath, wildcards matched against the files; for each, its `types` condition, else the `import` one), or its `types`/`typings`. +- For each entry point: every exported name (classes, functions, enums, variables, interfaces, type aliases, namespaces, and names re-exported from another package, by name only), and below a class or namespace what it holds: a class's public methods and properties, and its constructor's parameters; a namespace's classes, functions and namespaces. Symbols are named by the import path code writes: `@supabase/supabase-js.SupabaseClient.from`. +- Parameters compare by position, as TypeScript passes them: a parameter gone off the end (with no rest parameter now) is removed; one optional before and required now is a `changed_default`. A renamed parameter is no change. +- Ignores names marked `@internal`, `private` and `protected` members, `#private` fields, setters, index signatures, interface and object-type members, interfaces and type aliases inside a namespace (an entry point's own are read), entry points under a private path (`_shims`, `internal`, `src`), the `./index` duplicate of the root, and what the default export holds (it's the same declaration as a named one). +- One declaration reachable at several import paths is one event, every path in its `symbols`. +- Drops (and logs) a removal that may not be one: a member of a name now re-exported from another package, now a value, an interface or a type (whose members aren't read); a method gone from a class that extends a class of another package (it may define it); a name an entry point may still get from a package it re-exports wholesale (`export * from "other"`). + +### Known gaps + +- What a property's type holds isn't followed: `client.chat.completions.create` is read as the `Completions` class's `create`, reached through namespaces and entry points, not through the `chat` property's type. +- Type changes (a parameter's type narrowed, a return type changed, an interface's fields) aren't events. +- A package that re-exports another wholesale (`export * from "@scope/core"`) hides that package's API: it's a source of its own, or not read. +- Classes are indexed by name across files to follow a method to its base class: two classes of the same name (in two namespaces) are read as one, which can only turn a removal into a note, never add one. +- A parameter added without being optional is a note (the change-event contract has no subject for it yet). +- The packages it wraps are separate packages, not read by this source. + +## Supabase Python client (`supabase/python-surface`) + +### What it watches + +The public API of the `supabase` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. + +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). + +### Why this source + +- **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. +- **Why this one:** the wheel is exactly what `pip install supabase==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. +- **Alternatives considered:** CHANGELOG.md (release-please). +- **Quote:** `api: Optional[SyncGoTrueAPI] = None, replace_default_headers: bool = False,` in `SupabaseAuthClient.__init__` (`supabase/lib/auth_client.py`) at 0.7.1, gone at 1.0.0. + +### How the provider announces changes + +- The client is small (about a hundred public names) and wraps separate packages (postgrest, realtime, storage3, supabase_auth) whose own APIs aren't read here. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the `.py` and `.pyi` files under `supabase/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. +- Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). +- Drops (and logs): an overloaded function's parameters; a removed parameter when the function now takes `**kwargs`; a new parameter without a default (the change-event contract has no subject for it yet). +- A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. +- Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. + +### Known gaps + +- A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. +- A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. +- A module that star-imports from outside the package, or defines `__getattr__`, hides every removal from it: those are notes, not events. +- Type changes (an annotation narrowed, a return type changed) aren't events. +- The wheel read is the first one by file name (a `-none-any` wheel when there is one); a release whose platform wheels differ in their Python files is read from that one. +- The packages it wraps (`postgrest`, `supabase_auth`, …) are separate packages, not read by this source. diff --git a/providers/supabase/js_surface_test.go b/providers/supabase/js_surface_test.go new file mode 100644 index 0000000..06accf1 --- /dev/null +++ b/providers/supabase/js_surface_test.go @@ -0,0 +1,16 @@ +package supabase + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// @supabase/supabase-js 2.0.0 removed the v1 subscription methods. +func TestJSSurface(t *testing.T) { + apisurfacetest.NPM(t, apisurfacetest.Case{Package: JSSurface, Golden: [2]string{"1.35.7", "2.0.0"}, Want: []string{ + "removed_symbol SupabaseClient.getSubscriptions ", + "removed_symbol SupabaseClient.removeAllSubscriptions ", + "removed_symbol SupabaseClient.removeSubscription ", + }, Drop: [2]string{"2.118.0", "2.119.0"}}) +} diff --git a/providers/supabase/management_api.go b/providers/supabase/management_api.go new file mode 100644 index 0000000..6302322 --- /dev/null +++ b/providers/supabase/management_api.go @@ -0,0 +1,104 @@ +package supabase + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/patch-it-dev/patch-it-plugins/core/diff" + "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" +) + +// Variables, not constants, only so tests can point them at a local server. +var ( + // supabaseCommitsURL lists the commits that changed the Management API + // spec in supabase/supabase, newest first; with per_page=1, the newest. + supabaseCommitsURL = "https://api.github.com/repos/supabase/supabase/commits?path=apps/docs/spec/api_v1_openapi.json&per_page=1" + // supabaseCommitURL is one commit, for its date. + supabaseCommitURL = "https://api.github.com/repos/supabase/supabase/commits/%s" + // supabaseSpecURLTemplate is the Management API spec (api.supabase.com) + // at one commit. Supabase serves it live at + // https://api.supabase.com/api/v1-json, which has no versions; the docs + // copy in supabase/supabase is the same spec, committed when it changes + // (90 commits from 2024-05-31 to 2026-11-18), and a commit never changes. + supabaseSpecURLTemplate = "https://raw.githubusercontent.com/supabase/supabase/%s/apps/docs/spec/api_v1_openapi.json" +) + +// Supabase adapts the Supabase Management API spec in supabase/supabase for +// the openapi plugin. The repo tags no spec releases, so a tag here is the +// commit that last changed the spec. +type Supabase struct{} + +var _ adapter.Adapter = Supabase{} + +func (Supabase) API() string { return "supabase/management-api" } + +// LatestTag is the SHA of the newest commit that changed the spec. +func (Supabase) LatestTag(ctx context.Context) (string, error) { + sha, err := github.LatestCommit(ctx, github.Get, supabaseCommitsURL) + if err != nil { + return "", fmt.Errorf("looking up supabase's latest spec commit: %w", err) + } + return sha, nil +} + +// Fetch downloads the spec at commit sha. +// +// Version is the commit's date (YYYY-MM-DD): the Management API has no +// version of its own (`/v1`, info.version a fixed "1.0.0", checked +// 2026-11-19), so the date the spec changed is the closest thing to "the API +// version the change arrived in". +func (Supabase) Fetch(ctx context.Context, sha string) (adapter.Spec, error) { + fullSHA, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(supabaseCommitURL, sha)) + if err != nil { + return adapter.Spec{}, fmt.Errorf("looking up supabase spec commit %s: %w", sha, err) + } + if fullSHA == "" { + return adapter.Spec{}, fmt.Errorf("github commit %s has no sha or date", sha) + } + // Pin to the full SHA even when given a short one: the citation must + // name exactly one document. + url := fmt.Sprintf(supabaseSpecURLTemplate, fullSHA) + body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth + if err != nil { + return adapter.Spec{}, fmt.Errorf("fetching supabase spec %s: %w", sha, err) + } + if !json.Valid(body) { + return adapter.Spec{}, fmt.Errorf("supabase spec %s is not valid json", sha) + } + return adapter.Spec{Content: body, Version: date.UTC().Format("2006-01-02"), SourceURL: url}, nil +} + +// Versions are the commits that changed the Management API spec. +func (Supabase) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Commits(ctx, "supabase/supabase", "apps/docs/spec/api_v1_openapi.json") +} + +// supabaseDiff is how the Supabase Management API spec says what it says: +// +// - Deprecations use the `deprecated` flag, and the description sometimes +// says why ("This endpoint is deprecated - use the deploy endpoint."), so +// the event quotes the whole operation, not the bare `true`. +// - Path parameters get renamed, and that isn't a change for callers: +// /v1/branches/{branch_id}/merge became .../{branch_id_or_ref}/merge on +// 2025-09-11. +var supabaseDiff = diff.Options{PathTemplates: true, QuoteDeprecatedOperation: true} + +// supabaseKeep keeps operation deprecations, and removals of operations the +// old spec had marked deprecated. In the spec's history (90 commits, +// 2024-05-31 to 2026-11-18) that's 2 events: POST /v1/projects/{ref}/functions +// deprecated on 2025-02-19, GET /v1/projects/{ref}/analytics/endpoints/logs.all +// on 2026-06-29. Everything else is dropped: +// +// - 22 operations left the spec, none of them deprecated first: 14 +// analytics warehouse operations on 2024-07-15, 7 path-parameter renames +// (which PathTemplates pairs up anyway), and one that came back 12 +// days later. Without credentials every route answers 401, so whether a +// removed one still works can't be checked from outside. +// - Request and response property changes, new operations: not changes a +// caller has to fix, or not ones the spec's history shows reliably. +var supabaseKeep = openapi.DeprecationsOnly(supabaseDiff) diff --git a/plugins/openapi/adapter/supabase_test.go b/providers/supabase/management_api_fetch_test.go similarity index 74% rename from plugins/openapi/adapter/supabase_test.go rename to providers/supabase/management_api_fetch_test.go index 96ddea2..5500ac0 100644 --- a/plugins/openapi/adapter/supabase_test.go +++ b/providers/supabase/management_api_fetch_test.go @@ -1,11 +1,16 @@ -package adapter +package supabase import ( "context" + "fmt" "net/http" "net/http/httptest" "strings" "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" ) // fakeSupabaseGitHub serves the commits list, one commit, and specs by path. @@ -88,3 +93,29 @@ func TestSupabaseFetchFailures(t *testing.T) { } } } + +// The plugin lists the commits that changed the spec, through core/versions. +func TestSupabaseListsTheSpecsCommits(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/repos/supabase/supabase/commits" && r.URL.Query().Get("path") == "apps/docs/spec/api_v1_openapi.json" { + fmt.Fprint(w, `[{"sha":"b","commit":{"committer":{"date":"2026-02-01T00:00:00Z"}}},{"sha":"a","commit":{"committer":{"date":"2026-01-01T00:00:00Z"}}}]`) + return + } + http.NotFound(w, r) + })) + defer srv.Close() + old := versions.GitHubAPI + versions.GitHubAPI = srv.URL + defer func() { versions.GitHubAPI = old }() + vs, err := openapi.Plugin{Adapter: Supabase{}}.ListVersions(context.Background(), plugin.Env{}) + if err != nil { + t.Fatal(err) + } + var refs []string + for _, v := range vs { + refs = append(refs, v.Ref) + } + if strings.Join(refs, " ") != "a b" { + t.Errorf("refs %v, want a b", refs) + } +} diff --git a/plugins/openapi/supabase_test.go b/providers/supabase/management_api_test.go similarity index 85% rename from plugins/openapi/supabase_test.go rename to providers/supabase/management_api_test.go index 62604ad..96e5841 100644 --- a/plugins/openapi/supabase_test.go +++ b/providers/supabase/management_api_test.go @@ -1,4 +1,4 @@ -package openapi +package supabase import ( "context" @@ -9,7 +9,9 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // supabaseCommits are the spec commits saved under testdata/ (trimmed to the @@ -28,7 +30,7 @@ var supabaseCommits = map[string][2]string{ } // fakeSupabaseAdapter serves the saved copies, cited by the real URL each was -// copied from, as adapter.Supabase.Fetch cites it. +// copied from, as Supabase.Fetch cites it. type fakeSupabaseAdapter struct{ latest string } func (fakeSupabaseAdapter) API() string { return "supabase/management-api" } @@ -54,8 +56,8 @@ func supabaseURL(tag string) string { } // supabasePlugin is the plugin exactly as registered, over the saved copies. -func supabasePlugin(latest string) Plugin { - return Plugin{Adapter: fakeSupabaseAdapter{latest: latest}, Diff: supabaseDiff, Keep: supabaseKeep} +func supabasePlugin(latest string) openapi.Plugin { + return openapi.Plugin{Adapter: fakeSupabaseAdapter{latest: latest}, Diff: supabaseDiff, Keep: supabaseKeep} } // The golden test: the two operations Supabase deprecated in the @@ -68,8 +70,8 @@ func supabasePlugin(latest string) Plugin { // operation still in the spec: a change of words, which no diff sees.) func TestSupabaseGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - env := vercelEnv(s) + s := kittest.NewMem() + env := openapitest.Env(s) if rejected, err := kittest.Pair(ctx, env, s, supabasePlugin(""), "57d668c6", "bf04ff66"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } @@ -101,7 +103,7 @@ func TestSupabaseGolden(t *testing.T) { t.Errorf("%s: source_url %s, want %s", e.Subject.Operation, e.SourceURL, supabaseURL(tag)) } // The whole operation is quoted, so the reason is in the excerpt. - if node := jsonNode(t, supabaseFile(tag), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, supabaseFile(tag), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt doesn't match %s#%s", e.Subject.Operation, tag, e.SourcePointer) } if !strings.Contains(e.SourceExcerpt, `"deprecated":true`) { @@ -120,18 +122,18 @@ func TestSupabaseGolden(t *testing.T) { // be checked: no event. func TestSupabaseDropsRemovalsThatWerentDeprecated(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, supabasePlugin(""), "8aef4a08", "90b71e3e"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, supabasePlugin(""), "8aef4a08", "90b71e3e"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { t.Fatalf("stored %d events, want none", len(events)) } // Without the filter the same pair reports all 14 removals. - s = openStore(t) + s = kittest.NewMem() p := supabasePlugin("") p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "8aef4a08", "90b71e3e"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "8aef4a08", "90b71e3e"); err != nil { t.Fatal(err) } var removals int @@ -150,10 +152,10 @@ func TestSupabaseDropsRemovalsThatWerentDeprecated(t *testing.T) { // they'd read as removed. func TestSupabaseBranchParameterRenameIsNoChange(t *testing.T) { ctx := context.Background() - s := openStore(t) + s := kittest.NewMem() p := supabasePlugin("") p.Keep = nil // even unfiltered: the operations are paired, not removed - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "de806266", "a5fc0527"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "de806266", "a5fc0527"); err != nil { t.Fatal(err) } for _, e := range kittest.Stored(t, s) { @@ -161,9 +163,9 @@ func TestSupabaseBranchParameterRenameIsNoChange(t *testing.T) { t.Errorf("by template: %s", e.Description) } } - s = openStore(t) + s = kittest.NewMem() p.Diff.PathTemplates = false - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "de806266", "a5fc0527"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "de806266", "a5fc0527"); err != nil { t.Fatal(err) } var removed int diff --git a/providers/supabase/provider.go b/providers/supabase/provider.go new file mode 100644 index 0000000..d6916b3 --- /dev/null +++ b/providers/supabase/provider.go @@ -0,0 +1,34 @@ +// Package supabase is what patch-it reads for Supabase: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package supabase + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "supabase", Name: "Supabase", Category: plugin.CategoryDatabases, Homepage: "https://supabase.com", + Sources: []plugin.Source{ + // No Hints: Supabase's changelog is platform news, not keyed by + // operation. Only operation deprecations and removals: see management_api.go. + { + ID: "management-api", Layer: plugin.LayerAPI, + Watches: "Management API operations deprecated, and deprecated operations removed, between commits of the spec", + URLs: []string{"https://github.com/supabase/supabase"}, + Plugin: openapi.Plugin{Adapter: Supabase{}, Diff: supabaseDiff, Keep: supabaseKeep}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerSDK, "https://github.com/supabase/supabase-py"), + apisurface.NPM(JSSurface, "https://github.com/supabase/supabase-js"), + }, + }) +} + +// The packages whose public API the apisurface sources read. +var ( + JSSurface = apisurface.NPMPackage("supabase/js-surface", "@supabase/supabase-js") + PythonSurface = apisurface.Package{ID: "supabase/python-surface", Name: "supabase", Ecosystem: "pypi", Module: "supabase"} +) diff --git a/providers/supabase/python_surface_test.go b/providers/supabase/python_surface_test.go new file mode 100644 index 0000000..b15b970 --- /dev/null +++ b/providers/supabase/python_surface_test.go @@ -0,0 +1,19 @@ +package supabase + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// supabase 1.0.0's SupabaseAuthClient lost four parameters. 2.34.0 made +// supabase.client a star re-export of the package: still importable. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"0.7.1", "1.0.0"}, Want: []string{ + "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient api", + "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient cookie_options", + "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient local_storage", + "removed_parameter SupabaseAuthClient,lib.auth_client.SupabaseAuthClient replace_default_headers", + "removed_parameter lib.client_options.ClientOptions.replace local_storage", + }, Drop: [2]string{"2.33.0", "2.34.0"}}) +} diff --git a/providers/supabase/testdata/README.md b/providers/supabase/testdata/README.md new file mode 100644 index 0000000..e25eb3a --- /dev/null +++ b/providers/supabase/testdata/README.md @@ -0,0 +1,27 @@ +# Supabase: saved copies and goldens + +Real copies of what Supabase publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/supabase -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `supabase-57d668c6.json`, `supabase-bf04ff66.json` | https://raw.githubusercontent.com/supabase/supabase/57d668c6ce265d40cdc009ecadf8e3d80d17a310/apps/docs/spec/api_v1_openapi.json (and `bf04ff6681062bde3edf9d646054b9a8b2ef286c`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | "This endpoint is deprecated - use the deploy endpoint." (`POST /v1/projects/{ref}/functions`, new in `bf04ff66`) | +| `supabase-693bdc38.json`, `supabase-eb21ae25.json` | https://raw.githubusercontent.com/supabase/supabase/693bdc38d045353e5782f86febff4fddc82bb93a/apps/docs/spec/api_v1_openapi.json (and `eb21ae25f7954ea1e5db34209ff69fce597b0ae3`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `"deprecated": true` on `GET /v1/projects/{ref}/analytics/endpoints/logs.all` (new in `eb21ae25`) | +| `supabase-8aef4a08.json`, `supabase-90b71e3e.json` | https://raw.githubusercontent.com/supabase/supabase/8aef4a08bf56e1e0e1eb8af316f7f0b2bcfd2e88/apps/docs/spec/api_v1_openapi.json (and `90b71e3e42c5f933013e1a62acdc37c07e9378d7`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `/v1/projects/{ref}/analytics/warehouse/...` (14 operations in `8aef4a08`, none deprecated, all gone in `90b71e3e`): the drop test | +| `supabase-de806266.json`, `supabase-a5fc0527.json` | https://raw.githubusercontent.com/supabase/supabase/de806266717abddb08e285f9dd6d17ad7d262b34/apps/docs/spec/api_v1_openapi.json (and `a5fc0527045daaafd2a661146cac0b430adad20b`) | 2026-11-19 | Apache-2.0 (supabase/supabase) | `/v1/branches/{branch_id}` (in `de806266`), `/v1/branches/{branch_id_or_ref}` (in `a5fc0527`) | + +The Supabase copies keep each value unchanged but are re-indented: the source is Prettier-formatted (objects on one line where they fit), and minified on one line before 2025. + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/supabase/`: `supabase-0.7.1-py3-none-any.trimmed.whl`, `supabase-1.0.0-py3-none-any.trimmed.whl`, `supabase-2.33.0-py3-none-any.trimmed.whl`, `supabase-2.34.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/ea/1f/3aa8dd96fc0aab80693ff6c341b9178bd3eaacb81006703f3adf07719544/supabase-0.7.1-py3-none-any.whl; https://files.pythonhosted.org/packages/8d/7b/42e5e27e4c9f4f5e24c0d3294b7448948b97963c69d634c664b7beaaae4b/supabase-1.0.0-py3-none-any.whl; https://files.pythonhosted.org/packages/8d/48/1a8f57fdaf882f1dcd7836352e33829c1d455c6cfc387d2b0fb1e99ffdb6/supabase-2.33.0-py3-none-any.whl; https://files.pythonhosted.org/packages/18/20/48dc58aa9d3a0245694ef52433305edd4536f80ad3d30572d4658d160839/supabase-2.34.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `supabase/__init__.py`, `supabase/__version__.py`, `supabase/_async/__init__.py`, `supabase/_async/auth_client.py`, `supabase/_async/client.py`, `supabase/_sync/__init__.py`, `supabase/_sync/auth_client.py`, `supabase/_sync/client.py`, `supabase/client.py`, `supabase/lib/__init__.py`, `supabase/lib/auth_client.py`, `supabase/lib/client_options.py`, `supabase/lib/realtime_client.py`, `supabase/lib/storage_client.py`, `supabase/py.typed`, `supabase/types.py`, `supabase/version.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/supabase/`: `pypi-supabase-excerpt.json` and `pypi-supabase-0.7.1.json`, `pypi-supabase-1.0.0.json`, `pypi-supabase-2.33.0.json`, `pypi-supabase-2.34.0.json` | https://pypi.org/pypi/supabase/json, https://pypi.org/pypi/supabase/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | +| `npm/supabase-supabase-js/`: `supabase-js-1.35.7.trimmed.tgz`, `supabase-js-2.0.0.trimmed.tgz`, `supabase-js-2.118.0.trimmed.tgz`, `supabase-js-2.119.0.trimmed.tgz` | https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-1.35.7.tgz; https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.0.0.tgz; https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.118.0.tgz; https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.119.0.tgz | 2026-11-21 | MIT (the package's own license file is kept in each tarball). Trimmed: only `package.json`, the license and `dist/cors.d.cts`, `dist/cors.d.mts`, `dist/index.d.cts`, `dist/index.d.mts`, `dist/main/SupabaseClient.d.ts`, `dist/main/index.d.ts`, `dist/main/lib/SupabaseAuthClient.d.ts`, `dist/main/lib/SupabaseQueryBuilder.d.ts`, `dist/main/lib/SupabaseRealtimeClient.d.ts`, `dist/main/lib/constants.d.ts`, `dist/main/lib/fetch.d.ts`, `dist/main/lib/helpers.d.ts`, `dist/main/lib/types.d.ts`, `dist/main/lib/version.d.ts`, `dist/module/SupabaseClient.d.ts`, `dist/module/index.d.ts`, `dist/module/lib/SupabaseAuthClient.d.ts`, `dist/module/lib/SupabaseQueryBuilder.d.ts`, `dist/module/lib/SupabaseRealtimeClient.d.ts`, `dist/module/lib/constants.d.ts`, `dist/module/lib/fetch.d.ts`, `dist/module/lib/helpers.d.ts`, `dist/module/lib/types.d.ts`, `dist/module/lib/version.d.ts`, `dist/tracing.d.cts`, `dist/tracing.d.mts`, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `npm/supabase-supabase-js/`: `npm-supabase-supabase-js-excerpt.json` and `npm-supabase-supabase-js-1.35.7.json`, `npm-supabase-supabase-js-2.0.0.json`, `npm-supabase-supabase-js-2.118.0.json`, `npm-supabase-supabase-js-2.119.0.json` | https://registry.npmjs.org/@supabase%2Fsupabase-js, …/<version> | 2026-11-21 | npm registry metadata. Trimmed: `versions` to the saved versions (name and version only) and their `time`; each version's document to `name`, `version`, `dist.tarball` | | diff --git a/plugins/apisurface/testdata/golden/supabase-js-surface.json b/providers/supabase/testdata/golden/supabase-js-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/supabase-js-surface.json rename to providers/supabase/testdata/golden/supabase-js-surface.json diff --git a/plugins/apisurface/testdata/golden/supabase-python-surface.json b/providers/supabase/testdata/golden/supabase-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/supabase-python-surface.json rename to providers/supabase/testdata/golden/supabase-python-surface.json diff --git a/plugins/openapi/testdata/golden/supabase.json b/providers/supabase/testdata/golden/supabase.json similarity index 100% rename from plugins/openapi/testdata/golden/supabase.json rename to providers/supabase/testdata/golden/supabase.json diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-1.35.7.json b/providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-1.35.7.json similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-1.35.7.json rename to providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-1.35.7.json diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.0.0.json b/providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.0.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.0.0.json rename to providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.0.0.json diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.118.0.json b/providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.118.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.118.0.json rename to providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.118.0.json diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.119.0.json b/providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.119.0.json similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.119.0.json rename to providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-2.119.0.json diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-excerpt.json b/providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-excerpt.json rename to providers/supabase/testdata/npm/supabase-supabase-js/npm-supabase-supabase-js-excerpt.json diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-1.35.7.trimmed.tgz b/providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-1.35.7.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-1.35.7.trimmed.tgz rename to providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-1.35.7.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-2.0.0.trimmed.tgz b/providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-2.0.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-2.0.0.trimmed.tgz rename to providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-2.0.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-2.118.0.trimmed.tgz b/providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-2.118.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-2.118.0.trimmed.tgz rename to providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-2.118.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-2.119.0.trimmed.tgz b/providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-2.119.0.trimmed.tgz similarity index 100% rename from plugins/apisurface/testdata/npm/supabase-supabase-js/supabase-js-2.119.0.trimmed.tgz rename to providers/supabase/testdata/npm/supabase-supabase-js/supabase-js-2.119.0.trimmed.tgz diff --git a/plugins/apisurface/testdata/pypi/supabase/pypi-supabase-0.7.1.json b/providers/supabase/testdata/pypi/supabase/pypi-supabase-0.7.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/pypi-supabase-0.7.1.json rename to providers/supabase/testdata/pypi/supabase/pypi-supabase-0.7.1.json diff --git a/plugins/apisurface/testdata/pypi/supabase/pypi-supabase-1.0.0.json b/providers/supabase/testdata/pypi/supabase/pypi-supabase-1.0.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/pypi-supabase-1.0.0.json rename to providers/supabase/testdata/pypi/supabase/pypi-supabase-1.0.0.json diff --git a/plugins/apisurface/testdata/pypi/supabase/pypi-supabase-2.33.0.json b/providers/supabase/testdata/pypi/supabase/pypi-supabase-2.33.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/pypi-supabase-2.33.0.json rename to providers/supabase/testdata/pypi/supabase/pypi-supabase-2.33.0.json diff --git a/plugins/apisurface/testdata/pypi/supabase/pypi-supabase-2.34.0.json b/providers/supabase/testdata/pypi/supabase/pypi-supabase-2.34.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/pypi-supabase-2.34.0.json rename to providers/supabase/testdata/pypi/supabase/pypi-supabase-2.34.0.json diff --git a/plugins/apisurface/testdata/pypi/supabase/pypi-supabase-excerpt.json b/providers/supabase/testdata/pypi/supabase/pypi-supabase-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/pypi-supabase-excerpt.json rename to providers/supabase/testdata/pypi/supabase/pypi-supabase-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/supabase/supabase-0.7.1-py3-none-any.trimmed.whl b/providers/supabase/testdata/pypi/supabase/supabase-0.7.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/supabase-0.7.1-py3-none-any.trimmed.whl rename to providers/supabase/testdata/pypi/supabase/supabase-0.7.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/supabase/supabase-1.0.0-py3-none-any.trimmed.whl b/providers/supabase/testdata/pypi/supabase/supabase-1.0.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/supabase-1.0.0-py3-none-any.trimmed.whl rename to providers/supabase/testdata/pypi/supabase/supabase-1.0.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/supabase/supabase-2.33.0-py3-none-any.trimmed.whl b/providers/supabase/testdata/pypi/supabase/supabase-2.33.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/supabase-2.33.0-py3-none-any.trimmed.whl rename to providers/supabase/testdata/pypi/supabase/supabase-2.33.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/supabase/supabase-2.34.0-py3-none-any.trimmed.whl b/providers/supabase/testdata/pypi/supabase/supabase-2.34.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/supabase/supabase-2.34.0-py3-none-any.trimmed.whl rename to providers/supabase/testdata/pypi/supabase/supabase-2.34.0-py3-none-any.trimmed.whl diff --git a/plugins/openapi/testdata/supabase-57d668c6.json b/providers/supabase/testdata/supabase-57d668c6.json similarity index 100% rename from plugins/openapi/testdata/supabase-57d668c6.json rename to providers/supabase/testdata/supabase-57d668c6.json diff --git a/plugins/openapi/testdata/supabase-693bdc38.json b/providers/supabase/testdata/supabase-693bdc38.json similarity index 100% rename from plugins/openapi/testdata/supabase-693bdc38.json rename to providers/supabase/testdata/supabase-693bdc38.json diff --git a/plugins/openapi/testdata/supabase-8aef4a08.json b/providers/supabase/testdata/supabase-8aef4a08.json similarity index 100% rename from plugins/openapi/testdata/supabase-8aef4a08.json rename to providers/supabase/testdata/supabase-8aef4a08.json diff --git a/plugins/openapi/testdata/supabase-90b71e3e.json b/providers/supabase/testdata/supabase-90b71e3e.json similarity index 100% rename from plugins/openapi/testdata/supabase-90b71e3e.json rename to providers/supabase/testdata/supabase-90b71e3e.json diff --git a/plugins/openapi/testdata/supabase-a5fc0527.json b/providers/supabase/testdata/supabase-a5fc0527.json similarity index 100% rename from plugins/openapi/testdata/supabase-a5fc0527.json rename to providers/supabase/testdata/supabase-a5fc0527.json diff --git a/plugins/openapi/testdata/supabase-bf04ff66.json b/providers/supabase/testdata/supabase-bf04ff66.json similarity index 100% rename from plugins/openapi/testdata/supabase-bf04ff66.json rename to providers/supabase/testdata/supabase-bf04ff66.json diff --git a/plugins/openapi/testdata/supabase-de806266.json b/providers/supabase/testdata/supabase-de806266.json similarity index 100% rename from plugins/openapi/testdata/supabase-de806266.json rename to providers/supabase/testdata/supabase-de806266.json diff --git a/plugins/openapi/testdata/supabase-eb21ae25.json b/providers/supabase/testdata/supabase-eb21ae25.json similarity index 100% rename from plugins/openapi/testdata/supabase-eb21ae25.json rename to providers/supabase/testdata/supabase-eb21ae25.json diff --git a/providers/textual.md b/providers/textual.md deleted file mode 100644 index 602855e..0000000 --- a/providers/textual.md +++ /dev/null @@ -1,30 +0,0 @@ -# Textual (`textual/textual`) - -## What it watches - -Removals and breaking changes in each Textual release, read from that release's section of its changelog: symbols removed (`App.dark`, …) or renamed. One `package_release` event per changelog bullet the plugin can read with certainty. The releases are listed from PyPI (final releases only) and each is read at its tag (`v`); 0.86.0 is the release the golden test pins. - -Kind: `changelog` (`plugins/changelog`). - -## Why this source - -- **Source:** [CHANGELOG.md at v0.86.0](https://github.com/Textualize/textual/blob/v0.86.0/CHANGELOG.md), read raw at the tag (`https://raw.githubusercontent.com/Textualize/textual/v0.86.0/CHANGELOG.md`). Checked on 2026-11-14. -- **Why this one:** it's the maintainers' own changelog in the [Keep a Changelog](https://keepachangelog.com) format, with `Removed` and `Changed` sections and explicit "Breaking change:" bullets. At a tag it never changes, so the URL is its own citation. -- **Alternatives considered:** GitHub release notes (the same text, but editable after the fact and not in one file); the docs site's changelog page (rendered from this file); diffing the package's code (finds removals but not the maintainers' wording or intent). -- **Quote:** "Breaking change: Removed `App.dark` reactive attribute" (0.86.0, Changed). - -## How the provider announces changes - -- Textual is pre-1.0 and releases often; breaking changes can land in any minor release and are marked in the changelog. -- **Forced on upgrade**, for a repo whose pin reaches the release. - -## What the plugin reads and ignores - -- Reads the release's section only; a release missing from the file is an error. -- An event needs a bullet whose first sentence is one plain template over code spans: `Removed X`, `Removed the X method from Y`, `Renamed X to Y`, `X property removed`, `Deprecated X in favor of Y`, or a bare name under `Removed`. Any bullet starting "Breaking change:" counts as breaking. -- Drops (and logs) everything else: behavior changes, signature changes, removed options and parameters (of which call?), dropped Python versions. 2 events from 0.86.0. - -## Known gaps - -- A release is read at its tag; one whose tag or changelog section is missing fails that pair, it isn't guessed. -- Breaking behavior changes written as prose aren't events. diff --git a/providers/textual-python-surface.md b/providers/textual/README.md similarity index 54% rename from providers/textual-python-surface.md rename to providers/textual/README.md index bf71cac..7dc98f8 100644 --- a/providers/textual-python-surface.md +++ b/providers/textual/README.md @@ -1,24 +1,59 @@ -# Textual (`textual/python-surface`) +# Textual -## What it watches +Every source patch-it reads for Textual, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Textual changelog (`textual/textual`) + +### What it watches + +Removals and breaking changes in each Textual release, read from that release's section of its changelog: symbols removed (`App.dark`, …) or renamed. One `package_release` event per changelog bullet the plugin can read with certainty. The releases are listed from PyPI (final releases only) and each is read at its tag (`v`); 0.86.0 is the release the golden test pins. + +Kind: `changelog` (`kinds/changelog`). + +### Why this source + +- **Source:** [CHANGELOG.md at v0.86.0](https://github.com/Textualize/textual/blob/v0.86.0/CHANGELOG.md), read raw at the tag (`https://raw.githubusercontent.com/Textualize/textual/v0.86.0/CHANGELOG.md`). Checked on 2026-11-14. +- **Why this one:** it's the maintainers' own changelog in the [Keep a Changelog](https://keepachangelog.com) format, with `Removed` and `Changed` sections and explicit "Breaking change:" bullets. At a tag it never changes, so the URL is its own citation. +- **Alternatives considered:** GitHub release notes (the same text, but editable after the fact and not in one file); the docs site's changelog page (rendered from this file); diffing the package's code (finds removals but not the maintainers' wording or intent). +- **Quote:** "Breaking change: Removed `App.dark` reactive attribute" (0.86.0, Changed). + +### How the provider announces changes + +- Textual is pre-1.0 and releases often; breaking changes can land in any minor release and are marked in the changelog. +- **Forced on upgrade**, for a repo whose pin reaches the release. + +### What the plugin reads and ignores + +- Reads the release's section only; a release missing from the file is an error. +- An event needs a bullet whose first sentence is one plain template over code spans: `Removed X`, `Removed the X method from Y`, `Renamed X to Y`, `X property removed`, `Deprecated X in favor of Y`, or a bare name under `Removed`. Any bullet starting "Breaking change:" counts as breaking. +- Drops (and logs) everything else: behavior changes, signature changes, removed options and parameters (of which call?), dropped Python versions. 2 events from 0.86.0. + +### Known gaps + +- A release is read at its tag; one whose tag or changelog section is missing fails that pair, it isn't guessed. +- Breaking behavior changes written as prose aren't events. + +## Textual's public API (`textual/python-surface`) + +### What it watches The public API of the `textual` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). -## Why this source +### Why this source - **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. - **Why this one:** the wheel is exactly what `pip install textual==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. - **Alternatives considered:** CHANGELOG.md (read by `textual/textual`, kind `changelog`). - **Quote:** `def walk_selectable_widgets( root: DOMNode, bounds: Shape, bounded: set[DOMNode] ) -> Iterable[Widget]` (`textual/walk.py` line 176) at 8.2.5; the third parameter is `containers` at 8.2.6. -## How the provider announces changes +### How the provider announces changes - Textual releases often and changes public helpers in patch releases; its changelog (the `textual/textual` source) says so in prose. - **Forced on upgrade**, for a repo whose pin reaches the release. -## What the plugin reads and ignores +### What the plugin reads and ignores - Reads the `.py` and `.pyi` files under `textual/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. - Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). @@ -26,7 +61,7 @@ Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apis - A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. - Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. -## Known gaps +### Known gaps - A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. - A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. diff --git a/providers/textual/provider.go b/providers/textual/provider.go new file mode 100644 index 0000000..bd6733a --- /dev/null +++ b/providers/textual/provider.go @@ -0,0 +1,39 @@ +// Package textual is what patch-it reads for Textual: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package textual + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "textual", Name: "Textual", Category: plugin.CategoryPackages, Homepage: "https://textual.textualize.io", + Sources: []plugin.Source{ + { + ID: "textual", Layer: plugin.LayerPackage, + Watches: "Names removed, renamed or deprecated in each release, from the release's section of CHANGELOG.md at its tag", + URLs: []string{"https://github.com/Textualize/textual/blob/main/CHANGELOG.md", "https://pypi.org/project/textual/"}, + Packages: []string{"pypi:textual"}, + Plugin: changelog.Plugin{File: Textual}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerPackage, "https://github.com/Textualize/textual"), + }, + }) +} + +// Textual is Textual's Keep a Changelog CHANGELOG.md (checked 2026-11-14 at +// v0.86.0: "## [0.86.0] - 2024-11-16", "### Removed", and "Breaking change:" +// bullets under "### Changed"), tagged v. +var Textual = changelog.File{ + API: "textual/textual", Package: "textual", Ecosystem: "pypi", Module: "textual", + Repo: "Textualize/textual", TagPrefix: "v", Path: "CHANGELOG.md", +} + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "textual/python-surface", Name: "textual", Ecosystem: "pypi", Module: "textual"} +) diff --git a/providers/textual/python_surface_test.go b/providers/textual/python_surface_test.go new file mode 100644 index 0000000..b6390ed --- /dev/null +++ b/providers/textual/python_surface_test.go @@ -0,0 +1,12 @@ +package textual + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// textual 8.2.6's walk_selectable_widgets no longer takes bounded. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"8.2.5", "8.2.6"}, Want: []string{"removed_parameter walk.walk_selectable_widgets bounded"}, Drop: [2]string{"8.2.6", "8.2.7"}}) +} diff --git a/providers/textual/testdata/README.md b/providers/textual/testdata/README.md new file mode 100644 index 0000000..5c2e21b --- /dev/null +++ b/providers/textual/testdata/README.md @@ -0,0 +1,20 @@ +# Textual: saved copies and goldens + +Real copies of what Textual publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/textual -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/textual/`: `textual-8.2.5-py3-none-any.trimmed.whl`, `textual-8.2.6-py3-none-any.trimmed.whl`, `textual-8.2.7-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/cd/01/c4555f9c8a692ff83d84930150540f743ce94c89234f9e9a15ff4baba3a8/textual-8.2.5-py3-none-any.whl; https://files.pythonhosted.org/packages/b8/b4/c2b876f445e52522824cb900f2c7db3a7c24f89d20449ef278b4195d0ecb/textual-8.2.6-py3-none-any.whl; https://files.pythonhosted.org/packages/a8/f5/c1e18bc0707300a0e90204343abbf7d7acd6fb7ebe03a6d4893b99a234b8/textual-8.2.7-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `textual/walk.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/textual/`: `pypi-textual-excerpt.json` and `pypi-textual-8.2.5.json`, `pypi-textual-8.2.6.json`, `pypi-textual-8.2.7.json` | https://pypi.org/pypi/textual/json, https://pypi.org/pypi/textual/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | + +## Saved changelogs + +Real copies, saved once with `curl` from the release tag and never edited unless said. + +| File | URL | Tag commit | Saved | License | Quote | +|---|---|---|---|---|---| +| `textual-v0.86.0-CHANGELOG.md` | https://raw.githubusercontent.com/Textualize/textual/v0.86.0/CHANGELOG.md | `5a738fa` | 2026-11-14 08:36 UTC | MIT (Textual), kept whole | "Breaking change: Removed `App.dark` reactive attribute" | diff --git a/plugins/changelog/testdata/golden/textual-0.86.0.json b/providers/textual/testdata/golden/textual-0.86.0.json similarity index 100% rename from plugins/changelog/testdata/golden/textual-0.86.0.json rename to providers/textual/testdata/golden/textual-0.86.0.json diff --git a/plugins/apisurface/testdata/golden/textual-python-surface.json b/providers/textual/testdata/golden/textual-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/textual-python-surface.json rename to providers/textual/testdata/golden/textual-python-surface.json diff --git a/plugins/apisurface/testdata/pypi/textual/pypi-textual-8.2.5.json b/providers/textual/testdata/pypi/textual/pypi-textual-8.2.5.json similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/pypi-textual-8.2.5.json rename to providers/textual/testdata/pypi/textual/pypi-textual-8.2.5.json diff --git a/plugins/apisurface/testdata/pypi/textual/pypi-textual-8.2.6.json b/providers/textual/testdata/pypi/textual/pypi-textual-8.2.6.json similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/pypi-textual-8.2.6.json rename to providers/textual/testdata/pypi/textual/pypi-textual-8.2.6.json diff --git a/plugins/apisurface/testdata/pypi/textual/pypi-textual-8.2.7.json b/providers/textual/testdata/pypi/textual/pypi-textual-8.2.7.json similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/pypi-textual-8.2.7.json rename to providers/textual/testdata/pypi/textual/pypi-textual-8.2.7.json diff --git a/plugins/apisurface/testdata/pypi/textual/pypi-textual-excerpt.json b/providers/textual/testdata/pypi/textual/pypi-textual-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/pypi-textual-excerpt.json rename to providers/textual/testdata/pypi/textual/pypi-textual-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/textual/textual-8.2.5-py3-none-any.trimmed.whl b/providers/textual/testdata/pypi/textual/textual-8.2.5-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/textual-8.2.5-py3-none-any.trimmed.whl rename to providers/textual/testdata/pypi/textual/textual-8.2.5-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/textual/textual-8.2.6-py3-none-any.trimmed.whl b/providers/textual/testdata/pypi/textual/textual-8.2.6-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/textual-8.2.6-py3-none-any.trimmed.whl rename to providers/textual/testdata/pypi/textual/textual-8.2.6-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/textual/textual-8.2.7-py3-none-any.trimmed.whl b/providers/textual/testdata/pypi/textual/textual-8.2.7-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/textual/textual-8.2.7-py3-none-any.trimmed.whl rename to providers/textual/testdata/pypi/textual/textual-8.2.7-py3-none-any.trimmed.whl diff --git a/plugins/changelog/testdata/textual-v0.86.0-CHANGELOG.md b/providers/textual/testdata/textual-v0.86.0-CHANGELOG.md similarity index 100% rename from plugins/changelog/testdata/textual-v0.86.0-CHANGELOG.md rename to providers/textual/testdata/textual-v0.86.0-CHANGELOG.md diff --git a/providers/textual/textual_test.go b/providers/textual/textual_test.go new file mode 100644 index 0000000..53b4c61 --- /dev/null +++ b/providers/textual/textual_test.go @@ -0,0 +1,64 @@ +package textual + +import ( + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" +) + +// The real changelog at a release tag (testdata/README.md) in, every +// event out: the pair from the release before (on PyPI) to the pinned one. +func TestTextualGolden(t *testing.T) { + for _, c := range []struct { + file changelog.File + saved string + previous string + }{ + {Textual.At("0.86.0"), "testdata/textual-v0.86.0-CHANGELOG.md", "0.85.2"}, + } { + t.Run(c.file.Package, func(t *testing.T) { + got := changelogtest.Release(t, c.file, c.saved, c.previous) + kittest.Golden(t, "testdata/golden/"+c.file.Package+"-"+c.file.Release+".json", got) + }) + } +} + +// Every bullet of each release that is breaking or a deprecation but isn't +// plain enough is dropped, not guessed: pinned here with why. +func TestTextualUnsureBulletsAreDropped(t *testing.T) { + for _, c := range []struct { + file changelog.File + saved string + dropped []string // the start of each dropped bullet, in order + }{ + {Textual.At("0.86.0"), "testdata/textual-v0.86.0-CHANGELOG.md", []string{ + "Breaking change: To improve consistency", // a look change, no names + }}, + } { + _, fs, err := c.file.Read(kittest.Read(t, c.saved)) + if err != nil { + t.Fatal(err) + } + var drops []changelog.Finding + for _, f := range fs { + if f.Dropped != "" { + drops = append(drops, f) + } + } + if len(drops) != len(c.dropped) { + for _, d := range drops { + t.Logf("dropped %q: %s", d.Bullet.Text, d.Dropped) + } + t.Errorf("%s: dropped %d, want %d", c.file.Package, len(drops), len(c.dropped)) + continue + } + for i, want := range c.dropped { + if !strings.HasPrefix(drops[i].Bullet.Text, want) { + t.Errorf("%s: drop %d is %q, want %q…", c.file.Package, i, drops[i].Bullet.Text, want) + } + } + } +} diff --git a/providers/urllib3.md b/providers/urllib3.md deleted file mode 100644 index 7ba3bcc..0000000 --- a/providers/urllib3.md +++ /dev/null @@ -1,30 +0,0 @@ -# urllib3 (`urllib3/urllib3`) - -## What it watches - -Removals and deprecations in each urllib3 release, read from that release's section of its changelog: classes, methods and modules removed or renamed. One `package_release` event per bullet the plugin can read with certainty. The releases are listed from PyPI (final releases only) and each is read at its git tag (``); 2.0.0 is the release the golden test pins. - -Kind: `changelog` (`plugins/changelog`). - -## Why this source - -- **Source:** [CHANGES.rst at 2.0.0](https://github.com/urllib3/urllib3/blob/2.0.0/CHANGES.rst), read raw at the tag (`https://raw.githubusercontent.com/urllib3/urllib3/2.0.0/CHANGES.rst`). Checked on 2026-11-14. -- **Why this one:** it's the maintainers' own changelog, with a "Removed" and a "Deprecated" section per release, each bullet linking its issue. At a tag it never changes. -- **Alternatives considered:** the [v2 migration guide](https://urllib3.readthedocs.io/en/stable/v2-migration-guide.html) (prose and examples, harder to read deterministically); GitHub release notes (same content as the changelog); diffing the package's code. -- **Quote:** "Removed ``urllib3.HTTPResponse.from_httplib``" (2.0.0, Removed). - -## How the provider announces changes - -- Semantic versions; 2.0.0 (2023-04-26) was the major release that removed long-deprecated APIs. -- **Forced on a fresh install** for an unpinned `urllib3`, which many packages pull in indirectly. - -## What the plugin reads and ignores - -- reStructuredText titles: release and section levels are told apart by their underline character. -- Same bullet templates as [`textual`](textual.md). A name the same release's "Added" section adds back isn't reported as removed: 2.0.0 removed the `urllib3.request` module and added a `urllib3.request()` function. -- Drops (and logs) dropped Python and OpenSSL versions and behavior changes. 12 events from 2.0.0. - -## Known gaps - -- A release is read at its tag; one whose tag or changelog section is missing fails that pair, it isn't guessed. -- Changed defaults (TLS versions, retries) are behavior changes and aren't events. diff --git a/providers/urllib3-python-surface.md b/providers/urllib3/README.md similarity index 55% rename from providers/urllib3-python-surface.md rename to providers/urllib3/README.md index 365cc20..3d2fca3 100644 --- a/providers/urllib3-python-surface.md +++ b/providers/urllib3/README.md @@ -1,24 +1,59 @@ -# urllib3 (`urllib3/python-surface`) +# urllib3 -## What it watches +Every source patch-it reads for urllib3, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## urllib3 changelog (`urllib3/urllib3`) + +### What it watches + +Removals and deprecations in each urllib3 release, read from that release's section of its changelog: classes, methods and modules removed or renamed. One `package_release` event per bullet the plugin can read with certainty. The releases are listed from PyPI (final releases only) and each is read at its git tag (``); 2.0.0 is the release the golden test pins. + +Kind: `changelog` (`kinds/changelog`). + +### Why this source + +- **Source:** [CHANGES.rst at 2.0.0](https://github.com/urllib3/urllib3/blob/2.0.0/CHANGES.rst), read raw at the tag (`https://raw.githubusercontent.com/urllib3/urllib3/2.0.0/CHANGES.rst`). Checked on 2026-11-14. +- **Why this one:** it's the maintainers' own changelog, with a "Removed" and a "Deprecated" section per release, each bullet linking its issue. At a tag it never changes. +- **Alternatives considered:** the [v2 migration guide](https://urllib3.readthedocs.io/en/stable/v2-migration-guide.html) (prose and examples, harder to read deterministically); GitHub release notes (same content as the changelog); diffing the package's code. +- **Quote:** "Removed ``urllib3.HTTPResponse.from_httplib``" (2.0.0, Removed). + +### How the provider announces changes + +- Semantic versions; 2.0.0 (2023-04-26) was the major release that removed long-deprecated APIs. +- **Forced on a fresh install** for an unpinned `urllib3`, which many packages pull in indirectly. + +### What the plugin reads and ignores + +- reStructuredText titles: release and section levels are told apart by their underline character. +- Same bullet templates as [`textual/textual`](../textual/README.md#textual-changelog-textualtextual). A name the same release's "Added" section adds back isn't reported as removed: 2.0.0 removed the `urllib3.request` module and added a `urllib3.request()` function. +- Drops (and logs) dropped Python and OpenSSL versions and behavior changes. 12 events from 2.0.0. + +### Known gaps + +- A release is read at its tag; one whose tag or changelog section is missing fails that pair, it isn't guessed. +- Changed defaults (TLS versions, retries) are behavior changes and aren't events. + +## urllib3's public API (`urllib3/python-surface`) + +### What it watches The public API of the `urllib3` package on PyPI, release by release: classes, functions and methods removed or renamed, parameters removed, and parameters that lost their default (callers must now pass them). One `package_release` event per change. Every final release is listed from PyPI, and each consecutive pair is compared. -Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apisurface/pysurface`). +Kind: `apisurface` (`kinds/apisurface`), with the Python reader (`kinds/apisurface/pysurface`). -## Why this source +### Why this source - **Source:** the release files on PyPI (), each release's wheel read as published; the code is at . Checked on 2026-11-21. - **Why this one:** the wheel is exactly what `pip install urllib3==` installs, so its public names and signatures are what a customer's code calls. A published file never changes, so its URL is its own citation, and the line quoted is in it. - **Alternatives considered:** CHANGES.rst (read by `urllib3/urllib3`, kind `changelog`). - **Quote:** `def getheader(self, name: str, default: str | None = None) -> str | None` (`BaseHTTPResponse`, `urllib3/response.py` line 552) at 2.5.0, gone at 2.6.0, deprecated since 2.0. -## How the provider announces changes +### How the provider announces changes - Urllib3 deprecates for a major and removes in a later minor. - **Forced on upgrade**, for a repo whose pin reaches the release. -## What the plugin reads and ignores +### What the plugin reads and ignores - Reads the `.py` and `.pyi` files under `urllib3/` in the release's wheel (or, when a release has none, its sdist) as text, never importing or running them: module-level classes and functions, the methods of module-level classes, their parameters and defaults, `__all__`, an `__init__`'s re-exports from its own modules, and star imports. A `.pyi` stub is read instead of the `.py` beside it. - Ignores private names: a leading underscore, a module under a private one or under one named `internal` or `vendor`, a name left out of `__all__`, and tests. Also classes nested in classes, a property's parameters (and its setter), and `self`/`cls` (callers never pass them). @@ -26,7 +61,7 @@ Kind: `apisurface` (`plugins/apisurface`), with the Python reader (`plugins/apis - A removal is a rename only when the same scope loses one and gains one of the same kind with identical parameters, at least one of them besides `self`/`cls`; anything less sure is a removal. - Drops (and logs) a removal that may not be one: a name its module still binds in the newer release (an alias such as `DeadlineExceededError = GatewayTimeoutError`, an import from a private module, a star import from outside the package, a module-level `__getattr__` that hands out old names); a symbol whose file the newer release has too big to read (`MaxFileBytes`); a method whose class is still there but whose bases changed, which one of its bases now defines, or which the class now defines as an attribute. -## Known gaps +### Known gaps - A positional parameter renamed reads as the old one removed: a call that passes it by keyword breaks, one that passes it by position doesn't. - A class with no `__init__` of its own (generated pydantic or dataclass-like types) has no parameters to compare, so its rename reads as a removal of the old name, and its fields aren't compared. diff --git a/providers/urllib3/provider.go b/providers/urllib3/provider.go new file mode 100644 index 0000000..c35d83f --- /dev/null +++ b/providers/urllib3/provider.go @@ -0,0 +1,39 @@ +// Package urllib3 is what patch-it reads for urllib3: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package urllib3 + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "urllib3", Name: "urllib3", Category: plugin.CategoryPackages, Homepage: "https://urllib3.readthedocs.io", + Sources: []plugin.Source{ + { + ID: "urllib3", Layer: plugin.LayerPackage, + Watches: "Names removed or deprecated in each release, from the release's section of CHANGES.rst at its tag", + URLs: []string{"https://github.com/urllib3/urllib3/blob/main/CHANGES.rst", "https://pypi.org/project/urllib3/"}, + Packages: []string{"pypi:urllib3"}, + Plugin: changelog.Plugin{File: Urllib3}, + }, + apisurface.PyPI(PythonSurface, plugin.LayerPackage, "https://github.com/urllib3/urllib3"), + }, + }) +} + +// Urllib3 is urllib3's CHANGES.rst (checked 2026-11-14 at 2.0.0: "2.0.0 +// (2023-04-26)" over "=====", "Removed" and "Deprecated" over "-----"), +// tagged . +var Urllib3 = changelog.File{ + API: "urllib3/urllib3", Package: "urllib3", Ecosystem: "pypi", Module: "urllib3", + Repo: "urllib3/urllib3", Path: "CHANGES.rst", +} + +// The packages whose public API the apisurface sources read. +var ( + PythonSurface = apisurface.Package{ID: "urllib3/python-surface", Name: "urllib3", Ecosystem: "pypi", Module: "urllib3"} +) diff --git a/providers/urllib3/python_surface_test.go b/providers/urllib3/python_surface_test.go new file mode 100644 index 0000000..1808b4a --- /dev/null +++ b/providers/urllib3/python_surface_test.go @@ -0,0 +1,16 @@ +package urllib3 + +import ( + "testing" + + "github.com/patch-it-dev/patch-it-plugins/kinds/apisurface/apisurfacetest" +) + +// urllib3 2.6.0 removed BaseHTTPResponse.getheader and getheaders, +// deprecated since 2.0. +func TestPythonSurface(t *testing.T) { + apisurfacetest.PyPI(t, apisurfacetest.Case{Package: PythonSurface, Golden: [2]string{"2.5.0", "2.6.0"}, Want: []string{ + "removed_symbol BaseHTTPResponse.getheader,response.BaseHTTPResponse.getheader ", + "removed_symbol BaseHTTPResponse.getheaders,response.BaseHTTPResponse.getheaders ", + }, Drop: [2]string{"2.2.1", "2.2.2"}}) +} diff --git a/providers/urllib3/testdata/README.md b/providers/urllib3/testdata/README.md new file mode 100644 index 0000000..bd1e8c0 --- /dev/null +++ b/providers/urllib3/testdata/README.md @@ -0,0 +1,26 @@ +# urllib3: saved copies and goldens + +Real copies of what urllib3 publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/urllib3 -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved releases + +Each golden file, `golden/-.json`, is what the `apisurface` kind stores from the source's golden pair, read from `pypi//` or `npm//`. + +| File | URL | Saved | License | Quote | +|---|---|---|---|---| +| `pypi/urllib3/`: `urllib3-2.2.1-py3-none-any.trimmed.whl`, `urllib3-2.2.2-py3-none-any.trimmed.whl`, `urllib3-2.5.0-py3-none-any.trimmed.whl`, `urllib3-2.6.0-py3-none-any.trimmed.whl` | https://files.pythonhosted.org/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl; https://files.pythonhosted.org/packages/ca/1c/89ffc63a9605b583d5df2be791a27bc1a42b7c32bab68d3c8f2f73a98cd4/urllib3-2.2.2-py3-none-any.whl; https://files.pythonhosted.org/packages/a7/c2/fe1e52489ae3122415c51f387e221dd0773709bad6c6cdaa599e8a2c5185/urllib3-2.5.0-py3-none-any.whl; https://files.pythonhosted.org/packages/56/1a/9ffe814d317c5224166b23e7c47f606d6e473712a2fad0f704ea9b99f246/urllib3-2.6.0-py3-none-any.whl | 2026-11-21 | MIT (the wheel's own license files are kept in it). Trimmed: only `urllib3/__init__.py`, `urllib3/response.py` and the dist-info `METADATA`, `WHEEL` and license files, each copied byte for byte | see the source's section of [`../README.md`](../README.md) | +| `pypi/urllib3/`: `pypi-urllib3-excerpt.json` and `pypi-urllib3-2.2.1.json`, `pypi-urllib3-2.2.2.json`, `pypi-urllib3-2.5.0.json`, `pypi-urllib3-2.6.0.json` | https://pypi.org/pypi/urllib3/json, https://pypi.org/pypi/urllib3/<version>/json | 2026-11-21 | PyPI metadata. Trimmed: `releases` to the saved versions, each file to `filename`, `packagetype`, `upload_time_iso_8601`, `yanked`; each version's `urls` to `filename`, `packagetype`, `url`, `yanked` | | + +## Saved changelogs + +Real copies, saved once with `curl` from the release tag and never edited unless said. + +| File | URL | Tag commit | Saved | License | Quote | +|---|---|---|---|---|---| +| `urllib3-2.0.0-CHANGES.rst` | https://raw.githubusercontent.com/urllib3/urllib3/2.0.0/CHANGES.rst | `303ba81` | 2026-11-14 08:35 UTC | MIT (urllib3), kept whole | "Removed support for Python 2.7, 3.5, and 3.6" | + +## Version lists + +| File | URL | Saved | License | Use | +|---|---|---|---|---| +| `pypi-urllib3-excerpt.json` | https://pypi.org/pypi/urllib3/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | diff --git a/plugins/changelog/testdata/golden/urllib3-2.0.0.json b/providers/urllib3/testdata/golden/urllib3-2.0.0.json similarity index 100% rename from plugins/changelog/testdata/golden/urllib3-2.0.0.json rename to providers/urllib3/testdata/golden/urllib3-2.0.0.json diff --git a/plugins/apisurface/testdata/golden/urllib3-python-surface.json b/providers/urllib3/testdata/golden/urllib3-python-surface.json similarity index 100% rename from plugins/apisurface/testdata/golden/urllib3-python-surface.json rename to providers/urllib3/testdata/golden/urllib3-python-surface.json diff --git a/plugins/changelog/testdata/pypi-urllib3-excerpt.json b/providers/urllib3/testdata/pypi-urllib3-excerpt.json similarity index 100% rename from plugins/changelog/testdata/pypi-urllib3-excerpt.json rename to providers/urllib3/testdata/pypi-urllib3-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.2.1.json b/providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.2.1.json similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.2.1.json rename to providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.2.1.json diff --git a/plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.2.2.json b/providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.2.2.json similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.2.2.json rename to providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.2.2.json diff --git a/plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.5.0.json b/providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.5.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.5.0.json rename to providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.5.0.json diff --git a/plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.6.0.json b/providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.6.0.json similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-2.6.0.json rename to providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-2.6.0.json diff --git a/plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-excerpt.json b/providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-excerpt.json similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/pypi-urllib3-excerpt.json rename to providers/urllib3/testdata/pypi/urllib3/pypi-urllib3-excerpt.json diff --git a/plugins/apisurface/testdata/pypi/urllib3/urllib3-2.2.1-py3-none-any.trimmed.whl b/providers/urllib3/testdata/pypi/urllib3/urllib3-2.2.1-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/urllib3-2.2.1-py3-none-any.trimmed.whl rename to providers/urllib3/testdata/pypi/urllib3/urllib3-2.2.1-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/urllib3/urllib3-2.2.2-py3-none-any.trimmed.whl b/providers/urllib3/testdata/pypi/urllib3/urllib3-2.2.2-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/urllib3-2.2.2-py3-none-any.trimmed.whl rename to providers/urllib3/testdata/pypi/urllib3/urllib3-2.2.2-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/urllib3/urllib3-2.5.0-py3-none-any.trimmed.whl b/providers/urllib3/testdata/pypi/urllib3/urllib3-2.5.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/urllib3-2.5.0-py3-none-any.trimmed.whl rename to providers/urllib3/testdata/pypi/urllib3/urllib3-2.5.0-py3-none-any.trimmed.whl diff --git a/plugins/apisurface/testdata/pypi/urllib3/urllib3-2.6.0-py3-none-any.trimmed.whl b/providers/urllib3/testdata/pypi/urllib3/urllib3-2.6.0-py3-none-any.trimmed.whl similarity index 100% rename from plugins/apisurface/testdata/pypi/urllib3/urllib3-2.6.0-py3-none-any.trimmed.whl rename to providers/urllib3/testdata/pypi/urllib3/urllib3-2.6.0-py3-none-any.trimmed.whl diff --git a/plugins/changelog/testdata/urllib3-2.0.0-CHANGES.rst b/providers/urllib3/testdata/urllib3-2.0.0-CHANGES.rst similarity index 100% rename from plugins/changelog/testdata/urllib3-2.0.0-CHANGES.rst rename to providers/urllib3/testdata/urllib3-2.0.0-CHANGES.rst diff --git a/plugins/changelog/versions_test.go b/providers/urllib3/urllib3_test.go similarity index 50% rename from plugins/changelog/versions_test.go rename to providers/urllib3/urllib3_test.go index 123dec0..2d889ab 100644 --- a/plugins/changelog/versions_test.go +++ b/providers/urllib3/urllib3_test.go @@ -1,4 +1,4 @@ -package changelog +package urllib3 import ( "context" @@ -9,8 +9,77 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog" + "github.com/patch-it-dev/patch-it-plugins/kinds/changelog/changelogtest" ) +// The real changelog at a release tag (testdata/README.md) in, every +// event out: the pair from the release before (on PyPI) to the pinned one. +func TestUrllib3Golden(t *testing.T) { + for _, c := range []struct { + file changelog.File + saved string + previous string + }{ + {Urllib3.At("2.0.0"), "testdata/urllib3-2.0.0-CHANGES.rst", "1.26.15"}, + } { + t.Run(c.file.Package, func(t *testing.T) { + got := changelogtest.Release(t, c.file, c.saved, c.previous) + kittest.Golden(t, "testdata/golden/"+c.file.Package+"-"+c.file.Release+".json", got) + }) + } +} + +// Every bullet of each release that is breaking or a deprecation but isn't +// plain enough is dropped, not guessed: pinned here with why. +func TestUrllib3UnsureBulletsAreDropped(t *testing.T) { + for _, c := range []struct { + file changelog.File + saved string + dropped []string // the start of each dropped bullet, in order + }{ + {Urllib3.At("2.0.0"), "testdata/urllib3-2.0.0-CHANGES.rst", []string{ + "Removed support for Python 2.7", + "Removed fallback on certificate", + "Removed support for Python with an", + "Removed support for OpenSSL versions", + "Removed the list of default ciphers", + "Removed ``urllib3.contrib.appengine.AppEngineManager`` and support", // names and an environment + "Removed deprecated ``Retry`` options", // parameters + "Removed default value of ``None``", // a default, of a parameter + "Removed the ``urllib3.request`` module", // the release adds urllib3.request back + "Removed support for SSLv3.0", + "Removed ``DEFAULT_CIPHERS``, ``HAS_SNI``", // a private module + "Deprecated ``ssl_version`` option", // a parameter of what? + "Deprecated the ``strict`` parameter", + "Deprecated ``RequestField.header_formatter`` parameter", + }}, + } { + _, fs, err := c.file.Read(kittest.Read(t, c.saved)) + if err != nil { + t.Fatal(err) + } + var drops []changelog.Finding + for _, f := range fs { + if f.Dropped != "" { + drops = append(drops, f) + } + } + if len(drops) != len(c.dropped) { + for _, d := range drops { + t.Logf("dropped %q: %s", d.Bullet.Text, d.Dropped) + } + t.Errorf("%s: dropped %d, want %d", c.file.Package, len(drops), len(c.dropped)) + continue + } + for i, want := range c.dropped { + if !strings.HasPrefix(drops[i].Bullet.Text, want) { + t.Errorf("%s: drop %d is %q, want %q…", c.file.Package, i, drops[i].Bullet.Text, want) + } + } + } +} + // Unpinned, a changelog's versions are the package's final releases on PyPI, // each read at its tag; the 1.26.15 -> 2.0.0 pair gives the same events as // the pinned golden, with previous_version set. @@ -18,10 +87,10 @@ func TestReleasesAreListedAndExtractedPairByPair(t *testing.T) { pages := kittest.Pages{ "https://pypi.org/pypi/urllib3/json": "testdata/pypi-urllib3-excerpt.json", Urllib3.At("1.26.15").URL(): "testdata/urllib3-2.0.0-CHANGES.rst", // only 2.0.0's section is read - Urllib3200.URL(): "testdata/urllib3-2.0.0-CHANGES.rst", + Urllib3.At("2.0.0").URL(): "testdata/urllib3-2.0.0-CHANGES.rst", } env := kittest.Env(t, pages) - p := Plugin{File: Urllib3} + p := changelog.Plugin{File: Urllib3} ctx := context.Background() vs, err := p.ListVersions(ctx, env) if err != nil { @@ -47,7 +116,7 @@ func TestReleasesAreListedAndExtractedPairByPair(t *testing.T) { if err != nil || len(res.Rejected) > 0 { t.Fatalf("%v %v", err, res.Rejected) } - pinned := release(t, Urllib3200, "testdata/urllib3-2.0.0-CHANGES.rst", "1.26.15") + pinned := changelogtest.Release(t, Urllib3.At("2.0.0"), "testdata/urllib3-2.0.0-CHANGES.rst", "1.26.15") if len(res.Events) == 0 || len(res.Events) != len(pinned) { t.Fatalf("pair gave %d events, the pinned release %d", len(res.Events), len(pinned)) } @@ -66,7 +135,7 @@ func TestAReleaseWithNoSectionIsNothingToRead(t *testing.T) { Urllib3.At("2.0.1").URL(): "testdata/urllib3-2.0.0-CHANGES.rst", } env := kittest.Env(t, pages) - p := Plugin{File: Urllib3} + p := changelog.Plugin{File: Urllib3} ctx := context.Background() to, err := p.ReadAt(ctx, env, plugin.Version{ID: "2.0.1", Ref: "2.0.1"}) if err != nil { @@ -79,32 +148,3 @@ func TestAReleaseWithNoSectionIsNothingToRead(t *testing.T) { t.Errorf("err = %v, want plugin.ErrNothingToRead naming 2.0.1", err) } } - -// An ecosystem patch-it lists no registry for (Go here) lists the repo's -// TagPrefix + X.Y.Z tags; a source read from release notes lists the repo's -// published releases. Pre-releases, drafts and other tags are left out. -func TestReleasesFromTagsAndFromGitHubReleases(t *testing.T) { - env := kittest.Env(t, kittest.Pages{ - "https://api.github.com/repos/stripe/stripe-go/tags?per_page=100&page=1": "testdata/versions/stripe-go-tags.json", - "https://api.github.com/repos/octokit/rest.js/releases?per_page=100&page=1": "testdata/versions/octokit-rest-releases.json", - }) - for _, c := range []struct { - file File - want string - }{ - {File{API: "stripe/go", Ecosystem: "go", Repo: "stripe/stripe-go", TagPrefix: "v", Path: "CHANGELOG.md"}, "72.121.0@v72.121.0 72.122.0@v72.122.0 73.0.0@v73.0.0"}, - {File{API: "github/octokit-rest", Ecosystem: "npm", Repo: "octokit/rest.js", TagPrefix: "v", Notes: true}, "17.11.2@v17.11.2 18.0.0@v18.0.0"}, - } { - vs, err := Plugin{File: c.file}.ListVersions(context.Background(), env) - if err != nil { - t.Fatal(err) - } - var ids []string - for _, v := range vs { - ids = append(ids, v.ID+"@"+v.Ref) - } - if got := strings.Join(ids, " "); got != c.want { - t.Errorf("%s: %s, want %s", c.file.API, got, c.want) - } - } -} diff --git a/providers/vercel.md b/providers/vercel/README.md similarity index 91% rename from providers/vercel.md rename to providers/vercel/README.md index 1b01fc9..e0baa54 100644 --- a/providers/vercel.md +++ b/providers/vercel/README.md @@ -1,12 +1,16 @@ -# Vercel (`vercel/api`) +# Vercel -## What it watches +Every source patch-it reads for Vercel, one section each: what it watches, why this source, what it reads and ignores, its known gaps. Each is registered in [`provider.go`](provider.go) and read by its kind ([`kinds/`](../../kinds/)); the saved copies its tests replay, and the golden files, are in [`testdata/`](testdata/README.md). + +## Vercel (`vercel/api`) + +### What it watches Vercel's REST API, release by release: operations Vercel marks deprecated, and deprecated operations it then removes, between two versions of the OpenAPI spec Vercel generates its official SDK (`@vercel/sdk`) from. -Kind: `openapi` (`plugins/openapi`), with `adapter.Vercel`. +Kind: `openapi` (`kinds/openapi`), with its adapter, `Vercel` ([`api.go`](api.go)). -## Why this source +### Why this source - **Source:** `vercel-spec.json` in [vercel/sdk](https://github.com/vercel/sdk), pinned to a release tag (`https://raw.githubusercontent.com/vercel/sdk//vercel-spec.json`), with the newest tag taken from the GitHub Releases API. Checked on 2026-11-18. - **Why this one:** it's Vercel's own machine-readable description of the API, committed with every SDK release (207 releases from 2024-11-25 to 2026-11-17, nearly one a day). A pinned tag can be cited and replayed. @@ -18,13 +22,13 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Vercel`. - The Python SDK ([vercel/vercel-py](https://github.com/vercel/vercel-py), `vercel` on PyPI, 0.13.0) is hand-written helpers, not a client of this spec. - **Quote:** "Check the price for a domain (deprecated)" (the summary of `GET /v4/domains/price` from v1.13.5). The same day, Vercel's changelog said "The Legacy Domains API is now deprecated. … Sunset date: 2025-11-09." ([changelog](https://vercel.com/changelog/new-domains-registrar-api-for-domain-search-pricing-purchase-and-management)). -## How the provider announces changes +### How the provider announces changes - There's no API-wide version. Each endpoint carries its own in the path (`/v13/deployments`, `/v6/user/tokens`), and older versions usually keep working beside newer ones. `info.version` is a fixed `0.0.1`, so the event's `version` is the SDK release tag (`1.18.7`), which is also what a repo pins in `package.json`. - Deprecations are mostly said in words. Of the 22 operations deprecated over two years, 16 had no `deprecated` flag, only a summary ending "(deprecated)" or starting "Deprecated:". - A sunset is announced in the changelog with a date, roughly a month ahead for the Legacy Domains API. After the date, the endpoint answers with an error ("This endpoint has been sunsetted on November 9, 2025"). The operation left the spec later, between one and two months after the sunset. -## What the plugin reads and ignores +### What the plugin reads and ignores - **Reads:** the spec at the newest tag, diffed against the last one. Two events come out of it: - **Deprecations:** an operation that gains the `deprecated` flag, or a summary that starts "Deprecated:" (with the colon) or ends "(deprecated)". A bare leading "Deprecated" doesn't count, because it would match an operation about deprecated things, such as "Deprecated runtimes for a project". The event cites the flag or the summary. @@ -38,7 +42,7 @@ Kind: `openapi` (`plugins/openapi`), with `adapter.Vercel`. - Over the 207 releases, this keeps 26 events: 22 deprecations, and the removal of the four Legacy Domains operations, all four of which Vercel shut down. - **Reads** a historical pair (a version pair, `v1.18.6` → `v1.18.7`) and recreates the removal of `GET /v4/domains/price` and `GET /v4/domains/status`. The golden test also runs the deprecation of all four operations (`v1.13.4` to `v1.13.5`). The drop tests replay an unmarked removal (`v1.6.2` to `v1.6.3`) and the path-parameter rename (`v1.28.64` to `v1.28.65`). -## Known gaps +### Known gaps - Request and response property changes aren't events, even the ones that match an announced change. For example, `secret` left the `type` values of `POST /v10/projects/{idOrName}/env` in 2026-04, after Vercel [sunset legacy secrets](https://vercel.com/changelog/legacy-environment-variable-secrets-are-being-sunset), and it isn't reported. Telling those apart from the spec's churn needs a better union comparison first. - An operation Vercel removes without marking it deprecated first isn't reported. diff --git a/providers/vercel/api.go b/providers/vercel/api.go new file mode 100644 index 0000000..68f8881 --- /dev/null +++ b/providers/vercel/api.go @@ -0,0 +1,113 @@ +package vercel + +import ( + "context" + "encoding/json" + "fmt" + "regexp" + "strings" + + "github.com/patch-it-dev/patch-it-plugins/core/diff" + "github.com/patch-it-dev/patch-it-plugins/core/fetch" + "github.com/patch-it-dev/patch-it-plugins/core/github" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" +) + +// Variables, not constants, only so tests can point them at a local server. +var ( + vercelReleasesURL = "https://api.github.com/repos/vercel/sdk/releases/latest" + // vercelSpecURLTemplate is the REST API spec @vercel/sdk is generated from, + // committed at the root of vercel/sdk and regenerated on every release. + // Vercel also serves it live at https://openapi.vercel.sh/, but that URL + // has no versions to pin or replay. The SDK repo's copy is the same spec, + // a release behind at most (on 2026-11-18 the live one had 3 paths more + // out of 356), and tagged on every release. + vercelSpecURLTemplate = "https://raw.githubusercontent.com/vercel/sdk/%s/vercel-spec.json" +) + +// Vercel adapts the OpenAPI spec bundled in vercel/sdk for the openapi plugin. +type Vercel struct{} + +var _ adapter.Adapter = Vercel{} + +func (Vercel) API() string { return "vercel/api" } + +// LatestTag asks GitHub for vercel/sdk's newest release tag, e.g. "v1.28.65". +// The canary tags (v14.0.0-canary.9) aren't releases, so releases/latest never +// returns them (checked 2026-11-18). +func (Vercel) LatestTag(ctx context.Context) (string, error) { + tag, err := github.LatestRelease(ctx, github.Get, vercelReleasesURL) + if err != nil { + return "", fmt.Errorf("looking up vercel's latest release: %w", err) + } + return tag, nil +} + +// Fetch downloads the spec pinned to tag. It's JSON already, so it's passed +// through unchanged. +// +// Version is the release tag without its "v", not info.version: that is a +// fixed "0.0.1" in every release (checked 2026-11-18). The tag is what a +// customer pins in package.json ("@vercel/sdk": "1.28.65"). Vercel's REST API +// has no version of its own: each endpoint carries its own in the path +// (/v13/deployments, /v6/user/tokens). +func (Vercel) Fetch(ctx context.Context, tag string) (adapter.Spec, error) { + url := fmt.Sprintf(vercelSpecURLTemplate, tag) + body, err := fetch.Get(ctx, url, nil) // raw.githubusercontent.com needs no auth + if err != nil { + return adapter.Spec{}, fmt.Errorf("fetching vercel spec %s: %w", tag, err) + } + if !json.Valid(body) { + return adapter.Spec{}, fmt.Errorf("vercel spec %s is not valid json", tag) + } + return adapter.Spec{Content: body, Version: strings.TrimPrefix(tag, "v"), SourceURL: url}, nil +} + +// Versions are vercel/sdk's releases, canaries left out (as LatestTag does). +func (Vercel) Versions(ctx context.Context) ([]plugin.Version, error) { + return adapter.Releases(ctx, "vercel/sdk", func(tag string) bool { return !strings.Contains(tag, "canary") }) +} + +// vercelDiff is how Vercel's spec says what it says: +// +// - Most deprecations are in the summary, not the flag. Of the 22 operations +// deprecated between 2024-11 and 2026-11 in vercel/sdk's spec history, 16 +// said so only in words: "Check the price for a domain (deprecated)", +// "Deprecated: Use DELETE /v1/drives/:name. ...". +// - Renaming a path parameter isn't a change for callers, and Vercel does it: +// DELETE /v2/sandboxes/drives/{name} became .../{nameOrId} in v1.28.65. +var vercelDiff = diff.Options{PathTemplates: true, DeprecatedSummary: vercelDeprecatedSummary} + +// vercelDeprecatedWords are the two ways every word-only deprecation in the +// history is written: a summary that starts "Deprecated:" or ends +// "(deprecated)". Not "deprecat" anywhere, nor a bare leading "Deprecated", +// which would match an operation about deprecated things ("Deprecated +// runtimes for a project"). +var vercelDeprecatedWords = regexp.MustCompile(`(?i)^deprecated:|\(deprecated\)\s*$`) + +func vercelDeprecatedSummary(summary string) bool { + return vercelDeprecatedWords.MatchString(summary) +} + +// vercelKeep keeps operation deprecations, and removals of operations the old +// spec had marked deprecated. Everything else is dropped, because in +// vercel/sdk's spec history (207 releases, 2024-11 to 2026-11) it was mostly +// not a change to the API: +// +// - 108 operations left the spec, and only 5 had been marked deprecated: the +// four Legacy Domains endpoints, which Vercel did shut down on 2025-11-09 +// (they now answer "This endpoint has been sunsetted"), and the drives +// rename PathTemplates already pairs up. Of the other 103, 16 came back in +// a later release, and the edge-config ones were the product's rename to +// Global Config. +// - The response side reported 67,048 removed properties, about a thousand a +// release, from the generated schemas reshuffling. +// - The request side reported 478 breaking property changes, most of them +// union members compared by position as their order moved; outside unions +// there were still 142, and 27 of those reverted later. +// +// Additions are dropped too: nobody has to fix code for a new endpoint, and a +// re-added one isn't new. +func vercelKeep(c diff.Change) bool { return openapi.DeprecationsOnly(vercelDiff)(c) } diff --git a/plugins/openapi/adapter/vercel_test.go b/providers/vercel/api_fetch_test.go similarity index 99% rename from plugins/openapi/adapter/vercel_test.go rename to providers/vercel/api_fetch_test.go index a605beb..c9d1724 100644 --- a/plugins/openapi/adapter/vercel_test.go +++ b/providers/vercel/api_fetch_test.go @@ -1,4 +1,4 @@ -package adapter +package vercel import ( "context" diff --git a/plugins/openapi/vercel_test.go b/providers/vercel/api_test.go similarity index 77% rename from plugins/openapi/vercel_test.go rename to providers/vercel/api_test.go index bbe3261..233b2ef 100644 --- a/plugins/openapi/vercel_test.go +++ b/providers/vercel/api_test.go @@ -1,24 +1,22 @@ -package openapi +package vercel import ( "context" - "encoding/json" "fmt" "os" - "strconv" "strings" "testing" - "time" "github.com/patch-it-dev/patch-it-plugins/core/event" "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" - "github.com/patch-it-dev/patch-it-plugins/core/plugin" - "github.com/patch-it-dev/patch-it-plugins/plugins/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/adapter" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi/openapitest" ) // fakeVercelAdapter serves the trimmed, unedited excerpts of vercel/sdk's // vercel-spec.json saved under testdata/ (checked 2026-11-18), cited by the -// real URL each one was copied from, the way adapter.Vercel.Fetch cites it. +// real URL each one was copied from, the way Vercel.Fetch cites it. type fakeVercelAdapter struct{ latest string } func (fakeVercelAdapter) API() string { return "vercel/api" } @@ -44,12 +42,8 @@ func vercelURL(tag string) string { } // vercelPlugin is the plugin exactly as registered, over the saved copies. -func vercelPlugin(latest string) Plugin { - return Plugin{Adapter: fakeVercelAdapter{latest: latest}, Diff: vercelDiff, Keep: vercelKeep} -} - -func vercelEnv(*kittest.Mem) plugin.Env { - return plugin.Env{Now: func() time.Time { return kittest.Clock }} +func vercelPlugin(latest string) openapi.Plugin { + return openapi.Plugin{Adapter: fakeVercelAdapter{latest: latest}, Diff: vercelDiff, Keep: vercelKeep} } // The golden test: the whole life of Vercel's Legacy Domains API in its own @@ -63,8 +57,8 @@ func vercelEnv(*kittest.Mem) plugin.Env { // /v1/connect/networks operations, which the filter drops, saved here as one. func TestVercelGolden(t *testing.T) { ctx := context.Background() - s := openStore(t) - env := vercelEnv(s) + s := kittest.NewMem() + env := openapitest.Env(s) // The deprecations: v1.13.4 to the next day's release, v1.13.5. if rejected, err := kittest.Pair(ctx, env, s, vercelPlugin(""), "v1.13.4", "v1.13.5"); err != nil || rejected { @@ -107,7 +101,7 @@ func TestVercelGolden(t *testing.T) { if e.SourceURL != vercelURL(tag) { t.Errorf("%s: source_url %s, want %s", e.Description, e.SourceURL, vercelURL(tag)) } - if node := jsonNode(t, vercelFile(tag), e.SourcePointer); node != e.SourceExcerpt && !truncated(e.SourceExcerpt, node) { + if node := openapitest.JSONNode(t, vercelFile(tag), e.SourcePointer); node != e.SourceExcerpt && !openapitest.Truncated(e.SourceExcerpt, node) { t.Errorf("%s: excerpt %.120s…, but %s#%s holds %.120s…", e.Description, e.SourceExcerpt, tag, e.SourcePointer, node) } } @@ -126,8 +120,8 @@ func TestVercelGolden(t *testing.T) { // A deprecation said only in words is evidenced by the words: the summary. func TestVercelSummaryDeprecationQuotesTheSummary(t *testing.T) { ctx := context.Background() - s := openStore(t) - if _, err := kittest.Pair(ctx, vercelEnv(s), s, vercelPlugin(""), "v1.13.4", "v1.13.5"); err != nil { + s := kittest.NewMem() + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, vercelPlugin(""), "v1.13.4", "v1.13.5"); err != nil { t.Fatal(err) } for _, e := range kittest.Stored(t, s) { @@ -150,8 +144,8 @@ func TestVercelSummaryDeprecationQuotesTheSummary(t *testing.T) { // Nothing here is a change a caller had to fix. func TestVercelDropsRemovalsThatWerentDeprecated(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, vercelPlugin(""), "v1.6.2", "v1.6.3"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, vercelPlugin(""), "v1.6.2", "v1.6.3"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { @@ -163,10 +157,10 @@ func TestVercelDropsRemovalsThatWerentDeprecated(t *testing.T) { // Without the filter, the same pair reports the removals: the fixture still // shows what vercelKeep is for. - s = openStore(t) + s = kittest.NewMem() p := vercelPlugin("") p.Keep = nil - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "v1.6.2", "v1.6.3"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "v1.6.2", "v1.6.3"); err != nil { t.Fatal(err) } var removals int @@ -185,8 +179,8 @@ func TestVercelDropsRemovalsThatWerentDeprecated(t *testing.T) { // deprecated. Callers send the same URL as before, so neither is removed. func TestVercelPathParameterRenameIsNoChange(t *testing.T) { ctx := context.Background() - s := openStore(t) - if rejected, err := kittest.Pair(ctx, vercelEnv(s), s, vercelPlugin(""), "v1.28.64", "v1.28.65"); err != nil || rejected { + s := kittest.NewMem() + if rejected, err := kittest.Pair(ctx, openapitest.Env(s), s, vercelPlugin(""), "v1.28.64", "v1.28.65"); err != nil || rejected { t.Fatalf("pair: rejected=%v err=%v", rejected, err) } if events := kittest.Stored(t, s); len(events) != 0 { @@ -197,10 +191,10 @@ func TestVercelPathParameterRenameIsNoChange(t *testing.T) { } // Matching by exact path instead, the deprecated one reads as removed. - s = openStore(t) + s = kittest.NewMem() p := vercelPlugin("") p.Diff.PathTemplates = false - if _, err := kittest.Pair(ctx, vercelEnv(s), s, p, "v1.28.64", "v1.28.65"); err != nil { + if _, err := kittest.Pair(ctx, openapitest.Env(s), s, p, "v1.28.64", "v1.28.65"); err != nil { t.Fatal(err) } events := kittest.Stored(t, s) @@ -234,39 +228,3 @@ func TestVercelDeprecatedSummary(t *testing.T) { } } } - -// jsonNode resolves an RFC 6901 pointer in a JSON file and serializes the node -// the way normalize serializes excerpts. -func jsonNode(t *testing.T, file, pointer string) string { - t.Helper() - var node any - if err := json.Unmarshal(kittest.Read(t, file), &node); err != nil { - t.Fatal(err) - } - for _, tok := range strings.Split(strings.TrimPrefix(pointer, "/"), "/") { - tok = strings.NewReplacer("~1", "/", "~0", "~").Replace(tok) - switch n := node.(type) { - case map[string]any: - node = n[tok] - case []any: - i, err := strconv.Atoi(tok) - if err != nil || i >= len(n) { - return "" - } - node = n[i] - default: - return "" - } - } - b, err := json.Marshal(node) - if err != nil { - t.Fatal(err) - } - return string(b) -} - -// truncated reports whether excerpt is node cut to the contract's limit. -func truncated(excerpt, node string) bool { - prefix, ok := strings.CutSuffix(excerpt, "…") - return ok && strings.HasPrefix(node, prefix) -} diff --git a/providers/vercel/provider.go b/providers/vercel/provider.go new file mode 100644 index 0000000..f7ced52 --- /dev/null +++ b/providers/vercel/provider.go @@ -0,0 +1,26 @@ +// Package vercel is what patch-it reads for Vercel: every source, registered +// below with its metadata, each read by its kind (kinds/). README.md +// says why each source and what it reads. +package vercel + +import ( + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/kinds/openapi" +) + +func init() { + plugin.RegisterProvider(plugin.Provider{ + ID: "vercel", Name: "Vercel", Category: plugin.CategoryHosting, Homepage: "https://vercel.com", + Sources: []plugin.Source{ + // No Hints: Vercel's changelog is product news, not keyed by API change. + // Only operation deprecations and removals are kept: see vercelKeep. + { + ID: "api", Layer: plugin.LayerAPI, + Watches: "REST API operations deprecated, and deprecated operations removed, between SDK releases of the spec", + URLs: []string{"https://github.com/vercel/sdk"}, + Packages: []string{"npm:@vercel/sdk"}, + Plugin: openapi.Plugin{Adapter: Vercel{}, Diff: vercelDiff, Keep: vercelKeep}, + }, + }, + }) +} diff --git a/providers/vercel/testdata/README.md b/providers/vercel/testdata/README.md new file mode 100644 index 0000000..ef425a5 --- /dev/null +++ b/providers/vercel/testdata/README.md @@ -0,0 +1,14 @@ +# Vercel: saved copies and goldens + +Real copies of what Vercel publishes, read by this folder's tests instead of the network: each row says where it was fetched, when, its license and a quote. The golden files under `golden/` are every event the tests must store; `go test ./providers/vercel -update` rewrites them after an intended change, and the PR says why the new output is right. + +## Saved OpenAPI spec excerpts + +Each pair is a real breaking change between two releases of the provider's own spec, trimmed to the schemas and paths involved: every line is copied unchanged, the rest of the spec was left out. The tests replay one release to the next and check the events. + +| Files | Source | Checked | License | Quote | +|---|---|---|---|---| +| `vercel-v1.13.4.json`, `vercel-v1.13.5.json` | https://raw.githubusercontent.com/vercel/sdk/v1.13.4/vercel-spec.json (and `v1.13.5`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | "Check the price for a domain (deprecated)" (summary of `GET /v4/domains/price`, new in v1.13.5) | +| `vercel-v1.18.6.json`, `vercel-v1.18.7.json` | https://raw.githubusercontent.com/vercel/sdk/v1.18.6/vercel-spec.json (and `v1.18.7`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v4/domains/price": {` (in v1.18.6, gone in v1.18.7) | +| `vercel-v1.6.2.json`, `vercel-v1.6.3.json` | https://raw.githubusercontent.com/vercel/sdk/v1.6.2/vercel-spec.json (and `v1.6.3`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v1/log-drains": {` (in v1.6.2, gone in v1.6.3 without being deprecated, back in v1.15.0): the drop test | +| `vercel-v1.28.64.json`, `vercel-v1.28.65.json` | https://raw.githubusercontent.com/vercel/sdk/v1.28.64/vercel-spec.json (and `v1.28.65`) | 2026-11-18 | Apache-2.0 (vercel/sdk) | `"/v2/sandboxes/drives/{nameOrId}": {` (`DELETE` moved here from `.../{name}` in v1.28.65) | diff --git a/plugins/openapi/testdata/golden/vercel.json b/providers/vercel/testdata/golden/vercel.json similarity index 100% rename from plugins/openapi/testdata/golden/vercel.json rename to providers/vercel/testdata/golden/vercel.json diff --git a/plugins/openapi/testdata/vercel-v1.13.4.json b/providers/vercel/testdata/vercel-v1.13.4.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.13.4.json rename to providers/vercel/testdata/vercel-v1.13.4.json diff --git a/plugins/openapi/testdata/vercel-v1.13.5.json b/providers/vercel/testdata/vercel-v1.13.5.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.13.5.json rename to providers/vercel/testdata/vercel-v1.13.5.json diff --git a/plugins/openapi/testdata/vercel-v1.18.6.json b/providers/vercel/testdata/vercel-v1.18.6.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.18.6.json rename to providers/vercel/testdata/vercel-v1.18.6.json diff --git a/plugins/openapi/testdata/vercel-v1.18.7.json b/providers/vercel/testdata/vercel-v1.18.7.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.18.7.json rename to providers/vercel/testdata/vercel-v1.18.7.json diff --git a/plugins/openapi/testdata/vercel-v1.28.64.json b/providers/vercel/testdata/vercel-v1.28.64.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.28.64.json rename to providers/vercel/testdata/vercel-v1.28.64.json diff --git a/plugins/openapi/testdata/vercel-v1.28.65.json b/providers/vercel/testdata/vercel-v1.28.65.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.28.65.json rename to providers/vercel/testdata/vercel-v1.28.65.json diff --git a/plugins/openapi/testdata/vercel-v1.6.2.json b/providers/vercel/testdata/vercel-v1.6.2.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.6.2.json rename to providers/vercel/testdata/vercel-v1.6.2.json diff --git a/plugins/openapi/testdata/vercel-v1.6.3.json b/providers/vercel/testdata/vercel-v1.6.3.json similarity index 100% rename from plugins/openapi/testdata/vercel-v1.6.3.json rename to providers/vercel/testdata/vercel-v1.6.3.json diff --git a/providers/vertex-ai-models.md b/providers/vertex-ai-models.md deleted file mode 100644 index b34e22c..0000000 --- a/providers/vertex-ai-models.md +++ /dev/null @@ -1,31 +0,0 @@ -# Vertex AI generative models (`google/vertex-ai-models`) - -## What it watches - -Generative AI model endpoints on Google Cloud's Vertex AI that Google deprecates: one `model` event per model id in a "Discontinued endpoints" table, with the replacement when the row names exactly one. - -Kind: `notices` (`plugins/notices`), with the feed reader (`plugins/notices/feed`) and its `VertexAIModels` feed. - -## Why this source - -- **Source:** the [Generative AI on Vertex AI release notes](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/release-notes) Atom feed, `https://docs.cloud.google.com/feeds/generative-ai-on-vertex-ai-release-notes.xml` (the `cloud.google.com/feeds/…` URL redirects here). Checked on 2026-11-14. -- **Why this one:** it's Google's own release notes as a feed, one entry per day, each change under a heading naming its kind (`Deprecated`), and deprecations come with a table of discontinued endpoints and replacements. -- **Alternatives considered:** the model versions and lifecycle docs page (HTML, rewritten in place, no history); the Google Cloud deprecations page (all of Cloud, prose); the models list API (what exists now, not when it stops). -- **Quote:** "We recommend updating your model endpoints before June 30, 2026, to avoid service disruption." (Deprecated: Imagen generation GA endpoints deprecation). - -## How the provider announces changes - -- Deprecations are announced in the release notes with a date to move by; shutdown dates aren't always given. -- Content is licensed CC BY 4.0. - -## What the plugin reads and ignores - -- Only `Deprecated` sections with a "Discontinued endpoints" table; one event per model id, `provider: google`. `replacement` only when the row names one other plain id. -- The date the section says to move by is the event's `version`; a section saying it "is deprecated" with only a "before …" date is a deprecation, not breaking. -- Drops (and logs) product names in prose (third-party models mentioned in a sentence) and non-model deprecations (Vertex AI Extensions). 35 events from the saved feed. -- Every event cites a Wayback Machine snapshot of the feed and is read from it. - -## Known gaps - -- Whether an "update before " deprecation should wait for a stated shutdown date is open; today it's a deprecation with that date. -- Partner models (Claude, Llama on Vertex) are only named in prose, so they're dropped.