sonamu 0.7.1 → 0.7.3
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/ai/agents/types.d.ts +4 -3
- package/dist/ai/agents/types.d.ts.map +1 -1
- package/dist/ai/agents/types.js +1 -1
- package/dist/api/code-converters.js +2 -2
- package/dist/api/config.d.ts +4 -2
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +6 -3
- package/dist/api/decorators.d.ts.map +1 -1
- package/dist/api/decorators.js +3 -2
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +3 -4
- package/dist/bin/cli.js +13 -29
- package/dist/bin/{hot-hook-register.d.ts → hmr-hook-register.d.ts} +3 -3
- package/dist/bin/hmr-hook-register.d.ts.map +1 -0
- package/dist/bin/{hot-hook-register.js → hmr-hook-register.js} +5 -5
- package/dist/bin/ts-loader-register.d.ts +2 -0
- package/dist/bin/ts-loader-register.d.ts.map +1 -0
- package/dist/bin/ts-loader-register.js +34 -0
- package/dist/database/base-model.d.ts +2 -34
- package/dist/database/base-model.d.ts.map +1 -1
- package/dist/database/base-model.js +3 -170
- package/dist/database/base-model.types.d.ts +1 -0
- package/dist/database/base-model.types.d.ts.map +1 -1
- package/dist/database/base-model.types.js +2 -2
- package/dist/database/puri-wrapper.js +7 -3
- package/dist/database/upsert-builder.d.ts +7 -3
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +63 -25
- package/dist/entity/entity-manager.d.ts +1 -1
- package/dist/entity/entity.js +3 -3
- package/dist/migration/code-generation.d.ts.map +1 -1
- package/dist/migration/code-generation.js +8 -7
- package/dist/migration/migration-set.d.ts.map +1 -1
- package/dist/migration/migration-set.js +2 -25
- package/dist/migration/migrator.js +2 -2
- package/dist/migration/postgresql-schema-reader.d.ts.map +1 -1
- package/dist/migration/postgresql-schema-reader.js +2 -1
- package/dist/syncer/file-patterns.js +2 -2
- package/dist/syncer/syncer.js +3 -3
- package/dist/template/implementations/service.template.d.ts.map +1 -1
- package/dist/template/implementations/service.template.js +3 -2
- package/dist/template/zod-converter.js +4 -2
- package/dist/types/types.d.ts +6 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +2 -2
- package/dist/utils/model.d.ts +9 -2
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +1 -1
- package/dist/utils/path-utils.d.ts +1 -1
- package/dist/utils/path-utils.d.ts.map +1 -1
- package/dist/utils/path-utils.js +1 -1
- package/package.json +12 -12
- package/src/ai/agents/types.ts +6 -3
- package/src/api/code-converters.ts +2 -2
- package/src/api/config.ts +17 -6
- package/src/api/decorators.ts +2 -1
- package/src/api/sonamu.ts +2 -5
- package/src/bin/cli.ts +13 -30
- package/src/bin/{hot-hook-register.ts → hmr-hook-register.ts} +4 -4
- package/src/bin/{loader-register.ts → ts-loader-register.ts} +2 -2
- package/src/database/base-model.ts +5 -236
- package/src/database/base-model.types.ts +2 -0
- package/src/database/puri-wrapper.ts +2 -2
- package/src/database/upsert-builder.ts +88 -29
- package/src/entity/entity.ts +2 -2
- package/src/migration/code-generation.ts +8 -6
- package/src/migration/migration-set.ts +0 -20
- package/src/migration/migrator.ts +1 -1
- package/src/migration/postgresql-schema-reader.ts +1 -0
- package/src/shared/web.shared.ts.txt +6 -4
- package/src/syncer/file-patterns.ts +1 -1
- package/src/syncer/syncer.ts +2 -2
- package/src/template/implementations/service.template.ts +2 -1
- package/src/template/zod-converter.ts +3 -1
- package/src/types/types.ts +3 -2
- package/src/utils/model.ts +10 -4
- package/src/utils/path-utils.ts +5 -2
- package/dist/bin/hot-hook-register.d.ts.map +0 -1
- package/dist/bin/loader-register.d.ts +0 -2
- package/dist/bin/loader-register.d.ts.map +0 -1
- package/dist/bin/loader-register.js +0 -34
|
@@ -88,10 +88,6 @@ export function getMigrationSetFromEntity(entity: Entity): MigrationSetAndJoinTa
|
|
|
88
88
|
r.joinTables.push({
|
|
89
89
|
table: through.from.split(".")[0],
|
|
90
90
|
indexes: [
|
|
91
|
-
{
|
|
92
|
-
type: "unique",
|
|
93
|
-
columns: ["uuid"],
|
|
94
|
-
},
|
|
95
91
|
// 조인 테이블에 걸린 인덱스 찾아와서 연결
|
|
96
92
|
...entity.indexes
|
|
97
93
|
.filter((index) => index.columns.find((col) => col.includes(`${prop.joinTable}.`)))
|
|
@@ -113,11 +109,6 @@ export function getMigrationSetFromEntity(entity: Entity): MigrationSetAndJoinTa
|
|
|
113
109
|
nullable: false,
|
|
114
110
|
} as MigrationColumn;
|
|
115
111
|
}),
|
|
116
|
-
{
|
|
117
|
-
name: "uuid",
|
|
118
|
-
nullable: true,
|
|
119
|
-
type: "uuid",
|
|
120
|
-
},
|
|
121
112
|
],
|
|
122
113
|
foreigns: fields.map((field) => {
|
|
123
114
|
// 현재 필드가 어떤 테이블에 속하는지 판단
|
|
@@ -175,17 +166,6 @@ export function getMigrationSetFromEntity(entity: Entity): MigrationSetAndJoinTa
|
|
|
175
166
|
index.columns.find((col) => col.includes(".") === false),
|
|
176
167
|
);
|
|
177
168
|
|
|
178
|
-
// uuid
|
|
179
|
-
migrationSet.columns = migrationSet.columns.concat({
|
|
180
|
-
name: "uuid",
|
|
181
|
-
nullable: true,
|
|
182
|
-
type: "uuid",
|
|
183
|
-
} as MigrationColumn);
|
|
184
|
-
migrationSet.indexes = migrationSet.indexes.concat({
|
|
185
|
-
type: "unique",
|
|
186
|
-
columns: ["uuid"],
|
|
187
|
-
} as MigrationIndex);
|
|
188
|
-
|
|
189
169
|
return migrationSet;
|
|
190
170
|
}
|
|
191
171
|
|
|
@@ -86,10 +86,12 @@ export function defaultCatch(e: any) {
|
|
|
86
86
|
/*
|
|
87
87
|
Isomorphic Types
|
|
88
88
|
*/
|
|
89
|
-
export type ListResult<T> =
|
|
90
|
-
rows: T[]
|
|
91
|
-
|
|
92
|
-
}
|
|
89
|
+
export type ListResult<LP extends { queryMode?: SonamuQueryMode }, T> = LP["queryMode"] extends "list"
|
|
90
|
+
? { rows: T[] }
|
|
91
|
+
: LP["queryMode"] extends "count"
|
|
92
|
+
? { total: number }
|
|
93
|
+
: { rows: T[]; total: number };
|
|
94
|
+
|
|
93
95
|
export const SonamuQueryMode = z.enum(["both", "list", "count"]);
|
|
94
96
|
export type SonamuQueryMode = z.infer<typeof SonamuQueryMode>;
|
|
95
97
|
|
|
@@ -30,7 +30,7 @@ export const checksumPatternGroup: GlobPattern<ApiRelativePath> = {
|
|
|
30
30
|
model: "src/application/**/*.model.ts",
|
|
31
31
|
frame: "src/application/**/*.frame.ts",
|
|
32
32
|
functions: "src/application/**/*.functions.ts",
|
|
33
|
-
config: "sonamu.config.ts",
|
|
33
|
+
config: "src/sonamu.config.ts",
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/**
|
package/src/syncer/syncer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hot } from "@sonamu-kit/
|
|
1
|
+
import { hot } from "@sonamu-kit/hmr-hook";
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
@@ -122,7 +122,7 @@ export class Syncer {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// 싱크 작업이 끝나면 모든 모듈을 로드합니다.
|
|
125
|
-
//
|
|
125
|
+
// hmr-hook에 의해 invalidate된 부분들이 아니라면 캐시 그대로 유지합니다.
|
|
126
126
|
await this.autoloadTypes();
|
|
127
127
|
await this.autoloadModels();
|
|
128
128
|
await this.autoloadApis();
|
|
@@ -85,11 +85,12 @@ export class Template__service extends Template {
|
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
// 파라미터 타입 정의
|
|
88
|
-
const
|
|
88
|
+
const typeParametersAsTsType = api.typeParameters
|
|
89
89
|
.map((typeParam) => {
|
|
90
90
|
return apiParamTypeToTsType(typeParam, importKeys);
|
|
91
91
|
})
|
|
92
92
|
.join(", ");
|
|
93
|
+
const typeParamsDef = typeParametersAsTsType ? `<${typeParametersAsTsType}>` : "";
|
|
93
94
|
typeParamNames = typeParamNames.concat(
|
|
94
95
|
api.typeParameters.map((typeParam) => typeParam.id),
|
|
95
96
|
);
|
|
@@ -342,7 +342,7 @@ export function zodTypeToTsTypeDef(zt: z.ZodType): string {
|
|
|
342
342
|
// ZodType - 재귀적으로 변환
|
|
343
343
|
if (part && typeof part === "object" && (part as z.ZodType)._zod) {
|
|
344
344
|
const innerType = zodTypeToTsTypeDef(part as z.ZodType);
|
|
345
|
-
return
|
|
345
|
+
return `$\{${innerType}}`;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
// 폴백
|
|
@@ -571,6 +571,8 @@ function resolveRenderType(key: string, zodType: z.ZodTypeAny): RenderingNode["r
|
|
|
571
571
|
return "string-plain";
|
|
572
572
|
} else if (zodType instanceof z.ZodLiteral) {
|
|
573
573
|
return "string-plain";
|
|
574
|
+
} else if (zodType instanceof z.ZodTemplateLiteral) {
|
|
575
|
+
return "string-plain";
|
|
574
576
|
} else {
|
|
575
577
|
throw new Error(`타입 파싱 불가 ${key} ${zodType.def.type}`);
|
|
576
578
|
}
|
package/src/types/types.ts
CHANGED
|
@@ -175,7 +175,7 @@ export type EntityProp =
|
|
|
175
175
|
export type EntityIndex = {
|
|
176
176
|
type: "index" | "unique" | "fulltext";
|
|
177
177
|
columns: string[];
|
|
178
|
-
name
|
|
178
|
+
name: string;
|
|
179
179
|
parser?: "built-in" | "ngram";
|
|
180
180
|
};
|
|
181
181
|
export type EntityJson = {
|
|
@@ -451,6 +451,7 @@ export type MigrationColumn = {
|
|
|
451
451
|
scale?: number;
|
|
452
452
|
};
|
|
453
453
|
export type MigrationIndex = {
|
|
454
|
+
name: string;
|
|
454
455
|
columns: string[];
|
|
455
456
|
type: "unique" | "index" | "fulltext";
|
|
456
457
|
parser?: "built-in" | "ngram";
|
|
@@ -942,7 +943,7 @@ const EntityIndexSchema = z
|
|
|
942
943
|
.object({
|
|
943
944
|
type: z.enum(["index", "unique", "fulltext"]),
|
|
944
945
|
columns: z.array(z.string()),
|
|
945
|
-
name: z.string().
|
|
946
|
+
name: z.string().min(1).max(63),
|
|
946
947
|
parser: z.enum(["built-in", "ngram"]).optional(),
|
|
947
948
|
})
|
|
948
949
|
.strict();
|
package/src/utils/model.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
import type { SonamuQueryMode } from "..";
|
|
2
|
+
|
|
3
|
+
export type ListResult<
|
|
4
|
+
LP extends { queryMode?: SonamuQueryMode },
|
|
5
|
+
T,
|
|
6
|
+
> = LP["queryMode"] extends "list"
|
|
7
|
+
? { rows: T[] }
|
|
8
|
+
: LP["queryMode"] extends "count"
|
|
9
|
+
? { total: number }
|
|
10
|
+
: { rows: T[]; total: number };
|
|
5
11
|
|
|
6
12
|
export type ArrayOr<T> = T | T[];
|
|
7
13
|
|
package/src/utils/path-utils.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { isHotReloadServer, isTest } from "./controller.js";
|
|
|
10
10
|
*
|
|
11
11
|
* **기준점**: `Sonamu.apiRootPath` (일반적으로 프로젝트의 `/api` 디렉토리)
|
|
12
12
|
*/
|
|
13
|
-
export type ApiRelativePath = `${"src" | "dist"}/${string}
|
|
13
|
+
export type ApiRelativePath = `${"src" | "dist"}/${string}`;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* 앱 루트 기준 상대 경로 (api/, web/ 등 타겟 디렉토리로 시작)
|
|
@@ -90,7 +90,10 @@ export type AbsolutePath = `/${string}`;
|
|
|
90
90
|
* @param anyPath
|
|
91
91
|
* @returns
|
|
92
92
|
*/
|
|
93
|
-
export function runtimePath(
|
|
93
|
+
export function runtimePath(
|
|
94
|
+
anyPath: string,
|
|
95
|
+
isDev: boolean = isHotReloadServer() || isTest(),
|
|
96
|
+
): string {
|
|
94
97
|
if (isDev) {
|
|
95
98
|
return anyPath.replace(/dist\//, "src/").replace(/\.js/, ".ts");
|
|
96
99
|
} else {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hot-hook-register.d.ts","sourceRoot":"","sources":["../../src/bin/hot-hook-register.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader-register.d.ts","sourceRoot":"","sources":["../../src/bin/loader-register.ts"],"names":[],"mappings":""}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { register } from "node:module";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { exists } from "../utils/fs-utils.js";
|
|
4
|
-
import { findApiRootPath } from "../utils/utils.js";
|
|
5
|
-
/**
|
|
6
|
-
* @sonamu-kit/loader/loader를 등록하는 스크립트입니다.
|
|
7
|
-
* 이 스크립트는 sonamu cli로 dev 실행할 때 --import로 실행됩니다.
|
|
8
|
-
*/ async function setupSwcConfig() {
|
|
9
|
-
try {
|
|
10
|
-
const apiRoot = findApiRootPath();
|
|
11
|
-
// 프로젝트 루트에서 .swcrc 찾기
|
|
12
|
-
const projectSwcrcPath = path.join(apiRoot, ".swcrc");
|
|
13
|
-
if (await exists(projectSwcrcPath)) {
|
|
14
|
-
// 사용자 프로젝트에 .swcrc가 있으면 우선으로 사용합니다.
|
|
15
|
-
process.env.SWCRC_PATH = projectSwcrcPath;
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
// 아니라면 sonamu가 관리하는 .swcrc.project-default를 가져다 씁니다.
|
|
19
|
-
const sonamuSwcrcPath = path.join(import.meta.dirname, "..", "..", ".swcrc.project-default");
|
|
20
|
-
if (await exists(sonamuSwcrcPath)) {
|
|
21
|
-
process.env.SWCRC_PATH = sonamuSwcrcPath;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
} catch {
|
|
25
|
-
// 환경 변수 설정 실패는 무시 (loader가 기본 설정 사용)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// swc 설정 파일 경로를 환경 변수로 설정
|
|
29
|
-
await setupSwcConfig();
|
|
30
|
-
register("@sonamu-kit/loader/loader", {
|
|
31
|
-
parentURL: import.meta.url
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vbG9hZGVyLXJlZ2lzdGVyLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHJlZ2lzdGVyIH0gZnJvbSBcIm5vZGU6bW9kdWxlXCI7XG5pbXBvcnQgKiBhcyBwYXRoIGZyb20gXCJub2RlOnBhdGhcIjtcbmltcG9ydCB7IGV4aXN0cyB9IGZyb20gXCIuLi91dGlscy9mcy11dGlscy5qc1wiO1xuaW1wb3J0IHsgZmluZEFwaVJvb3RQYXRoIH0gZnJvbSBcIi4uL3V0aWxzL3V0aWxzLmpzXCI7XG5cbi8qKlxuICogQHNvbmFtdS1raXQvbG9hZGVyL2xvYWRlcuulvCDrk7HroZ3tlZjripQg7Iqk7YGs66a97Yq47J6F64uI64ukLlxuICog7J20IOyKpO2BrOumve2KuOuKlCBzb25hbXUgY2xp66GcIGRldiDsi6TtlontlaAg65WMIC0taW1wb3J066GcIOyLpO2WieuQqeuLiOuLpC5cbiAqL1xuYXN5bmMgZnVuY3Rpb24gc2V0dXBTd2NDb25maWcoKSB7XG4gIHRyeSB7XG4gICAgY29uc3QgYXBpUm9vdCA9IGZpbmRBcGlSb290UGF0aCgpO1xuXG4gICAgLy8g7ZSE66Gc7KCd7Yq4IOujqO2KuOyXkOyEnCAuc3djcmMg7LC+6riwXG4gICAgY29uc3QgcHJvamVjdFN3Y3JjUGF0aCA9IHBhdGguam9pbihhcGlSb290LCBcIi5zd2NyY1wiKTtcbiAgICBpZiAoYXdhaXQgZXhpc3RzKHByb2plY3RTd2NyY1BhdGgpKSB7XG4gICAg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