Skip to content

feat: add --filter support to apiops publish - #236

Merged
Alexander Zaslonov (azaslonov) merged 7 commits into
Azure:mainfrom
cdayne:feat/publish-filtering
Sep 4, 2026
Merged

feat: add --filter support to apiops publish#236
Alexander Zaslonov (azaslonov) merged 7 commits into
Azure:mainfrom
cdayne:feat/publish-filtering

Conversation

@cdayne

@cdayne Chris Dayne (cdayne) commented Aug 3, 2026

Copy link
Copy Markdown

Summary

Adds --filter <path> and --no-transitive flags to apiops publish, reusing the filter YAML format, matching rules, and transitive-dependency resolution already supported by apiops extract. The change also extends transitive extraction to workspace-scoped resources, strengthens filtering and target-existence safeguards during publishing, and documents publish filtering.

Fixes #215

What's included

Filtered publishing

  • Adds --filter <path> to publish a selected subset of resources using the same case-insensitive names, wildcards, ! exclusions, and nested API/workspace sub-filters as extraction.
  • Enables transitive dependency resolution by default for referenced named values, backends and backend pool members, policy fragments, and API version sets.
  • Adds --no-transitive to publish only direct filter matches.
  • Supports filtered publishing with --commit-id and --dry-run, including republishing eligible child resources and associations when their parent changes.
  • Rejects incompatible combinations of --delete-unmatched with --filter or --commit-id using clear validation errors.

Safer resource selection and publishing

  • Applies exclusions consistently to APIs, products, workspaces, subscriptions, API tags, and related child resources and associations.
  • Verifies association and subscription targets exist in the artifact set before creating them, skipping unavailable targets with a warning instead of failing at the APIM request.
  • Expands resource-path handling and publisher filtering so full, incremental, and dry-run modes use consistent selection semantics.

Transitive extraction

  • Introduces a shared transitive extraction service for named values, backends, backend pool members, and policy fragments.
  • Uses the shared flow for top-level and workspace-scoped extraction while respecting configured exclusions.
  • Extends transitive resolution and cycle-safe dependency handling used by extraction and publishing.

Documentation

  • Documents publish filtering, transitive behavior, and option compatibility in README.md and docs/commands/publish.md.
  • Updates docs/guides/filtering-resources.md only where needed to cover publishing with the shared filter configuration.
  • Updates the architecture diagram for publish filtering and transitive resolution.

Test plan

  • npm run lint
  • npx tsc --noEmit
  • npm test — 1196/1196 passing
  • Manual smoke test against a real APIM instance

- Implemented unit tests for extracting backend pool members and policy fragment dependencies transitively in extract-service.
- Added tests to ensure API exclusions are respected during product publishing in product-publisher.
- Enhanced publish-service tests to cover filtering resources, including transitive dependencies and dry-run scenarios.
- Introduced tests for resource-publisher to skip entries based on exclusion filters for subscriptions and API tags.
- Added tests for workspace-extractor to validate workspace exclusions and transitive extraction of policy fragments.
- Created transitive-extractor service to handle extraction of transitive dependencies with proper logging and error handling.
@cdayne

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds filter-aware publishing using extraction-compatible filters, transitive dependency resolution, and workspace support.

Changes:

  • Adds --filter and --no-transitive publish options.
  • Expands dependency and association handling across publish and extraction.
  • Adds tests and documentation for filtering behavior.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/cli/publish-command.ts Adds publish filter options and validation.
src/models/config.ts Extends publish configuration.
src/lib/resource-path.ts Adds descriptor identity helpers.
src/services/filter-service.ts Shares workspace filter resolution.
src/services/transitive-resolver.ts Scans artifact and structural dependencies.
src/services/transitive-extractor.ts Adds shared fixed-point extraction.
src/services/extract-service.ts Uses shared transitive extraction.
src/services/workspace-extractor.ts Adds workspace transitive extraction.
src/services/publish-service.ts Filters and expands publish targets.
src/services/api-publisher.ts Applies filtering to API children.
src/services/product-publisher.ts Filters product associations and policies.
src/services/resource-publisher.ts Validates association and subscription targets.
tests/unit/cli/publish-command.test.ts Tests new CLI options.
tests/unit/lib/resource-path.test.ts Tests descriptor identity.
tests/unit/services/api-publisher.test.ts Tests filtered API publishing.
tests/unit/services/extract-service.test.ts Tests expanded extraction dependencies.
tests/unit/services/product-publisher.test.ts Tests product association filtering.
tests/unit/services/publish-service.test.ts Tests filtered and transitive publishing.
tests/unit/services/resource-publisher.test.ts Tests target safeguards.
tests/unit/services/transitive-resolver.test.ts Tests artifact reference scanning.
tests/unit/services/workspace-extractor.test.ts Tests workspace filtering and dependencies.
README.md Documents publish filtering.
docs/commands/publish.md Documents options and behavior.
docs/guides/filtering-resources.md Extends filtering guidance to publishing.
docs/architecture.md Adds publish-to-filter service flow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/services/api-publisher.ts
Comment thread src/services/publish-service.ts
Comment thread src/services/publish-service.ts
Comment thread src/services/product-publisher.ts Outdated
Chris Dayne and others added 4 commits September 1, 2026 10:18
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Align live and dry-run publish planning, incremental deletion safety,
workspace associations, environment mapping, and concrete action results.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 4, 2026 23:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Transitive publishing and extraction currently override explicit filter exclusions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 38/38 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread src/services/publish-service.ts
Comment thread src/services/transitive-extractor.ts
@azaslonov
Alexander Zaslonov (azaslonov) merged commit 420b993 into Azure:main Sep 4, 2026
6 checks passed
@cdayne
Chris Dayne (cdayne) deleted the feat/publish-filtering branch September 5, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --filter flag to subset resources during publish

5 participants