Remove useless shortcut

This commit is contained in:
Arnaud 2025-04-01 11:35:41 +02:00
parent 0b66e55016
commit 18cffa0e02
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
18 changed files with 45 additions and 54 deletions

View File

@ -38,8 +38,8 @@ export function AvailabilityReservations({
error, error,
} = useQuery({ } = useQuery({
queryFn: () => queryFn: () =>
CodexSdk.marketplace() CodexSdk.client()
.reservations(availability!.id) .marketplace.reservations(availability!.id)
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
queryKey: ["reservations"], queryKey: ["reservations"],

View File

@ -33,8 +33,8 @@ export function useAvailabilityMutation(
input: Omit<AvailabilityState, "totalSizeUnit" | "durationUnit"> input: Omit<AvailabilityState, "totalSizeUnit" | "durationUnit">
) => Promise<"" | CodexAvailability> = input.id ) => Promise<"" | CodexAvailability> = input.id
? (input) => { ? (input) => {
return CodexSdk.marketplace() return CodexSdk.client()
.updateAvailability({ .marketplace.updateAvailability({
totalSize: input.totalSize, totalSize: input.totalSize,
duration: input.duration, duration: input.duration,
minPricePerBytePerSecond: input.minPricePerBytePerSecond, minPricePerBytePerSecond: input.minPricePerBytePerSecond,
@ -44,8 +44,8 @@ export function useAvailabilityMutation(
.then((s) => Promises.rejectOnError(s)); .then((s) => Promises.rejectOnError(s));
} }
: (input) => : (input) =>
CodexSdk.marketplace() CodexSdk.client()
.createAvailability(input) .marketplace.createAvailability(input)
.then((s) => Promises.rejectOnError(s)); .then((s) => Promises.rejectOnError(s));
return fn({ return fn({

View File

@ -26,8 +26,8 @@ type Props = {
export function FileDetails({ onClose, details }: Props) { export function FileDetails({ onClose, details }: Props) {
const { data: purchases = [] } = useQuery({ const { data: purchases = [] } = useQuery({
queryFn: () => queryFn: () =>
CodexSdk.marketplace() CodexSdk.client()
.purchases() .marketplace.purchases()
.then(async (res) => { .then(async (res) => {
if (res.error) { if (res.error) {
return res; return res;

View File

@ -17,8 +17,8 @@ export function LogLevel() {
const [level, setLevel] = useState<CodexLogLevel>("DEBUG"); const [level, setLevel] = useState<CodexLogLevel>("DEBUG");
const { mutateAsync, isPending } = useMutation({ const { mutateAsync, isPending } = useMutation({
mutationFn: (level: CodexLogLevel) => mutationFn: (level: CodexLogLevel) =>
CodexSdk.debug() CodexSdk.client()
.setLogLevel(level) .debug.setLogLevel(level)
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
onSuccess: () => { onSuccess: () => {
setToast({ setToast({

View File

@ -11,8 +11,8 @@ export function ManifestFetch() {
const { refetch } = useQuery({ const { refetch } = useQuery({
queryFn: () => { queryFn: () => {
CodexSdk.data() CodexSdk.client()
.networkDownload(cid) .data.networkDownload(cid)
.then((s) => { .then((s) => {
if (s.error === false) { if (s.error === false) {
setCid(""); setCid("");
@ -21,8 +21,8 @@ export function ManifestFetch() {
return Promises.rejectOnError(s); return Promises.rejectOnError(s);
}); });
return CodexSdk.data() return CodexSdk.client()
.fetchManifest(cid) .data.fetchManifest(cid)
.then((s) => { .then((s) => {
if (s.error === false) { if (s.error === false) {
setCid(""); setCid("");

View File

@ -15,8 +15,8 @@ const defaultSpace = {
export function NodeSpace() { export function NodeSpace() {
const { data: space, isPending } = useQuery({ const { data: space, isPending } = useQuery({
queryFn: () => queryFn: () =>
CodexSdk.data() CodexSdk.client()
.space() .data.space()
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
queryKey: ["space"], queryKey: ["space"],
initialData: defaultSpace, initialData: defaultSpace,

View File

@ -23,8 +23,8 @@ export function PurchasesTable() {
const content = useData(); const content = useData();
const { data, isPending } = useQuery({ const { data, isPending } = useQuery({
queryFn: () => queryFn: () =>
CodexSdk.marketplace() CodexSdk.client()
.purchases() .marketplace.purchases()
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
queryKey: ["purchases"], queryKey: ["purchases"],

View File

@ -92,7 +92,7 @@ export function StorageRequestFileChooser({
editable={false} editable={false}
multiple={false} multiple={false}
onDeleteItem={onDelete} onDeleteItem={onDelete}
codexData={CodexSdk.data()} codexData={CodexSdk.client().data}
successMessage={"Success, the CID has been copied to the field on top."} successMessage={"Success, the CID has been copied to the field on top."}
/> />
</div> </div>

View File

@ -18,8 +18,8 @@ export function useStorageRequestMutation(
const { mutateAsync } = useMutation({ const { mutateAsync } = useMutation({
mutationFn: (input: CodexCreateStorageRequestInput) => mutationFn: (input: CodexCreateStorageRequestInput) =>
CodexSdk.marketplace() CodexSdk.client()
.createStorageRequest(input) .marketplace.createStorageRequest(input)
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
onSuccess: async () => { onSuccess: async () => {
queryClient.invalidateQueries({ queryKey: ["purchases"] }); queryClient.invalidateQueries({ queryKey: ["purchases"] });

View File

@ -16,7 +16,7 @@ export function UploadCard() {
<main> <main>
<Upload <Upload
multiple multiple
codexData={CodexSdk.data()} codexData={CodexSdk.client().data}
onSuccess={onSuccess} onSuccess={onSuccess}
Icon={() => <UploadIcon width={40} color={"#96969666"} />} Icon={() => <UploadIcon width={40} color={"#96969666"} />}
/> />

View File

@ -8,8 +8,8 @@ export function useCodexConnection() {
const { data, isError, isFetching, refetch } = useQuery({ const { data, isError, isFetching, refetch } = useQuery({
queryKey: ["spr"], queryKey: ["spr"],
queryFn: async () => { queryFn: async () => {
return CodexSdk.node() return CodexSdk.client()
.spr() .node.spr()
.then((data) => Promises.rejectOnError(data, report)); .then((data) => Promises.rejectOnError(data, report));
}, },
refetchInterval: 5000, refetchInterval: 5000,

View File

@ -8,8 +8,8 @@ export function useData() {
const { data = { content: [] } satisfies CodexDataResponse } = const { data = { content: [] } satisfies CodexDataResponse } =
useQuery<CodexDataResponse>({ useQuery<CodexDataResponse>({
queryFn: () => queryFn: () =>
CodexSdk.data() CodexSdk.client()
.cids() .data.cids()
.then((res) => Promises.rejectOnError(res)), .then((res) => Promises.rejectOnError(res)),
queryKey: ["cids"], queryKey: ["cids"],

View File

@ -6,8 +6,8 @@ export function useDebug(throwOnError: boolean) {
const { data, isError, isPending, refetch, isSuccess, isFetching } = useQuery( const { data, isError, isPending, refetch, isSuccess, isFetching } = useQuery(
{ {
queryFn: () => queryFn: () =>
CodexSdk.debug() CodexSdk.client()
.info() .debug.info()
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
queryKey: ["debug"], queryKey: ["debug"],

View File

@ -8,8 +8,8 @@ export function usePersistence(isCodexOnline: boolean) {
const { data, isError, isFetching, refetch } = useQuery({ const { data, isError, isFetching, refetch } = useQuery({
queryKey: [], queryKey: [],
queryFn: async () => { queryFn: async () => {
return CodexSdk.marketplace() return CodexSdk.client()
.activeSlots() .marketplace.activeSlots()
.then((data) => Promises.rejectOnError(data, report)); .then((data) => Promises.rejectOnError(data, report));
}, },

View File

@ -33,7 +33,6 @@ class CodexMarketplaceMock extends CodexMarketplace {
override async createStorageRequest( override async createStorageRequest(
input: CodexCreateStorageRequestInput input: CodexCreateStorageRequestInput
): Promise<SafeValue<string>> { ): Promise<SafeValue<string>> {
console.info(input);
const res = await super.createStorageRequest(input); const res = await super.createStorageRequest(input);
if (res.error) { if (res.error) {

View File

@ -34,15 +34,15 @@ export function AvailabilitiesRoute() {
AvailabilityWithSlots[] AvailabilityWithSlots[]
>({ >({
queryFn: () => queryFn: () =>
CodexSdk.marketplace() CodexSdk.client()
.availabilities() .marketplace.availabilities()
.then((s) => Promises.rejectOnError(s)) .then((s) => Promises.rejectOnError(s))
.then((res) => res.sort((a, b) => b.totalSize - a.totalSize)) .then((res) => res.sort((a, b) => b.totalSize - a.totalSize))
.then((data) => .then((data) =>
Promise.all( Promise.all(
data.map((a) => data.map((a) =>
CodexSdk.marketplace() CodexSdk.client()
.reservations(a.id) .marketplace.reservations(a.id)
.then((res) => { .then((res) => {
if (res.error) { if (res.error) {
Errors.report(res); Errors.report(res);
@ -85,8 +85,8 @@ export function AvailabilitiesRoute() {
// Error will be catched in ErrorBounday // Error will be catched in ErrorBounday
const { data: space = defaultSpace } = useQuery({ const { data: space = defaultSpace } = useQuery({
queryFn: () => queryFn: () =>
CodexSdk.data() CodexSdk.client()
.space() .data.space()
.then((s) => Promises.rejectOnError(s)), .then((s) => Promises.rejectOnError(s)),
queryKey: ["space"], queryKey: ["space"],
initialData: defaultSpace, initialData: defaultSpace,

View File

@ -45,4 +45,8 @@
.input input { .input input {
--codex-input-background-color: rgba(35, 35, 35, 1); --codex-input-background-color: rgba(35, 35, 35, 1);
} }
.basic-auth-checkbox {
margin-bottom: 16px;
}
} }

View File

@ -16,6 +16,10 @@ export const CodexSdk = {
return url; return url;
}, },
client() {
return client;
},
async load() { async load() {
const [ const [
u = import.meta.env.VITE_CODEX_API_URL, u = import.meta.env.VITE_CODEX_API_URL,
@ -42,7 +46,7 @@ export const CodexSdk = {
url = u; url = u;
const promises = [WebStorage.set("codex-node-url", url)]; const promises = [WebStorage.set("codex-node-url", url)];
console.info(url);
if (options.auth) { if (options.auth) {
const { username, password } = options.auth; const { username, password } = options.auth;
basicAuthSecret = btoa(`${username}:${password}`); basicAuthSecret = btoa(`${username}:${password}`);
@ -62,20 +66,4 @@ export const CodexSdk = {
return Promise.all(promises); return Promise.all(promises);
}, },
debug() {
return client.debug;
},
data() {
return client.data;
},
node() {
return client.node;
},
marketplace() {
return client.marketplace;
},
}; };