"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const postSheet_1 = __importDefault(require("../google-sheets/postSheet"));
const destination = {
    name: 'Google Sheets (dev only)',
    slug: 'actions-google-sheets-dev',
    mode: 'cloud',
    authentication: {
        scheme: 'oauth-managed',
        fields: {},
        refreshAccessToken: async (request, { auth }) => {
            if (!auth.refreshTokenUrl)
                throw new Error('destination misconfigured: missing refresh token URL');
            const res = await request(auth.refreshTokenUrl, {
                method: 'POST',
                body: new URLSearchParams({
                    refresh_token: auth.refreshToken,
                    client_id: auth.clientId,
                    client_secret: auth.clientSecret,
                    grant_type: 'refresh_token'
                })
            });
            return { accessToken: res.data.access_token };
        }
    },
    extendRequest({ auth }) {
        return {
            headers: {
                authorization: `Bearer ${auth?.accessToken}`
            }
        };
    },
    actions: {
        postSheet: postSheet_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map