@gencow/core 0.1.6 → 0.1.7
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/dist/auth-config.d.ts +47 -0
- package/dist/auth-config.js +30 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/reactive.d.ts +4 -0
- package/dist/storage.js +15 -7
- package/package.json +37 -35
- package/src/auth-config.ts +59 -0
- package/src/index.ts +2 -0
- package/src/reactive.ts +4 -0
- package/src/storage.ts +17 -7
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/auth-config.ts
|
|
3
|
+
*
|
|
4
|
+
* Gencow Auth 설정 타입 및 defineAuth() 함수.
|
|
5
|
+
* 사용자 앱의 gencow/auth.ts 에서 사용.
|
|
6
|
+
*
|
|
7
|
+
* shadcn 패턴: auth.ts는 사용자가 소유하고 직접 수정할 수 있는 파일.
|
|
8
|
+
* defineAuth()는 타입 안전한 설정 헬퍼일 뿐, 런타임 로직은 server에서 처리.
|
|
9
|
+
*/
|
|
10
|
+
export interface AuthEmailVerification {
|
|
11
|
+
/** 가입 시 인증 메일 자동 발송 (default: true) */
|
|
12
|
+
sendOnSignUp?: boolean;
|
|
13
|
+
/** 이메일 미인증 시 로그인 차단 (default: true) */
|
|
14
|
+
requireEmailVerification?: boolean;
|
|
15
|
+
/** 인증 완료 후 자동 로그인 (default: true) */
|
|
16
|
+
autoSignInAfterVerification?: boolean;
|
|
17
|
+
/** 인증 메일 발송 함수 — 사용자가 직접 구현 */
|
|
18
|
+
sendVerificationEmail: (data: {
|
|
19
|
+
user: {
|
|
20
|
+
email: string;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
url: string;
|
|
24
|
+
token: string;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export interface GencowAuthConfig {
|
|
28
|
+
emailVerification?: AuthEmailVerification;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Auth 설정 정의 헬퍼.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // gencow/auth.ts
|
|
36
|
+
* import { defineAuth } from "gencow";
|
|
37
|
+
*
|
|
38
|
+
* export default defineAuth({
|
|
39
|
+
* emailVerification: {
|
|
40
|
+
* sendVerificationEmail: async ({ user, url }) => {
|
|
41
|
+
* // 이메일 발송 로직
|
|
42
|
+
* },
|
|
43
|
+
* },
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function defineAuth(config: GencowAuthConfig): GencowAuthConfig;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/auth-config.ts
|
|
3
|
+
*
|
|
4
|
+
* Gencow Auth 설정 타입 및 defineAuth() 함수.
|
|
5
|
+
* 사용자 앱의 gencow/auth.ts 에서 사용.
|
|
6
|
+
*
|
|
7
|
+
* shadcn 패턴: auth.ts는 사용자가 소유하고 직접 수정할 수 있는 파일.
|
|
8
|
+
* defineAuth()는 타입 안전한 설정 헬퍼일 뿐, 런타임 로직은 server에서 처리.
|
|
9
|
+
*/
|
|
10
|
+
// ─── defineAuth() ────────────────────────────────────────
|
|
11
|
+
/**
|
|
12
|
+
* Auth 설정 정의 헬퍼.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // gencow/auth.ts
|
|
17
|
+
* import { defineAuth } from "gencow";
|
|
18
|
+
*
|
|
19
|
+
* export default defineAuth({
|
|
20
|
+
* emailVerification: {
|
|
21
|
+
* sendVerificationEmail: async ({ user, url }) => {
|
|
22
|
+
* // 이메일 발송 로직
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function defineAuth(config) {
|
|
29
|
+
return config;
|
|
30
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export { withRetry } from "./retry";
|
|
|
15
15
|
export type { RetryOptions } from "./retry";
|
|
16
16
|
export { cronJobs } from "./crons";
|
|
17
17
|
export type { CronJobsBuilder, CronJobDef, IntervalOptions, DailyOptions, WeeklyOptions } from "./crons";
|
|
18
|
+
export { defineAuth } from "./auth-config";
|
|
19
|
+
export type { GencowAuthConfig, AuthEmailVerification } from "./auth-config";
|
package/dist/index.js
CHANGED
package/dist/reactive.d.ts
CHANGED
|
@@ -55,6 +55,10 @@ export interface AIContext {
|
|
|
55
55
|
temperature?: number;
|
|
56
56
|
maxTokens?: number;
|
|
57
57
|
}) => Promise<AIResult>;
|
|
58
|
+
/** 텍스트 임베딩 (단일) — ctx.ai.embed("검색 텍스트") */
|
|
59
|
+
embed: (text: string) => Promise<number[]>;
|
|
60
|
+
/** 배치 임베딩 — ctx.ai.embedMany(["텍스트1", "텍스트2"]) */
|
|
61
|
+
embedMany: (texts: string[]) => Promise<number[][]>;
|
|
58
62
|
}
|
|
59
63
|
export interface GencowCtx {
|
|
60
64
|
/** Drizzle DB 인스턴스 — ctx.db.select().from(table) */
|
package/dist/storage.js
CHANGED
|
@@ -104,13 +104,21 @@ export function storageRoutes(storage, rawSql, storageDir) {
|
|
|
104
104
|
if (!meta) {
|
|
105
105
|
return c.json({ error: "Not found" }, 404);
|
|
106
106
|
}
|
|
107
|
+
// Bun 런타임에서는 Bun.file()을 사용하여 바이너리 무결성 보장
|
|
108
|
+
// Node의 fs.readFile()은 Bun에서 Buffer 인코딩 문제가 있을 수 있음
|
|
109
|
+
const headers = {
|
|
110
|
+
"Content-Type": meta.type,
|
|
111
|
+
"Content-Disposition": `inline; filename="${encodeURIComponent(meta.name)}"; filename*=UTF-8''${encodeURIComponent(meta.name)}`,
|
|
112
|
+
"Cache-Control": "public, max-age=31536000, immutable",
|
|
113
|
+
};
|
|
114
|
+
// Bun은 Bun.file()로 직접 BunFile(Blob) 생성 → Response에 그대로 전달
|
|
115
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
116
|
+
const bunFile = Bun.file(meta.path);
|
|
117
|
+
return new Response(bunFile, { headers });
|
|
118
|
+
}
|
|
119
|
+
// Node.js 폴백
|
|
107
120
|
const file = await fs.readFile(meta.path);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"Content-Type": meta.type,
|
|
111
|
-
"Content-Disposition": `attachment; filename="${encodeURIComponent(meta.name)}"; filename*=UTF-8''${encodeURIComponent(meta.name)}`,
|
|
112
|
-
"Content-Length": String(meta.size),
|
|
113
|
-
},
|
|
114
|
-
});
|
|
121
|
+
headers["Content-Length"] = String(file.byteLength);
|
|
122
|
+
return c.body(file, 200, headers);
|
|
115
123
|
};
|
|
116
124
|
}
|
package/package.json
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "@gencow/core",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "Gencow core library — defineQuery, defineMutation, reactive subscriptions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./server": {
|
|
14
|
+
"import": "./dist/server.js",
|
|
15
|
+
"types": "./dist/server.d.ts"
|
|
16
|
+
}
|
|
12
17
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"src/"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
|
+
"postinstall": "tsc"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@electric-sql/pglite": "^0.3.15",
|
|
30
|
+
"drizzle-orm": "^0.45.1",
|
|
31
|
+
"hono": "^4.12.0",
|
|
32
|
+
"node-cron": "^4.2.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/bun": "^1.3.9",
|
|
36
|
+
"@types/node": "^25.3.0",
|
|
37
|
+
"@types/node-cron": "^3.0.11",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
16
39
|
}
|
|
17
|
-
|
|
18
|
-
"files": [
|
|
19
|
-
"dist/",
|
|
20
|
-
"src/"
|
|
21
|
-
],
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@electric-sql/pglite": "^0.3.15",
|
|
24
|
-
"drizzle-orm": "^0.45.1",
|
|
25
|
-
"hono": "^4.12.0",
|
|
26
|
-
"node-cron": "^4.2.1"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/bun": "^1.3.9",
|
|
30
|
-
"@types/node": "^25.3.0",
|
|
31
|
-
"@types/node-cron": "^3.0.11",
|
|
32
|
-
"typescript": "^5.9.3"
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "tsc",
|
|
36
|
-
"typecheck": "tsc --noEmit"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/auth-config.ts
|
|
3
|
+
*
|
|
4
|
+
* Gencow Auth 설정 타입 및 defineAuth() 함수.
|
|
5
|
+
* 사용자 앱의 gencow/auth.ts 에서 사용.
|
|
6
|
+
*
|
|
7
|
+
* shadcn 패턴: auth.ts는 사용자가 소유하고 직접 수정할 수 있는 파일.
|
|
8
|
+
* defineAuth()는 타입 안전한 설정 헬퍼일 뿐, 런타임 로직은 server에서 처리.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ─── Email Verification ──────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export interface AuthEmailVerification {
|
|
14
|
+
/** 가입 시 인증 메일 자동 발송 (default: true) */
|
|
15
|
+
sendOnSignUp?: boolean;
|
|
16
|
+
/** 이메일 미인증 시 로그인 차단 (default: true) */
|
|
17
|
+
requireEmailVerification?: boolean;
|
|
18
|
+
/** 인증 완료 후 자동 로그인 (default: true) */
|
|
19
|
+
autoSignInAfterVerification?: boolean;
|
|
20
|
+
/** 인증 메일 발송 함수 — 사용자가 직접 구현 */
|
|
21
|
+
sendVerificationEmail: (data: {
|
|
22
|
+
user: { email: string; name: string };
|
|
23
|
+
url: string;
|
|
24
|
+
token: string;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ─── Auth Config ─────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
export interface GencowAuthConfig {
|
|
31
|
+
emailVerification?: AuthEmailVerification;
|
|
32
|
+
// 확장 예정:
|
|
33
|
+
// socialProviders?: { ... }
|
|
34
|
+
// passwordPolicy?: { ... }
|
|
35
|
+
// sessionExpiry?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ─── defineAuth() ────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Auth 설정 정의 헬퍼.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // gencow/auth.ts
|
|
46
|
+
* import { defineAuth } from "gencow";
|
|
47
|
+
*
|
|
48
|
+
* export default defineAuth({
|
|
49
|
+
* emailVerification: {
|
|
50
|
+
* sendVerificationEmail: async ({ user, url }) => {
|
|
51
|
+
* // 이메일 발송 로직
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function defineAuth(config: GencowAuthConfig): GencowAuthConfig {
|
|
58
|
+
return config;
|
|
59
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -16,5 +16,7 @@ export { withRetry } from "./retry";
|
|
|
16
16
|
export type { RetryOptions } from "./retry";
|
|
17
17
|
export { cronJobs } from "./crons";
|
|
18
18
|
export type { CronJobsBuilder, CronJobDef, IntervalOptions, DailyOptions, WeeklyOptions } from "./crons";
|
|
19
|
+
export { defineAuth } from "./auth-config";
|
|
20
|
+
export type { GencowAuthConfig, AuthEmailVerification } from "./auth-config";
|
|
19
21
|
|
|
20
22
|
|
package/src/reactive.ts
CHANGED
|
@@ -61,6 +61,10 @@ export interface AIContext {
|
|
|
61
61
|
temperature?: number;
|
|
62
62
|
maxTokens?: number;
|
|
63
63
|
}) => Promise<AIResult>;
|
|
64
|
+
/** 텍스트 임베딩 (단일) — ctx.ai.embed("검색 텍스트") */
|
|
65
|
+
embed: (text: string) => Promise<number[]>;
|
|
66
|
+
/** 배치 임베딩 — ctx.ai.embedMany(["텍스트1", "텍스트2"]) */
|
|
67
|
+
embedMany: (texts: string[]) => Promise<number[][]>;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export interface GencowCtx {
|
package/src/storage.ts
CHANGED
|
@@ -162,13 +162,23 @@ export function storageRoutes(
|
|
|
162
162
|
return c.json({ error: "Not found" }, 404);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
// Bun 런타임에서는 Bun.file()을 사용하여 바이너리 무결성 보장
|
|
166
|
+
// Node의 fs.readFile()은 Bun에서 Buffer 인코딩 문제가 있을 수 있음
|
|
167
|
+
const headers: Record<string, string> = {
|
|
168
|
+
"Content-Type": meta.type,
|
|
169
|
+
"Content-Disposition": `inline; filename="${encodeURIComponent(meta.name)}"; filename*=UTF-8''${encodeURIComponent(meta.name)}`,
|
|
170
|
+
"Cache-Control": "public, max-age=31536000, immutable",
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// Bun은 Bun.file()로 직접 BunFile(Blob) 생성 → Response에 그대로 전달
|
|
174
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
175
|
+
const bunFile = Bun.file(meta.path);
|
|
176
|
+
return new Response(bunFile, { headers });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Node.js 폴백
|
|
165
180
|
const file = await fs.readFile(meta.path);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"Content-Type": meta.type,
|
|
169
|
-
"Content-Disposition": `attachment; filename="${encodeURIComponent(meta.name)}"; filename*=UTF-8''${encodeURIComponent(meta.name)}`,
|
|
170
|
-
"Content-Length": String(meta.size),
|
|
171
|
-
},
|
|
172
|
-
});
|
|
181
|
+
headers["Content-Length"] = String(file.byteLength);
|
|
182
|
+
return c.body(file, 200, headers);
|
|
173
183
|
};
|
|
174
184
|
}
|