target-supabase-sdk 0.1.0 → 0.1.2

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 target-supabase-sdk contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 target-supabase-sdk contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,70 +1,121 @@
1
- # target-supabase-sdk
2
-
3
- Supabase client initializer and data access APIs for Target-based backends.
4
-
5
- ## Install
6
-
7
- ```bash
8
- pnpm add target-supabase-sdk
9
- ```
10
-
11
- This package declares `@supabase/supabase-js`, `@supabase/postgrest-js`, and `lodash-es` as **peer dependencies** — your app must have them available at runtime, but they are not bundled into the SDK itself. This avoids duplicate Supabase client instances and lets you control dependency versions.
12
-
13
- **pnpm 8+** and **npm 7+** usually auto-install missing peer dependencies, so the command above is often enough.
14
-
15
- If you see peer dependency warnings or `Cannot find module` errors at runtime, install them explicitly:
16
-
17
- ```bash
18
- pnpm add target-supabase-sdk @supabase/supabase-js @supabase/postgrest-js lodash-es
19
- ```
20
-
21
- > `@supabase/postgrest-js` is also pulled in transitively by `@supabase/supabase-js`; it is listed here because the SDK uses its types directly (e.g. `PostgrestFilterBuilder`).
22
-
23
- ## Environment Variables
24
-
25
- Copy `.env.example` to `.env.local` and fill in your Supabase project values:
26
-
27
- ```bash
28
- cp .env.example .env.local
29
- ```
30
-
31
- | Variable | Required | Description |
32
- |----------|----------|-------------|
33
- | `VITE_SUPABASE_URL` | Yes | Main Supabase project URL |
34
- | `VITE_SUPABASE_ANON_KEY` | Yes | Main project anon (public) key |
35
- | `VITE_SUPABASE_NEED_AUTH_URL` | No | Separate auth project URL |
36
- | `VITE_SUPABASE_NEED_AUTH_ANON_KEY` | No | Separate auth project anon key |
37
-
38
- ### Security
39
-
40
- - `VITE_*` variables are embedded in the client bundle at build time. Only use the **anon (public) key** — it is designed to be public when protected by Row Level Security (RLS).
41
- - **Never** put the `service_role` key in a `VITE_*` variable or any frontend code. Use it only in trusted server-side environments.
42
- - Do not commit `.env` or `.env.local`. They are gitignored; only `.env.example` (placeholders) should be tracked.
43
- - Auth APIs return session tokens. Store them securely and never log them.
44
-
45
- ## Usage
46
-
47
- ```typescript
48
- import { supabase, getTarget, loginUser } from "target-supabase-sdk";
49
-
50
- await supabase.initialize({
51
- supabaseUrl: import.meta.env.VITE_SUPABASE_URL,
52
- supabaseAnonKey: import.meta.env.VITE_SUPABASE_ANON_KEY,
53
- supabaseNeedAuthUrl: import.meta.env.VITE_SUPABASE_NEED_AUTH_URL,
54
- supabaseNeedAuthAnonKey: import.meta.env.VITE_SUPABASE_NEED_AUTH_ANON_KEY,
55
- });
56
-
57
- const target = await getTarget({ id: "..." });
58
- ```
59
-
60
- ## Development
61
-
62
- ```bash
63
- pnpm install
64
- pnpm build
65
- pnpm dev
66
- ```
67
-
68
- ## License
69
-
70
- MIT
1
+ # target-supabase-sdk
2
+
3
+ Supabase client initializer and data access APIs for Target-based backends.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add target-supabase-sdk
9
+ ```
10
+
11
+ This package declares `@supabase/supabase-js`, `@supabase/postgrest-js`, and `lodash-es` as **peer dependencies** — your app must have them available at runtime, but they are not bundled into the SDK itself. This avoids duplicate Supabase client instances and lets you control dependency versions.
12
+
13
+ **pnpm 8+** and **npm 7+** usually auto-install missing peer dependencies, so the command above is often enough.
14
+
15
+ If you see peer dependency warnings or `Cannot find module` errors at runtime, install them explicitly:
16
+
17
+ ```bash
18
+ pnpm add target-supabase-sdk @supabase/supabase-js @supabase/postgrest-js lodash-es
19
+ ```
20
+
21
+ > `@supabase/postgrest-js` is also pulled in transitively by `@supabase/supabase-js`; it is listed here because the SDK uses its types directly (e.g. `PostgrestFilterBuilder`).
22
+
23
+ ## Environment Variables
24
+
25
+ Copy `.env.example` to `.env.local` and fill in your Supabase project values:
26
+
27
+ ```bash
28
+ cp .env.example .env.local
29
+ ```
30
+
31
+ | Variable | Required | Description |
32
+ |----------|----------|-------------|
33
+ | `VITE_SUPABASE_URL` | Yes | Main Supabase project URL |
34
+ | `VITE_SUPABASE_ANON_KEY` | Yes | Main project anon (public) key |
35
+ | `VITE_SUPABASE_NEED_AUTH_URL` | No | Separate auth project URL |
36
+ | `VITE_SUPABASE_NEED_AUTH_ANON_KEY` | No | Separate auth project anon key |
37
+
38
+ ### Security
39
+
40
+ - `VITE_*` variables are embedded in the client bundle at build time. Only use the **anon (public) key** — it is designed to be public when protected by Row Level Security (RLS).
41
+ - **Never** put the `service_role` key in a `VITE_*` variable or any frontend code. Use it only in trusted server-side environments.
42
+ - Do not commit `.env` or `.env.local`. They are gitignored; only `.env.example` (placeholders) should be tracked.
43
+ - Auth APIs return session tokens. Store them securely and never log them.
44
+
45
+ ## Usage
46
+
47
+ ```typescript
48
+ import { supabase, getTarget, loginUser } from "target-supabase-sdk";
49
+
50
+ await supabase.initialize({
51
+ supabaseUrl: import.meta.env.VITE_SUPABASE_URL,
52
+ supabaseAnonKey: import.meta.env.VITE_SUPABASE_ANON_KEY,
53
+ supabaseNeedAuthUrl: import.meta.env.VITE_SUPABASE_NEED_AUTH_URL,
54
+ supabaseNeedAuthAnonKey: import.meta.env.VITE_SUPABASE_NEED_AUTH_ANON_KEY,
55
+ });
56
+
57
+ const target = await getTarget({ id: "..." });
58
+ ```
59
+
60
+ ## Development
61
+
62
+ ```bash
63
+ pnpm install
64
+ pnpm typecheck
65
+ pnpm build
66
+ pnpm dev
67
+ ```
68
+
69
+ Verify the publishable tarball locally:
70
+
71
+ ```bash
72
+ pnpm pack:check
73
+ ```
74
+
75
+ ## Release
76
+
77
+ Publishing is automated via GitHub Actions when a version tag is pushed.
78
+
79
+ ### One-time setup
80
+
81
+ 1. Create an npm [Granular Access Token](https://www.npmjs.com/settings/~your-username/tokens) with **Read and Write** permission and **Bypass 2FA for automation** enabled.
82
+ 2. Add it to the GitHub repository as a secret named `NPM_TOKEN`:
83
+ - Repository → **Settings** → **Secrets and variables** → **Actions** → **New repository secret**
84
+
85
+ ### Publish a new version
86
+
87
+ ```bash
88
+ npm version patch
89
+ git push
90
+ git push --tags
91
+ ```
92
+
93
+ - `npm version patch` — bump version (`0.1.0` → `0.1.1`), commit, and create git tag `v0.1.1`. Use `minor` or `major` when needed.
94
+ - `git push` — push the version commit to GitHub
95
+ - `git push --tags` — push the tag; triggers `.github/workflows/release.yml` to publish to npm
96
+
97
+ First push on a new machine (set upstream once):
98
+
99
+ ```bash
100
+ git push -u origin main
101
+ git push --tags
102
+ ```
103
+
104
+ PowerShell 5.x does not support `&&`. Run each command on its own line, or use `git push; git push --tags`.
105
+
106
+ The release workflow will:
107
+
108
+ 1. Verify the git tag matches `package.json` version (e.g. tag `v0.1.1` ↔ version `0.1.1`)
109
+ 2. Build the package
110
+ 3. Publish to npm with [provenance](https://docs.npmjs.com/generating-provenance-statements)
111
+
112
+ ### Manual publish (fallback)
113
+
114
+ ```bash
115
+ pnpm pack:check
116
+ npm publish --otp=YOUR_2FA_CODE
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from "./link/link.interface";
13
13
  export { CategoryParcel } from "./parcel/parcel.interface";
14
14
  export type { Parcel, ParcelDetails, Chunk, LifecycleStatus as ParcelLifecycleStatus, Lifecycle as ParcelLifecycle, } from "./parcel/parcel.interface";
15
15
  export { default as ParcelManager } from "./parcel/parcel-manager";
16
+ export type { StorageAdapter, ParcelTargetBase } from "./parcel/parcel-manager";
16
17
  export * from "./file/file.interface";
17
18
  export * from "./file/file.api";
18
19
  export * from "./file/file-manager";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAA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AAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAIjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,WAAW,EAAE,CAAC;AAE1D,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAE7B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQ3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGnE,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAElD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AAGpC,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,mBAAmB,IAAI,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE5H,cAAc,0CAA0C,CAAC;AAEzD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Parcel, ParcelDetails } from "./parcel.interface";
2
2
  /** 可插拔的存储适配器:不同文件系统 */
3
- interface StorageAdapter {
3
+ export interface StorageAdapter {
4
4
  /** 上传一段数据,返回可下载的 URL */
5
5
  upload(data: ArrayBuffer, pathOrKey: string): Promise<{
6
6
  url: string;
@@ -23,7 +23,7 @@ interface CreateResult {
23
23
  key?: CryptoKey;
24
24
  }
25
25
  /** 调用方提供的 Target 基础字段,用于拼成完整 Parcel */
26
- type ParcelTargetBase = Pick<Parcel, "id" | "category" | "name" | "value" | "tagList" | "created_at">;
26
+ export type ParcelTargetBase = Pick<Parcel, "id" | "category" | "name" | "value" | "tagList" | "created_at">;
27
27
  /** 将文件加密后拆分成多个 chunk */
28
28
  declare function create(file: ArrayBuffer, options?: CreateOptions): Promise<CreateResult>;
29
29
  /** 将 chunk 均匀分布到不同文件系统并存储 */
@@ -1 +1 @@
1
- {"version":3,"file":"parcel-manager.d.ts","sourceRoot":"","sources":["../../src/parcel/parcel-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,MAAM,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAUvE,uBAAuB;AACvB,UAAU,cAAc;IACtB,wBAAwB;IACxB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxE;AAED,UAAU,aAAa;IACrB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED,UAAU,YAAY;IACpB,gCAAgC;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED,uCAAuC;AACvC,KAAK,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC;AAoCtG,wBAAwB;AACxB,iBAAe,MAAM,CAAC,IAAI,EAAE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AAC,CAAC;AAoC7G,wBAAwB;AACxB,iBAAe,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgD3F;AAED,6BAA6B;AAC7B,iBAAe,IAAI,CACjB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,cAAc,EAAE,EAC7B,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,sCAAsC;AACtC,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CA+C9E;AAED,QAAA,MAAM,aAAa;;;;CAIlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,45 +1,57 @@
1
- {
2
- "name": "target-supabase-sdk",
3
- "version": "0.1.0",
4
- "description": "Supabase client initializer and data access APIs",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/KyLoc20/target-supabase-sdk.git"
9
- },
10
- "type": "module",
11
- "types": "./dist/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "import": "./dist/index.js",
16
- "default": "./dist/index.js"
17
- }
18
- },
19
- "files": [
20
- "dist",
21
- "src"
22
- ],
23
- "scripts": {
24
- "clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist', { recursive: true, force: true })\"",
25
- "build": "pnpm clean && tsc -p tsconfig.build.json",
26
- "dev": "tsc -p tsconfig.build.json --watch",
27
- "prepublishOnly": "pnpm build"
28
- },
29
- "peerDependencies": {
30
- "@supabase/postgrest-js": "^1.19.0",
31
- "@supabase/supabase-js": "^2.50.0",
32
- "lodash-es": "^4.17.21"
33
- },
34
- "devDependencies": {
35
- "@supabase/postgrest-js": "1.19.4",
36
- "@supabase/supabase-js": "2.50.3",
37
- "@types/lodash-es": "^4.17.12",
38
- "@types/wicg-file-system-access": "^2023.10.7",
39
- "lodash-es": "^4.17.21",
40
- "typescript": "~5.7.2"
41
- },
42
- "publishConfig": {
43
- "access": "public"
44
- }
45
- }
1
+ {
2
+ "name": "target-supabase-sdk",
3
+ "version": "0.1.2",
4
+ "description": "Supabase client initializer and data access APIs",
5
+ "license": "MIT",
6
+ "author": "KyLoc20",
7
+ "homepage": "https://github.com/KyLoc20/target-supabase-sdk#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/KyLoc20/target-supabase-sdk/issues"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/KyLoc20/target-supabase-sdk.git"
14
+ },
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "packageManager": "pnpm@9.15.0",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "src"
32
+ ],
33
+ "scripts": {
34
+ "clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist', { recursive: true, force: true })\"",
35
+ "build": "pnpm clean && tsc -p tsconfig.build.json",
36
+ "typecheck": "tsc -p tsconfig.json --noEmit",
37
+ "dev": "tsc -p tsconfig.build.json --watch",
38
+ "pack:check": "npm pack --dry-run",
39
+ "prepack": "pnpm build"
40
+ },
41
+ "peerDependencies": {
42
+ "@supabase/postgrest-js": "^1.19.0",
43
+ "@supabase/supabase-js": "^2.50.0",
44
+ "lodash-es": "^4.17.21"
45
+ },
46
+ "devDependencies": {
47
+ "@supabase/postgrest-js": "1.19.4",
48
+ "@supabase/supabase-js": "2.50.3",
49
+ "@types/lodash-es": "^4.17.12",
50
+ "@types/wicg-file-system-access": "^2023.10.7",
51
+ "lodash-es": "^4.17.21",
52
+ "typescript": "~5.7.2"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
57
+ }
@@ -1,85 +1,85 @@
1
- import { supabase } from "..";
2
- import { createResponse } from "../core.interface";
3
- import { handleSupabaseError } from "../core.utils";
4
-
5
- export interface LoginPayload {
6
- email: string;
7
- password: string;
8
- }
9
-
10
- export interface RegisterPayload {
11
- email: string;
12
- password: string;
13
- confirmPassword?: string;
14
- }
15
-
16
- export interface User {
17
- id: string;
18
- email: string;
19
- created_at: string;
20
- last_sign_in_at?: string;
21
- }
22
-
23
- // 用户注册
24
- export const registerUser = async ({ email, password }: RegisterPayload) => {
25
- const { data, error } = await supabase.authClient!.auth.signUp({
26
- email,
27
- password,
28
- });
29
-
30
- if (error) {
31
- handleSupabaseError("registerUser", error, "Registration failed. Please try again.");
32
- }
33
-
34
- return createResponse.success(data);
35
- };
36
-
37
- // 用户登录
38
- export const loginUser = async ({ email, password }: LoginPayload) => {
39
- const { data, error } = await supabase.authClient!.auth.signInWithPassword({
40
- email,
41
- password,
42
- });
43
-
44
- if (error) {
45
- handleSupabaseError("loginUser", error, "Login failed. Please check your credentials.");
46
- }
47
-
48
- return createResponse.success(data);
49
- };
50
-
51
- // 用户登出
52
- export const logoutUser = async () => {
53
- const { error } = await supabase.authClient!.auth.signOut();
54
-
55
- if (error) {
56
- handleSupabaseError("logoutUser", error, "Logout failed.");
57
- }
58
-
59
- return createResponse.success();
60
- };
61
-
62
- // 获取当前用户
63
- export const getCurrentUser = async () => {
64
- const {
65
- data: { user },
66
- error,
67
- } = await supabase.authClient!.auth.getUser();
68
-
69
- if (error) {
70
- handleSupabaseError("getCurrentUser", error, "Failed to get current user.");
71
- }
72
-
73
- return createResponse.success<User | null>(user as User | null);
74
- };
75
-
76
- // 重置密码
77
- export const resetPassword = async (email: string) => {
78
- const { error } = await supabase.authClient!.auth.resetPasswordForEmail(email);
79
-
80
- if (error) {
81
- handleSupabaseError("resetPassword", error, "Password reset request failed.");
82
- }
83
-
84
- return createResponse.success();
85
- };
1
+ import { supabase } from "..";
2
+ import { createResponse } from "../core.interface";
3
+ import { handleSupabaseError } from "../core.utils";
4
+
5
+ export interface LoginPayload {
6
+ email: string;
7
+ password: string;
8
+ }
9
+
10
+ export interface RegisterPayload {
11
+ email: string;
12
+ password: string;
13
+ confirmPassword?: string;
14
+ }
15
+
16
+ export interface User {
17
+ id: string;
18
+ email: string;
19
+ created_at: string;
20
+ last_sign_in_at?: string;
21
+ }
22
+
23
+ // 用户注册
24
+ export const registerUser = async ({ email, password }: RegisterPayload) => {
25
+ const { data, error } = await supabase.authClient!.auth.signUp({
26
+ email,
27
+ password,
28
+ });
29
+
30
+ if (error) {
31
+ handleSupabaseError("registerUser", error, "Registration failed. Please try again.");
32
+ }
33
+
34
+ return createResponse.success(data);
35
+ };
36
+
37
+ // 用户登录
38
+ export const loginUser = async ({ email, password }: LoginPayload) => {
39
+ const { data, error } = await supabase.authClient!.auth.signInWithPassword({
40
+ email,
41
+ password,
42
+ });
43
+
44
+ if (error) {
45
+ handleSupabaseError("loginUser", error, "Login failed. Please check your credentials.");
46
+ }
47
+
48
+ return createResponse.success(data);
49
+ };
50
+
51
+ // 用户登出
52
+ export const logoutUser = async () => {
53
+ const { error } = await supabase.authClient!.auth.signOut();
54
+
55
+ if (error) {
56
+ handleSupabaseError("logoutUser", error, "Logout failed.");
57
+ }
58
+
59
+ return createResponse.success();
60
+ };
61
+
62
+ // 获取当前用户
63
+ export const getCurrentUser = async () => {
64
+ const {
65
+ data: { user },
66
+ error,
67
+ } = await supabase.authClient!.auth.getUser();
68
+
69
+ if (error) {
70
+ handleSupabaseError("getCurrentUser", error, "Failed to get current user.");
71
+ }
72
+
73
+ return createResponse.success<User | null>(user as User | null);
74
+ };
75
+
76
+ // 重置密码
77
+ export const resetPassword = async (email: string) => {
78
+ const { error } = await supabase.authClient!.auth.resetPasswordForEmail(email);
79
+
80
+ if (error) {
81
+ handleSupabaseError("resetPassword", error, "Password reset request failed.");
82
+ }
83
+
84
+ return createResponse.success();
85
+ };