Skip to content

Add aws marketplace commands#221

Merged
odinellefsen merged 5 commits into
mainfrom
add-aws-marketplace-commands
May 4, 2026
Merged

Add aws marketplace commands#221
odinellefsen merged 5 commits into
mainfrom
add-aws-marketplace-commands

Conversation

@odinellefsen
Copy link
Copy Markdown
Contributor

@odinellefsen odinellefsen commented May 4, 2026

Summary by CodeRabbit

  • New Features
    • Resolve AWS Marketplace customers using registration tokens.
    • Manage marketplace links: create, fetch, list with filtering options, and delete operations.
    • Support for product properties, license key configuration, and dedicated cluster type settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

This PR introduces AWS Marketplace integration by adding five new command classes for customer resolution and link management (CRUD operations), comprehensive TypeBox schemas defining AWS Marketplace data contracts, and test coverage verifying command behavior across bearer token and API key authentication modes.

Changes

AWS Marketplace Integration

Layer / File(s) Summary
Data Contracts
src/contracts/aws-marketplace.ts, src/contracts/index.ts
Defines TypeBox schemas for AWS Marketplace entities: DedicatedClusterType, ProductMode, ProductProperties, Customer, Link; and operation payloads: CustomerResolve, LinkCreate, LinkList, LinkFetch, LinkDelete. Type exports are re-exposed in contracts barrel.
Command Implementations
src/commands/aws-marketplace/aws-marketplace-customer.resolve.ts, src/commands/aws-marketplace/aws-marketplace-link.*.ts (create, delete, fetch, list)
Implements five command classes, each extending Command with fixed configuration: base URL to https://subscription-2.api.flowcore.io, no retry on failure, bearer-only authentication, and response parsing via schema validators. Customer resolve uses POST; link operations use POST (create), DELETE (delete), GET with path param (fetch), and GET with query params (list).
Command Exports
src/commands/index.ts
Re-exports all five new AWS Marketplace command modules under an // AWS Marketplace section.
Tests & Mocking
test/tests/commands/aws-marketplace.test.ts
Verifies customer resolve, link CRUD operations, and API-key mode rejection via mocked HTTP requests. Includes buildAwsMarketplaceLink() helper for generating deterministic test fixtures and per-test mock verification.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • suuunly
  • jbiskur

Poem

🐰 Five new commands hop into the fray,
AWS Marketplace links dance and play,
With schemas all typed and tests keeping watch,
Each POST and GET, a perfectly notched,
Bearer tokens bouncing, credentials in check! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add aws marketplace commands' directly and clearly summarizes the main change: adding new AWS Marketplace command modules (customer resolve and link CRUD operations).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-aws-marketplace-commands

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/contracts/aws-marketplace.ts (2)

68-68: 💤 Low value

Consider documenting expected formats for string fields.

The metadata and linkedAt fields are typed as strings but likely contain structured data:

  • metadata (line 68): May contain JSON or specific AWS Marketplace metadata format
  • linkedAt (line 99): Likely an ISO 8601 timestamp

Adding JSDoc comments describing the expected format would improve developer experience.

📝 Example documentation enhancement
 export const AwsMarketplaceCustomerSchema: TObject<{
   customerId: TString
   productCode: TString
   accountId: TString
+  /** Metadata in JSON string format */
   metadata: TString
   productMode: typeof AwsMarketplaceProductModeSchema
 }> = Type.Object({

...

 export const AwsMarketplaceLinkSchema: TObject<{
   linkingId: TString
   awsCustomerId: TString
   awsProductCode: TString
   awsAccountId: TString
   tenant: TUnion<[TString, TNull]>
   tenantId: TString
   contactInfo: TUnion<[TString, TNull]>
   productProperties: TUnion<[TRecord<TString, TString>, TNull]>
+  /** ISO 8601 timestamp of when the link was created */
   linkedAt: TString
 }> = Type.Object({

Also applies to: 99-99

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/contracts/aws-marketplace.ts` at line 68, Add JSDoc comments above the
`metadata` and `linkedAt` fields in the AWS Marketplace contract to document
expected formats (leave their Type.String() types unchanged); e.g., describe
`metadata` as JSON or the specific AWS Marketplace metadata structure
(keys/values or example shape) and describe `linkedAt` as an ISO 8601 timestamp
(UTC) so IDEs and future readers know the canonical formats for `metadata` and
`linkedAt`.

32-35: Consider reusing AwsMarketplaceProductPropertiesSchema for consistency or clarify intent.

AwsMarketplaceProductPropertiesSchema is defined and exported but not used within this file or elsewhere in the codebase. Additionally, there's a semantic inconsistency:

  • AwsMarketplaceProductPropertiesSchema (line 32): Record<string, Optional<string>> — values may be undefined
  • AwsMarketplaceLinkSchema.productProperties (line 98): Record<string, string> | null — values must be strings, entire record may be null

If both represent the same concept, reuse AwsMarketplaceProductPropertiesSchema in line 98 for consistency. If they intentionally differ, document why in the schema JSDoc.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/contracts/aws-marketplace.ts` around lines 32 - 35, The exported
AwsMarketplaceProductPropertiesSchema defines a Record<string, Optional<string>>
but is not used and conflicts with AwsMarketplaceLinkSchema.productProperties
which is typed as Record<string, string> | null; update the code so these
representations are consistent: either reuse
AwsMarketplaceProductPropertiesSchema for productProperties (make
productProperties a union with null if nullability is required) by referencing
AwsMarketplaceProductPropertiesSchema in AwsMarketplaceLinkSchema, or if the
difference is intentional add a clear JSDoc on
AwsMarketplaceProductPropertiesSchema explaining why values are Optional<string>
while AwsMarketplaceLinkSchema.productProperties requires non-optional strings
and may be null; change the schema references
(AwsMarketplaceProductPropertiesSchema,
AwsMarketplaceLinkSchema.productProperties) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/aws-marketplace/aws-marketplace-link.list.ts`:
- Around line 50-57: The getPath method in AwsMarketplaceLinkListCommand appends
a trailing '?' when no query params exist; change it to only append the query
string when queryParams.toString() is non-empty (mirror the conditional pattern
used in AwsMarketplaceLinkDeleteCommand): build queryParams as now, store const
q = queryParams.toString(), and return `/api/v1/aws-marketplace/links${q ?
`?${q}` : ''}` so no trailing '?' is emitted for empty input.

---

Nitpick comments:
In `@src/contracts/aws-marketplace.ts`:
- Line 68: Add JSDoc comments above the `metadata` and `linkedAt` fields in the
AWS Marketplace contract to document expected formats (leave their Type.String()
types unchanged); e.g., describe `metadata` as JSON or the specific AWS
Marketplace metadata structure (keys/values or example shape) and describe
`linkedAt` as an ISO 8601 timestamp (UTC) so IDEs and future readers know the
canonical formats for `metadata` and `linkedAt`.
- Around line 32-35: The exported AwsMarketplaceProductPropertiesSchema defines
a Record<string, Optional<string>> but is not used and conflicts with
AwsMarketplaceLinkSchema.productProperties which is typed as Record<string,
string> | null; update the code so these representations are consistent: either
reuse AwsMarketplaceProductPropertiesSchema for productProperties (make
productProperties a union with null if nullability is required) by referencing
AwsMarketplaceProductPropertiesSchema in AwsMarketplaceLinkSchema, or if the
difference is intentional add a clear JSDoc on
AwsMarketplaceProductPropertiesSchema explaining why values are Optional<string>
while AwsMarketplaceLinkSchema.productProperties requires non-optional strings
and may be null; change the schema references
(AwsMarketplaceProductPropertiesSchema,
AwsMarketplaceLinkSchema.productProperties) accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d4af46ea-dc1d-4b60-b818-9d07669a432c

📥 Commits

Reviewing files that changed from the base of the PR and between 984698e and 4e0bf83.

📒 Files selected for processing (9)
  • src/commands/aws-marketplace/aws-marketplace-customer.resolve.ts
  • src/commands/aws-marketplace/aws-marketplace-link.create.ts
  • src/commands/aws-marketplace/aws-marketplace-link.delete.ts
  • src/commands/aws-marketplace/aws-marketplace-link.fetch.ts
  • src/commands/aws-marketplace/aws-marketplace-link.list.ts
  • src/commands/index.ts
  • src/contracts/aws-marketplace.ts
  • src/contracts/index.ts
  • test/tests/commands/aws-marketplace.test.ts

Comment on lines +50 to +57
protected override getPath(): string {
const queryParams = new URLSearchParams()
if (this.input.tenant) queryParams.set("tenant", this.input.tenant)
if (this.input.tenantId) queryParams.set("tenantId", this.input.tenantId)
if (this.input.awsCustomerId) queryParams.set("awsCustomerId", this.input.awsCustomerId)
if (this.input.awsProductCode) queryParams.set("awsProductCode", this.input.awsProductCode)
return `/api/v1/aws-marketplace/links?${queryParams.toString()}`
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Trailing ? emitted when no query parameters are provided.

When AwsMarketplaceLinkListCommand is called with an empty input (all four optional fields absent), queryParams.toString() returns "" and the resulting path is /api/v1/aws-marketplace/links?. Some API gateways and routing layers treat a trailing ? as a distinct path, which can cause unexpected 404s or routing mismatches. AwsMarketplaceLinkDeleteCommand already uses the correct conditional pattern — apply the same here.

🐛 Proposed fix
   protected override getPath(): string {
     const queryParams = new URLSearchParams()
     if (this.input.tenant) queryParams.set("tenant", this.input.tenant)
     if (this.input.tenantId) queryParams.set("tenantId", this.input.tenantId)
     if (this.input.awsCustomerId) queryParams.set("awsCustomerId", this.input.awsCustomerId)
     if (this.input.awsProductCode) queryParams.set("awsProductCode", this.input.awsProductCode)
-    return `/api/v1/aws-marketplace/links?${queryParams.toString()}`
+    const query = queryParams.toString()
+    return `/api/v1/aws-marketplace/links${query ? `?${query}` : ""}`
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/aws-marketplace/aws-marketplace-link.list.ts` around lines 50 -
57, The getPath method in AwsMarketplaceLinkListCommand appends a trailing '?'
when no query params exist; change it to only append the query string when
queryParams.toString() is non-empty (mirror the conditional pattern used in
AwsMarketplaceLinkDeleteCommand): build queryParams as now, store const q =
queryParams.toString(), and return `/api/v1/aws-marketplace/links${q ? `?${q}` :
''}` so no trailing '?' is emitted for empty input.

@odinellefsen odinellefsen merged commit cf0ea9e into main May 4, 2026
2 checks passed
@odinellefsen odinellefsen deleted the add-aws-marketplace-commands branch May 4, 2026 08:36
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.

1 participant