···1-import { AtpAgent } from "@atproto/api";
2-3-export const agent = new AtpAgent({
4- // App View URL
5- service: "https://api.bsky.app",
6- // If you were making an authenticated client, you would
7- // use the PDS URL here instead - the main one is bsky.social
8- // service: "https://bsky.social",
9-});
···000000000
-29
lib/sheetsConnector.js
···1-import Papa from "papaparse";
2-3-/**Fetch the CSV data from the provided Google Sheets URL. */
4-export async function getSheetsCSV(url) {
5- const response = await fetch(url);
6-7- if (!response.ok) {
8- throw new Error(`Failed to fetch data from ${url}`);
9- }
10-11- const csv = await response.text();
12- return csv;
13-}
14-15-/**Parse the provided CSV data into an array of JSON objects. */
16-export function parseCSV(csvData) {
17- return Papa.parse(csvData, { header: true });
18-}
19-20-/**Convenience function to fetch CSV data from the provided Google Sheets URL
21- * and parse it into an array of JSON objects, all in one.
22- *
23- * Combines getSheetsCSV and parseCSV.
24- */
25-export async function importCSVDataAsJson(url) {
26- const csv = await getSheetsCSV(url);
27- const json = parseCSV(csv);
28- return json;
29-}
···00000000000000000000000000000
+2-2
lib/sheetsConnector.ts
···14}
1516/**Parse the provided CSV data into an array of JSON objects. */
17-function parseCSV(csvData: string): ParseResult<string> {
18 return Papa.parse(csvData, { header: true });
19}
20···25 */
26export async function importCSVDataAsJson(
27 url: string
28-): Promise<ParseResult<string>> {
29 const urlObj = new URL(url);
3031 const csv = await getSheetsCSV(urlObj);
···14}
1516/**Parse the provided CSV data into an array of JSON objects. */
17+function parseCSV(csvData: string): ParseResult<any> {
18 return Papa.parse(csvData, { header: true });
19}
20···25 */
26export async function importCSVDataAsJson(
27 url: string
28+): Promise<ParseResult<any>> {
29 const urlObj = new URL(url);
3031 const csv = await getSheetsCSV(urlObj);