aurabase-js 0.1.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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "timestamp": "2026-03-09T11:49:17.080Z",
3
+ "backgroundTasks": [],
4
+ "sessionStartTimestamp": "2026-03-09T11:37:51.558Z",
5
+ "sessionId": "a7635597b80deb9e"
6
+ }
@@ -0,0 +1 @@
1
+ {"session_id":"85311ae7-4e13-466c-9bb0-4bf05ada3ed1","transcript_path":"C:\\Users\\Jay\\.claude\\projects\\D--000-FrontEnd-242-dino-game\\85311ae7-4e13-466c-9bb0-4bf05ada3ed1.jsonl","cwd":"D:\\000.FrontEnd\\242.dino_game\\packages\\aurabase-js","model":{"id":"GLM-5","display_name":"GLM-5"},"workspace":{"current_dir":"D:\\000.FrontEnd\\242.dino_game\\packages\\aurabase-js","project_dir":"D:\\000.FrontEnd\\242.dino_game","added_dirs":[]},"version":"2.1.71","output_style":{"name":"default"},"cost":{"total_cost_usd":1.0113789999999998,"total_duration_ms":1112478,"total_api_duration_ms":476001,"total_lines_added":1354,"total_lines_removed":2},"context_window":{"total_input_tokens":32475,"total_output_tokens":11628,"context_window_size":200000,"current_usage":{"input_tokens":169,"output_tokens":104,"cache_creation_input_tokens":0,"cache_read_input_tokens":48768},"used_percentage":24,"remaining_percentage":76},"exceeds_200k_tokens":false}
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # aurabase-js
2
+
3
+ AuraBase JavaScript/TypeScript 클라이언트 - Supabase 스타일의 SDK
4
+
5
+ ## 설치
6
+
7
+ ```bash
8
+ npm install aurabase-js
9
+ # 또는
10
+ yarn add aurabase-js
11
+ # 또는
12
+ pnpm add aurabase-js
13
+ ```
14
+
15
+ ## 사용법
16
+
17
+ ### 클라이언트 생성
18
+
19
+ ```typescript
20
+ import { createClient } from 'aurabase-js'
21
+
22
+ const aurabase = createClient({
23
+ url: 'http://localhost:8000', // 또는 배포된 URL
24
+ anonKey: 'your-anon-key'
25
+ })
26
+ ```
27
+
28
+ ### 데이터 조회 (SELECT)
29
+
30
+ ```typescript
31
+ // 전체 조회
32
+ const { data, error } = await aurabase
33
+ .from('todos')
34
+ .select('*')
35
+
36
+ // 특정 컬럼 선택
37
+ const { data, error } = await aurabase
38
+ .from('todos')
39
+ .select('id, title, completed')
40
+
41
+ // 필터링
42
+ const { data, error } = await aurabase
43
+ .from('todos')
44
+ .select('*')
45
+ .eq('completed', false)
46
+ .order('created_at', { ascending: false })
47
+ .limit(10)
48
+
49
+ // 단일 결과
50
+ const { data, error } = await aurabase
51
+ .from('todos')
52
+ .select('*')
53
+ .eq('id', 1)
54
+ .single()
55
+ ```
56
+
57
+ ### 데이터 삽입 (INSERT)
58
+
59
+ ```typescript
60
+ // 단일 행 삽입
61
+ const { data, error } = await aurabase
62
+ .from('todos')
63
+ .insert({ title: '새 할일', completed: false })
64
+
65
+ // 여러 행 삽입
66
+ const { data, error } = await aurabase
67
+ .from('todos')
68
+ .insert([
69
+ { title: '할일 1', completed: false },
70
+ { title: '할일 2', completed: true }
71
+ ])
72
+ ```
73
+
74
+ ### 데이터 수정 (UPDATE)
75
+
76
+ ```typescript
77
+ const { data, error } = await aurabase
78
+ .from('todos')
79
+ .update({ completed: true })
80
+ .eq('id', 1)
81
+ ```
82
+
83
+ ### 데이터 삭제 (DELETE)
84
+
85
+ ```typescript
86
+ const { data, error } = await aurabase
87
+ .from('todos')
88
+ .delete()
89
+ .eq('id', 1)
90
+ ```
91
+
92
+ ### Upsert
93
+
94
+ ```typescript
95
+ const { data, error } = await aurabase
96
+ .from('todos')
97
+ .upsert({ id: 1, title: '업데이트된 할일', completed: true })
98
+ ```
99
+
100
+ ## 인증 (Auth)
101
+
102
+ ### 로그인
103
+
104
+ ```typescript
105
+ const { data, error } = await aurabase.auth.signInWithPassword({
106
+ email: 'user@example.com',
107
+ password: 'password123'
108
+ })
109
+
110
+ if (data) {
111
+ console.log('로그인 성공:', data.user)
112
+ console.log('액세스 토큰:', data.session.access_token)
113
+ }
114
+ ```
115
+
116
+ ### 회원가입
117
+
118
+ ```typescript
119
+ const { data, error } = await aurabase.auth.signUp({
120
+ email: 'user@example.com',
121
+ password: 'password123',
122
+ username: 'myusername'
123
+ })
124
+ ```
125
+
126
+ ### 로그아웃
127
+
128
+ ```typescript
129
+ await aurabase.auth.signOut()
130
+ ```
131
+
132
+ ### 현재 사용자 조회
133
+
134
+ ```typescript
135
+ const { data: { user } } = await aurabase.auth.getUser()
136
+ ```
137
+
138
+ ### 인증 상태 변경 감지
139
+
140
+ ```typescript
141
+ const { data: { subscription } } = aurabase.auth.onAuthStateChange((event, session) => {
142
+ if (event === 'SIGNED_IN') {
143
+ console.log('로그인됨:', session?.user)
144
+ } else if (event === 'SIGNED_OUT') {
145
+ console.log('로그아웃됨')
146
+ }
147
+ })
148
+
149
+ // 구독 해제
150
+ subscription.unsubscribe()
151
+ ```
152
+
153
+ ### 비밀번호 재설정
154
+
155
+ ```typescript
156
+ await aurabase.auth.resetPasswordForEmail('user@example.com')
157
+ ```
158
+
159
+ ## 필터 메서드
160
+
161
+ | 메서드 | 설명 | 예시 |
162
+ |--------|------|------|
163
+ | `.eq(column, value)` | 같음 | `.eq('status', 'active')` |
164
+ | `.neq(column, value)` | 같지 않음 | `.neq('status', 'deleted')` |
165
+ | `.gt(column, value)` | 초과 | `.gt('age', 18)` |
166
+ | `.gte(column, value)` | 이상 | `.gte('age', 18)` |
167
+ | `.lt(column, value)` | 미만 | `.lt('price', 100)` |
168
+ | `.lte(column, value)` | 이하 | `.lte('price', 100)` |
169
+ | `.like(column, pattern)` | LIKE 패턴 | `.like('name', '%John%')` |
170
+ | `.ilike(column, pattern)` | 대소문자 구분 없는 LIKE | `.ilike('email', '%@gmail.com')` |
171
+ | `.in(column, values)` | 값 목록 중 하나 | `.in('id', [1, 2, 3])` |
172
+ | `.isNull(column)` | NULL | `.isNull('deleted_at')` |
173
+ | `.isNotNull(column)` | NOT NULL | `.isNotNull('email')` |
174
+
175
+ ## RPC (원격 함수 호출)
176
+
177
+ ```typescript
178
+ const { data, error } = await aurabase.rpc('my_function', {
179
+ arg1: 'value1',
180
+ arg2: 'value2'
181
+ })
182
+ ```
183
+
184
+ ## TypeScript 지원
185
+
186
+ ```typescript
187
+ interface Todo {
188
+ id: number
189
+ title: string
190
+ completed: boolean
191
+ created_at: string
192
+ }
193
+
194
+ // 타입 지정
195
+ const { data, error } = await aurabase
196
+ .from<Todo>('todos')
197
+ .select('*')
198
+
199
+ // data는 Todo[] 타입으로 추론됨
200
+ ```
201
+
202
+ ## 라이선스
203
+
204
+ MIT
@@ -0,0 +1,392 @@
1
+ interface AuraBaseClientOptions {
2
+ url: string;
3
+ anonKey: string;
4
+ headers?: Record<string, string>;
5
+ }
6
+ interface AuthSession {
7
+ access_token: string;
8
+ token_type: string;
9
+ user: User;
10
+ }
11
+ interface User {
12
+ id: number;
13
+ email: string;
14
+ username?: string;
15
+ role_id?: number;
16
+ created_at?: string;
17
+ }
18
+ interface AuthError {
19
+ error: string;
20
+ detail?: string | Array<{
21
+ msg: string;
22
+ }>;
23
+ }
24
+ interface PostgrestResponse<T> {
25
+ data: T | T[] | null;
26
+ error: AuraBaseError | null;
27
+ status: number;
28
+ statusText: string;
29
+ }
30
+ interface AuraBaseError {
31
+ message: string;
32
+ code?: string;
33
+ details?: string;
34
+ }
35
+ interface AuthStateChangeEvent {
36
+ SIGNED_IN: 'SIGNED_IN';
37
+ SIGNED_OUT: 'SIGNED_OUT';
38
+ TOKEN_REFRESHED: 'TOKEN_REFRESHED';
39
+ USER_UPDATED: 'USER_UPDATED';
40
+ }
41
+ type AuthChangeEvent = AuthStateChangeEvent[keyof AuthStateChangeEvent];
42
+ interface Subscription {
43
+ unsubscribe: () => void;
44
+ }
45
+ interface SignInWithPasswordCredentials {
46
+ email: string;
47
+ password: string;
48
+ }
49
+ interface SignUpCredentials {
50
+ email: string;
51
+ password: string;
52
+ username?: string;
53
+ }
54
+ interface UpdateUserAttributes {
55
+ email?: string;
56
+ password?: string;
57
+ username?: string;
58
+ }
59
+
60
+ declare class QueryBuilder<T> {
61
+ private url;
62
+ private anonKey;
63
+ private accessToken;
64
+ private tableName;
65
+ private queryParams;
66
+ private headers;
67
+ private isSingle;
68
+ constructor(url: string, anonKey: string, accessToken: string | null, tableName: string, headers?: Record<string, string>);
69
+ /**
70
+ * Select columns
71
+ * @example
72
+ * .select('id, name, email')
73
+ * .select('*')
74
+ */
75
+ select(columns?: string): this;
76
+ /**
77
+ * Filter by column equality
78
+ * @example
79
+ * .eq('id', 1)
80
+ * .eq('status', 'active')
81
+ */
82
+ eq(column: string, value: unknown): this;
83
+ /**
84
+ * Filter by column inequality
85
+ */
86
+ neq(column: string, value: unknown): this;
87
+ /**
88
+ * Filter by greater than
89
+ */
90
+ gt(column: string, value: unknown): this;
91
+ /**
92
+ * Filter by greater than or equal
93
+ */
94
+ gte(column: string, value: unknown): this;
95
+ /**
96
+ * Filter by less than
97
+ */
98
+ lt(column: string, value: unknown): this;
99
+ /**
100
+ * Filter by less than or equal
101
+ */
102
+ lte(column: string, value: unknown): this;
103
+ /**
104
+ * Filter by like pattern
105
+ */
106
+ like(column: string, pattern: string): this;
107
+ /**
108
+ * Filter by case-insensitive like pattern
109
+ */
110
+ ilike(column: string, pattern: string): this;
111
+ /**
112
+ * Filter by array contains
113
+ */
114
+ contains(column: string, value: unknown[]): this;
115
+ /**
116
+ * Filter by value in array
117
+ */
118
+ in(column: string, values: unknown[]): this;
119
+ /**
120
+ * Filter for null values
121
+ */
122
+ isNull(column: string): this;
123
+ /**
124
+ * Filter for non-null values
125
+ */
126
+ isNotNull(column: string): this;
127
+ /**
128
+ * Order results
129
+ * @example
130
+ * .order('created_at', { ascending: false })
131
+ */
132
+ order(column: string, options?: {
133
+ ascending?: boolean;
134
+ nullsFirst?: boolean;
135
+ }): this;
136
+ /**
137
+ * Limit results
138
+ */
139
+ limit(count: number): this;
140
+ /**
141
+ * Offset results
142
+ */
143
+ offset(count: number): this;
144
+ /**
145
+ * Range of results (offset + limit)
146
+ */
147
+ range(from: number, to: number): this;
148
+ /**
149
+ * Return single result
150
+ */
151
+ single(): this;
152
+ /**
153
+ * Return single result or null
154
+ */
155
+ maybeSingle(): this;
156
+ private getHeaders;
157
+ private request;
158
+ /**
159
+ * Execute SELECT query
160
+ */
161
+ then<TResult = T[]>(resolve: (value: PostgrestResponse<TResult>) => void | PromiseLike<void>, reject?: (reason: unknown) => void | PromiseLike<void>): Promise<void>;
162
+ /**
163
+ * Insert row(s)
164
+ */
165
+ insert(row: Partial<T> | Partial<T>[]): Promise<PostgrestResponse<T>>;
166
+ /**
167
+ * Update row(s)
168
+ */
169
+ update(data: Partial<T>): Promise<PostgrestResponse<T>>;
170
+ /**
171
+ * Upsert row(s)
172
+ */
173
+ upsert(row: Partial<T> | Partial<T>[]): Promise<PostgrestResponse<T>>;
174
+ /**
175
+ * Delete row(s)
176
+ */
177
+ delete(): Promise<PostgrestResponse<T>>;
178
+ }
179
+
180
+ declare class AuthClient {
181
+ private url;
182
+ private anonKey;
183
+ private listeners;
184
+ private currentSession;
185
+ private storageKey;
186
+ constructor(url: string, anonKey: string);
187
+ private loadSession;
188
+ private saveSession;
189
+ private getHeaders;
190
+ private emitEvent;
191
+ /**
192
+ * Sign in with email and password
193
+ */
194
+ signInWithPassword(credentials: SignInWithPasswordCredentials): Promise<{
195
+ data: {
196
+ user: User;
197
+ session: AuthSession;
198
+ } | null;
199
+ error: AuthError | null;
200
+ }>;
201
+ /**
202
+ * Sign up with email and password
203
+ */
204
+ signUp(credentials: SignUpCredentials): Promise<{
205
+ data: {
206
+ user: User;
207
+ } | null;
208
+ error: AuthError | null;
209
+ }>;
210
+ /**
211
+ * Sign out
212
+ */
213
+ signOut(): Promise<{
214
+ error: AuthError | null;
215
+ }>;
216
+ /**
217
+ * Get current session
218
+ */
219
+ getSession(): {
220
+ data: {
221
+ session: AuthSession | null;
222
+ };
223
+ };
224
+ /**
225
+ * Get current user
226
+ */
227
+ getUser(): Promise<{
228
+ data: {
229
+ user: User | null;
230
+ };
231
+ error: AuthError | null;
232
+ }>;
233
+ /**
234
+ * Update user
235
+ */
236
+ updateUser(attributes: UpdateUserAttributes): Promise<{
237
+ data: {
238
+ user: User;
239
+ } | null;
240
+ error: AuthError | null;
241
+ }>;
242
+ /**
243
+ * Request password reset
244
+ */
245
+ resetPasswordForEmail(email: string): Promise<{
246
+ error: AuthError | null;
247
+ }>;
248
+ /**
249
+ * Subscribe to auth state changes
250
+ */
251
+ onAuthStateChange(callback: (event: AuthChangeEvent, session: AuthSession | null) => void): {
252
+ data: {
253
+ subscription: Subscription;
254
+ };
255
+ };
256
+ }
257
+
258
+ declare class AuraBaseClient {
259
+ private url;
260
+ private anonKey;
261
+ private accessToken;
262
+ private customHeaders;
263
+ auth: AuthClient;
264
+ constructor(options: AuraBaseClientOptions);
265
+ /**
266
+ * Set access token for authenticated requests
267
+ */
268
+ setAccessToken(token: string | null): void;
269
+ /**
270
+ * Get the current access token
271
+ */
272
+ getAccessToken(): string | null;
273
+ /**
274
+ * Query a table
275
+ * @example
276
+ * const { data, error } = await client.from('todos').select('*')
277
+ */
278
+ from<T = unknown>(tableName: string): QueryBuilder<T>;
279
+ /**
280
+ * Execute raw SQL (RPC function call)
281
+ * @example
282
+ * const { data, error } = await client.rpc('my_function', { arg1: 'value' })
283
+ */
284
+ rpc<T = unknown>(functionName: string, params?: Record<string, unknown>): Promise<{
285
+ data: T | null;
286
+ error: {
287
+ message: string;
288
+ } | null;
289
+ }>;
290
+ /**
291
+ * Get storage client (if available)
292
+ */
293
+ get storage(): {
294
+ from: (bucket: string) => StorageBucket;
295
+ };
296
+ }
297
+ /**
298
+ * Storage bucket operations
299
+ */
300
+ declare class StorageBucket {
301
+ private url;
302
+ private anonKey;
303
+ private bucket;
304
+ private accessToken;
305
+ constructor(url: string, anonKey: string, bucket: string, accessToken: string | null);
306
+ private getHeaders;
307
+ /**
308
+ * Upload a file
309
+ */
310
+ upload(path: string, file: File | Blob, options?: {
311
+ contentType?: string;
312
+ upsert?: boolean;
313
+ }): Promise<{
314
+ data: {
315
+ path: string;
316
+ } | null;
317
+ error: {
318
+ message: string;
319
+ } | null;
320
+ }>;
321
+ /**
322
+ * Download a file
323
+ */
324
+ download(path: string): Promise<{
325
+ data: Blob | null;
326
+ error: {
327
+ message: string;
328
+ } | null;
329
+ }>;
330
+ /**
331
+ * Get public URL for a file
332
+ */
333
+ getPublicUrl(path: string): string;
334
+ /**
335
+ * Delete a file
336
+ */
337
+ remove(paths: string[]): Promise<{
338
+ error: {
339
+ message: string;
340
+ } | null;
341
+ }>;
342
+ /**
343
+ * List files in a bucket
344
+ */
345
+ list(prefix?: string): Promise<{
346
+ data: Array<{
347
+ name: string;
348
+ id: string;
349
+ created_at: string;
350
+ }> | null;
351
+ error: {
352
+ message: string;
353
+ } | null;
354
+ }>;
355
+ }
356
+
357
+ /**
358
+ * Create an AuraBase client
359
+ * @param options - Client options containing url and anonKey
360
+ * @returns AuraBaseClient instance
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * import { createClient } from 'aurabase-js'
365
+ *
366
+ * const aurabase = createClient({
367
+ * url: 'http://localhost:8000',
368
+ * anonKey: 'your-anon-key'
369
+ * })
370
+ *
371
+ * // Query data
372
+ * const { data, error } = await aurabase
373
+ * .from('todos')
374
+ * .select('*')
375
+ * .order('created_at', { ascending: false })
376
+ * .limit(10)
377
+ *
378
+ * // Insert data
379
+ * const { data: newTodo, error: insertError } = await aurabase
380
+ * .from('todos')
381
+ * .insert({ title: 'My todo', completed: false })
382
+ *
383
+ * // Auth
384
+ * const { data, error } = await aurabase.auth.signInWithPassword({
385
+ * email: 'user@example.com',
386
+ * password: 'password'
387
+ * })
388
+ * ```
389
+ */
390
+ declare function createClient(options: AuraBaseClientOptions): AuraBaseClient;
391
+
392
+ export { AuraBaseClient, type AuraBaseClientOptions, type AuraBaseError, type AuthChangeEvent, type AuthError, type AuthSession, type PostgrestResponse, type SignInWithPasswordCredentials, type SignUpCredentials, type Subscription, type UpdateUserAttributes, type User, createClient, createClient as default };