Skip to content

feat: adds eligible licenses and available licenses#2951

Open
dineshswamy (dineshswamy) wants to merge 10 commits intomasterfrom
HEJO-8467-license-inventory-api
Open

feat: adds eligible licenses and available licenses#2951
dineshswamy (dineshswamy) wants to merge 10 commits intomasterfrom
HEJO-8467-license-inventory-api

Conversation

@dineshswamy
Copy link
Copy Markdown

@dineshswamy dineshswamy (dineshswamy) commented Mar 31, 2026

This pull request introduces support for two new API resources: Available Licenses at the organization level and Eligible Licenses at the space level. It adds endpoint implementations, entity definitions, and updates the SDK's type system to enable retrieving these license collections.

https://contentful.atlassian.net/browse/HEJO-8476

New License Resource Support

  • Added new REST endpoints for fetching Available Licenses (getAvailableLicenses) on organizations and Eligible Licenses (getEligibleLicenses) on spaces, including integration into the main endpoint index and API factories.

Summary

Description

Motivation and Context

PR Checklist

  • I have read the CONTRIBUTING.md file
  • All commits follow conventional commits
  • Documentation is updated (if necessary)
  • PR doesn't contain any sensitive information
  • There are no breaking changes

Summary by Bito

This pull request introduces support for two new API resources: Available Licenses at the organization level and Eligible Licenses at the space level. It adds endpoint implementations, entity definitions, and updates the SDK's type system to enable retrieving these license collections. This functionality allows developers to query license availability and eligibility for better license management.

Detailed Changes
  • Updates common-types.ts to include new AvailableLicense and EligibleLicense entity types and getMany actions for fetching license collections.
  • Defines new AvailableLicense and EligibleLicense entity types in lib/entities/ with properties for license id, name, count, quotas, and required add-on allocations.
  • Adds new REST endpoints for available licenses in organizations and eligible licenses in spaces in lib/adapters/REST/endpoints/, integrated into the endpoint index.
  • Adds getAvailableLicenses method to organization API in lib/create-organization-api.ts and getEligibleLicenses method to space API in lib/create-space-api.ts.
  • Adds unit tests in test/unit/ for the new license API methods using mocks in test/unit/mocks/entities.ts.

@dineshswamy dineshswamy (dineshswamy) requested a review from a team as a code owner March 31, 2026 10:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SDK support for two new license collection resources: organization-level Available Licenses and space-level Eligible Licenses, including REST endpoints, entity types, and unit tests.

Changes:

  • Introduce AvailableLicense and EligibleLicense REST endpoints (getMany) and register them in the REST endpoint index.
  • Add new entity type definitions + collection wrappers for available/eligible licenses.
  • Extend Space/Organization APIs with getEligibleLicenses / getAvailableLicenses and add corresponding unit tests/mocks.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/unit/mocks/entities.ts Adds mock entities + wrapper mocks for the new license resources.
test/unit/create-space-api.test.ts Adds unit tests for space.getEligibleLicenses().
test/unit/create-organization-api.test.ts Adds unit tests for organization.getAvailableLicenses().
lib/entities/eligible-license.ts Introduces Eligible License entity types + wrapping helpers.
lib/entities/available-license.ts Introduces Available License entity types + wrapping helpers.
lib/create-space-api.ts Adds getEligibleLicenses method to the space API.
lib/create-organization-api.ts Adds getAvailableLicenses method to the organization API.
lib/common-types.ts Extends request/action typing to include the new resources.
lib/adapters/REST/endpoints/index.ts Registers the new endpoints in the REST endpoint map.
lib/adapters/REST/endpoints/eligible-license.ts Implements REST endpoint for space eligible licenses.
lib/adapters/REST/endpoints/available-license.ts Implements REST endpoint for org available licenses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bito-code-review
Copy link
Copy Markdown

bito-code-review bot commented Apr 2, 2026

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted Summary
New Feature - License REST Endpoints
Introduces new REST endpoints for available and eligible licenses, integrating them into the endpoint index.
New Feature - License Entity Definitions
Defines new entity types for AvailableLicense and EligibleLicense with properties for license details, quotas, and required allocations.
New Feature - SDK Type System Updates
Updates the SDK's type system to include new entity types and API actions for license resources.
New Feature - API Method Integration
Adds getAvailableLicenses method to organization API and getEligibleLicenses method to space API.
Bug Fix - License Entity Wrapper Updates
Updates license wrapper functions to accept the makeRequest parameter, enabling proper collection wrapping and API functionality.
Testing - Test Updates for License APIs
Adds unit tests and mocks for the new available and eligible license APIs.

@bito-code-review
Copy link
Copy Markdown

bito-code-review bot commented Apr 2, 2026

Impact Analysis by Bito

Interaction Diagram
sequenceDiagram
participant Developer
participant OrganizationApi as OrganizationApi<br/>🔄 Updated | ●●● High
participant MakeRequest
participant AvailableLicenseEndpoint as AvailableLicenseEndpoint<br/>🟩 Added | ●●● High
participant RawAdapter
participant Axios
participant ContentfulAPI
Note over Developer, ContentfulAPI: License data retrieved and transformed through entity wrapping
Developer->>OrganizationApi: getAvailableLicenses(query)
OrganizationApi->>MakeRequest: makeRequest(entityType: AvailableLicense, action: getMany)
MakeRequest->>AvailableLicenseEndpoint: getMany(http, params)
AvailableLicenseEndpoint->>RawAdapter: raw.get<CollectionProp>(http, url, config)
RawAdapter->>Axios: http.get(url, config)
Axios->>ContentfulAPI: GET /organizations/&#123;id&#125;/available_licenses
ContentfulAPI-->>Axios: response data
Axios-->>RawAdapter: response.data
RawAdapter-->>AvailableLicenseEndpoint: CollectionProp<AvailableLicenseProps>
AvailableLicenseEndpoint-->>MakeRequest: data
MakeRequest->>OrganizationApi: wrapAvailableLicenseCollection(data)
OrganizationApi-->>Developer: wrapped collection
Loading

This MR adds license management features by introducing new API methods for available and eligible licenses, including REST endpoints, entity definitions, and data transformation through entity wrapping. It integrates with the external Contentful API for license data retrieval and includes comprehensive testing.

Code Paths Analyzed

Impact:
Adds new API endpoints and methods for retrieving available licenses at the organization level and eligible licenses at the space level, expanding the SDK's capabilities for license management.

Flow:
New REST endpoints (available-license.ts, eligible-license.ts) integrate with existing adapter pattern; new entity wrappers (available-license.ts, eligible-license.ts) follow the established entity structure; API methods (getAvailableLicenses in create-organization-api.ts, getEligibleLicenses in create-space-api.ts) use the makeRequest system to call the endpoints and wrap responses.

Direct Changes (Diff Files):
• lib/adapters/REST/endpoints/available-license.ts [1-22] — New REST endpoint file defining getMany function for available licenses API at /organizations/{organizationId}/available_licenses
• lib/adapters/REST/endpoints/eligible-license.ts [1-16] — New REST endpoint file defining getMany function for eligible licenses API at /spaces/{spaceId}/eligible_licenses
• lib/adapters/REST/endpoints/index.ts [20-28,101-111] — Added imports and exports for AvailableLicense and EligibleLicense endpoints in the REST endpoints index
• lib/common-types.ts [36-37,63-64,580-582,633-637,1495-1501,1718-1730] — Added type imports and MRInternal/MRActions type definitions for AvailableLicense and EligibleLicense entities
• lib/create-organization-api.ts [39,476-477] — Added import for wrapAvailableLicenseCollection and getAvailableLicenses method to organization API
• lib/create-space-api.ts [22,1686-1687] — Added import for wrapEligibleLicenseCollection and getEligibleLicenses method to space API
• lib/entities/available-license.ts [1-312] — New entity file defining AvailableLicenseProps type, quotas, and wrapper functions following SDK patterns
• lib/entities/eligible-license.ts [1-396] — New entity file defining EligibleLicenseProps type, quotas, requiredAddOnAllocation, and wrapper functions
• test/integration/space-add-on-integration.test.ts [42-433] — Added integration tests for getEligibleLicenses method including pagination and structure validation
• test/unit/create-organization-api.test.ts [22,958-959] — Added unit tests for getAvailableLicenses API call and error handling
• test/unit/create-space-api.test.ts [18,641-642] — Added unit tests for getEligibleLicenses API call and error handling
• test/unit/mocks/entities.ts [102-103,1527-1530,1799-1802,2009-2011] — Added mock data and setup for AvailableLicense and EligibleLicense entities in unit tests

Repository Impact:
License Management APIs: Introduces new APIs for querying available licenses per organization and eligible licenses per space, enabling programmatic access to license information
Entity System: Extends the entity wrapping system with new license-related entities, maintaining consistency with existing patterns
Type System: Adds new TypeScript types for license properties, quotas, and API actions, enhancing type safety for license operations

Cross-Repository Dependencies:
None.

Database/Caching Impact:
• None

API Contract Violations:
None.

Infrastructure Dependencies:
None.

Additional Insights:
Quota Management: New license entities include quota information (contentTypes, records, environments), supporting space usage limits and add-on requirements

Testing Recommendations

Frontend Impact:
None.

Service Integration:
• Test the new getAvailableLicenses method with real organization data to verify API responses match expected schema
• Test the new getEligibleLicenses method with real space data to verify API responses match expected schema
• Verify that pagination parameters (limit, skip) work correctly for both new methods
• Test error handling when organization/space IDs are invalid or access is denied

Data Serialization:
• Validate that AvailableLicenseProps and EligibleLicenseProps are correctly serialized/deserialized from API responses
• Test that quota fields handle both numeric values and 'unlimited' string values properly
• Ensure RequiredAddOnAllocation in EligibleLicense is parsed correctly from API data

Privacy Compliance:
None.

Backward Compatibility:
• Verify that existing organization and space API methods remain unaffected by the additions
• Confirm that no breaking changes were introduced to existing entity types or common types

OAuth Functionality:
• None

Reliability Testing:
• None

Additional Insights:
• Run full test suite to ensure no regressions in existing functionality
• Test the new endpoints with various quota combinations (numeric vs unlimited) to ensure proper handling
• Document the new API methods in README or API documentation

Analysis based on known dependency patterns and edges. Actual impact may vary.

Copy link
Copy Markdown

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #72b56b

Actionable Suggestions - 1
  • test/unit/create-space-api.test.ts - 1
    • Incorrect test helper usage for query-based collection method · Line 646-658
Review Details
  • Files reviewed - 11 · Commit Range: f67e445..33b92ad
    • lib/adapters/REST/endpoints/available-license.ts
    • lib/adapters/REST/endpoints/eligible-license.ts
    • lib/adapters/REST/endpoints/index.ts
    • lib/common-types.ts
    • lib/create-organization-api.ts
    • lib/create-space-api.ts
    • lib/entities/available-license.ts
    • lib/entities/eligible-license.ts
    • test/unit/create-organization-api.test.ts
    • test/unit/create-space-api.test.ts
    • test/unit/mocks/entities.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at jared.jolton@contentful.com.

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review
Copy link
Copy Markdown

bito-code-review bot commented Apr 6, 2026

Code Review Agent Run #7f9b6e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 33b92ad..82d7879
    • lib/create-space-api.ts
    • lib/entities/available-license.ts
    • lib/entities/eligible-license.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at jared.jolton@contentful.com.

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review
Copy link
Copy Markdown

bito-code-review bot commented Apr 7, 2026

Code Review Agent Run #4b5ac3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 82d7879..40b507e
    • lib/adapters/REST/endpoints/available-license.ts
    • lib/adapters/REST/endpoints/eligible-license.ts
    • lib/entities/available-license.ts
    • lib/entities/eligible-license.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at jared.jolton@contentful.com.

Documentation & Help

AI Code Review powered by Bito Logo

@cpesket
Copy link
Copy Markdown
Contributor

cpesket commented Apr 7, 2026

Can we add an integration test? It is fine even if it will return empty licenses

@bito-code-review
Copy link
Copy Markdown

bito-code-review bot commented Apr 7, 2026

Code Review Agent Run #27f112

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 40b507e..eeab5b6
    • test/unit/create-space-api.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at jared.jolton@contentful.com.

Documentation & Help

AI Code Review powered by Bito Logo

mu-majid-cf
mu-majid-cf previously approved these changes Apr 7, 2026
Copy link
Copy Markdown

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #645143

Actionable Suggestions - 1
  • test/integration/space-add-on-integration.test.ts - 1
    • Missing test assertion for license count · Line 54-60
Additional Suggestions - 1
  • test/integration/space-add-on-integration.test.ts - 1
    • Inconsistent limit assertion in pagination test · Line 67-69
      The pagination test conditionally checks response.limit only if defined, unlike the similar space add-on test which directly asserts the expected limit value. This inconsistency could mask issues if the API fails to return limit when requested.
Review Details
  • Files reviewed - 1 · Commit Range: eeab5b6..ed8403e
    • test/integration/space-add-on-integration.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at jared.jolton@contentful.com.

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review
Copy link
Copy Markdown

bito-code-review bot commented Apr 7, 2026

Code Review Agent Run #537b99

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: ed8403e..90f53be
    • test/integration/space-add-on-integration.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at jared.jolton@contentful.com.

Documentation & Help

AI Code Review powered by Bito Logo

@dineshswamy dineshswamy (dineshswamy) enabled auto-merge (squash) April 7, 2026 19:33
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.

6 participants