Skip to content

Commit 31153eb

Browse files
committed
chore: fix formatting
1 parent ae5e761 commit 31153eb

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/**
22
* Parses a url and returns the table name the url is interacting with.
33
*
4-
* For mutations, the .split("?") goes unused.
4+
* For mutations, the .split('?') goes unused.
55
*
66
* @param url The url we are pulling the table name from
77
* @returns Table name
88
*/
99
export const getTableFromUrl = (url: string): string => {
10-
const split = url.toString().split("/");
10+
const split = url.toString().split('/');
1111
const table = split.pop() as string;
1212
const maybeRpc = split.pop() as string;
13-
return [maybeRpc === "rpc" ? maybeRpc : null, table]
13+
return [maybeRpc === 'rpc' ? maybeRpc : null, table]
1414
.filter(Boolean)
15-
.join("/");
15+
.join('/');
1616
};
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import type { PostgrestBuilder } from "@supabase/postgrest-js";
1+
import type { PostgrestBuilder } from '@supabase/postgrest-js';
22

3-
import { encodeObject } from "./lib/encode-object";
4-
import { isObject } from "./lib/is-object";
5-
import type { OrderDefinition } from "./lib/query-types";
6-
import { sortSearchParams } from "./lib/sort-search-param";
3+
import { encodeObject } from './lib/encode-object';
4+
import { isObject } from './lib/is-object';
5+
import type { OrderDefinition } from './lib/query-types';
6+
import { sortSearchParams } from './lib/sort-search-param';
77
import {
88
PostgrestQueryParser,
99
type PostgrestQueryParserOptions,
10-
} from "./postgrest-query-parser";
11-
import { getTableFromUrl } from "./lib/get-table-from-url";
10+
} from './postgrest-query-parser';
11+
import { getTableFromUrl } from './lib/get-table-from-url';
1212

1313
export class PostgrestParser<Result> extends PostgrestQueryParser {
1414
private readonly _url: URL;
1515
private readonly _headers: { [key: string]: string };
1616
private readonly _body: object | undefined;
17-
private readonly _method: "GET" | "HEAD" | "POST" | "PATCH" | "DELETE";
17+
private readonly _method: 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
1818

1919
public readonly queryKey: string;
2020
public readonly bodyKey: string | undefined;
@@ -31,12 +31,12 @@ export class PostgrestParser<Result> extends PostgrestQueryParser {
3131
fb: PostgrestBuilder<Result>,
3232
public readonly opts?: PostgrestQueryParserOptions
3333
) {
34-
super(new URL(fb["url"]).searchParams.toString(), opts);
34+
super(new URL(fb['url']).searchParams.toString(), opts);
3535

36-
this._url = new URL(fb["url"]);
37-
this._headers = { ...fb["headers"] };
38-
this._body = isObject(fb["body"]) ? { ...fb["body"] } : undefined;
39-
this._method = fb["method"];
36+
this._url = new URL(fb['url']);
37+
this._headers = { ...fb['headers'] };
38+
this._body = isObject(fb['body']) ? { ...fb['body'] } : undefined;
39+
this._method = fb['method'];
4040

4141
this.queryKey = sortSearchParams(this._url.searchParams).toString();
4242

@@ -48,38 +48,38 @@ export class PostgrestParser<Result> extends PostgrestQueryParser {
4848

4949
// 'Prefer': return=minimal|representation,count=exact|planned|estimated
5050
const preferHeaders: Record<string, string> = (
51-
this._headers["Prefer"] ?? ""
51+
this._headers['Prefer'] ?? ''
5252
)
53-
.split(",")
53+
.split(',')
5454
.reduce<Record<string, string>>((prev, curr) => {
55-
const s = curr.split("=");
55+
const s = curr.split('=');
5656
return {
5757
...prev,
5858
[s[0]]: s[1],
5959
};
6060
}, {});
61-
this.count = preferHeaders["count"] ?? null;
61+
this.count = preferHeaders['count'] ?? null;
6262

63-
this.schema = fb["schema"] as string;
63+
this.schema = fb['schema'] as string;
6464

65-
this.isHead = this._method === "HEAD";
65+
this.isHead = this._method === 'HEAD';
6666

67-
const limit = this._url.searchParams.get("limit");
67+
const limit = this._url.searchParams.get('limit');
6868
this.limit = limit ? Number(limit) : undefined;
69-
const offset = this._url.searchParams.get("offset");
69+
const offset = this._url.searchParams.get('offset');
7070
this.offset = offset ? Number(offset) : undefined;
7171

7272
this._url.searchParams.forEach((value, key) => {
73-
const split = key.split(".");
74-
if (split[split.length === 2 ? 1 : 0] === "order") {
73+
const split = key.split('.');
74+
if (split[split.length === 2 ? 1 : 0] === 'order') {
7575
// separated by ,
76-
const orderByDefs = value.split(",");
76+
const orderByDefs = value.split(',');
7777
orderByDefs.forEach((def) => {
78-
const [column, ascending, nullsFirst] = def.split(".");
78+
const [column, ascending, nullsFirst] = def.split('.');
7979
this.orderBy.push({
80-
ascending: ascending === "asc",
80+
ascending: ascending === 'asc',
8181
column,
82-
nullsFirst: nullsFirst === "nullsfirst",
82+
nullsFirst: nullsFirst === 'nullsfirst',
8383
foreignTable: split.length === 2 ? split[0] : undefined,
8484
});
8585
});
@@ -88,10 +88,10 @@ export class PostgrestParser<Result> extends PostgrestQueryParser {
8888
this.orderByKey = this.orderBy
8989
.map(
9090
({ column, ascending, nullsFirst, foreignTable }) =>
91-
`${foreignTable ? `${foreignTable}.` : ""}${column}:${
92-
ascending ? "asc" : "desc"
93-
}.${nullsFirst ? "nullsFirst" : "nullsLast"}`
91+
`${foreignTable ? `${foreignTable}.` : ''}${column}:${
92+
ascending ? 'asc' : 'desc'
93+
}.${nullsFirst ? 'nullsFirst' : 'nullsLast'}`
9494
)
95-
.join("|");
95+
.join('|');
9696
}
9797
}

0 commit comments

Comments
 (0)