aurabase-js 0.5.0 → 0.6.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.
@@ -1 +1 @@
1
- {"session_id":"1c1e8df6-335a-4058-8bd4-4c0a67d996cd","transcript_path":"C:\\Users\\Jay\\.claude\\projects\\D--000-FrontEnd-242-dino-game\\1c1e8df6-335a-4058-8bd4-4c0a67d996cd.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":2.823248,"total_duration_ms":1638396,"total_api_duration_ms":797770,"total_lines_added":333,"total_lines_removed":70},"context_window":{"total_input_tokens":76386,"total_output_tokens":19574,"context_window_size":200000,"current_usage":{"input_tokens":160,"output_tokens":64,"cache_creation_input_tokens":0,"cache_read_input_tokens":82624},"used_percentage":41,"remaining_percentage":59},"exceeds_200k_tokens":false}
1
+ {"session_id":"1c1e8df6-335a-4058-8bd4-4c0a67d996cd","transcript_path":"C:\\Users\\Jay\\.claude\\projects\\D--000-FrontEnd-242-dino-game\\1c1e8df6-335a-4058-8bd4-4c0a67d996cd.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":3.1387229999999997,"total_duration_ms":1800053,"total_api_duration_ms":890803,"total_lines_added":356,"total_lines_removed":168},"context_window":{"total_input_tokens":80855,"total_output_tokens":22864,"context_window_size":200000,"current_usage":{"input_tokens":137,"output_tokens":64,"cache_creation_input_tokens":0,"cache_read_input_tokens":86976},"used_percentage":44,"remaining_percentage":56},"exceeds_200k_tokens":false}
package/dist/cli.js CHANGED
@@ -27,109 +27,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var fs = __toESM(require("fs"));
28
28
  var path = __toESM(require("path"));
29
29
  var TEMPLATES = {
30
- "lib/aurabase.ts": `import { createClient } from 'aurabase-js';
30
+ "lib/client.ts": `import { createClient } from 'aurabase-js';
31
31
 
32
- const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || '';
33
- const AURABASE_ANON_KEY = process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '';
34
-
35
- export const aurabase = createClient({
36
- url: AURABASE_URL,
37
- anonKey: AURABASE_ANON_KEY,
32
+ export const client = createClient({
33
+ url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
34
+ anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
38
35
  });
39
36
  `,
40
- "lib/api-client.ts": `import { NextRequest, NextResponse } from 'next/server';
41
-
42
- const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || '';
43
- const AURABASE_ANON_KEY = process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '';
37
+ "lib/server.ts": `import { createClient } from 'aurabase-js';
38
+ import { cookies } from 'next/headers';
44
39
 
45
- /**
46
- * \uC11C\uBC84 \uC0AC\uC774\uB4DC API \uD504\uB85D\uC2DC \uC720\uD2F8\uB9AC\uD2F0
47
- */
48
- export async function proxyApiRequest(
49
- req: NextRequest,
50
- path: string
51
- ): Promise<NextResponse> {
52
- const accessToken = req.cookies.get('access_token')?.value;
53
- const authToken = accessToken || AURABASE_ANON_KEY;
54
-
55
- let body: string | undefined;
56
- if (req.method !== 'GET' && req.method !== 'HEAD') {
57
- body = await req.text();
58
- }
40
+ export async function server() {
41
+ const cookieStore = await cookies();
42
+ const accessToken = cookieStore.get('access_token')?.value;
59
43
 
60
- const headers: Record<string, string> = {
61
- 'Content-Type': 'application/json',
62
- };
63
- if (authToken) {
64
- headers['Authorization'] = \`Bearer \${authToken}\`;
65
- }
66
-
67
- const fetchOptions: RequestInit = {
68
- method: req.method,
69
- headers,
70
- };
71
- if (body) {
72
- fetchOptions.body = body;
73
- }
74
-
75
- const res = await fetch(\`\${AURABASE_URL}\${path}\`, fetchOptions);
76
- const data = await res.text();
77
- return new NextResponse(data, {
78
- status: res.status,
79
- headers: { 'Content-Type': 'application/json' },
44
+ const client = createClient({
45
+ url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
46
+ anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
80
47
  });
81
- }
82
-
83
- /**
84
- * \uD074\uB77C\uC774\uC5B8\uD2B8\uC6A9 fetch \uB798\uD37C
85
- */
86
- export function createApiClient(baseUrl: string = '') {
87
- return {
88
- async get<T>(path: string): Promise<T> {
89
- const res = await fetch(\`\${baseUrl}\${path}\`, { credentials: 'include' });
90
- if (!res.ok) throw new Error(\`API Error: \${res.status}\`);
91
- return res.json();
92
- },
93
48
 
94
- async post<T>(path: string, data?: unknown): Promise<T> {
95
- const options: RequestInit = {
96
- method: 'POST',
97
- headers: { 'Content-Type': 'application/json' },
98
- credentials: 'include',
99
- };
100
- if (data) options.body = JSON.stringify(data);
101
- const res = await fetch(\`\${baseUrl}\${path}\`, options);
102
- if (!res.ok) {
103
- const error = await res.json().catch(() => ({ error: 'Unknown error' }));
104
- throw error;
105
- }
106
- return res.json();
107
- },
108
-
109
- async put<T>(path: string, data?: unknown): Promise<T> {
110
- const options: RequestInit = {
111
- method: 'PUT',
112
- headers: { 'Content-Type': 'application/json' },
113
- credentials: 'include',
114
- };
115
- if (data) options.body = JSON.stringify(data);
116
- const res = await fetch(\`\${baseUrl}\${path}\`, options);
117
- if (!res.ok) {
118
- const error = await res.json().catch(() => ({ error: 'Unknown error' }));
119
- throw error;
120
- }
121
- return res.json();
122
- },
49
+ if (accessToken) {
50
+ client.setAccessToken(accessToken);
51
+ }
123
52
 
124
- async delete<T>(path: string): Promise<T> {
125
- const res = await fetch(\`\${baseUrl}\${path}\`, {
126
- method: 'DELETE',
127
- credentials: 'include',
128
- });
129
- if (!res.ok) throw new Error(\`API Error: \${res.status}\`);
130
- return res.json();
131
- },
132
- };
53
+ return client;
133
54
  }
134
55
  `
135
56
  };
@@ -170,8 +91,8 @@ function createFile(projectRoot, filename) {
170
91
  function init() {
171
92
  const projectRoot = findProjectRoot();
172
93
  console.log("\x1B[1m\n\u{1F680} Initializing AuraBase...\x1B[0m\n");
173
- createFile(projectRoot, "lib/aurabase.ts");
174
- createFile(projectRoot, "lib/api-client.ts");
94
+ createFile(projectRoot, "lib/client.ts");
95
+ createFile(projectRoot, "lib/server.ts");
175
96
  console.log("\x1B[36m%s\x1B[0m", ENV_TEMPLATE);
176
97
  }
177
98
  function showHelp() {
@@ -184,6 +105,10 @@ function showHelp() {
184
105
  \x1B[1mOptions:\x1B[0m
185
106
  -h, --help Show this help message
186
107
  -v, --version Show version
108
+
109
+ \x1B[1mGenerated files:\x1B[0m
110
+ lib/client.ts Browser client
111
+ lib/server.ts Server client (with cookie auth)
187
112
  `);
188
113
  }
189
114
  function showVersion() {
package/dist/cli.mjs CHANGED
@@ -4,109 +4,30 @@
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
6
  var TEMPLATES = {
7
- "lib/aurabase.ts": `import { createClient } from 'aurabase-js';
7
+ "lib/client.ts": `import { createClient } from 'aurabase-js';
8
8
 
9
- const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || '';
10
- const AURABASE_ANON_KEY = process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '';
11
-
12
- export const aurabase = createClient({
13
- url: AURABASE_URL,
14
- anonKey: AURABASE_ANON_KEY,
9
+ export const client = createClient({
10
+ url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
11
+ anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
15
12
  });
16
13
  `,
17
- "lib/api-client.ts": `import { NextRequest, NextResponse } from 'next/server';
18
-
19
- const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || '';
20
- const AURABASE_ANON_KEY = process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '';
14
+ "lib/server.ts": `import { createClient } from 'aurabase-js';
15
+ import { cookies } from 'next/headers';
21
16
 
22
- /**
23
- * \uC11C\uBC84 \uC0AC\uC774\uB4DC API \uD504\uB85D\uC2DC \uC720\uD2F8\uB9AC\uD2F0
24
- */
25
- export async function proxyApiRequest(
26
- req: NextRequest,
27
- path: string
28
- ): Promise<NextResponse> {
29
- const accessToken = req.cookies.get('access_token')?.value;
30
- const authToken = accessToken || AURABASE_ANON_KEY;
31
-
32
- let body: string | undefined;
33
- if (req.method !== 'GET' && req.method !== 'HEAD') {
34
- body = await req.text();
35
- }
17
+ export async function server() {
18
+ const cookieStore = await cookies();
19
+ const accessToken = cookieStore.get('access_token')?.value;
36
20
 
37
- const headers: Record<string, string> = {
38
- 'Content-Type': 'application/json',
39
- };
40
- if (authToken) {
41
- headers['Authorization'] = \`Bearer \${authToken}\`;
42
- }
43
-
44
- const fetchOptions: RequestInit = {
45
- method: req.method,
46
- headers,
47
- };
48
- if (body) {
49
- fetchOptions.body = body;
50
- }
51
-
52
- const res = await fetch(\`\${AURABASE_URL}\${path}\`, fetchOptions);
53
- const data = await res.text();
54
- return new NextResponse(data, {
55
- status: res.status,
56
- headers: { 'Content-Type': 'application/json' },
21
+ const client = createClient({
22
+ url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
23
+ anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
57
24
  });
58
- }
59
-
60
- /**
61
- * \uD074\uB77C\uC774\uC5B8\uD2B8\uC6A9 fetch \uB798\uD37C
62
- */
63
- export function createApiClient(baseUrl: string = '') {
64
- return {
65
- async get<T>(path: string): Promise<T> {
66
- const res = await fetch(\`\${baseUrl}\${path}\`, { credentials: 'include' });
67
- if (!res.ok) throw new Error(\`API Error: \${res.status}\`);
68
- return res.json();
69
- },
70
25
 
71
- async post<T>(path: string, data?: unknown): Promise<T> {
72
- const options: RequestInit = {
73
- method: 'POST',
74
- headers: { 'Content-Type': 'application/json' },
75
- credentials: 'include',
76
- };
77
- if (data) options.body = JSON.stringify(data);
78
- const res = await fetch(\`\${baseUrl}\${path}\`, options);
79
- if (!res.ok) {
80
- const error = await res.json().catch(() => ({ error: 'Unknown error' }));
81
- throw error;
82
- }
83
- return res.json();
84
- },
85
-
86
- async put<T>(path: string, data?: unknown): Promise<T> {
87
- const options: RequestInit = {
88
- method: 'PUT',
89
- headers: { 'Content-Type': 'application/json' },
90
- credentials: 'include',
91
- };
92
- if (data) options.body = JSON.stringify(data);
93
- const res = await fetch(\`\${baseUrl}\${path}\`, options);
94
- if (!res.ok) {
95
- const error = await res.json().catch(() => ({ error: 'Unknown error' }));
96
- throw error;
97
- }
98
- return res.json();
99
- },
26
+ if (accessToken) {
27
+ client.setAccessToken(accessToken);
28
+ }
100
29
 
101
- async delete<T>(path: string): Promise<T> {
102
- const res = await fetch(\`\${baseUrl}\${path}\`, {
103
- method: 'DELETE',
104
- credentials: 'include',
105
- });
106
- if (!res.ok) throw new Error(\`API Error: \${res.status}\`);
107
- return res.json();
108
- },
109
- };
30
+ return client;
110
31
  }
111
32
  `
112
33
  };
@@ -147,8 +68,8 @@ function createFile(projectRoot, filename) {
147
68
  function init() {
148
69
  const projectRoot = findProjectRoot();
149
70
  console.log("\x1B[1m\n\u{1F680} Initializing AuraBase...\x1B[0m\n");
150
- createFile(projectRoot, "lib/aurabase.ts");
151
- createFile(projectRoot, "lib/api-client.ts");
71
+ createFile(projectRoot, "lib/client.ts");
72
+ createFile(projectRoot, "lib/server.ts");
152
73
  console.log("\x1B[36m%s\x1B[0m", ENV_TEMPLATE);
153
74
  }
154
75
  function showHelp() {
@@ -161,6 +82,10 @@ function showHelp() {
161
82
  \x1B[1mOptions:\x1B[0m
162
83
  -h, --help Show this help message
163
84
  -v, --version Show version
85
+
86
+ \x1B[1mGenerated files:\x1B[0m
87
+ lib/client.ts Browser client
88
+ lib/server.ts Server client (with cookie auth)
164
89
  `);
165
90
  }
166
91
  function showVersion() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aurabase-js",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "AuraBase client library - Supabase-style SDK for AuraBase",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/cli.ts CHANGED
@@ -4,109 +4,30 @@ import * as fs from 'fs';
4
4
  import * as path from 'path';
5
5
 
6
6
  const TEMPLATES = {
7
- 'lib/aurabase.ts': `import { createClient } from 'aurabase-js';
7
+ 'lib/client.ts': `import { createClient } from 'aurabase-js';
8
8
 
9
- const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || '';
10
- const AURABASE_ANON_KEY = process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '';
11
-
12
- export const aurabase = createClient({
13
- url: AURABASE_URL,
14
- anonKey: AURABASE_ANON_KEY,
9
+ export const client = createClient({
10
+ url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
11
+ anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
15
12
  });
16
13
  `,
17
- 'lib/api-client.ts': `import { NextRequest, NextResponse } from 'next/server';
18
-
19
- const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || '';
20
- const AURABASE_ANON_KEY = process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '';
21
-
22
- /**
23
- * 서버 사이드 API 프록시 유틸리티
24
- */
25
- export async function proxyApiRequest(
26
- req: NextRequest,
27
- path: string
28
- ): Promise<NextResponse> {
29
- const accessToken = req.cookies.get('access_token')?.value;
30
- const authToken = accessToken || AURABASE_ANON_KEY;
31
-
32
- let body: string | undefined;
33
- if (req.method !== 'GET' && req.method !== 'HEAD') {
34
- body = await req.text();
35
- }
14
+ 'lib/server.ts': `import { createClient } from 'aurabase-js';
15
+ import { cookies } from 'next/headers';
36
16
 
37
- const headers: Record<string, string> = {
38
- 'Content-Type': 'application/json',
39
- };
40
- if (authToken) {
41
- headers['Authorization'] = \`Bearer \${authToken}\`;
42
- }
43
-
44
- const fetchOptions: RequestInit = {
45
- method: req.method,
46
- headers,
47
- };
48
- if (body) {
49
- fetchOptions.body = body;
50
- }
17
+ export async function server() {
18
+ const cookieStore = await cookies();
19
+ const accessToken = cookieStore.get('access_token')?.value;
51
20
 
52
- const res = await fetch(\`\${AURABASE_URL}\${path}\`, fetchOptions);
53
- const data = await res.text();
54
- return new NextResponse(data, {
55
- status: res.status,
56
- headers: { 'Content-Type': 'application/json' },
21
+ const client = createClient({
22
+ url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
23
+ anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
57
24
  });
58
- }
59
25
 
60
- /**
61
- * 클라이언트용 fetch 래퍼
62
- */
63
- export function createApiClient(baseUrl: string = '') {
64
- return {
65
- async get<T>(path: string): Promise<T> {
66
- const res = await fetch(\`\${baseUrl}\${path}\`, { credentials: 'include' });
67
- if (!res.ok) throw new Error(\`API Error: \${res.status}\`);
68
- return res.json();
69
- },
70
-
71
- async post<T>(path: string, data?: unknown): Promise<T> {
72
- const options: RequestInit = {
73
- method: 'POST',
74
- headers: { 'Content-Type': 'application/json' },
75
- credentials: 'include',
76
- };
77
- if (data) options.body = JSON.stringify(data);
78
- const res = await fetch(\`\${baseUrl}\${path}\`, options);
79
- if (!res.ok) {
80
- const error = await res.json().catch(() => ({ error: 'Unknown error' }));
81
- throw error;
82
- }
83
- return res.json();
84
- },
85
-
86
- async put<T>(path: string, data?: unknown): Promise<T> {
87
- const options: RequestInit = {
88
- method: 'PUT',
89
- headers: { 'Content-Type': 'application/json' },
90
- credentials: 'include',
91
- };
92
- if (data) options.body = JSON.stringify(data);
93
- const res = await fetch(\`\${baseUrl}\${path}\`, options);
94
- if (!res.ok) {
95
- const error = await res.json().catch(() => ({ error: 'Unknown error' }));
96
- throw error;
97
- }
98
- return res.json();
99
- },
100
-
101
- async delete<T>(path: string): Promise<T> {
102
- const res = await fetch(\`\${baseUrl}\${path}\`, {
103
- method: 'DELETE',
104
- credentials: 'include',
105
- });
106
- if (!res.ok) throw new Error(\`API Error: \${res.status}\`);
107
- return res.json();
108
- },
109
- };
26
+ if (accessToken) {
27
+ client.setAccessToken(accessToken);
28
+ }
29
+
30
+ return client;
110
31
  }
111
32
  `,
112
33
  };
@@ -157,8 +78,8 @@ function init() {
157
78
 
158
79
  console.log('\x1b[1m\n🚀 Initializing AuraBase...\x1b[0m\n');
159
80
 
160
- createFile(projectRoot, 'lib/aurabase.ts');
161
- createFile(projectRoot, 'lib/api-client.ts');
81
+ createFile(projectRoot, 'lib/client.ts');
82
+ createFile(projectRoot, 'lib/server.ts');
162
83
 
163
84
  console.log('\x1b[36m%s\x1b[0m', ENV_TEMPLATE);
164
85
  }
@@ -173,6 +94,10 @@ function showHelp() {
173
94
  \x1b[1mOptions:\x1b[0m
174
95
  -h, --help Show this help message
175
96
  -v, --version Show version
97
+
98
+ \x1b[1mGenerated files:\x1b[0m
99
+ lib/client.ts Browser client
100
+ lib/server.ts Server client (with cookie auth)
176
101
  `);
177
102
  }
178
103