Skip to content

Commit 5cb8bce

Browse files
author
Josselin Liebe
committed
fix(asin): address review feedback
- Describe Read Offers without Prime, which the API does not return - Keep response mappers with a single caller in that tool's file - Document the AsinIcon export - Read the operation from the mapper context so agent tools coerce Days too
1 parent b632395 commit 5cb8bce

10 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎apps/docs/components/icons.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,6 +10460,7 @@ export function PlaneIcon(props: SVGProps<SVGSVGElement>) {
1046010460
)
1046110461
}
1046210462

10463+
/** Asin logo, as used by the Asin block. */
1046310464
export function AsinIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' {...props}>

‎apps/docs/content/docs/integrations/asin.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Search an Amazon store and get up to 60 results, sponsored ones included, with A
6060

6161
### Asin Read Offers
6262

63-
Read every offer for an ASIN from Amazon now (uses a credit): seller, price, Prime and FBA, delivery, with Amazon's own price and the lowest new and used offers.
63+
Read every offer for an ASIN from Amazon now (uses a credit): seller, price, whether Amazon ships it (FBA), delivery, with Amazon's own price and the lowest new and used offers.
6464

6565
<ReferenceDetails>
6666

‎apps/sim/blocks/blocks/asin.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ export const AsinBlock: BlockConfig = {
112112
],
113113
config: {
114114
tool: (params) => `asin_${params.operation}`,
115-
params: (params) => {
115+
params: (params, context) => {
116+
const operation = context?.operation ?? params.operation
116117
const result: Record<string, unknown> = {}
117-
if (params.operation === 'get_price_history') {
118+
if (operation === 'get_price_history') {
118119
result.days = parseOptionalNumberInput(params.days, 'Days', { integer: true, min: 1 })
119120
}
120121
return result

‎apps/sim/components/icons.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10460,6 +10460,7 @@ export function PlaneIcon(props: SVGProps<SVGSVGElement>) {
1046010460
)
1046110461
}
1046210462

10463+
/** Asin logo, as used by the Asin block. */
1046310464
export function AsinIcon(props: SVGProps<SVGSVGElement>) {
1046410465
return (
1046510466
<svg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' {...props}>

‎apps/sim/tools/asin/get_price_history.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2-
import { toArray, toRecord } from '@sim/utils/object'
1+
import { toBooleanOrNull, toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
33
import type {
44
AsinGetPriceHistoryParams,
55
AsinGetPriceHistoryResponse,
66
AsinPricePoint,
77
} from '@/tools/asin/types'
88
import { ASIN_PRICE_POINT_OUTPUT_PROPERTIES } from '@/tools/asin/types'
9-
import { mapAsinPricePoint } from '@/tools/asin/utils'
109
import type { ToolConfig } from '@/tools/types'
1110

11+
/** Reads a `AsinPricePoint` from an untyped Asin API payload. */
12+
function mapAsinPricePoint(value: unknown): AsinPricePoint | null {
13+
const record = toRecordOrNull(value)
14+
if (!record) return null
15+
return {
16+
price: toNumberOrNull(record.price),
17+
inStock: toBooleanOrNull(record.in_stock),
18+
coupon: toStringOrNull(record.coupon),
19+
seller: toStringOrNull(record.seller),
20+
checkedAt: toStringOrNull(record.checked_at),
21+
}
22+
}
23+
1224
export const asinGetPriceHistoryTool: ToolConfig<
1325
AsinGetPriceHistoryParams,
1426
AsinGetPriceHistoryResponse

‎apps/sim/tools/asin/read_offers.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const asinReadOffersTool: ToolConfig<AsinReadOffersParams, AsinReadOffers
99
id: 'asin_read_offers',
1010
name: 'Asin Read Offers',
1111
description:
12-
"Read every offer for an ASIN from Amazon now (uses a credit): seller, price, Prime and FBA, delivery, with Amazon's own price and the lowest new and used offers.",
12+
"Read every offer for an ASIN from Amazon now (uses a credit): seller, price, whether Amazon ships it (FBA), delivery, with Amazon's own price and the lowest new and used offers.",
1313
version: '1.0.0',
1414

1515
params: {

‎apps/sim/tools/asin/search_products.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
import { toArray, toRecord } from '@sim/utils/object'
1+
import { toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
2+
import { toArray, toRecord, toRecordOrNull } from '@sim/utils/object'
23
import type {
34
AsinSearchProductsParams,
45
AsinSearchProductsResponse,
56
AsinSearchResult,
67
} from '@/tools/asin/types'
78
import { ASIN_SEARCH_RESULT_OUTPUT_PROPERTIES } from '@/tools/asin/types'
8-
import { mapAsinSearchResult } from '@/tools/asin/utils'
99
import type { ToolConfig } from '@/tools/types'
1010

11+
/** Reads a `AsinSearchResult` from an untyped Asin API payload. */
12+
function mapAsinSearchResult(value: unknown): AsinSearchResult | null {
13+
const record = toRecordOrNull(value)
14+
if (!record) return null
15+
return {
16+
asin: toStringOrNull(record.asin),
17+
title: toStringOrNull(record.title),
18+
image: toStringOrNull(record.image),
19+
price: toNumberOrNull(record.price),
20+
currency: toStringOrNull(record.currency),
21+
rating: toNumberOrNull(record.rating),
22+
reviewsCount: toNumberOrNull(record.reviews_count),
23+
}
24+
}
25+
1126
export const asinSearchProductsTool: ToolConfig<
1227
AsinSearchProductsParams,
1328
AsinSearchProductsResponse

‎apps/sim/tools/asin/utils.ts‎

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
import { toBooleanOrNull, toNumberOrNull, toStringOrNull } from '@sim/utils/coerce'
22
import { toRecordOrNull } from '@sim/utils/object'
3-
import type { AsinOffer, AsinPricePoint, AsinSearchResult } from '@/tools/asin/types'
4-
5-
/** Reads a `AsinSearchResult` from an untyped Asin API payload. */
6-
export function mapAsinSearchResult(value: unknown): AsinSearchResult | null {
7-
const record = toRecordOrNull(value)
8-
if (!record) return null
9-
return {
10-
asin: toStringOrNull(record.asin),
11-
title: toStringOrNull(record.title),
12-
image: toStringOrNull(record.image),
13-
price: toNumberOrNull(record.price),
14-
currency: toStringOrNull(record.currency),
15-
rating: toNumberOrNull(record.rating),
16-
reviewsCount: toNumberOrNull(record.reviews_count),
17-
}
18-
}
3+
import type { AsinOffer } from '@/tools/asin/types'
194

205
/** Reads a `AsinOffer` from an untyped Asin API payload. */
216
export function mapAsinOffer(value: unknown): AsinOffer | null {
@@ -32,16 +17,3 @@ export function mapAsinOffer(value: unknown): AsinOffer | null {
3217
deliveryPrice: toStringOrNull(record.delivery_price),
3318
}
3419
}
35-
36-
/** Reads a `AsinPricePoint` from an untyped Asin API payload. */
37-
export function mapAsinPricePoint(value: unknown): AsinPricePoint | null {
38-
const record = toRecordOrNull(value)
39-
if (!record) return null
40-
return {
41-
price: toNumberOrNull(record.price),
42-
inStock: toBooleanOrNull(record.in_stock),
43-
coupon: toStringOrNull(record.coupon),
44-
seller: toStringOrNull(record.seller),
45-
checkedAt: toStringOrNull(record.checked_at),
46-
}
47-
}

‎apps/sim/tools/generated/tool-metadata.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎packages/deployment-config/src/integrations.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@
19191919
},
19201920
{
19211921
"name": "Read Offers",
1922-
"description": "Read every offer for an ASIN from Amazon now (uses a credit): seller, price, Prime and FBA, delivery, with Amazon's own price and the lowest new and used offers."
1922+
"description": "Read every offer for an ASIN from Amazon now (uses a credit): seller, price, whether Amazon ships it (FBA), delivery, with Amazon's own price and the lowest new and used offers."
19231923
},
19241924
{
19251925
"name": "Get Last Known Offers",

0 commit comments

Comments
 (0)