@proofkit/fmdapi
Version:
FileMaker Data API client
30 lines (29 loc) • 1.16 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { BaseFetchAdapter } from "./fetch-base.js";
class OttoAdapter extends BaseFetchAdapter {
constructor(options) {
super({ ...options, refreshToken: false });
__publicField(this, "apiKey");
__publicField(this, "port");
__publicField(this, "getToken", async () => {
return this.apiKey;
});
this.apiKey = options.auth.apiKey;
this.port = options.auth.ottoPort;
if (this.apiKey.startsWith("KEY_")) {
this.baseUrl.port = (this.port ?? 3030).toString();
} else if (this.apiKey.startsWith("dk_")) {
this.baseUrl.pathname = `otto/${this.baseUrl.pathname.replace(/^\/+|\/+$/g, "")}`;
} else {
throw new Error(
"Invalid Otto API key format. Must start with 'KEY_' (Otto v3) or 'dk_' (OttoFMS)"
);
}
}
}
export {
OttoAdapter
};
//# sourceMappingURL=otto.js.map