var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { AirtableApiKey, AirtableBaseId } from "../EnvironmentConfig";
import PositiveNumber from "../../Types/PositiveNumber";
import AirtableLib from "airtable";
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
class Airtable {
    static async find(tableName, airtableView, limit) {
        return this.base(tableName)
            .select({ view: airtableView, pageSize: limit.toNumber() })
            .firstPage();
    }
    static async update(tableName, id, fields) {
        await this.base(tableName).update(id, fields);
    }
    static async create(tableName, fields) {
        await this.base(tableName).create(fields);
    }
    static async delete(tableName, id) {
        await this.base(tableName).destroy(id);
    }
}
Airtable.base = new AirtableLib({ apiKey: AirtableApiKey }).base(AirtableBaseId);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, PositiveNumber]),
    __metadata("design:returntype", Promise)
], Airtable, "find", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object]),
    __metadata("design:returntype", Promise)
], Airtable, "update", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], Airtable, "create", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", Promise)
], Airtable, "delete", null);
export default Airtable;
//# sourceMappingURL=Airtable.js.map