wordpress_client 10.0.0
wordpress_client: ^10.0.0 copied to clipboard
A library to interact with the Wordpress REST API. Supports most of the common endpoints and all of the CRUD operations on the endpoints.
10.0.0 #
Retries, auto-pagination, cache revalidation, GraphQL improvements and the Abilities API ship together with the breaking changes below.
Breaking
- Requests are locked to the client's origin. An absolute
RequestUrlis used verbatim only when its scheme, host and port match the base URL; otherwise the request is not sent and the response hasRequestErrorType.originMismatch. Previously only the host was rewritten. The base URL changes only via a new client orreconfigure(baseUri: ...). (#87) - Credentials follow the origin.
reconfigure(baseUri: ...)to a different scheme, host or port drops the default authorization and the cached discovery data, so credentials are never sent to a site they were not meant for. Pass the new credentials in thebootstrapperof the same call.clearDefaultAuthorization()now also survives laterreconfigurecalls, andBootstrapBuilder.withoutDefaultAuthorization()was added. Per-requestauthorizationis unaffected. (#87) - Request metadata is no longer sent as HTTP headers. The
method,request-urlandrequest-querypseudo-headers are gone. Middlewares read them from the newWordpressRequest.extra(keysWordpressRequest.metaMethod,metaUrl,metaQuery), which is also copied ontoWordpressRawResponse.extra. (#85) - No more process-wide state.
CodableMapdecoders/encoders and the endpoint statistics (counts and thewithStatisticDelegatecallback) are now owned by eachWordpressClient.CodableMap.getDecoder/getEncoderare instance methods, and the globalserialize<T>()/deserialize<T>()helpers are removed. Disposing one client no longer clears the codecs of every other client. (#92) - Transport errors are classified. Timeouts, connection errors and cancelled requests used to surface as
internalGenericErrorwith the stack trace inmessage. They now useRequestErrorType.timeout,connectionFailedandrequestCancelled; the exception and stack trace stay inextra(exception/stackTraceon the failure response). Invalid JSON behind a JSON content type isinvalidResponse. (#93) RequestErrorTypegainedoriginMismatch,invalidResponseandtimeout(appended, existing indices unchanged).
Changed
- GraphQL requests now run through the middleware pipeline (
onRequest/onResponse) like REST requests, and transport errors are returned as failures instead of thrown.
Fixed
CacheMiddlewarenever served a hit because the lookup and store keys differed. Both now come from one function. (#84)- Cache keys no longer contain the
Authorizationvalue, only a SHA-256 digest of it. (#89) WordpressRawResponse.durationnow covers the full round trip (it was ~0), including a re-auth retry. (#86)- A 2xx response whose body cannot be decoded (for example a non-array body for a list endpoint) now returns a
WordpressFailureResponsewithRequestErrorType.invalidResponseinstead of throwing a cast error. (#88) - The GraphQL endpoint follows
reconfigure(baseUri: ...); a customsetEndpointPathsurvives it. - The request header map passed in a
WordpressRequestis no longer mutated. WordpressRawResponse.asResponseno longer throws on a failure with a null or non-map body.
Added
- Abilities API (WordPress 6.9+).
client.abilitieslists and retrieves abilities (list,listAll,retrieve), their categories (categories,category) and runs them (run,runAbility), pickingGET/DELETE/POSTfrom the ability'sreadonly/destructiveannotations. Requests go to/wp-json/wp-abilities/v1on the client's own origin and always send credentials. New modelsAbilityandAbilityCategory. (#99) - GraphQL improvements. (#100)
graphql.executereturns data and errors as aGraphQLResult(GraphQLErrorwithpath,locations,extensions), so partial responses are usable.querystill fails on errors but now exposes them asextra[GraphQLInterface.errorsKey].query(useGet: true)sends reads withGET, soCacheMiddleware, HTTP caches and retries apply.mutateis now a real mutation call: it rejects non-mutation documents, always usesPOSTand clears the cache;POSTqueries no longer clear it.graphql.paginate/queryAllwalk a Relay connection (pageInfo.endCursor,nodesoredges { node }).- Automatic Persisted Queries (
useAutomaticPersistedQueries) and query batching (graphql.batch).
- Automatic retries.
BootstrapBuilder.withRetryPolicy(RetryPolicy.standard())retries timeouts, connection errors and 429/502/503/504 with exponential backoff and jitter, honouringRetry-After. Only idempotent methods are retried by default (neverPOST/PATCH), cancelling a request aborts the wait, andWordpressRequest.retryPolicyoverrides the client policy per request. The number of tries is reported inextra[WordpressRequest.metaAttempts]. Off by default. (#96) - Auto-pagination. Every list interface gains
listPages(request), a lazyStreamwith one response per page driven byX-WP-TotalPages, andlistAll(request), which collects all pages into one response. Both takeperPage(default 100) andmaxPages;listAllalso takesmaxItems. A failing page ends the walk. (#97) - Resource-level cache invalidation. A successful write now evicts only the cached GET responses of the resource it touched (
CacheInvalidation.resource, the new default) instead of the whole cache;CacheInvalidation.allrestores the old behaviour. NewISelectiveCache.removeWhere(implemented byMemoryCacheStore; other stores fall back toclear()), plusttlFor(per-endpoint TTL) andshouldCachehooks onCacheMiddleware/withCache. (#90) - ETag / Last-Modified revalidation.
CacheMiddlewarekeeps expired entries that carry a validator forrevalidateWindow(default 1 hour) and revalidates them withIf-None-Match/If-Modified-Since; a304refreshes the cached body without downloading it (X-Cache: REVALIDATED).MiddlewareRawResponse.requestHeaderslets any middleware add headers fromonExecute. Only 2xx responses are cached now (3xx used to be). (#98) - Typed failures.
WordpressFailureResponse.failurereturns a sealedWordpressFailure(NetworkFailure,AuthFailure,ApiFailure,DecodeFailure,MiddlewareFailure,ClientFailure) that can be switched over exhaustively, each carrying itscause,stackTraceand relevant details (status code,WordpressError, raw body). The existingcode,error,messageandexceptionaccessors are unchanged, andWordpressFailureResponse.errorTypewas added. (#93) package:wordpress_client/testing.dartwithMockWordpressAdapter,MockResponseandRecordedRequestfor testing code that uses the client without a live site. (#94, #101)WordpressRequest.extrafor local request metadata.
Internal
- The request executor's six copy-pasted pipelines are one
_pipelineplus one_toResponse.retriveis renamedretrieve(the old name is a deprecated alias). (#91) - Offline test suite under
test/offline; integration tests are taggedintegrationand CI runsdart test -x integrationwith a coverage floor. Integration credentials now come fromWP_*environment variables first, thentest/test_local.json. (#94, #95)
9.4.0 #
Added
- GraphQL Registered Queries: Register and reuse GraphQL queries throughout your application.
- New
RegisteredQuery<T>class to encapsulate query document, parser, default variables, and auth requirements. - Registry methods on
GraphQLInterface:register()/registerAll()- Add queries to the registryunregister()/clearRegistry()- Remove queriesisRegistered()/registeredQueryNames/registeredQueryCount- Query the registrygetRegistered()- Retrieve a registered query definitionexecuteRegistered()- Execute a registered query by name with optional variable overrides
- Variables from
defaultVariablesmerge with execution-time variables.
- New
Docs
- Wiki GraphQL page updated with Registered Queries section and examples.
9.3.0 #
Added
- Streaming APIs for polling single-resource endpoints:
RetrieveOperation.retrieveStream(...)for built-in retrieve operationsCustomOperation.requestStream(...)for custom interfaces- Features: configurable interval, emit-on-start, distinct-by-data, optional failure emissions with de-duplication, external CancelToken support, and on-demand
refetchTrigger.
Fixed
- Middleware execution now maps
MiddlewareRawResponse.bodyintoWordpressRawResponse.data, so decoders receive the actual payload. RequestUrl.relativeParts(...)now uses forward slashes regardless of OS to avoid Windows path separator issues.
Docs
- README feature list updated; new Wiki page: Streaming and Polling with examples and Riverpod wiring.
9.2.0 #
Added
- GraphQL support via
client.graphqltargeting WPGraphQL endpoint (/graphql).- query(), mutate(), and raw() helpers.
- Works with existing authorization (Application Passwords, JWT, etc.).
- Reuses middlewares, timeouts, and response helpers.
- Endpoint auto-resolves from REST base and can be overridden via
client.graphql.setEndpointPath().
Docs
- README updated with usage examples.
- Wiki updated with a new GraphQL page and links in the sidebar.
9.0.0 #
-
New response models: Added typed models for multiple WordPress REST resources
- Settings (
/wp/v2/settings) - Sidebars (
/wp/v2/sidebars) including widget handling - Taxonomies (e.g., categories, tags)
- Template Parts (
/wp/v2/template-parts) - Templates (
/wp/v2/templates) - Themes (
/wp/v2/themes) - Widgets (
/wp/v2/widgets) - Widget Types (
/wp/v2/widget-types)
- Settings (
-
Client enhancements: easier initialization and richer ergonomics
- Added
WordpressClient.forSitefactory to initialize from a site root URL (auto-derives/wp-json/wp/v2). - Introduced convenience extensions for most interfaces (Posts, Pages, Media, Users, Categories, Tags, Comments, Blocks, Block Types, Templates, Template Parts, Template Revisions, Template Part Revisions, Navigations, Navigation Revisions, Navigation Autosaves, Menus, Menu Items, Menu Locations, Widgets, Sidebars, Widget Types, Post Types, Taxonomies, Post Statuses, Themes, Global Styles, Post Revisions, Page Revisions, Settings).
- Implemented a raw request API on
WordpressClientfor custom endpoint calls. - Added
WordpressAuthhelpers for App Passwords and JWT (Useful/Basic) to simplify setup. - Exported new extensions via library exports; example app updated with composite ID samples.
- Added
-
Parallel requests behavior: configurable error handling
- Added
failOnError(default: false) toParallelWordpress.list(...). Whenfalse, non-success pages contribute empty results; whentrue, the first non-success response throwsParallelProcessingException.
- Added
-
Discovery and authorization robustness
- Hardened
WordpressDiscovery.fromJsonto tolerate mixed JSON types (e.g., numeric or stringgmt_offset;site_icon/site_logoas int or string) with safe defaults. - Updated classic Basic JWT flow to parse the top-level
tokencorrectly during authorization and simplified token validation.
- Hardened
-
Docs & Wiki
- Added GitHub wiki as a submodule under
/wikiand started populating advanced docs; README updated with a concise Wiki section and links.
- Added GitHub wiki as a submodule under
-
Fluent queries and interface helpers (non‑breaking)
- Added a discoverable fluent API via a
queryproperty on each interface:- Example:
client.posts.query.withPage(1).withPerPage(5).withSearch('hello').execute() - No seed class required. The builder auto‑creates the correct request internally (e.g.,
ListPostRequest). - Advanced: access/modify the underlying seed via
configureSeed((seed) { ... })orseedRequest.
- Example:
- Introduced a dedicated
extensionsproperty on interfaces to group simple convenience methods:- Example:
client.posts.extensions.getById(123),findBySlug('hello-world'),listAll(perPage: 100)
- Example:
- Base interface remains minimal and focused on CRUD via operation mixins; fluent and helpers are additive.
- Note: Some auto‑seeded builders (e.g., revisions/navigation) use placeholder IDs; set them via
configureSeedbeforeexecute().
- Added a discoverable fluent API via a
-
New endpoint coverage
- Pattern Directory Items (
/wp/v2/pattern-directory/patterns) with fluent support viaclient.patternDirectory.query.withSearch('hero').execute().
- Pattern Directory Items (
-
Local dev and integration testing
- Added Docker Compose stack (WordPress + MariaDB) and PowerShell helper scripts (
.scripts/wp-up.ps1,wp-down.ps1,wp-reset.ps1). - Introduced an integration test harness that loads config from
test/test_local.json(withtest_local.json.exampleprovided) or environment variables. - Wrote grouped integration tests covering posts CRUD (with faker data), comments, media, settings, blocks, search, revisions, templates, and template parts. Tests are tolerant of unauthenticated environments and no-op when missing local config.
- Added Docker Compose stack (WordPress + MariaDB) and PowerShell helper scripts (
-
Misc & housekeeping
- Version bumped to 9.0.0 in
README.mdandpubspec.yaml. - Minor refactors and stability improvements, including legacy tests and parallel pagination fixes.
- Version bumped to 9.0.0 in
8.6.0 #
- Add Global Styles support (interface + retrieve/update requests + response model)
- Themes: add is_block_theme, screenshot, theme_supports fields
- Me endpoint: send DELETE force/reassign via query; add rolesNames (role names array) with legacy roles fallback
- Templates & Template Parts: audit and confirm alignment with REST docs
- Navigation/Menus/Widgets: audit and minor compliance fix (widgets DELETE force as query param)
8.5.4 #
- Added support for creating media from bytes
- Updated documentation
8.5.3 #
- Fix invalid base url on web
8.5.2 #
- Fix versions
8.5.1 #
- Fix dio sendTimeout exception
8.5.0 #
- Added support for initializing the client without a base url.
- Use the
WordpressClient.genericconstructor to initialize the client without a base url. - Use the
reconfiguremethod to set the base url after initializing the client. - Failure to set the base url will throw an exception when making requests.
- Use the
- Added
isAuthenticatedmethod to check if the current instance has a valid authentication.- Optionally, pass an instance of
IAuthorizationto check if the client is authenticated with the given authorization.
- Optionally, pass an instance of
- 💥 Deprecated
reconfigureClientmethod in favour ofreconfiguremethod.
8.4.10 #
- Fix bug on clearing middleware list
8.4.9 #
- Downgrade meta package to match flutter meta version
8.4.8 #
- Bug fixes
- 💥 Deprecated
WordpressClient.initialize(...)ctor andinitialize()method - Added
WordpressClient.fromDioInstance(...)constructor
8.4.7 #
- Bug fixes
- Fix validations for entered
baseUrl; Supporting sites with custom REST Api paths
8.4.6 #
- Bug fixes
- Added validations for entered
baseUrl - 💥 Renamed
executeGuardedtoguardAsyncand addedguardmethod
8.4.5 #
- Bug fixes
8.4.4 #
- Bug fixes
8.4.3 #
- New static method to check if a site is built using WordPress
8.4.2 #
- Bug fixes
- Added static methods to validate base URL and discover a website
8.4.1 #
- Introduce
ParallelWordpressclass to generate and execute parallel requests - Bug fixes
8.4.0 #
- Added support for Middlewares
- 💥 Removed dependency on
synchronisedpackage
8.3.10 #
- Bug fixes
8.3.9 #
- Bug fixes
- Iterate over the raw response of the endpoint using [] operator
8.3.8 #
- Renamed retrive -> retrieve. Fix typo
8.3.7 #
- Support for raw requests
- Bug fixes
8.3.6 #
- Bug fixes on enum parsing
8.3.5 #
- Bug fixes on comment list request
8.3.4 #
- Media response model null exception when parsing if media details is empty
8.3.3 #
- Packages downgrade
- collection 1.18.0 -> 1.17.2
8.3.2 #
- Packages downgrade
- meta 1.11.0 -> 1.9.1
8.3.1 #
- Packages downgrade
- test 1.24.8 -> 1.24.5
- Added avatar URLs model class for users response
8.3.0 #
- Supports Application Password endpoint
- Packages update
8.2.2 #
- Bug fixes
8.2.1 #
- Fixed exporting WordPressDiscovery class
8.2.0 #
- Added support for Pages endpoint
8.1.0 #
- Added ability to fetch and cache the discovery endpoint of WordPress REST API
8.0.11 #
- Added
extraproperty to all request classes - Added
addAllIfNotNull(...)extension method
8.0.10 #
featured_media_src_urlkey now decodes as expected- Added
decodeByMultiKeysmethod
8.0.9 #
- Added App Password support
8.0.8 #
- Integrated new lint rules and code refactors
8.0.7 #
- Bug fixes
- Introduced
RequestErrorTypefor failure responses - Introduced
mapGuarded(...)andexecuteGuarded(...)methods - Usual refactors and improvements
8.0.6 #
- Docs update
8.0.5 #
- Bug fixes and improvements
8.0.4 #
- Bug fixes and improvements
8.0.3 #
- Export response extensions
8.0.2 #
- Downgrade collection version
8.0.1 #
- Docs update
8.0.0 #
- 💥 Several major updates and changes
7.0.0 #
- 💥 Major changes (Please check our documentation for more details)
6.3.1 #
- Implemented search endpoint
6.3.0 #
- Major changes in the API
6.2.1-pre #
- Misc changes
6.2.0-pre #
- Refactoring, Request Synchronization, and Debug Mode
6.1.7-pre to 6.1.9-pre #
- Refactoring & Bug fixes
6.1.6-pre #
- Support 3xx series responses (Cached Response)
6.1.5-pre #
- Added Post extension for Media and Author
6.1.3-pre & 6.1.4-pre #
- Bug fixes
6.1.2-pre #
- Version fix
6.1.1-pre #
- Removed test package
6.1.0-pre #
- Entire API changed
- Fluency maintained using Dart's cascading operator
- Performance and memory consumption improvements
5.4.3 #
- Total pages parsing fix
5.4.2 #
- Packages fix
5.4.1 #
- Null safety fix
5.4.0 #
- Packages update
5.3.1 #
- Response structure fix
5.3.0 #
- Bug fix
5.2.9 #
- Bug Fix
5.2.8 #
- Revert author meta & featured image removal
5.2.7 #
- Bug fix
5.2.6 #
- Experimental Request Caching system
5.2.5 #
- 💥 BREAKING CHANGE: Remove Author Meta & Featured Image URL Fields from Post response
5.2.4 #
- Remove unused package
5.2.3 #
- 💥 BREAKING CHANGE: Request API Change
5.1.1 #
- Formatting changes
5.1.0 #
- 💥 BREAKING CHANGE: Authorization API Change
5.0.4 #
- Fixed Authorization Bugs
4.0.0 #
- Initial version, created by Stagehand