2024-03-21 05:15:12 +00:00
|
|
|
import type {AuthProvider} from "@refinedev/core";
|
2024-03-19 11:20:11 +00:00
|
|
|
import {fileProvider} from "~/data/file-provider.js";
|
|
|
|
import {Sdk} from "@lumeweb/portal-sdk";
|
|
|
|
import {accountProvider} from "~/data/account-provider.js";
|
|
|
|
import type {SdkProvider} from "~/data/sdk-provider.js";
|
|
|
|
import {createPortalAuthProvider} from "~/data/auth-provider.js";
|
2024-03-21 05:15:12 +00:00
|
|
|
import { pinningProvider } from "./pinning-provider";
|
2024-03-19 11:20:11 +00:00
|
|
|
|
|
|
|
interface DataProviders {
|
|
|
|
default: SdkProvider;
|
|
|
|
auth: AuthProvider;
|
|
|
|
[key: string]: SdkProvider | AuthProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
let providers: DataProviders;
|
|
|
|
|
|
|
|
export function getProviders(sdk: Sdk) {
|
|
|
|
if (providers) {
|
|
|
|
return providers;
|
|
|
|
}
|
|
|
|
|
|
|
|
accountProvider.sdk = sdk;
|
|
|
|
fileProvider.sdk = sdk;
|
|
|
|
providers = {
|
|
|
|
default: accountProvider,
|
|
|
|
auth: createPortalAuthProvider(sdk),
|
|
|
|
files: fileProvider,
|
2024-03-21 05:15:12 +00:00
|
|
|
pinning: pinningProvider
|
2024-03-19 11:20:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return providers;
|
|
|
|
}
|