Add aws marketplace commands#221
Conversation
…omer, product, and link management
📝 WalkthroughWalkthroughThis 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. ChangesAWS Marketplace Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/contracts/aws-marketplace.ts (2)
68-68: 💤 Low valueConsider documenting expected formats for string fields.
The
metadataandlinkedAtfields are typed as strings but likely contain structured data:
metadata(line 68): May contain JSON or specific AWS Marketplace metadata formatlinkedAt(line 99): Likely an ISO 8601 timestampAdding 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 reusingAwsMarketplaceProductPropertiesSchemafor consistency or clarify intent.
AwsMarketplaceProductPropertiesSchemais 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 undefinedAwsMarketplaceLinkSchema.productProperties(line 98):Record<string, string> | null— values must be strings, entire record may be nullIf both represent the same concept, reuse
AwsMarketplaceProductPropertiesSchemain 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
📒 Files selected for processing (9)
src/commands/aws-marketplace/aws-marketplace-customer.resolve.tssrc/commands/aws-marketplace/aws-marketplace-link.create.tssrc/commands/aws-marketplace/aws-marketplace-link.delete.tssrc/commands/aws-marketplace/aws-marketplace-link.fetch.tssrc/commands/aws-marketplace/aws-marketplace-link.list.tssrc/commands/index.tssrc/contracts/aws-marketplace.tssrc/contracts/index.tstest/tests/commands/aws-marketplace.test.ts
| 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()}` | ||
| } |
There was a problem hiding this comment.
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.
Summary by CodeRabbit