@biltme/backend 0.5.0
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/README.md +138 -0
- package/dist/index.js +11210 -0
- package/package.json +50 -0
- package/src/index.ts +13 -0
- package/src/storage/async-storage.ts +15 -0
- package/src/storage/index.ts +9 -0
- package/src/storage/memory.ts +16 -0
- package/src/storage/web.ts +38 -0
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@biltme/backend",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Bilt backend SDK — thin shim over @supabase/supabase-js for bilt-cloud projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./src/index.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/buildingapplications/bilt-backend.git"
|
|
24
|
+
},
|
|
25
|
+
"license": "UNLICENSED",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "bun test",
|
|
28
|
+
"lint": "oxlint --type-aware --type-check src/",
|
|
29
|
+
"lint:fix": "oxlint --type-aware --type-check --fix src/",
|
|
30
|
+
"format": "oxfmt --write src/",
|
|
31
|
+
"format:check": "oxfmt --check src/",
|
|
32
|
+
"build": "bun build src/index.ts --outdir dist --target node"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/bun": "latest",
|
|
36
|
+
"oxfmt": "^0.44.0",
|
|
37
|
+
"oxlint": "^1.59.0",
|
|
38
|
+
"oxlint-tsgolint": "^0.20.0",
|
|
39
|
+
"typescript": "^5"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@supabase/supabase-js": "^2.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@react-native-async-storage/async-storage": "^2.0.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"@react-native-async-storage/async-storage": { "optional": true }
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { createClient } from '@supabase/supabase-js'
|
|
2
|
+
export { webStorage, memoryStorage, asyncStorage } from './storage'
|
|
3
|
+
export type { StorageAdapter } from './storage'
|
|
4
|
+
export { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError, FunctionRegion } from '@supabase/supabase-js'
|
|
5
|
+
export { StorageApiError } from '@supabase/supabase-js'
|
|
6
|
+
export type {
|
|
7
|
+
SupabaseClient,
|
|
8
|
+
Session,
|
|
9
|
+
User,
|
|
10
|
+
AuthError,
|
|
11
|
+
PostgrestError,
|
|
12
|
+
FunctionInvokeOptions,
|
|
13
|
+
} from '@supabase/supabase-js'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StorageAdapter } from './index'
|
|
2
|
+
|
|
3
|
+
export interface AsyncStorageImpl {
|
|
4
|
+
getItem(key: string): Promise<string | null>
|
|
5
|
+
setItem(key: string, value: string): Promise<void>
|
|
6
|
+
removeItem(key: string): Promise<void>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function asyncStorage(impl: AsyncStorageImpl): StorageAdapter {
|
|
10
|
+
return {
|
|
11
|
+
getItem: (key) => impl.getItem(key),
|
|
12
|
+
setItem: (key, value) => impl.setItem(key, value),
|
|
13
|
+
removeItem: (key) => impl.removeItem(key),
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface StorageAdapter {
|
|
2
|
+
getItem(key: string): string | null | Promise<string | null>
|
|
3
|
+
setItem(key: string, value: string): void | Promise<void>
|
|
4
|
+
removeItem(key: string): void | Promise<void>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { memoryStorage } from './memory'
|
|
8
|
+
export { webStorage } from './web'
|
|
9
|
+
export { asyncStorage } from './async-storage'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StorageAdapter } from './index'
|
|
2
|
+
|
|
3
|
+
export function memoryStorage(): StorageAdapter {
|
|
4
|
+
const store = new Map<string, string>()
|
|
5
|
+
return {
|
|
6
|
+
getItem(key) {
|
|
7
|
+
return store.get(key) ?? null
|
|
8
|
+
},
|
|
9
|
+
setItem(key, value) {
|
|
10
|
+
store.set(key, value)
|
|
11
|
+
},
|
|
12
|
+
removeItem(key) {
|
|
13
|
+
store.delete(key)
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { StorageAdapter } from './index'
|
|
2
|
+
|
|
3
|
+
export function webStorage(): StorageAdapter {
|
|
4
|
+
let warned = false
|
|
5
|
+
const warnOnce = (op: string, err: unknown) => {
|
|
6
|
+
if (warned) return
|
|
7
|
+
warned = true
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.warn(`[bilt] localStorage ${op} failed:`, err)
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
getItem(key) {
|
|
13
|
+
try {
|
|
14
|
+
if (typeof window === 'undefined') return null
|
|
15
|
+
return window.localStorage.getItem(key)
|
|
16
|
+
} catch (err) {
|
|
17
|
+
warnOnce('getItem', err)
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setItem(key, value) {
|
|
22
|
+
try {
|
|
23
|
+
if (typeof window === 'undefined') return
|
|
24
|
+
window.localStorage.setItem(key, value)
|
|
25
|
+
} catch (err) {
|
|
26
|
+
warnOnce('setItem', err)
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
removeItem(key) {
|
|
30
|
+
try {
|
|
31
|
+
if (typeof window === 'undefined') return
|
|
32
|
+
window.localStorage.removeItem(key)
|
|
33
|
+
} catch (err) {
|
|
34
|
+
warnOnce('removeItem', err)
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
}
|