Skip to content

Commit 1cc3991

Browse files
committed
prettier fix
1 parent 0cfb3fa commit 1cc3991

File tree

9 files changed

+43
-46
lines changed

9 files changed

+43
-46
lines changed

src/server/auth/custom-providers/etsy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { env } from "@/env";
22
import type { OAuth2Config, OAuthUserConfig } from "@auth/core/providers";
3-
import {db} from "@/server/db";
3+
import { db } from "@/server/db";
44

55
export interface EtsyProfile {
66
user_id: number; // The numeric ID of a user. Also a valid shop ID.
@@ -66,16 +66,16 @@ export default function EtsyProvider<P extends EtsyProfile>(
6666
}
6767

6868
export async function refreshEtsyAccessToken(
69-
refreshToken: string,
70-
providerAccountId: string
69+
refreshToken: string,
70+
providerAccountId: string,
7171
) {
7272
const response = await fetch("https://api.etsy.com/v3/public/oauth/token", {
7373
method: "POST",
7474
headers: { "Content-Type": "application/x-www-form-urlencoded" },
7575
body: new URLSearchParams({
7676
grant_type: "refresh_token",
7777
client_id: process.env.AUTH_ETSY_ID!, // your app's client_id
78-
refresh_token: refreshToken, // the one you stored
78+
refresh_token: refreshToken, // the one you stored
7979
}),
8080
});
8181
if (!response.ok) {

src/toolkits/toolkits/Etsy/base.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import type { ToolkitConfig } from "@/toolkits/types";
33
import { EtsyTools } from "./tools/tools";
44
import { getListings } from "@/toolkits/toolkits/Etsy/tools/getListings/base";
55

6-
76
export const etsyParameters = z.object({});
87

98
export const baseEtsyToolkitConfig: ToolkitConfig<
109
EtsyTools,
1110
typeof etsyParameters.shape
1211
> = {
1312
tools: {
14-
[EtsyTools.getListings]: getListings
13+
[EtsyTools.getListings]: getListings,
1514
},
1615
parameters: etsyParameters,
17-
}
16+
};

src/toolkits/toolkits/Etsy/client.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export const etsyClientToolkit = createClientToolkit(
2626
<Link href="https://www.etsy.com/developers">here</Link>
2727
</span>
2828
),
29-
}],
29+
},
30+
],
3031
},
3132
{
32-
[EtsyTools.getListings]: getListingsClientConfig
33-
}
34-
)
33+
[EtsyTools.getListings]: getListingsClientConfig,
34+
},
35+
);

src/toolkits/toolkits/Etsy/server.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { getListingsServerConfig } from "@/toolkits/toolkits/Etsy/tools/getListi
55
import { api } from "@/trpc/server";
66
export const etsyToolkitServer = createServerToolkit(
77
baseEtsyToolkitConfig,
8-
'You have access to the Etsy toolkit for general account management. Currently, this toolkit provides:\n' +
9-
'- **Get Listings**: Retrieves all listings and their image URLs associated with the shop associated with the signed-in user.\n\n',
8+
"You have access to the Etsy toolkit for general account management. Currently, this toolkit provides:\n" +
9+
"- **Get Listings**: Retrieves all listings and their image URLs associated with the shop associated with the signed-in user.\n\n",
1010
async () => {
1111
const account = await api.accounts.getAccountByProvider("etsy");
1212

@@ -18,7 +18,7 @@ export const etsyToolkitServer = createServerToolkit(
1818
}
1919

2020
return {
21-
[EtsyTools.getListings]: getListingsServerConfig()
22-
};
23-
}
24-
);
21+
[EtsyTools.getListings]: getListingsServerConfig(),
22+
};
23+
},
24+
);

src/toolkits/toolkits/Etsy/tools/getListings/base.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import { ShopListing } from "etsy-ts/dist/api/ShopListing";
44
import type { IShopListingsWithAssociations } from "etsy-ts";
55

66
export const getListings = createBaseTool({
7-
description: "Fetches all listings from the Etsy shop associated with the authenticated user.",
8-
inputSchema: z.object({
9-
}),
10-
outputSchema: z.object({
11-
})
7+
description:
8+
"Fetches all listings from the Etsy shop associated with the authenticated user.",
9+
inputSchema: z.object({}),
10+
outputSchema: z.object({}),
1211
// outputSchema: z.object({
1312
// title: z.string().describe("The title of the Etsy listing"),
1413
// description: z.string().describe("The description of the Etsy listing"),
1514
// price: z.number().describe("The price of the Etsy listing"),
1615
// currencyCode: z.string().describe("The currency code for the price"),
1716
// images: z.array(z.string()).describe("URLs of images for the Etsy listing"),
1817
// }),
19-
});
18+
});
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ClientToolConfig} from "@/toolkits/types";
1+
import type { ClientToolConfig } from "@/toolkits/types";
22
import type { getListings } from "./base";
33

44
export const getListingsClientConfig: ClientToolConfig<
@@ -12,8 +12,6 @@ export const getListingsClientConfig: ClientToolConfig<
1212
</div>
1313
),
1414
ResultComponent: ({ args, result }) => (
15-
<div className="border rounded p-4">
16-
17-
</div>
18-
)
19-
};
15+
<div className="rounded border p-4"></div>
16+
),
17+
};

src/toolkits/toolkits/Etsy/tools/getListings/server.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import type { ServerToolConfig } from "@/toolkits/types";
22
import type { getListings } from "./base";
33
import { api } from "@/trpc/server";
4-
import { refreshEtsyAccessToken} from "@/server/auth/custom-providers/etsy";
4+
import { refreshEtsyAccessToken } from "@/server/auth/custom-providers/etsy";
55

6-
7-
export const getListingsServerConfig = (
8-
9-
): ServerToolConfig<
6+
export const getListingsServerConfig = (): ServerToolConfig<
107
typeof getListings.inputSchema.shape,
118
typeof getListings.outputSchema.shape
129
> => {
@@ -21,36 +18,40 @@ export const getListingsServerConfig = (
2118
const accessExpiry = account?.expires_at;
2219

2320
if (!apiKey) throw new Error("Missing AUTH_ETSY_ID");
24-
if (accessExpiry && refreshToken && userID && (accessExpiry < Date.now() / 1000)) {
21+
if (
22+
accessExpiry &&
23+
refreshToken &&
24+
userID &&
25+
accessExpiry < Date.now() / 1000
26+
) {
2527
await refreshEtsyAccessToken(refreshToken, userID);
2628
}
2729

2830
const accessToken = account?.access_token;
2931
if (!accessToken) throw new Error("Missing Etsy access token");
3032

31-
3233
const shopResponse = await fetch(
3334
`https://openapi.etsy.com/v3/application/users/${etsyUserId}/shops`,
3435
{
3536
headers: {
3637
"x-api-key": apiKey,
3738
Authorization: `Bearer ${accessToken}`,
38-
}
39+
},
3940
},
4041
);
4142

42-
const shop = (await shopResponse.json());
43+
const shop = await shopResponse.json();
4344

4445
const listingResponse = await fetch(
4546
`https://openapi.etsy.com/v3/application/shops/${shop.shop_id}/listings`,
4647
{
4748
headers: {
4849
"x-api-key": apiKey,
4950
Authorization: `Bearer ${accessToken}`,
50-
}
51+
},
5152
},
5253
);
53-
const listings = (await listingResponse.json());
54+
const listings = await listingResponse.json();
5455

5556
// this is going to be very inefficient code for large shops, but let's do this for now. I can raise QPS ratelimits if needed
5657
// for each listing, fetch the images
@@ -62,14 +63,13 @@ export const getListingsServerConfig = (
6263
headers: {
6364
"x-api-key": apiKey,
6465
Authorization: `Bearer ${accessToken}`,
65-
}
66+
},
6667
},
6768
);
68-
const images = (await imageResponse.json());
69+
const images = await imageResponse.json();
6970
listing.images = images.results;
7071
}
7172

72-
7373
return {
7474
listings: listings,
7575
};
@@ -82,4 +82,4 @@ export const getListingsServerConfig = (
8282
"Successfully retrieved the Etsy listing. The user is shown the responses in the UI. Do not reiterate them. " +
8383
"If you called this tool because the user asked a question, answer the question.",
8484
};
85-
};
85+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export enum EtsyTools {
22
getListings = "get-listings",
3-
}
3+
}

src/toolkits/toolkits/Etsy/wrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ export const EtsyWrapper: ClientToolkitWrapper = ({ Item }) => {
5757
}
5858

5959
return <Item isLoading={false} />;
60-
};
60+
};

0 commit comments

Comments
 (0)