aurabase-js 0.2.0 → 0.2.1
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/.omc/state/hud-state.json +3 -3
- package/.omc/state/hud-stdin-cache.json +1 -1
- package/README.md +70 -2
- package/dist/cli.js +127 -115
- package/dist/index.js +116 -75
- package/dist/index.mjs +111 -81
- package/package.json +6 -5
- package/src/AuraBaseClient.ts +6 -16
- package/src/QueryBuilder.ts +122 -161
- package/src/cli.ts +116 -97
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -109
- package/lib/aurabase.ts +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2026-03-
|
|
2
|
+
"timestamp": "2026-03-09T11:49:17.080Z",
|
|
3
3
|
"backgroundTasks": [],
|
|
4
|
-
"sessionStartTimestamp": "2026-03-09T11:
|
|
5
|
-
"sessionId": "
|
|
4
|
+
"sessionStartTimestamp": "2026-03-09T11:37:51.558Z",
|
|
5
|
+
"sessionId": "a7635597b80deb9e"
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"session_id":"
|
|
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
CHANGED
|
@@ -12,6 +12,74 @@ yarn add aurabase-js
|
|
|
12
12
|
pnpm add aurabase-js
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
설치 후 아래 명령어 한 번으로 `lib/` 폴더와 환경변수 파일을 자동 생성합니다:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx aurabase-js init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
aurabase-js init
|
|
23
|
+
──────────────────────────────────
|
|
24
|
+
✔ lib/client.ts 생성
|
|
25
|
+
✔ lib/server.ts 생성
|
|
26
|
+
✔ lib/admin.ts 생성
|
|
27
|
+
|
|
28
|
+
📋 환경변수 설정
|
|
29
|
+
──────────────────────────────────
|
|
30
|
+
✔ .env.local 생성 — 아래 값을 채워주세요
|
|
31
|
+
|
|
32
|
+
NEXT_PUBLIC_AURABASE_URL=https://your-project.cloudfront.net
|
|
33
|
+
NEXT_PUBLIC_AURABASE_ANON_KEY=your-anon-key
|
|
34
|
+
NEXT_PUBLIC_AURABASE_SERVICE_ROLE_KEY=your-service-role-key
|
|
35
|
+
|
|
36
|
+
→ AuraBase 대시보드 API Keys 메뉴에서 확인하세요.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## ⚙️ 환경변수 설정 (Next.js)
|
|
42
|
+
|
|
43
|
+
설치 후 프로젝트 루트에 `.env.local` 파일을 생성하고 아래 값을 입력하세요.
|
|
44
|
+
|
|
45
|
+
```env
|
|
46
|
+
# AuraBase 프로젝트 URL
|
|
47
|
+
NEXT_PUBLIC_AURABASE_URL=https://your-project.cloudfront.net
|
|
48
|
+
|
|
49
|
+
# 일반 사용자용 키 (클라이언트 컴포넌트, RLS 적용)
|
|
50
|
+
NEXT_PUBLIC_AURABASE_ANON_KEY=your-anon-key
|
|
51
|
+
|
|
52
|
+
# 관리자용 키 (서버 컴포넌트 / API Route 전용, RLS 우회)
|
|
53
|
+
NEXT_PUBLIC_AURABASE_SERVICE_ROLE_KEY=your-service-role-key
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> 위 값은 AuraBase 대시보드 → **API Keys** 메뉴에서 확인할 수 있습니다.
|
|
57
|
+
|
|
58
|
+
### `lib/client.ts` — 클라이언트 컴포넌트용
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { createClient } from 'aurabase-js'
|
|
62
|
+
|
|
63
|
+
export const client = createClient({
|
|
64
|
+
url: process.env.NEXT_PUBLIC_AURABASE_URL!,
|
|
65
|
+
anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY!,
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `lib/admin.ts` — 서버 전용 (API Route, Server Component)
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { createClient } from 'aurabase-js'
|
|
73
|
+
|
|
74
|
+
// ⚠️ 절대 클라이언트 컴포넌트에서 사용 금지 — RLS를 우회합니다
|
|
75
|
+
export const admin = createClient({
|
|
76
|
+
url: process.env.NEXT_PUBLIC_AURABASE_URL!,
|
|
77
|
+
anonKey: process.env.NEXT_PUBLIC_AURABASE_SERVICE_ROLE_KEY!,
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
15
83
|
## 사용법
|
|
16
84
|
|
|
17
85
|
### 클라이언트 생성
|
|
@@ -20,8 +88,8 @@ pnpm add aurabase-js
|
|
|
20
88
|
import { createClient } from 'aurabase-js'
|
|
21
89
|
|
|
22
90
|
const aurabase = createClient({
|
|
23
|
-
url:
|
|
24
|
-
anonKey:
|
|
91
|
+
url: process.env.NEXT_PUBLIC_AURABASE_URL!,
|
|
92
|
+
anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY!,
|
|
25
93
|
})
|
|
26
94
|
```
|
|
27
95
|
|
package/dist/cli.js
CHANGED
|
@@ -1,132 +1,144 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// src/cli.ts
|
|
27
|
-
var fs = __toESM(require("fs"));
|
|
28
|
-
var path = __toESM(require("path"));
|
|
29
|
-
var TEMPLATES = {
|
|
30
|
-
"lib/aurabase.ts": `import { createClient } from 'aurabase-js';
|
|
31
|
-
|
|
32
|
-
const AURABASE_URL = process.env.NEXT_PUBLIC_AURABASE_URL || 'https://your-project.cloudfront.net';
|
|
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,
|
|
38
|
-
});
|
|
39
|
-
`,
|
|
40
|
-
"lib/supabase.ts": `import { createClient } from 'aurabase-js';
|
|
41
3
|
|
|
42
|
-
const
|
|
43
|
-
const
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
44
6
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
anonKey: AURABASE_ANON_KEY,
|
|
48
|
-
});
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const command = args[0];
|
|
49
9
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# AuraBase Configuration
|
|
56
|
-
# Add these to your .env.local file:
|
|
10
|
+
const BOLD = '\x1b[1m';
|
|
11
|
+
const GREEN = '\x1b[32m';
|
|
12
|
+
const YELLOW = '\x1b[33m';
|
|
13
|
+
const CYAN = '\x1b[36m';
|
|
14
|
+
const RESET = '\x1b[0m';
|
|
57
15
|
|
|
58
|
-
|
|
59
|
-
|
|
16
|
+
function success(msg) { console.log(`${GREEN}✔${RESET} ${msg}`); }
|
|
17
|
+
function warn(msg) { console.log(`${YELLOW}⚠${RESET} ${msg}`); }
|
|
18
|
+
function info(msg) { console.log(`${CYAN}ℹ${RESET} ${msg}`); }
|
|
19
|
+
|
|
20
|
+
// ─── 생성할 파일 내용 ──────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
const CLIENT_TS = `import { createClient } from 'aurabase-js';
|
|
23
|
+
|
|
24
|
+
export const client = createClient({
|
|
25
|
+
url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
|
|
26
|
+
anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
|
|
27
|
+
});
|
|
60
28
|
`;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
if (fs.existsSync(filePath)) {
|
|
79
|
-
console.log(`\x1B[33m\u26A0 ${filename} already exists. Skipping...\x1B[0m`);
|
|
80
|
-
return;
|
|
29
|
+
|
|
30
|
+
const SERVER_TS = `import { createClient } from 'aurabase-js';
|
|
31
|
+
import { cookies } from 'next/headers';
|
|
32
|
+
|
|
33
|
+
export async function server() {
|
|
34
|
+
const cookieStore = await cookies();
|
|
35
|
+
const accessToken = cookieStore.get('access_token')?.value;
|
|
36
|
+
|
|
37
|
+
const client = createClient({
|
|
38
|
+
url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
|
|
39
|
+
anonKey: process.env.NEXT_PUBLIC_AURABASE_ANON_KEY || '',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (accessToken) {
|
|
43
|
+
client.setAccessToken(accessToken);
|
|
81
44
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log(`\x1B[32m\u2713 Created ${filename}\x1B[0m`);
|
|
85
|
-
console.log("\x1B[36m%s\x1B[0m", ENV_TEMPLATE);
|
|
45
|
+
|
|
46
|
+
return client;
|
|
86
47
|
}
|
|
87
|
-
|
|
88
|
-
console.log(`
|
|
89
|
-
\x1B[1mAuraBase JS CLI\x1B[0m
|
|
48
|
+
`;
|
|
90
49
|
|
|
91
|
-
|
|
92
|
-
npx aurabase-js init [options]
|
|
50
|
+
const ADMIN_TS = `import { createClient } from 'aurabase-js';
|
|
93
51
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Admin client with service_role key
|
|
54
|
+
* ⚠️ ONLY use on server-side (API routes, server components)
|
|
55
|
+
* ⚠️ Bypasses all RLS policies - use with caution!
|
|
56
|
+
*/
|
|
57
|
+
export const admin = createClient({
|
|
58
|
+
url: process.env.NEXT_PUBLIC_AURABASE_URL || '',
|
|
59
|
+
anonKey: process.env.NEXT_PUBLIC_AURABASE_SERVICE_ROLE_KEY || '',
|
|
60
|
+
});
|
|
61
|
+
`;
|
|
97
62
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
const ENV_EXAMPLE = `# AuraBase
|
|
64
|
+
NEXT_PUBLIC_AURABASE_URL=https://your-project.cloudfront.net
|
|
65
|
+
NEXT_PUBLIC_AURABASE_ANON_KEY=your-anon-key
|
|
66
|
+
NEXT_PUBLIC_AURABASE_SERVICE_ROLE_KEY=your-service-role-key
|
|
67
|
+
`;
|
|
101
68
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
console.log(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
69
|
+
// ─── init ─────────────────────────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
function init() {
|
|
72
|
+
const cwd = process.cwd();
|
|
73
|
+
const libDir = path.join(cwd, 'lib');
|
|
74
|
+
|
|
75
|
+
console.log('');
|
|
76
|
+
console.log(`${BOLD}aurabase-js init${RESET}`);
|
|
77
|
+
console.log('──────────────────────────────────');
|
|
78
|
+
|
|
79
|
+
if (!fs.existsSync(libDir)) {
|
|
80
|
+
fs.mkdirSync(libDir, { recursive: true });
|
|
81
|
+
success('lib/ 폴더 생성');
|
|
82
|
+
} else {
|
|
83
|
+
info('lib/ 폴더가 이미 존재합니다');
|
|
117
84
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
85
|
+
|
|
86
|
+
const files = [
|
|
87
|
+
['lib/client.ts', CLIENT_TS],
|
|
88
|
+
['lib/server.ts', SERVER_TS],
|
|
89
|
+
['lib/admin.ts', ADMIN_TS],
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
for (const [relPath, content] of files) {
|
|
93
|
+
const fullPath = path.join(cwd, relPath);
|
|
94
|
+
if (fs.existsSync(fullPath)) {
|
|
95
|
+
warn(`${relPath} 이미 존재 — 건너뜀`);
|
|
96
|
+
} else {
|
|
97
|
+
fs.writeFileSync(fullPath, content, 'utf8');
|
|
98
|
+
success(`${relPath} 생성`);
|
|
99
|
+
}
|
|
121
100
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
101
|
+
|
|
102
|
+
const envPath = path.join(cwd, '.env.local');
|
|
103
|
+
console.log('');
|
|
104
|
+
console.log(`${BOLD}📋 환경변수 설정${RESET}`);
|
|
105
|
+
console.log('──────────────────────────────────');
|
|
106
|
+
|
|
107
|
+
if (!fs.existsSync(envPath)) {
|
|
108
|
+
fs.writeFileSync(envPath, ENV_EXAMPLE, 'utf8');
|
|
109
|
+
success('.env.local 생성 — 아래 값을 채워주세요');
|
|
110
|
+
} else {
|
|
111
|
+
info('.env.local 이미 존재 — 아래 항목이 있는지 확인하세요');
|
|
127
112
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
113
|
+
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log(` ${CYAN}NEXT_PUBLIC_AURABASE_URL${RESET}=https://your-project.cloudfront.net`);
|
|
116
|
+
console.log(` ${CYAN}NEXT_PUBLIC_AURABASE_ANON_KEY${RESET}=your-anon-key`);
|
|
117
|
+
console.log(` ${CYAN}NEXT_PUBLIC_AURABASE_SERVICE_ROLE_KEY${RESET}=your-service-role-key`);
|
|
118
|
+
console.log('');
|
|
119
|
+
console.log(` → AuraBase 대시보드 ${BOLD}API Keys${RESET} 메뉴에서 확인하세요.`);
|
|
120
|
+
console.log('');
|
|
121
|
+
console.log(`${GREEN}✔ 완료!${RESET} 이제 아래처럼 사용할 수 있습니다:`);
|
|
122
|
+
console.log('');
|
|
123
|
+
console.log(` ${CYAN}// 클라이언트 컴포넌트${RESET}`);
|
|
124
|
+
console.log(` import { client } from '@/lib/client'`);
|
|
125
|
+
console.log(` const { data } = await client.from('todos').select('*')`);
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log(` ${CYAN}// 서버 전용 (API Route, Server Component)${RESET}`);
|
|
128
|
+
console.log(` import { admin } from '@/lib/admin'`);
|
|
129
|
+
console.log(` const { data } = await admin.from('todos').select('*')`);
|
|
130
|
+
console.log('');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ─── 진입점 ────────────────────────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
if (command === 'init') {
|
|
136
|
+
init();
|
|
137
|
+
} else {
|
|
138
|
+
console.log('');
|
|
139
|
+
console.log(`${BOLD}aurabase-js CLI${RESET}`);
|
|
140
|
+
console.log('');
|
|
141
|
+
console.log('사용법:');
|
|
142
|
+
console.log(` ${CYAN}npx aurabase-js init${RESET} lib/ 폴더 및 환경변수 파일 자동 생성`);
|
|
143
|
+
console.log('');
|
|
131
144
|
}
|
|
132
|
-
main();
|