restructure and reorganize

This commit is contained in:
2026-02-16 07:47:08 -06:00
parent 561aef8ee3
commit 6d046e90ed
29 changed files with 156 additions and 1797 deletions
-27
View File
@@ -1,27 +0,0 @@
import axios, { AxiosInstance } from "axios";
export async function fetchAuthRedirectUri(api_url: string): Promise<{
uri: string;
callbackKey: string;
}> {
const client: AxiosInstance = axios.create({
baseURL: api_url || "",
timeout: 5000,
});
try {
const res = await client.get("/v1/auth/uri");
const d = res.data ?? {};
const uri = d.data.uri;
const callbackKey = d.data.callbackKey;
if (typeof uri !== "string" || !uri)
throw new Error("redirect uri missing from response");
return {
uri,
callbackKey,
};
} catch (e) {
throw new Error(
`Failed to fetch auth redirect uri: ${(e as Error).message}`,
);
}
}
+9 -4
View File
@@ -1,10 +1,15 @@
// place files you want to import through the `$lib` alias in this folder.
export * from "./axios";
export * from "./user";
export * from "./companies";
export * from "./credentialTypes";
import { user } from "./optima-api/modules/user";
export const optima = {
auth: (await import("./optima-api/modules/auth")).auth,
company: (await import("./optima-api/modules/companies")).company,
credential: (await import("./optima-api/modules/credentials")).credential,
credentialType: (await import("./optima-api/modules/credentialTypes"))
.credentialType,
user,
};
/**
* @TODO
*
+29
View File
@@ -0,0 +1,29 @@
import axios, { AxiosInstance } from "axios";
export const auth = {
async fetchAuthRedirectUri(api_url: string): Promise<{
uri: string;
callbackKey: string;
}> {
const client: AxiosInstance = axios.create({
baseURL: api_url || "",
timeout: 5000,
});
try {
const res = await client.get("/v1/auth/uri");
const d = res.data ?? {};
const uri = d.data.uri;
const callbackKey = d.data.callbackKey;
if (typeof uri !== "string" || !uri)
throw new Error("redirect uri missing from response");
return {
uri,
callbackKey,
};
} catch (e) {
throw new Error(
`Failed to fetch auth redirect uri: ${(e as Error).message}`,
);
}
},
};
@@ -1,4 +1,4 @@
import api from "./axios";
import api from "../axios";
export const company = {
async fetch(accessToken: string, id: string) {
@@ -1,4 +1,4 @@
import api from "./axios";
import api from "../axios";
export interface CredentialTypeField {
id: string;
@@ -1,4 +1,4 @@
import api from "./axios";
import api from "../axios";
export interface CredentialField {
id: string;