infra: add linting and formatting for js projects (#230)
* wip * wip * wip * format * wip(mobile): lint and format * cleanup * nits * nits * idiomatic react * nit * format all root files
This commit was merged in pull request #230.
This commit is contained in:
+38
-41
@@ -1,6 +1,6 @@
|
||||
import { appConfig } from "@/config/env";
|
||||
import { ApiError } from "@/lib/errors";
|
||||
import type { z } from "zod";
|
||||
import { appConfig } from '@/config/env';
|
||||
import { ApiError } from '@/lib/errors';
|
||||
import type { z } from 'zod';
|
||||
import {
|
||||
BillingStatusSchema,
|
||||
CheckoutSessionResponseSchema,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
PortalSessionResponseSchema,
|
||||
PrepareUploadResponseSchema,
|
||||
SignInResponseSchema,
|
||||
} from "./types";
|
||||
} from './types';
|
||||
import type {
|
||||
AcceptInvitationRequest,
|
||||
AddMembersRequest,
|
||||
@@ -25,7 +25,7 @@ import type {
|
||||
RequestCodeRequest,
|
||||
RevokeInvitationRequest,
|
||||
SignInRequest,
|
||||
} from "./types";
|
||||
} from './types';
|
||||
|
||||
/**
|
||||
* HTTP transport for Orion. Holds the bearer token as private state — the auth
|
||||
@@ -51,11 +51,11 @@ class ApiClient {
|
||||
const headers: Record<string, string> = {};
|
||||
|
||||
if (body) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
|
||||
if (this.token) {
|
||||
headers["Authorization"] = `Bearer ${this.token}`;
|
||||
headers['Authorization'] = `Bearer ${this.token}`;
|
||||
}
|
||||
|
||||
const response = await fetch(`${this.baseUrl}${path}`, {
|
||||
@@ -65,11 +65,11 @@ class ApiClient {
|
||||
});
|
||||
|
||||
if (response.status === 401) {
|
||||
throw new ApiError(401, "Unauthorized");
|
||||
throw new ApiError(401, 'Unauthorized');
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text().catch(() => "Unknown error");
|
||||
const text = await response.text().catch(() => 'Unknown error');
|
||||
throw new ApiError(response.status, text);
|
||||
}
|
||||
|
||||
@@ -98,35 +98,32 @@ class ApiClient {
|
||||
// --- Auth ---
|
||||
|
||||
async requestCode(data: RequestCodeRequest): Promise<void> {
|
||||
await this.requestVoid("POST", "/auth/request-code", data);
|
||||
await this.requestVoid('POST', '/auth/request-code', data);
|
||||
}
|
||||
|
||||
async signIn(data: SignInRequest) {
|
||||
return this.request(SignInResponseSchema, "POST", "/auth/sign-in", data);
|
||||
return this.request(SignInResponseSchema, 'POST', '/auth/sign-in', data);
|
||||
}
|
||||
|
||||
async me() {
|
||||
return this.request(HumanSchema, "GET", "/auth/me");
|
||||
return this.request(HumanSchema, 'GET', '/auth/me');
|
||||
}
|
||||
|
||||
async signOut(): Promise<void> {
|
||||
await this.requestVoid("POST", "/auth/sign-out");
|
||||
await this.requestVoid('POST', '/auth/sign-out');
|
||||
}
|
||||
|
||||
async getFirebaseToken() {
|
||||
return this.request(
|
||||
FirebaseTokenResponseSchema,
|
||||
"POST",
|
||||
"/auth/firebase-token",
|
||||
'POST',
|
||||
'/auth/firebase-token',
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: security: require passing in the particle id once api deprecates this
|
||||
async getParticleDownloadUrl(objectId: string): Promise<string> {
|
||||
const response = await this.fetch(
|
||||
"GET",
|
||||
`/particles/${objectId}/download`,
|
||||
);
|
||||
const response = await this.fetch('GET', `/particles/${objectId}/download`);
|
||||
const data = await response.json();
|
||||
return data.url;
|
||||
}
|
||||
@@ -136,21 +133,21 @@ class ApiClient {
|
||||
async updateSettings(data: {
|
||||
email_notifications_enabled?: boolean;
|
||||
}): Promise<void> {
|
||||
await this.requestVoid("PATCH", "/humans/me/settings", data);
|
||||
await this.requestVoid('PATCH', '/humans/me/settings', data);
|
||||
}
|
||||
|
||||
// --- Push notification tokens ---
|
||||
|
||||
async registerPushToken(data: {
|
||||
token: string;
|
||||
platform: "ios" | "android";
|
||||
platform: 'ios' | 'android';
|
||||
app_version: string;
|
||||
}): Promise<void> {
|
||||
await this.requestVoid("POST", "/humans/me/push-tokens", data);
|
||||
await this.requestVoid('POST', '/humans/me/push-tokens', data);
|
||||
}
|
||||
|
||||
async unregisterPushToken(token: string): Promise<void> {
|
||||
await this.requestVoid("DELETE", "/humans/me/push-tokens", { token });
|
||||
await this.requestVoid('DELETE', '/humans/me/push-tokens', { token });
|
||||
}
|
||||
|
||||
// --- Depot ---
|
||||
@@ -158,8 +155,8 @@ class ApiClient {
|
||||
async prepareUpload(data: PrepareUploadRequest) {
|
||||
return this.request(
|
||||
PrepareUploadResponseSchema,
|
||||
"POST",
|
||||
"/depot/upload",
|
||||
'POST',
|
||||
'/depot/upload',
|
||||
data,
|
||||
);
|
||||
}
|
||||
@@ -167,7 +164,7 @@ class ApiClient {
|
||||
async confirmUpload(objectId: string) {
|
||||
return this.request(
|
||||
DepotObjectSchema,
|
||||
"POST",
|
||||
'POST',
|
||||
`/depot/objects/${objectId}/confirm`,
|
||||
);
|
||||
}
|
||||
@@ -175,24 +172,24 @@ class ApiClient {
|
||||
// --- Networks ---
|
||||
|
||||
async listNetworks() {
|
||||
return this.request(ListNetworksResponseSchema, "GET", "/networks");
|
||||
return this.request(ListNetworksResponseSchema, 'GET', '/networks');
|
||||
}
|
||||
|
||||
async createNetwork(data: CreateNetworkRequest) {
|
||||
return this.request(NetworkSchema, "POST", "/networks", data);
|
||||
return this.request(NetworkSchema, 'POST', '/networks', data);
|
||||
}
|
||||
|
||||
async getNetwork(id: string) {
|
||||
return this.request(NetworkSchema, "GET", `/networks/${id}`);
|
||||
return this.request(NetworkSchema, 'GET', `/networks/${id}`);
|
||||
}
|
||||
|
||||
async addMembers(networkId: string, data: AddMembersRequest): Promise<void> {
|
||||
await this.requestVoid("POST", `/networks/${networkId}/members`, data);
|
||||
await this.requestVoid('POST', `/networks/${networkId}/members`, data);
|
||||
}
|
||||
|
||||
async removeMember(networkId: string, humanId: string): Promise<void> {
|
||||
await this.requestVoid(
|
||||
"DELETE",
|
||||
'DELETE',
|
||||
`/networks/${networkId}/members/${humanId}`,
|
||||
);
|
||||
}
|
||||
@@ -202,17 +199,17 @@ class ApiClient {
|
||||
async listNetworkInvitations(networkId: string) {
|
||||
return this.request(
|
||||
ListInvitationsResponseSchema,
|
||||
"GET",
|
||||
'GET',
|
||||
`/networks/${networkId}/invitations`,
|
||||
);
|
||||
}
|
||||
|
||||
async listMyInvitations() {
|
||||
return this.request(ListInvitationsResponseSchema, "GET", "/invitations");
|
||||
return this.request(ListInvitationsResponseSchema, 'GET', '/invitations');
|
||||
}
|
||||
|
||||
async acceptInvitation(data: AcceptInvitationRequest): Promise<void> {
|
||||
await this.requestVoid("POST", "/invitations/accept", data);
|
||||
await this.requestVoid('POST', '/invitations/accept', data);
|
||||
}
|
||||
|
||||
async revokeInvitation(
|
||||
@@ -220,7 +217,7 @@ class ApiClient {
|
||||
data: RevokeInvitationRequest,
|
||||
): Promise<void> {
|
||||
await this.requestVoid(
|
||||
"DELETE",
|
||||
'DELETE',
|
||||
`/networks/${networkId}/invitations`,
|
||||
data,
|
||||
);
|
||||
@@ -231,8 +228,8 @@ class ApiClient {
|
||||
async getLivekitToken(networkId: string, streamId: string) {
|
||||
return this.request(
|
||||
GetLivekitTokenResponseSchema,
|
||||
"POST",
|
||||
"/livekit/token",
|
||||
'POST',
|
||||
'/livekit/token',
|
||||
{ network_id: networkId, stream_id: streamId },
|
||||
);
|
||||
}
|
||||
@@ -242,7 +239,7 @@ class ApiClient {
|
||||
async getNetworkBilling(networkId: string) {
|
||||
return this.request(
|
||||
BillingStatusSchema,
|
||||
"GET",
|
||||
'GET',
|
||||
`/networks/${networkId}/billing`,
|
||||
);
|
||||
}
|
||||
@@ -250,7 +247,7 @@ class ApiClient {
|
||||
async createCheckoutSession(networkId: string, cadence: BillingCadence) {
|
||||
return this.request(
|
||||
CheckoutSessionResponseSchema,
|
||||
"POST",
|
||||
'POST',
|
||||
`/networks/${networkId}/billing/checkout-session`,
|
||||
{ cadence },
|
||||
);
|
||||
@@ -259,7 +256,7 @@ class ApiClient {
|
||||
async createPortalSession(networkId: string) {
|
||||
return this.request(
|
||||
PortalSessionResponseSchema,
|
||||
"POST",
|
||||
'POST',
|
||||
`/networks/${networkId}/billing/portal-session`,
|
||||
);
|
||||
}
|
||||
@@ -267,7 +264,7 @@ class ApiClient {
|
||||
async getNetworkUsage(networkId: string) {
|
||||
return this.request(
|
||||
NetworkUsageSchema,
|
||||
"GET",
|
||||
'GET',
|
||||
`/networks/${networkId}/usage`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user