@koloseum/utils 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils.d.ts +1 -13
- package/dist/utils.js +0 -21
- package/package.json +2 -2
- package/src/utils.ts +1 -28
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Database } from "@koloseum/types/database";
|
|
2
1
|
import type { CustomError, PronounsCheckboxes, SocialMediaPlatform } from "@koloseum/types/public/auth";
|
|
3
|
-
import type { PostgrestError
|
|
2
|
+
import type { PostgrestError } from "@supabase/supabase-js";
|
|
4
3
|
import type { MobilePhoneLocale } from "validator";
|
|
5
4
|
export declare const Status: {
|
|
6
5
|
/**
|
|
@@ -17,17 +16,6 @@ export declare const Status: {
|
|
|
17
16
|
PASSWORD_RESET_REQUESTED: string;
|
|
18
17
|
};
|
|
19
18
|
export declare const Utility: {
|
|
20
|
-
/**
|
|
21
|
-
* Calls an Edge function.
|
|
22
|
-
* @param {SupabaseClient} supabase - The Supabase client
|
|
23
|
-
* @param {string} path - The path to the Edge function
|
|
24
|
-
* @param {"GET" | "POST"} [method="GET"] - The HTTP method to use
|
|
25
|
-
* @returns The response from the Edge function
|
|
26
|
-
*/
|
|
27
|
-
callEdgeFunction: (supabase: SupabaseClient<Database>, path: string, method?: "GET" | "POST") => Promise<{
|
|
28
|
-
data?: any;
|
|
29
|
-
error?: string;
|
|
30
|
-
}>;
|
|
31
19
|
/**
|
|
32
20
|
* Capitalises a given word.
|
|
33
21
|
* @param {string} word - The word to be capitalised
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/supabase-js";
|
|
2
1
|
import { error as svelteError } from "@sveltejs/kit";
|
|
3
2
|
import parser from "any-date-parser";
|
|
4
3
|
import sanitize from "sanitize-html";
|
|
@@ -22,26 +21,6 @@ export const Status = {
|
|
|
22
21
|
};
|
|
23
22
|
/* Utility functions */
|
|
24
23
|
export const Utility = {
|
|
25
|
-
/**
|
|
26
|
-
* Calls an Edge function.
|
|
27
|
-
* @param {SupabaseClient} supabase - The Supabase client
|
|
28
|
-
* @param {string} path - The path to the Edge function
|
|
29
|
-
* @param {"GET" | "POST"} [method="GET"] - The HTTP method to use
|
|
30
|
-
* @returns The response from the Edge function
|
|
31
|
-
*/
|
|
32
|
-
callEdgeFunction: async (supabase, path, method = "GET") => {
|
|
33
|
-
// Fetch response
|
|
34
|
-
const { data, error } = await supabase.functions.invoke(path, { method });
|
|
35
|
-
// Return error if any
|
|
36
|
-
if (error instanceof FunctionsHttpError)
|
|
37
|
-
return { error: await error.context.json() };
|
|
38
|
-
else if (error instanceof FunctionsRelayError)
|
|
39
|
-
return { error: error.message };
|
|
40
|
-
else if (error instanceof FunctionsFetchError)
|
|
41
|
-
return { error: error.message };
|
|
42
|
-
// Return response
|
|
43
|
-
return { data };
|
|
44
|
-
},
|
|
45
24
|
/**
|
|
46
25
|
* Capitalises a given word.
|
|
47
26
|
* @param {string} word - The word to be capitalised
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koloseum/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"author": "Koloseum Technologies Limited",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Utility logic for use across Koloseum web apps (TypeScript)",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "vitest --run"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@koloseum/types": "^0.1.
|
|
33
|
+
"@koloseum/types": "^0.1.3",
|
|
34
34
|
"@supabase/supabase-js": "^2.48.1",
|
|
35
35
|
"@sveltejs/kit": "^2.17.1",
|
|
36
36
|
"any-date-parser": "^2.0.3",
|
package/src/utils.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type { Database } from "@koloseum/types/database";
|
|
2
1
|
import type { CustomError, PronounsCheckboxes, SocialMediaPlatform } from "@koloseum/types/public/auth";
|
|
3
|
-
|
|
4
|
-
import type { PostgrestError, SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
import type { PostgrestError } from "@supabase/supabase-js";
|
|
5
3
|
import type { MobilePhoneLocale } from "validator";
|
|
6
4
|
|
|
7
|
-
import { FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/supabase-js";
|
|
8
5
|
import { error as svelteError } from "@sveltejs/kit";
|
|
9
6
|
|
|
10
7
|
import parser from "any-date-parser";
|
|
@@ -32,30 +29,6 @@ export const Status = {
|
|
|
32
29
|
|
|
33
30
|
/* Utility functions */
|
|
34
31
|
export const Utility = {
|
|
35
|
-
/**
|
|
36
|
-
* Calls an Edge function.
|
|
37
|
-
* @param {SupabaseClient} supabase - The Supabase client
|
|
38
|
-
* @param {string} path - The path to the Edge function
|
|
39
|
-
* @param {"GET" | "POST"} [method="GET"] - The HTTP method to use
|
|
40
|
-
* @returns The response from the Edge function
|
|
41
|
-
*/
|
|
42
|
-
callEdgeFunction: async (
|
|
43
|
-
supabase: SupabaseClient<Database>,
|
|
44
|
-
path: string,
|
|
45
|
-
method: "GET" | "POST" = "GET"
|
|
46
|
-
): Promise<{ data?: any; error?: string }> => {
|
|
47
|
-
// Fetch response
|
|
48
|
-
const { data, error } = await supabase.functions.invoke(path, { method });
|
|
49
|
-
|
|
50
|
-
// Return error if any
|
|
51
|
-
if (error instanceof FunctionsHttpError) return { error: await error.context.json() };
|
|
52
|
-
else if (error instanceof FunctionsRelayError) return { error: error.message };
|
|
53
|
-
else if (error instanceof FunctionsFetchError) return { error: error.message };
|
|
54
|
-
else if (error.message) return { error: error.message };
|
|
55
|
-
|
|
56
|
-
// Return response
|
|
57
|
-
return { data };
|
|
58
|
-
},
|
|
59
32
|
/**
|
|
60
33
|
* Capitalises a given word.
|
|
61
34
|
* @param {string} word - The word to be capitalised
|